Theoremcore
Curry-Howard correspondence
Also called propositions as types, proofs as programs.
Simple types are the formulas of intuitionistic implicational logic, typed lambda terms are its natural deduction proofs, and beta reduction is the removal of detours from proofs.
The Curry-Howard correspondence says that a type is a logical formula and a program of that type is a proof of the formula. In its first and most precise form, the types of the simply typed lambda calculus are the formulas of intuitionistic logic with implication only, the typed terms are exactly the natural deduction proofs, and one step of beta reduction is one step of the normalization of proofs. Curry saw the match for combinators in the 1930s and 1950s, and Howard stated it for natural deduction in 1969. It is the reason that a type checker can be a proof checker.
Statement
Fix a set of atoms . Formulas, which are also types, are . Natural deduction for intuitionistic implicational logic, NJ(), proves judgments , where lists labelled hypotheses . It has three rules: a hypothesis (Ax), implication introduction (I), which discharges a hypothesis, and implication elimination (E), which is modus ponens. A detour is a (I) whose conclusion is at once the major premise of a (E). Prawitz's reduction of a detour replaces each use of the discharged hypothesis by the proof of the minor premise. A derivation is normal if it has no detour. The terms are the Church-style terms , and , typed by T-Var, T-Abs and T-App.
Theorem (Curry-Howard).
- Erasure. If , then removing the terms from the typing derivation gives an NJ() derivation of .
- Bijection. For each and , erasure is a bijection between the terms with (up to renaming of bound variables) and the NJ() derivations of (up to renaming of discharged labels). T-Var, T-Abs and T-App match (Ax), (I) and (E).
- Reduction. A beta-redex in is a detour in its derivation, and the beta step is the reduction of that detour. So is beta-normal if and only if its derivation is normal.
- Normalization. Every sequence of detour reductions of an NJ() derivation is finite, and it ends in a normal derivation of the same judgment.
Corollary. A formula is provable in NJ() if and only if the type has a closed term.
Natural deduction normalization is the natural deduction form of Gentzen's cut elimination: a detour is a cut, an introduction followed at once by an elimination of the same connective.
In plain words
Read a type as a claim. The type "from A to B" is the claim "if A then B". A program of that type is a method that turns any evidence for A into evidence for B, and that is what a proof of "if A then B" is. Writing a function is proving an "if" claim; calling a function is using one. A program that builds a function only to call it at once is a proof with a pointless detour: it proves a general rule and then applies it once. Running that call is cutting out the detour. Because typed programs in this calculus always finish, every proof can be made direct. The match is with constructive logic, where a proof must give a method. Some classical laws, such as Peirce's law, have no program.
Proof
The proof file has the full proof of parts 1 to 3, and of part 4 from strong normalization of the STLC, which it cites.
- Erasure is an induction on the typing derivation: each typing rule, with the terms removed, is a rule of NJ().
- Bijection. Church-style terms have unique typing derivations, so erasure is a function. Its inverse reads a term off a derivation: a hypothesis labelled gives the variable , (I) discharging gives , and (E) gives application. Two inductions show the maps are inverse.
- Reduction. A redex is typed by T-App above T-Abs, which erases to a detour. The substitution lemma builds the typing of by putting a copy of the derivation of at each occurrence of . That is exactly Prawitz's reduction.
- Normalization. By part 3, detour reductions of a derivation are beta steps of its term. The STLC is strongly normalizing (Tait 1967; the proof is on the reducibility method page), so every such sequence is finite.
Example: a detour. The term has type . Its derivation first proves the general rule by (I), then applies it to the proof of by (E). One beta step gives , the direct proof by one (I) over one hypothesis.
Example: Peirce's law has no proof. Let . A closed normal term of type must be with . An atom-typed normal term is a variable applied to arguments, and the only variable is , so with . A head form with head has type or , so with . Now the head of is or , and neither can produce . So there is no normal term, and by normalization no term at all. A depth-bounded search for long normal forms, run as a script, confirms this. The same search finds exactly one normal inhabitant of , namely (the combinator ), and exactly one of , namely (the combinator ). Peirce's law holds in classical logic, so the correspondence is with intuitionistic logic.
Consequences
The theorem extends connective by connective. Each extension has the same three parts: formulas as types, proofs as terms, normalization as evaluation.
- Products, sums and the empty type. Pairs are conjunction, with pairing as I and projections as E. Tagged unions are disjunction, with
caseas E. The empty type is falsity , and is . - Hilbert systems and combinators. The types of and are the two axiom schemes of the Hilbert system for implication, and application is modus ponens. This was Curry's observation (combinatory logic). The translation of lambda terms to combinators is the deduction theorem.
- Second-order logic. System F is second-order intuitionistic propositional logic: is quantification over propositions. Normalization of System F implies the consistency of second-order arithmetic, so by Gödel's second incompleteness theorem Girard's normalization proof cannot be formalized inside second-order arithmetic.
- Predicate logic. Dependent types are predicate logic: a dependent function type is , and a dependent pair type is . Automath (de Bruijn, 1968), Martin-Löf type theory, Coq, Agda and Lean rest on this.
- Classical logic. Griffin (1990) showed that
call/cccan be given the type , which is Peirce's law, and the control operator the type . Classical proofs are programs with control effects. The double-negation translations of classical logic into intuitionistic logic are CPS translations. - Linear logic. Girard's linear logic corresponds to linear types, where each hypothesis is used exactly once.
- Complexity. Provability in intuitionistic implicational logic is the inhabitation problem for simple types, which is PSPACE-complete (Statman 1979). Type checking a proof term is proof checking, which takes linear time for this calculus.
Tightness
- Only intuitionistic logic. Peirce's law, the excluded middle and double negation elimination are classical tautologies with no closed term in the pure typed lambda calculus. Adding them needs control operators, as above.
- Termination is needed for consistency. If the language has general recursion, for example , then has every type , including . The logic becomes inconsistent. This is why proof assistants require every function to terminate, and why ML or Haskell types are not sound as a logic.
- The bijection needs Church style and labelled hypotheses. In Curry style, one untyped term such as is the image of a derivation of and of a derivation of . If hypotheses are not labelled, the two terms and of type give the same unlabelled proof tree, although they are different programs.
- Proofs are finer than provability. All the closed terms of type prove the same formula, but they are the Church numerals , an infinite set of different programs. The correspondence keeps the structure of proofs, not only provability.
Proof: The Curry-Howard correspondence between the simply typed lambda calculus and implicational natural deductionfull
This file proves parts 1 to 3 of the statement in full. Part 4 uses strong normalization of the simply typed lambda calculus, which is proved on the reducibility method page and in Girard, Lafont and Taylor, Proofs and Types, Chapter 6. Given that theorem, part 4 is proved here in full.
Setting
Formulas and types. Fix a set of atoms . Formulas, which are also the types, are .
Natural deduction NJ(). A derivation has open hypotheses, each with a label. We write where lists the labels of the open hypotheses with their formulas; the labels are distinct, and two labels may carry the same formula. The rules are:
- (Ax) If , then by the hypothesis .
- (I) From a derivation of , infer and discharge the hypotheses labelled .
- (E) From derivations of and , infer .
Two derivations are the same if they differ only in the names of discharged labels.
Terms. The Church-style terms are , up to renaming of bound variables, with the typing rules T-Var, T-Abs and T-App of the simply typed lambda calculus.
Detours. A detour in a derivation is an application of (I) whose conclusion is at once the major premise of (E). Its reduction (Prawitz) takes the subderivation of and the subderivation of , and replaces each use of the hypothesis in by a copy of . The result is a derivation of . A derivation is normal if it has no detour.
Part 1: erasure
Claim. If , then the derivation of the typing judgment, with each term removed, is an NJ() derivation of .
Proof. By induction on the typing derivation. T-Var with becomes (Ax) with hypothesis . T-Abs, from to , becomes (I) on the erased premise, discharging . T-App becomes (E) on the two erased premises. Each rule has the same premises and conclusion once terms are removed, so the result is a derivation.
Write for this erasure of a typing derivation .
Part 2: the bijection
Claim. For each and , the map , where is the typing derivation of , is a bijection from the terms with to the NJ() derivations of .
Proof. First, the map is well defined: by the inversion lemma for T-Var, T-Abs and T-App (one rule per form of term, and in T-App the type of the argument is fixed by uniqueness of types), each typable Church term has exactly one typing derivation .
Define the inverse on derivations by induction:
- of the hypothesis is the variable .
- of (I) discharging above a derivation is .
- of (E) with premises and is .
By induction on , , because each clause is the matching typing rule. By induction on , : each clause makes a term whose last typing rule erases to the last rule of , and the subterms come from the subderivations. By induction on , , for the same reason. Renaming a discharged label on one side is renaming a bound variable on the other, so the two notions of sameness match.
Part 3: beta reduction is detour reduction
Claim. Let . Then has a beta-redex if and only if has a detour. Contracting a redex in gives the term whose derivation is the reduction of the matching detour. So is beta-normal if and only if its derivation is normal.
Proof. A subterm is typed by T-App whose first premise is T-Abs, and this erases to (E) whose major premise is (I): a detour. Conversely, by Part 2, a detour is the image of a T-App whose function premise ends in T-Abs, and a term typed that way is a redex. So redexes and detours are in one-to-one correspondence, by position.
Let be the derivation of and that of . The substitution lemma (proved in full for this calculus on the type soundness page) builds the derivation of by induction on : at each occurrence of the variable it puts a copy of , weakened by the bound variables of above that occurrence, and it keeps every other rule. After erasure this is exactly Prawitz's reduction: each use of the hypothesis in is replaced by a copy of . The context of the whole term is unchanged, because a redex inside sits under the same rules before and after the step.
Part 4: normalization
Claim. Every NJ() derivation reduces, by any sequence of detour reductions, in finitely many steps, to a normal derivation of the same sequent.
Proof. Let be a derivation of , and . By Part 3, a sequence of detour reductions from is the image of a sequence of beta steps from , of the same length. By strong normalization of the simply typed lambda calculus (Tait 1967), every such sequence from is finite. When no step is possible, the term is beta-normal, and by Part 3 the derivation is normal. Each step keeps the sequent, by Part 3 and preservation.
Corollary: Peirce's law has no proof
Claim. For distinct atoms and , there is no closed term of type , so the formula has no NJ() proof.
Proof. By Parts 2 and 4 it is enough to show that there is no closed beta-normal term of this type. A beta-normal term has the form with , a variable at the head and beta-normal , because a term that is not an abstraction is a variable applied to arguments (otherwise its leftmost head would be an abstraction applied to an argument, a redex).
- is closed, so it is not of the form with free. So with .
- has the atom type , so it is not an abstraction, and with , the only variable. The type ends in after one argument, so with .
- is an abstraction or a head form. A head form has head , and its type is with no argument or with one argument. Neither is . So with .
- has the atom type , so it is a head form with head or . A head form with head has type or , and a head form with head has type . None is , because .
So no normal term exists, and no term exists.
The same argument with finds the term , so the atoms must be distinct. A depth-bounded search over long normal forms, run as a script, finds no inhabitant of Peirce's law, one of , and one of the type of .
History
Curry noticed in 1934 that the types of the basic combinators are axioms of implicational logic, and Curry and Feys (1958) stated the match between combinator types and Hilbert-style proofs. Tait (1965) connected cut elimination with the normalization of typed terms. Prawitz (1965) proved normalization for natural deduction. Howard wrote "The formulae-as-types notion of construction" in 1969 and circulated it as a manuscript. It gave the match for natural deduction, extended it to first-order arithmetic with dependent types, and was published in 1980 in the Festschrift for Curry. De Bruijn's Automath (from 1968) used the same idea for computer-checked mathematics, and Martin-Löf (1971 onward) made it the base of a constructive type theory. Girard (1972) and Reynolds (1974) found System F, Girard from second-order logic. Lambek added the third side, cartesian closed categories. Wadler (2015) gives a survey.
References
- William A. Howard, The formulae-as-types notion of construction, in J. P. Seldin and J. R. Hindley (eds.), To H. B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism, Academic Press, 1980, pages 479 to 490 (manuscript of 1969), Sections 1 and 2 (implicational formulas as types, terms as constructions, and the match of normalization of terms with normalization of proofs)
- Philip Wadler, Propositions as types, Communications of the ACM 58(12), 2015, pages 75 to 84, the whole survey (history, the natural deduction and lambda calculus side by side, and the extensions to other logics)
- Jean-Yves Girard, Yves Lafont and Paul Taylor, Proofs and Types, Cambridge University Press, 1989, Chapter 2 (natural deduction), Chapter 3 (the Curry-Howard isomorphism), Chapter 4 (the normalization theorem), Chapter 6 (strong normalization), Chapter 11 (System F and second-order logic)
- Morten Heine Sorensen and Pawel Urzyczyn, Lectures on the Curry-Howard Isomorphism, Elsevier, 2006, Chapter 4 (the isomorphism for implicational logic), Chapter 5 (proofs as combinators, Hilbert systems), Chapter 6 (classical logic and control operators)
- Haskell B. Curry and Robert Feys, Combinatory Logic, Volume I, North-Holland, 1958, the chapter on functionality (the types of the basic combinators are the axioms of implicational logic)
- Dag Prawitz, Natural Deduction: A Proof-Theoretical Study, Almqvist and Wiksell, 1965, the normalization theorem for intuitionistic natural deduction and the reduction of detours
- Richard Statman, Intuitionistic propositional logic is polynomial-space complete, Theoretical Computer Science 9(1), 1979, pages 67 to 72, the main theorem (provability in intuitionistic implicational logic, and so inhabitation of simple types, is PSPACE-complete)
- Timothy G. Griffin, A formulae-as-types notion of control, POPL 1990, the typing of call/cc and the control operator C with classical tautologies such as double negation elimination
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag PHJYVS Edit this page History Report an error Markdown