
Hi, In Haskell what roles are played by 1)lambda calculus and 2) equational logic? Are these roles related? Hopefully this question can be answered at a level suitable for this forum. Thanks, Pat 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

On Wed, Jul 07, 2010 at 09:56:08AM +0100, Patrick Browne wrote:
Hi, In Haskell what roles are played by 1)lambda calculus and 2) equational logic? Are these roles related?
Hopefully this question can be answered at a level suitable for this forum.
Since no one else has responded I'll take a quick stab at answering, and others can fill in more information as appropriate, or ask further questions. 1) In general, the lambda calculus is seen as foundational conceptual basis for functional programming: Haskell has anonymous lambda expressions, higher-order functions, and currying, all of which come directly from the lambda calculus. More specifically, GHC's core language is based on a variant of System F omega, which is a fancy version of the simply-typed lambda calculus with polymorphism and type constructors. If you were to print out the core language code generated by GHC for some Haskell program, you would essentially see a bunch of lambda calculus expressions. 2) Haskell is able to embrace equational logic because of its insistence on purity: in a Haskell program (leaving aside for the moment things like seq and unsafePerformIO) you can always "replace equals by equals" (where equality is the normal beta-equality for System F omega, plus definitional equality introduced by Haskell declarations) without changing the semantics of your program. So the story of an equational logic for System F omega and the story of evaluating Haskell programs are to a large extent the same story. Coming up with equational logics corresponding to most imperative languages (or even a non-pure functional language like OCaml) is massively complicated by the need to keep track of an implicit "state of the world" due to the presence of side effects. I am not sure what to say about their relationship. Perhaps my above answers have already shed some light on that. -Brent

On 13/07/2010, at 20:47 , Brent Yorgey wrote:
On Wed, Jul 07, 2010 at 09:56:08AM +0100, Patrick Browne wrote:
Hi, In Haskell what roles are played by 1)lambda calculus and 2) equational logic? Are these roles related?
Hopefully this question can be answered at a level suitable for this forum.
Since no one else has responded I'll take a quick stab at answering, and others can fill in more information as appropriate, or ask further questions.
2) Haskell is able to embrace equational logic because of its insistence on purity: in a Haskell program (leaving aside for the moment things like seq and unsafePerformIO) you can always "replace equals by equals" (where equality is the normal beta-equality for System F omega, plus definitional equality introduced by Haskell declarations) without changing the semantics of your program. So the story of an equational logic for System F omega and the story of evaluating Haskell programs are to a large extent the same story.
Replacing equals by equals usually doesn't change anything. What kind of equality do you use for getChar :: IO Char ?
Coming up with equational logics corresponding to most imperative languages (or even a non-pure functional language like OCaml) is massively complicated by the need to keep track of an implicit "state of the world" due to the presence of side effects.
By "massively complicated" you mean "harder than the simplest case." Haskell's do-notation makes the "state of the world" implicit, and performing the desugaring makes it explicit again -- but then that state isn't really "the state of the word"... Sorry or my heckling. You gave a fine answer, to the standard question. However, I propose mandating that all such questions asked on the haskell-beginners list are answered with "Haskell's purity solves everything" -- but on haskell-cafe they should get "Haskell's purity solves everything, but read Sabry's paper on What is a Purely Functional Language, because it's really more subtle than that." Cheers, Ben.

Ben, comments from the peanut gallery: On 13/07/2010, at 11:51 PM, Ben Lippmeier wrote:
What kind of equality do you use for getChar :: IO Char ?
Surely this is easy: getChar denotes a particular IO action, which is always the same thing (i.e. self-identical and distinct from all other IO actions).
By "massively complicated" you mean "harder than the simplest case." Haskell's do-notation makes the "state of the world" implicit, and performing the desugaring makes it explicit again -- but then that state isn't really "the state of the word"...
... which tells you that the passing-the-world semantics is not a faithful model of I/O. In the archives of this list there are many comments on exactly this topic. A couple of quick pointers: - Wouter Swierstra wrote a paper on this. http://www.cse.chalmers.se/~wouter/repos/IOSpec/index.html - Resumptions are a better model: http://www.haskell.org/pipermail/haskell-cafe/2003-August/004892.html Intuitively the state monad used by GHC works because it only needs to track dependencies between I/O actions - there is no need for the compiler to impose a total order on everything going on in the world (taken to be all of the context that could influence the execution of the program). For interesting programs it cannot, anyway. cheers peter -- http://peteg.org/

In Haskell what roles are played by 1)lambda calculus and 2) equational logic? Are these roles related?
Hi, Thanks for your clear and helpful responses. I am aware that this question can lead to into very deep water. I am comparing Haskell with languages based on equational logic (EL) (e.g. Maude/CafeOBJ, lets call them ELLs). I need to identify the fundamental distinction between the semantics of ELLs and Haskell. The focus of my original question was just the purely functional, side effect free, part of Haskell. Semantics can be understood under three headings: *Denotational Semantics; is a model theoretical approach which describes a program in terms of precise mathematical objects (e.g. sets and functions) which provide meaning to a program text. *Operational semantics: provides a technique for computing a result, ELs use term rewriting systems for their operational semantics. *Proof theoretic semantic: syntactically derivable proofs, can use the rules of a logic The relationship between the denotational and the proof theoretic semantic is important for soundness and completeness. Which was sort of behind my original question. Would it be fair to say 1)Lambda calculus provides the operational semantics for Haskell 2)Maybe equational logic provides the denotational semantics. 3)I am not sure of proof theoretic semantic for Haskell. The Curry-Howard correspondence is a proof theoretic view but only at type level. Obviously, the last three points are represent my efforts to address this question. Hopefully the café can comment on the accuracy of these points. Thanks, Pat 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

