[Haskell-cafe] Propositions in Haskell

Dan Mead d.w.mead at gmail.com
Thu May 16 13:29:15 CEST 2013


maybe this will help?

Haskell code in and of itself isn't special. proofs can happen with the
type system, but typically you'd want to define a target language and do
assertions about it, similar to how a compiler inspects it's input
programs. Haskell is not homoiconic nor is it like coq or prolog. But it
is  really really good at defining an ast and doing operations on it.


On Thu, May 16, 2013 at 5:27 AM, Patrick Browne <patrick.browne at dit.ie>wrote:

> I do understand the difference between theorem provers and Haskell
> programs.
> Logic can be used to reason 'about' Haskell programs and logic can be used
> 'within' Haskell programs.
> I am trying to clarify the difference between 'about' and 'within'
> Is approach 1 concerned with  |= (model based 'within'), whereas approach
> 2 is concerned with |- (proof based 'about')?
>
> Thanks,
> Pat
>
>
> On 15/05/13, *"Alberto G. Corona " * <agocorona at gmail.com> wrote:
>
> Not exactly what you ask, but it is noteworthy that the mind has different
> logic processors. The fastest one work with IF THEN ELSE rules applied
> specifically to deals. This is why your example (and most examples of
> logic) involves a kind of deal expressed in the first person. This trigger
> a fast mental evaluation, while an equivalent but more general case is
> harder to process and need some paper work.  (That special treatment of
> first person deals logic respond to the need to detect breaks of deals as
> fast as possible)
>
> http://en.wikipedia.org/wiki/Wason_selection_task
>
> That's why higher level languages have redundant logical structures and do
> not follow a general abstract and short mathematical notation. Therefore
> "higher level", in programming languages, does not mean higher
> mathematical abstraction, but to be closer to the way the mind works.
>
>
> 2013/5/15 Patrick Browne <patrick.browne at dit.ie <patrick.browne at dit.ie>>
>
>> -- Hi
>> -- I am trying to show that a set of propositions and a conclusion the
>> form a valid argument.
>> -- I used two approaches; 1) using if-then-else, 2) using pattern
>> matching.
>> -- The version using if-then-else seems to be consistent with my
>> knowledge of Haskell and logic (either of which could be wrong).
>> -- Can the second approach be improved to better reflect the propositions
>> and conclusion? Maybe type level reasoning could be used?
>> --
>> -- Valid argument?
>> -- 1. I work hard or I play piano
>> -- 2. If I work hard then I will get a bonus
>> -- 3. But I did not get a bonus
>> --     Therefore I played piano
>> -- Variables: p = Piano, w = worked hard, b = got a bonus
>> --    (w \/ p) /\ (w => b) /\ ¬(b)
>> --   ---------------------------
>> --                p
>>
>> -- First approach using language control structure if-then-else
>> w, p, b::Bool
>> -- Two equivalences for (w \/ p) as an implication.
>> -- 1. (w \/ p) =equivalent-to=> (not p) => w
>> -- 2. (w \/ p) =equivalent-to=> (not w) => p
>> -- Picked 2
>> p = if (not w) then True else False
>> -- Contrapositive:  (w => b)  =equivalent-to=>  ~b => ~w
>> w = if (not b) then False else True
>> b = False
>> -- gives p is true and w is false
>>
>> -- Second approach using pattern matching
>> -- I think the rewriting goes from left to right but the logical
>> inference goes in the opposite direction.
>> w1, p1, b1::Bool
>> p1 = (not w1)
>> w1 = b1 -- Not consistent with statements, but I do not know how to write
>> ~b1 => ~w1 in Haskell
>> b1 = False
>> -- Again gives p1 is true and w1 is false
>>
>>
>> Tá an teachtaireacht seo scanta ó thaobh ábhar agus víreas ag Seirbhís
>> Scanta Ríomhphost de chuid Seirbhísí Faisnéise, ITBÁC agus meastar í a
>> bheith slán. http://www.dit.ie
>> This message has been scanned for content and viruses by the DIT
>> Information Services E-Mail Scanning Service, and is believed to be clean.
>> http://www.dit.ie
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org <Haskell-Cafe at haskell.org>
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>>
>
>
> --
> Alberto.
>
>
> Tá an teachtaireacht seo scanta ó thaobh ábhar agus víreas ag Seirbhís
> Scanta Ríomhphost de chuid Seirbhísí Faisnéise, ITBÁC agus meastar í a
> bheith slán. http://www.dit.ie
> This message has been scanned for content and viruses by the DIT
> Information Services E-Mail Scanning Service, and is believed to be clean.
> http://www.dit.ie
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130516/bf519221/attachment.htm>


More information about the Haskell-Cafe mailing list