On 14/07/2010, at 6:26 , Patrick Browne wrote:
Thanks for your clear and helpful responses. I am aware that this question can lead to into very deep water. I am comparing Haskell with languages based on equational logic (EL) (e.g. Maude/CafeOBJ, lets call them ELLs). I need to identify the fundamental distinction between the semantics of ELLs and Haskell. The focus of my original question was just the purely functional, side effect free, part of Haskell.
If you ignore anything to do with the IO monad (or ST), then all of Haskell can be desugared to (untyped) call-by-name/need lambda calculus. If you stick with Haskell98 then you can desugar it to the rank-2 fragment of System-F + algebraic data types + case expressions + appropriate constants and primops. This is generally regarded as the "Haskell Kernel Language", which is mentioned but explicitly not defined in the language standard.
The relationship between the denotational and the proof theoretic semantic is important for soundness and completeness. Which was sort of behind my original question.
Would it be fair to say 1) Lambda calculus provides the operational semantics for Haskell
Notionally yes, but practically no. AFAIC there isn't a formal semantics for Haskell, but there is for fragments of it, and for intermediate representations like System-Fc (on which GHC is based). There are also multiple lambda calculi, depending on which evaluation mechanism you use. The point I was trying to make in the previous message is what while "Haskell" includes the IO monad, people insist on calling the whole language "purely functional" and "side effect free", which is murky territory. Sabry's "What is a Purely Functional Language" shows that unrestricted beta-reduction is not sound in a simple monadic language using a pass-the-world implementation -- though Wouter's paper gives a cleaner one. Another paper that might help is Sondergaard and Sestoft's highly readable "Referential Transparency, Definiteness and Unfoldability".
2) Maybe equational logic provides the denotational semantics. 3)I am not sure of proof theoretic semantic for Haskell. The Curry-Howard correspondence is a proof theoretic view but only at type level.
Obviously, the last three points are represent my efforts to address this question. Hopefully the café can comment on the accuracy of these points.
My (limited) understanding of Maude is that rewrites can happen at any point in the term being reduced. This is different from, say, the semantics of call-by-name lambda calculus which has a specific evaluation order. In Haskell it's no problem to pass a diverging expression to some function, which might store it in a data structure, but then discard it later. However, when rewrites can happen at any point in the term being reduced, if any part of it diverges then the whole thing does. This is just from skimming slides for Maude talks though... Ben.

Patrick Browne wrote:
In Haskell what roles are played by 1)lambda calculus and 2) equational logic? Are these roles related?
Thanks for your clear and helpful responses. I am aware that this question can lead to into very deep water. I am comparing Haskell with languages based on equational logic (EL) (e.g. Maude/CafeOBJ, lets call them ELLs). I need to identify the fundamental distinction between the semantics of ELLs and Haskell. The focus of my original question was just the purely functional, side effect free, part of Haskell.
Semantics can be understood under three headings: *Denotational Semantics; is a model theoretical approach which describes a program in terms of precise mathematical objects (e.g. sets and functions) which provide meaning to a program text. *Operational semantics: provides a technique for computing a result, ELs use term rewriting systems for their operational semantics. *Proof theoretic semantic: syntactically derivable proofs, can use the rules of a logic
The relationship between the denotational and the proof theoretic semantic is important for soundness and completeness. Which was sort of behind my original question.
Would it be fair to say 1)Lambda calculus provides the operational semantics for Haskell
2)Maybe equational logic provides the denotational semantics.
3)I am not sure of proof theoretic semantic for Haskell. The Curry-Howard correspondence is a proof theoretic view but only at type level.
Obviously, the last three points are represent my efforts to address this question. Hopefully the café can comment on the accuracy of these points.
Lambda calculus is the basis for all three types of semantics: 1) Call-by-need (usually, implementations of Haskell are free to choose other evaluation strategies as long as the denotational semantics match) 2) The denotational semantics of a lambda calculus with general recursion, see also http://en.wikibooks.org/wiki/Haskell/Denotational_semantics 3) Not sure what you mean by proof theoretic semantics. Apparently, the trace of any program execution like, say product [1..5] -> 1 * product [2..5] -> .. -> 120 is a proof that the initial and the final expression denote the same value. The Curry-Howards correspondence is about the type system, viewing types as logical propositions and programs as their proofs. Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com

Heinrich Apfelmus wrote:
Lambda calculus is the basis for all three types of semantics:
1) Call-by-need (usually, implementations of Haskell are free to choose other evaluation strategies as long as the denotational semantics match)
2) The denotational semantics of a lambda calculus with general recursion, see also
http://en.wikibooks.org/wiki/Haskell/Denotational_semantics
3) Not sure what you mean by proof theoretic semantics. Apparently, the trace of any program execution like, say
product [1..5] -> 1 * product [2..5] -> .. -> 120
is a proof that the initial and the final expression denote the same value.
The Curry-Howards correspondence is about the type system, viewing types as logical propositions and programs as their proofs.
This seems to address the first point (the role of lambda calculus. But what of the second point, the role equational logic. I assume (perhaps incorrectly) that lambda calculus is not *a logic*. See: http://lambda-the-ultimate.org/node/3719 Best Regards, Pat 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

Patrick Browne wrote:
Heinrich Apfelmus wrote:
3) Not sure what you mean by proof theoretic semantics. Apparently, the trace of any program execution like, say
product [1..5] -> 1 * product [2..5] -> .. -> 120
is a proof that the initial and the final expression denote the same value.
The Curry-Howards correspondence is about the type system, viewing types as logical propositions and programs as their proofs.
This seems to address the first point (the role of lambda calculus. But what of the second point, the role equational logic. I assume (perhaps incorrectly) that lambda calculus is not *a logic*. See: http://lambda-the-ultimate.org/node/3719
That depends a lot on what you think "logic" means. Certainly we should be willing to call Haskell's type system a logic, with the term-level serving as proofs of the types/propositions (by Curry/Howard). It's a woefully inconsistent logic[1], sure, but a logic nevertheless. Whether we would want to call the term-level a logic is a different matter. And this is where we get into terminological disputes; e.g., to what extent are algebraic systems different/similar to logical systems? (and to what extent are computational systems similar/different to algebraic systems?) This isn't just an issue of terminology: it throws a spotlight on elephants hiding in the room, elephants such as whether all mathematics can be reduced to logic, what the relationship is between logic and language, etc. Mathematicians, logicians, philosophers, theoretical linguists, and computer scientists all have a stake in those arguments--- a stake which is, at best, tangential to the actual question, and therefore makes it hard to get a decent answer/discussion. Equational logic is used heavily for reasoning about programs in Haskell (and pure functional languages generally). It shows up in the safety proofs for the type system, correctness proofs for compilers, strictness analysis, optimizations, etc. However, as you mention in that LtU post, equational reasoning doesn't really show up *in* Haskell, only in reasoning *about* Haskell. Without dependent types or a more developed formal language for reasoning with RULES and proving their correctness, it does not seem possible to support equational reasoning within Haskell (except in the most trivial sense that defining functions is defining a system of equations). It's not clear to me whether you're asking about equational reasoning for theory or metatheory. Also, because the type system is inconsistent, that raises the question of what it could mean to reason in such a logic. Logicians throw up their hands whenever a logic is inconsistent, but computer scientists have been reasoning with inconsistency for years. In discussing a constructive LEM, Oleg highlights some interesting connections between the idea of monads-as-computation and well-known results about how the boundary of computability separates the space of Classical and Intuitionistic theorems. Issues of inconsistency also show up in reasoning about language-based security systems where sometimes we may wish to allow inconsistent states during computation so long as there is a formal guarantee that consistency is restored soon. But overall, the question of what it means to reason formally and correctly in the face of an inconsistent system is still an open question. [1] Because of bottom, as well as many other reasons: http://okmij.org/ftp/Haskell/types.html#fix [2] http://okmij.org/ftp/Computation/lem.html -- Live well, ~wren

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 7/15/10 23:31 , wren ng thornton wrote:
Issues of inconsistency also show up in reasoning about language-based security systems where sometimes we may wish to allow inconsistent states during computation so long as there is a formal guarantee that consistency is restored soon. But overall, the question of what it means to reason formally and correctly in the face of an inconsistent system is still an open question.
Hm. Do databases provide any useful insights here? I'm thinking that the above sounds a lot like an uncommitted transaction. - -- brandon s. allbery [linux,solaris,freebsd,perl] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxBH4QACgkQIn7hlCsL25V5mwCghnH2So1voCGAhnregwNb6hb/ wu8AoIMJpbFGAxtYD6hYFj5QVkli9/bs =x8pe -----END PGP SIGNATURE-----

On Jul 14, 2010, at 1:51 AM, Ben Lippmeier wrote:
Replacing equals by equals usually doesn't change anything.
What kind of equality do you use for getChar :: IO Char ?
The usual one: getChar = getChar. It's a pure value. If I find [getChar,getChar] in a program, I can safely replace it by let g = getChar in [g,g].

Patrick Browne wrote:
Hi, In Haskell what roles are played by 1)lambda calculus and 2) equational logic? Are these roles related?
I think this thread is getting a bit too theoretical, so I moved it to http://lambda-the-ultimate.org/node/4014 Thanks for putting the time and effort into your really helpful replies. Pat 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
participants (8)
-
Ben Lippmeier
-
Brandon S Allbery KF8NH
-
Brent Yorgey
-
Heinrich Apfelmus
-
Patrick Browne
-
Peter Gammie
-
Richard O'Keefe
-
wren ng thornton