coursang2.pdf

Upload: abel-ganz

Post on 14-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/29/2019 Coursang2.PDF

    1/70

    Part II

    Around Curry-Howard

    112

  • 7/29/2019 Coursang2.PDF

    2/70

    Chapter 5

    Functional interpretations

    5.1 Proofs as functions

    5.1.1 The semantics of proofs

    Around 1930 appeared several explanations of logic. Tarski and his truth, butalso an interpretation due to Kolmogorov, and independently Heyting1. Oneoften uses for that matter the expression semantics of proofs.

    Semantics

    conveys a large range of significance : its semantics is con-

    fused ! Normally, this expression applies to the sense of an expression ; awell-established use links it to syntax

    in an opposition syntax/semantics

    whose poles are completeness and soundness. Semantics has been dressed inall possible sauces, for instance the opposition between denotational semantics(the category-theoretic interpretation of logic) and operational semantics (thetiresome and unimaginative paraphrases of a programming language). Notto speak of algebraic semantics (the interpretation of a system in itself bychanging the typeset : syntax in italics, semantics in boldface), and moregenerally of a very creative activity trying to obscure the sense, so as to pro-duce one more useless paper or PhD. This is why I prefer to confine the use of

    this dubious word to its original sense, and use for the rest

    interpretation

    , explanation

    , which have the advantage to be clear and honest, withoutsubliminal background.

    As to the importance of the choice of words, the fact that some of themare used on purpose to ossify the discussion, see the appendix of Orwells

    1984

    . An example of Orwellian misunderstanding is the expression gamesemantics

    : one (correctly) interprets logic as a game between a player (who

    tries to prove) and an opponent (who tries to refute) ; the player thereforereplaces syntax, and the opponent replaces semantics. But to style this a

    1Most likely Brouwer, of whom Heyting was the assistant, and who cordially hated logic.

    113

  • 7/29/2019 Coursang2.PDF

    3/70

    114 CHAPTER 5. FUNCTIONAL INTERPRETATIONS

    semantics, this amounts at introducing a second interpretative layer, a meth-

    odological confusion which forgets that it is at the level of the opponent andnot at that of the game that one should look for the semantics. In otherterms game semantics is a semantics of semantics

    ; why not choosing an-other expression ?

    I know that my insistence at Giving a purer sense to the words of thetribe.2 can sometimes be irritating. But it is one of the lessons I took fromKreisel : try to use the right word. This is why, in this text, I am using

    antinomy

    , an expression stronger than paradox

    , to speak of Russell ;what, by the way, restores Gdels theorem its status of paradox. It is why,in this chapter at least, I try to respect a distinction between application

    and

    function

    . This is also why I banished

    meta

    from my vocabularybecause of the essentialism it conveys. On the other hand, I made no attemptsat modifying honest expressions ; typically syntax

    which means languageand nothing more.

    5.1.2 The functional interpretation

    It is indeed a procedural interpretation : one defines the expression is aproof of A , for, say, the language of Heytings arithmetic AH. In whatfollows, A is a closed formula, and is an object whose formal status must be

    left the most vague possible. Any premature attempt at formalisation3

    couldonly weaken the idea.

    Atom : If A is an atom 0, t = u, t < u, then is a proof of A iff A is true.

    Conjunction : is a proof ofA B iff is a pair (1, 2), where 1 is a proofof A and 2 is a proof of B.

    Disjunction : is a proof of A B iff is a pair (i, 1), where, either i = 1and 1 is a proof of A, or i = 2 and 1 is a proof of B.

    Implication : is a proof ofA B iff is an application associating to eachproof of A a proof () of B.

    Universal quantification : is a proof ofxA iff is an application whichassociates to each integer n a proof(n) of A[n/x].

    Existential quantification : is a proof of xA iff is a pair (n, 1), wheren is an integer and 1 is a proof of A[n/x].

    2Donner un sens plus pur aux mots de la tribu (Mallarm).3E.g., at reducing it to a recursive or category-theoretic interpretation : it is much more

    than that.

  • 7/29/2019 Coursang2.PDF

    4/70

    5.1. PROOFS AS FUNCTIONS 115

    A few remarks :

    This is not a matter of formal proofs. A formal proof is a sequence ofsymbols, by no way an application ; it is rather an interpretation offormal proofs, or again the attempt at explaining logic out of a primitivematerial external to formalism.

    It could however be the case that this approach presents, under disguise,an alternative definition of formal proofs. It is tenable for all operations,but implication and universal quantification which refer to applicationswhose domain is not finite (nor definite in the case of implication). Kre-isels attempt to overcome this mismatch foundered into mockery andsectarianism, see 5.A.

    The cases of existence and disjunction (which are reminiscent of the well-known properties of system LJ) show that is reminiscent of cut-free,explicit proofs : one is quite far from the deductive world.

    One does not simply say a proof ofA or a proof ofB , one says whichone. This immediately induces, even in the finite case, an immensedifference with semantics. Indeed, anything is a proof of 0 = 0 ; but aproof of 0 = 0 0 = 0 is not a proof of one or the other (in case it would

    be anything), it is a pair (i, ) where is indeed anything, but wherei is a bit making a left/right choice. This is a radical novelty w.r.t.semantics ; for instance, the not quite exciting Kripke models. Thefunctional interpretation is not concerned with the raw fact of knowingthat A is true, it says how, here, leftwise or rightwise.

    It is out of question to verify this interpretation, since we didnt even formaliseit. Remark however that the identity application, which sends any proof of A toitself, id() := , is a proof of A A. Similarly, one can justify the inductionprinciple as follows : if is a proof ofA[0] and is a proof ofz(A[z] A[Sz]),then , defined by recurrence by (0) := , (n+1) := ((n))((n)) is a proof

    of xA[x].

    5.1.3 Blind spots

    This definition leaves some blind spots. For instance, since 0 is false, is aproof of A := A 0 iff A has no proof at all ; indeed, must send theproofs of A in the proofs of 0, i.e., in the empty set, what is possible only incase A has no proof at all ; in which case is arbitrary. In particular, doublynegated formulas are quite mistreated by this interpretation. Either A hasa proof (and everything is then a proof of A) or it is A who has a proof

  • 7/29/2019 Coursang2.PDF

    5/70

    116 CHAPTER 5. FUNCTIONAL INTERPRETATIONS

    (and everything is then a proof of A). All one can object to my remark

    is poor : I am using the excluded middle, so my

    meta is inappropriate !Witness how this Mister Meta comes in time to tangle up the cards.

    In the same way recessive formulas are mistreated. Indeed, if A has onlybounded quantifiers, a truth computation for A induces a proof of A, so Ahas a proof

    iff it is true. Therefore xA has proof iff it is true ; in case

    anything is a proof of it, but how do we this ? Only since it is true. . . In thatcase, the functional interpretation of proofs does not better than Tarski : it isa pure tautology.

    The functional interpretation is a matrix from which one can build category-theoretic, ludic. . . interpretations, but that one should not take literally. One

    can by the way make it say almost anything : for instance, by taking a cornyset-theoretic standpoint, one can associate a proof to any classical truth com-putation. The functional object thence obtained is, on the other hand, non-effective, non-computable, and of no interest.

    5.1.4 NJ functionally revisited

    For want of something better4, we shall keep the set-theoretic viewpoint andfollow the rules of NJ stepwise. Here, we forget the arithmetic substrate ; inother terms, we assume that the interpretation of non-logical atoms has been

    given to us. To each closed formula A we associate a set |A|, as follows :

    |A B| := |A| |B|

    |A B| := |A| + |B|

    |A B| := |B||A|

    |0| :=

    |xA| :=

    dD

    |A[d/x]|

    |xA| :=

    dD

    |A[d/x]|

    (5.1)

    One uses : the Cartesian product, the disjoint sum X+Y := {1}X{2}Y,the space YX of all functions from X to Y. Quantifiers make use of sums andproducts indexed by a domain D supposedly given : we shall almost lose anyinterest in them5. Not because the interpretation does not work well in thiscase ; but it is second order (propositional) quantification which is of interest,see chapter 6.

    4While waiting for categories, see section 7.2.5See however section 6.A.2.

  • 7/29/2019 Coursang2.PDF

    6/70

    5.1. PROOFS AS FUNCTIONS 117

    To each deduction of a formula A in NJ, under the hypotheses , one

    associates a function [] sending arguments x chosen in the || to the result[x] |A|. We carefully distinguish, at least in this chapter, the notion offunction, [x], from that of application (x). By a function, we quite meana function, by an application, we mean for want of better its set-theoreticgraph. Please, do not think that this is a matter of hairsplitting, of fly wingsweighted in scales made of spider thread : the distinction function/applicationis reminiscent of the distinction property/set, of which we know, by Russellsantinomy that it is explosive.

    Hypothesis : The function associating to the argument xA the result xA.

    Conjunction : This case makes use of the pairing function (, ), as well asthe two projections l, r :

    -introduction : If the two premises of the rule have been interpretedby functions 1[x

    ] and 2[x], then [x] := (1[x

    ], 2[x]).

    Left -elimination : If the premise of the rule has been interpreted bya function 1[x

    ], then [x] := l1[x].

    Right -elimination : If the premise of the rule has been interpretedby a function 1[x

    ], then [x] := r1[x].

    Disjunction : This case makes use of the injectionsl, r and the conditional :

    Left -introduction : If the premise of the rule has been interpretedby a function 1[x

    ], then [x] := l1[x].

    Right -introduction : If the premise of the rule has been interpretedby a function 1[x

    ], then [x] := r1[x].

    -elimination : If the three premises of the rule have been interpretedby functions 1[x

    ], 2[x, yA] and 3[x

    , zB] then

    [x] := 2[x, yA] if 1[x

    ] = lyA

    := 3[x, zB] if 1[x

    ] = rzB (5.2)

    Implication : This case makes use of two operations which seem to go withoutsaying, on one hand the association to a function [x] of an application,its graph x[x] (which is a set) ; on the other hand the possibility toapply a functional graph g (element ofYX) to an element x X, yieldingan element g(x) B.

    -introduction : If the premise of the rule has been interpreted by afunction 1[x

    , yA], then [x] := yA1[x, yA].

  • 7/29/2019 Coursang2.PDF

    7/70

    118 CHAPTER 5. FUNCTIONAL INTERPRETATIONS

    -elimination : If the two premises of the rule have been interpreted

    by functions 1[x] and 2[x], then [x] := 2[x](1[x])

    Absurdity : This case uses the canonical inclusion of the empty set intoanything.

    0-elimination : If the premise of the rule has been interpreted by afunction 1[x

    ], then [x] := 1[x].

    5.1.5 Occurrences, locative aspects

    It is time to stoop over an ambiguity that could become embarrassing. The

    two deductions :

    [A] [B]I

    A BI

    B A BI

    A (B A B)

    [B] [A]I

    B AI

    B B AI

    A (B B A)

    correspond to the functions f(x)(y) = (x, y) et g(x)(y) = (y, x). This beingsaid, making A = B, the notation

    [A] [A] IA A

    I

    A A AI

    A (A A A)

    becomes ambiguous, since one cannot tell which occurrence of A has beendischarged at the occasion of a -introduction6. The best solution is due tode Bruijn : it consists in indexing each discharged hypothesis by means of aninteger yielding the relative location of the discharging rule, i.e., how manysteps below. The two previous cases will be distinguished by :

    [A]3 [A]2I

    A AI

    A A AI

    A (A A A)

    [A]2 [A]3I

    A AI

    A A AI

    A (A A A)

    This solution is excellent, especially in practice. I propose an explanationof it, based on locativity, a recent idea, see [47]. Let us not forget that the goal

    6There are indeed four possibilities, since one can discharge both hypotheses at once.

  • 7/29/2019 Coursang2.PDF

    8/70

    5.2. PURE-CALCULUS 119

    of any deductive system is to prove formulas without context (hypotheses) : in

    order to prove , one uses subformulas of , A , B . . ., and the problem is notto mix up the various occurrences of the same subformula A of. I propose aradical solution : abolish the notion of occurrence. Thus, in A (A A A)one no longer deals with four occurrences of the same7 subformula A : onehas four distinct isomorphic subformulas, what one should note A1 (A2 A3 A4). In which sense are they distinct ? They are distinct since theyoccupy distinct locations of the arborescence of :

    1

    2

    3 4

    5

    6

    0

    We have indicated the other locations of subformulas by 0, 5, 6 : thus is loc-ated in 0. The ambiguity as to occurrences disappears : one replaces equalitywith isomorphism. This poses a notational problem with the identity axiom,since it has not the same location as a hypothesis (1 or 2) and conclusion (3or 4). One should normally note A24 the apparition in conclusion, in location4 of the hypothesis located in 2. This is, in my opinion, the most satisfactorytheoretical solution. De Bruijns notation fundamentally does the same thing :

    since it locates the discharged hypotheses in a formula located below.This being said, in practice, we shall take no account of this. This sort

    of solution is indeed like the bracket-free, called Polish, notation : ABinstead of A B. This is theoretically perfect, very good for machines, butthe poor human beings lose their milestones. Theoretically, our occurrence-freeapproach could be useful in relation to subtyping, an interesting, but sometimesconfused, idea, see 6.E.

    5.2 Pure -calculus

    5.2.1 A naive function theory

    The set-theoretic functional interpretation is quite brutal. One has difficultiesin believing that logical operations may live in something as little constructiveas set theory. -calculus will provide us with another space of reference8.

    One will never repeat too much that nothing is more fecund than a mistake,provided one gets out of it. Originally, the inventors of this system sought a sort

    7In the same way, twins are not occurrences of the same person, they are distinct, butsimilar, individuals.

    8Speaking of references : Barendregts book [7], the encyclopedia of -calculus.

  • 7/29/2019 Coursang2.PDF

    9/70

    120 CHAPTER 5. FUNCTIONAL INTERPRETATIONS

    of naive function theory

    . One declines the correspondence sets/properties in

    applications/functions a nuance introduced here for the sake of pedagogy :by application

    I mean the functional object, while the function is ratherthe passage argument ; result. To the comprehension schema (1.1) everyproperty defines a set

    , answers a functional analogue every function defines

    an application

    . For what follows, it imports to clearly differentiate the func-tional dependency f[a] (the value of f on a) from the applicative dependency,f(a) (f applied to a). In the same way a property P[a] induces a set {x; P[x]},a function f[a] induces an application xf[x]. The application corresponds tothe function just like the set corresponds to the property :

    xf[x](a) = f[a] (5.3)

    Notice the replacement of equivalence by equality.This is obviously a bad start, since one knows that sets can be encoded by

    means of their characteristic functions : we shall be able to import Russellsantinomy. We have exact analogues of all the notions of naive set-theory, butnegation, which will come later, let us call it N. The literal translation of{x; (x x)} will be, once N has been determined, A := xN(x(x)). Animmediate application of equation (5.3) yields

    A(A) = N(A(A)) (5.4)

    Exit -calculus ? No, but if it eventually recovered, there was for a whilea definite hesitation among the inventors, Church, Kleene, Rosser. . . Therewas eventually a second thought : the logical setting was replaced with acomputational setting, which amounts at a passage from essence to existence.If it is no longer a matter of total functions, but of partial functions, then

    lhonneur est sauf

    : one gets a fixed point for negation under the formof a diverging algorithm. More generally, since I was cautious in not makingN precise, one sees that any application admits a fixed point. This is thefundamental principle behind recursive functions, i.e., functions defined interms of themselves. A definition of the form (x) := . . . . . . x . . . will beexpressed in -calculus as a fixed point of the expression y x . . . y . . . x . . .

    Originally a variant of set-theory, -calculus developed into a (theoretical)programming language. In general all relations with set-theory are very shal-low, and produce wrong intuitions. There is an incompatibility of temperbetween set-theory and -calculus, between unrestricted infinity and comput-ability, between essence and existence.

    5.2.2 Examples

    Before proceeding further, let us indicate how to encode a certain number ofdata and functions.

  • 7/29/2019 Coursang2.PDF

    10/70

    5.2. PURE-CALCULUS 121

    Booleans

    Truth values are traditionally represented by v := xyx and f := xyy.This is justified only because it enables one to represent the conditional if tthen a else b

    by (t(a))(b). Indeed, ((xyx)(a))(b) = a, while((xyy)(a))(b) = b. One can thence define the usual boolean connectives ;for instance negation by N := z(z(f))(v).

    Remark that these are not quite the logical truth values, but their closealgorithmic analogues. It is indeed a matter of the answers one can give to abinary question (yes/no, left/right, spin up/down).

    PairsIt is possible to encode ordered pairs by means of (a, b) := x(x(a))(b). Thiscoding is operational, since it enables one to represent both projections bylc := c(v), rc := c(f) : indeed, one verifies that l(a, b) = a, r(a, b) = b.

    Natural numbers

    Natural numbers are encoded as Church integers

    , the iteratorsn := xyx(x(. . . (x(y)) . . .)), with n occurrences of x after the prefix xy :n sends x on x . . . x. This coding is operational, since it enables one to

    represent definitions by recurrence, of the type [0] := a, [n + 1] := f[[n]] :take [z] := (z(wf[w]))(a). To be noticed that the successor functionis represented by S[z] := xy(x(z(x)))(y). Since the fixed point enables thepossibility of recursive (i.e., self-referential) definitions, it will be possible torepresent any partial recursive function in -calculus. And nothing more, sincethe expansive nature of the equation of -calculus forces a partial numericalfunction representable in it to be recursive.

    5.2.3 The Church-Rosser theorem

    The syntax of -calculusA change of standpoint enabled one to avoid a logical contradiction. But thesystem could still be algorithmically inconsistent. This would be the case ifthe use of equation (5.3) could lead to absurdities, e.g., v = f. Observe thatwe have no heavy argument showing algorithmic consistency. The only wecould think of would be set-theoretic, but a set-theoretic interpretation of thetype application = graph

    immediately requires naive comprehension (1.1),

    which is contradictory.One will eventually produce an elementary consistency proof, a real, a good

    one. Gdel has nothing to object, since -calculus has carefully been emptied

  • 7/29/2019 Coursang2.PDF

    11/70

    122 CHAPTER 5. FUNCTIONAL INTERPRETATIONS

    from any explosive logical contents.

    We must first carefully define a syntax. -terms are constructed by meansof three operations :

    Variable : A variable x , y , z , . . . is a -term.

    -abstraction : If t is a -term, then xt is a -term. Observe that thevariable x is bound. One should therefore not hesitate to rename it incase of ambiguity9.

    Application : If t, u are -terms, (t)u is a -term.

    Observe the notation : (t)u instead of t(u), while one really means thefunction t applied to the argument u

    . This notation due to Krivine

    enables one to avoid avalanches of parentheses. With respect to the codingsof the last section, this yields :

    x((x)a)b for the pair (a, b), (a)xyx for the left projection la.

    xy(x)(x)(x)y for integer 3,xy(x)((z)x)y for S[z], [z] := ((z)wf[w])a for recurrence.

    One proceeds by defining an immediate reduction :

    (xt)u;

    t[u/x] (5.5)

    more precisely, one can replace, in arbitrary term, any part of the form (xt)u(redex) with its contractum t[u/x] (respecting the freshness of bound vari-ables) : this is immediate reduction. Reduction ; is defined as the reflexiveand symmetric closure of immediate reduction.

    One step reduction

    The Church-Rosser theorem establishes computational consistency by meansof confluence, see theorem 14. The idea of the proof is to express reduction as

    the reflexive/transitive closure of a confluent one step reduction;1.

    Lemma 17.1If;1 is confluent, the same is true of;.

    Proof : If t = t00 ;1 t10 ;1 . . . tm0 = t and t = t00 ;1 t01 ;1 . . . t0n = t

    ,one can, like in a building game, add new pieces tij such thatti+1j, tij+1 ;1 ti+1j+1. Eventually, the ultimate piece tmn = t

    is such thatt, t ; t. 2

    9This bureaucratic baloney is the pretext to a specific rule, -conversion ; better to ignoreit, this leads nowhere.

  • 7/29/2019 Coursang2.PDF

    12/70

    5.2. PURE-CALCULUS 123

    One step confluence

    The obvious candidate for one step reduction is immediate reduction. Butthis does not work, take for instance (x(x)x)(xx)xx, which contains tworedexes, let us call them r, s. By reducing r, one gets ((xx)xx)(xx)xx,i.e., (s)s ; by reducing s one gets (((x)x)xx). These two terms are indeedconfluent on (xx)xx, but respectively in two and one steps. The idea ofTait to whom this proof is due consists in allowing the simultaneousreduction of a family of redexes. Which is not the same as the unlimitediteration of immediate reduction : in the previous example, one can at mostsimultaneously reduce r, s, what will lead to (xx)xx.

    Definition 7 (Reduction of a family)If F is a family (set) of redexes of t, one notes t ;F u the result of thesimultaneous reduction of all redexes of F.

    This should be defined more pedantically, but this informal definition hidesno ambiguity. Now, if I reduced a family F of t, t ;F u, and if G is anotherfamily of t, I can consider G \ F in u. It is indeed an abuse of notation tospeak of what happened of G \ F, after the reductions have been performed ;indeed these redexes have images

    in u, which are sometimes duplicated,

    sometimes bluntly erased : thus, if F = {r}, G = {s}, G \ F is made of twodistinct redexes of u, i.e., the two occurrences of s in s(s).

    Lemma 17.2If t ;F u ;G\F v, then t ;GF v

    Proof : Immediate. 2

    In particular, if one defines one step reduction as the reduction of an arbitraryfamily, this notion is confluent.

    Computational consistency

    Theorem 17 (Church-Rosser theorem)The reduction of-calculus is confluent.

    Proof : Immediate from the previous lemmas. 2

    Corollary 17.1The relation defined byt = u : v t, u ; v is an equivalence.

    Proof : Transitivity is a consequence of Church-Rosser. 2

    Corollary 17.2-calcul est algorithmically consistent.

  • 7/29/2019 Coursang2.PDF

    13/70

    124 CHAPTER 5. FUNCTIONAL INTERPRETATIONS

    Proof : Simply because equality (equivalence) between normal terms, i.e.,

    without redex, is the identity. For instance v and f are not equal. 2

    Remark that equality is an expansive notion : the more we reduce, the moreequalities we get. This is why the functions representable in -calculus arepartial recursive.

    5.3 The Curry-Howard isomorphism

    5.3.1 The simply typed -calculus

    A set-theoretic analogy, for once not too catastrophic : after the discovery ofthe antinomies in the naive theory, one proposed typing. It is a sort of super-ego10 forbidding certain forms of logical incest of the kind x x. For instance,in a typed set-theoretic system like the Principia Mathematica of Whitehead& Russell, a set of type n can only belong to a set of typen + 1. We observed that -calculus is algorithmically consistent ; the superegois thence not supposed to guarantee consistency, it indeed ensures the termin-ation of the computations. It is still based on the prohibition of incest : afunction cannot take itself as argument, apply to itself, like in (f)f. The dis-cussion essence/existence will bounce into a discussion typed/pure -calculus.Therefore, do no say that the philosophical preamble of chapter 1 was useless,or that it was included in oldies of the kind platonism/formalism. . .

    The simplest typed -calculus comprises only one primitive, implication :in other terms, starting with atomic types, one can form new types only by useof implication. The type A B therefore designates the functions sendingtype A into type B. The rules of term formation are as follows :

    Variable : A variable xA, yA, zA, . . . is a term of type A.

    -abstraction : Ift is a term of type B, then xAt is a term of type A B.

    Application : If t, u are terms of respective types A B and A, (t)u is aterm of type B.

    This system of terms is governed by a rewriting :

    (xAt)u ; t[u/x] (5.6)

    of which we can predict without risk that it enjoys Church-Rosser.

    10Therefore subject to essentialist deviances.

  • 7/29/2019 Coursang2.PDF

    14/70

    5.3. THE CURRY-HOWARD ISOMORPHISM 125

    5.3.2 Sum, product, exponential

    Let us make it work, this system. If I start with a constant o11, I can definetypes n by n + 1 := n n. One can then write a typed version of Churchintegers in all types n + 2 : one defines pn+2 := xn+1yn(x)(x) . . . (x)y. Andintroduce binary functions : +, , , yielding a result of type n + 2 when theirfirst argument is of type n + 2 and their second argument is of respective typen + 2, n + 2, n + 3.

    X+ Y := xn+1yn((X)x)((Y)x)y

    X Y := xn+1(X)(Y)x

    XY

    := (Y)X

    (5.7)

    Sum is the composition of a function iterated p times with a function iteratedq times, it is therefore an iteration p + q times. Product consists in iteratingp times a function iterated q times, it is therefore an iteration p q times.Finally, exponential consists in iterating q times the p times iteration, it istherefore an iterationpq times. What is confirmed by computation, for instance(qn+3)pn+2 ; pq

    n+2.

    In particular, one see that the function 22

    2x

    can be represented by a termof type 2 depending on a variable x of type k + 2, where k is the height of the

    tower of exponentials. Which by the way shows, modulo Curry-Howard, thatthe bounds found in section 4.C.4 for natural deduction cannot essentially beimproved.

    5.3.3 The isomorphism

    The Curry-Howard isomorphism enunciates the equivalence, total, complete,between two viewpoints :

    Natural deduction : formulas A, deductions of A, normalisation in naturaldeduction.

    Typed calculus : types A, terms of type A, normalisation in typed -calculus.

    This presents no difficulty. One must only be careful with matters of occur-rences. One can use a notation in the style of de Bruijn12.

    Conceptually speaking, the locative viewpoint of section 5.1.5, transposedin the world of -calculus, would yield something like :

    For each type, there is only one variable.

    11Not to be confused with 0.12Originally introduced for -calculus.

  • 7/29/2019 Coursang2.PDF

    15/70

    126 CHAPTER 5. FUNCTIONAL INTERPRETATIONS

    On the other hand, the basic primitive, the variable, becomes a delocation, i.e.,

    the operation replacing xA (argument of type A) with its isomorphic image oftype A. As before, it is a splendid theoretical idea that one will ignore inpractice for questions of legibility.

    Curry-Howard is not a mere correspondence, it is really a matter of iso-morphic structures. It is surprising if one keeps in mind that the two domainsdeveloped in parallel, on one side the typed calculus, on the other side naturaldeduction and sequents. With system F and the forgetful functor, we shall dis-cover in 6.1.2 the unexpected (and unpremeditated) correspondence betweenthe codings of -calculus and the logical translations la Dedekind.

    Curry is responsible for the main idea of the isomorphism, i.e., the corres-

    pondence between functional terms and proofs, in the limited, but essential,context of implication. The contribution of Howard is first the extension to alllogical connectives, and above all the use of Gentzen-style calculi in placed ofthe obsolete Hilbert-style systems used by Curry (in relation with combinatorssee section 5.B).

    5.3.4 Strong normalisation

    Definition 8 (Strong normalisation)A term t is strongly normalisable (sN) if the supremum |t| of the lengths of all

    sequences of immediate reductions starting from t is finite.

    In particular, t is normal when |t| = 0. A weaker definition is that any sequenceof immediate reductions is finite ; since one has at each step the choice betweena finite number of redexes, this weaker version is modulo Knigs lemma

    a well-founded tree with finite branchings is finite

    equivalent to thestronger version we have given. This strong version turns out to be muchmore manageable, typically for matters of formalisation.

    We postpone to the next chapter, for questions of thematic coherence, theproof of strong normalisation. Due to the Curry-Howard isomorphism, thisresult implies the strong normalisation of NJ, for which we so far only gotweak normalisation see theorem 15.

    5.A Kreisel and functional interpretation

    We already mentioned the infinitary character of the explanation of implicationand universal quantification. And that one can therefore have a proof withoutbeing able to verify its status (which would at least require an infinite process) :this is typically the case for recessive formulas, see section 5.1.3. This is whyone tried to improve

    the treatment of these two cases by adding a second

  • 7/29/2019 Coursang2.PDF

    16/70

    5.B. COMBINATORY LOGIC 127

    component to the application : a proof that it really does what it is

    supposed to do .Thats pure baloney ; indeed, let us take a true recessive formula negxA.

    Anything is a proof

    of it ; but it is so only because we know that theformula is true. One sees that a proof xA becomes the pair of an object devoid of interest and. . . of a proof ofxA.

    Kreisel therefore proposed in [63] to remove this circularity by requiringthe auxiliary proofs to be formal ones, moreover in a formal system T given inadvance. In return of which, he was able to establish a sound correspondencebetween the functional notion and formal proofs in T. Nothing astonishing inthat, since it is more or less ad hoc.

    This the way the best ideas are killed. This sort of Kreiselic regression13

    unleashed passions, especially fanatic adhesions. This is regrettable, and es-pecially ridiculous if one keeps in mind that all this stays at the level zero ofreflexion : who can seriously believe in an explanation made of three piecesof string ? This is presumably because it was indefensible that the Kreiselians(Troelstra, etc.) made a case of excommunication out of this matter.

    5.B Combinatory logic

    This is a variant of -calcul14. It is a calculus without variables, based on thesole application, and two primitive combinators K and S for which one writesthe immediate reductions :

    ((K)a)b ; a

    (((S)a)b)c ; ((a)c)(b)c(5.8)

    The combinators can be encoded in -calculus by K := xyx andS := xyz((x)z)(y)z. One can conversely code -calculus in combinators, byrepresenting -abstraction. For instance the identity xx becomes ((S)K)K.

    Obviously this works as well in the typed case. With Curry-Howard in

    mind, we immediately see that this coding of -abstraction is the analogue ofthe deduction theorem of section 3.1.2 which enables one to translate hypo-thetical reasoning (i.e., terms with variables) into proofs la

    Hilbert (i.e.,

    combinators). This intuition is confirmed by the fact that the usual axiomsfor implication in a Hilbert-style system are :

    A (B A)

    (A (B C)) ((A B) (A C))(5.9)

    13In the same style, he required applications to be recursive.14Misnamed, since -calculus carefully expelled any logical contents.

  • 7/29/2019 Coursang2.PDF

    17/70

    128 CHAPTER 5. FUNCTIONAL INTERPRETATIONS

    which are inhabited by typed variants of K and S, xAyBx and

    xA(BC)yABzA((x)z)(y)z. And, by the way, the first step of the deduc-tion theorem consists in deducing A A by means of two Modus Ponens bymaking B := A, then B := A A in the first axiom, B := A A, C := Ain the second axiom, which yields, modulo Curry-Howard, a typed variant of((S)K)K.

    Combinatory logic remains globally inferior to -calculus. One understandsit by comparing Curry to Howard in Curry-Howard

    : the ancient version

    puts in relation combinators and Hilbert-style systems, the modern one -terms and natural deduction. There is the same nuance between combinatorsand -terms as between old-style proofs and natural deduction.

    5.C Other connectives

    The Curry-Howard isomorphism extends to the other logical connectives. Oneshould use for conjunction, + for disjunction, but, keeping in mind theisomorphism, I prefer to stick to the logical notations.

    5.C.1 Conjunction

    Pairing : If t and u are terms of respective types A and B, then (t, u) is oftype A B.

    Left projection : If t is of type A B, then lt is of type A.

    Right projection : If t is of type A B, then rt is of type B.

    One introduces the immediate reductions :

    l(t, u) ; t

    r(t, u) ; u(5.10)

    Curry-Howard is immediately extended ; Church-Rosser still holds.

    5.C.2 Disjunction

    Left inclusion : If t is of type A, then lt is of type A B.

    Right inclusion : If t is of type B, then rt is of type A B.

    Conditional : If t,u,v are of respective types A B, C and C, if xA, yB arevariables of respective types A, B, then (xAu)(yBv)t is of type C.

  • 7/29/2019 Coursang2.PDF

    18/70

    5.C. OTHER CONNECTIVES 129

    The reduction rules are manifold, because of the commutations15 :

    (xAu)(yBv)lt ; u[t/xA]

    (xAu)(yBv)rt ; v[t/yB]

    ((xAu)(yBv)t)w ; (xA(u)w)(yB(v)w)t

    {(xAu)(yBv)t}C; (xA{u}C)(yB{v}C)t

    l(xAu)(yBv)t ; (xAlu)(y

    Blv)t

    r(xAu)(yBv)t ; (xAru)(y

    Brv)t

    (zCr)(wDs)(xAu)(yBv)t ; (xA(zCr)(wDs)u)(yB(zCr)(wDs)v)t

    (5.11)

    5.C.3 Absurdity

    Vide : If t is of type 0, then At is of type A.

    There are only commutative reductions :

    (ABt)u ; Bt

    {XAt}B ; A[B/X]t

    lABt ; At

    rAB

    t;

    B

    t(xAu)(yBv)ABt ; Ct

    A0t ; At

    (5.12)

    Between us, this is not of the utmost interest.

    5.C.4 Quantifiers

    One could do the same with first order quantifiers. But this amounts at writingin a functional setting things that we already encountered in natural deduction,

    and which much resemble the cases conjunction/disjunction. . . So, should weforget it ?

    5.C.5 Normalisation

    Anticipating upon next chapter, section 6.2.1, let us indicate how to adaptthe proof of strong normalisation to the conjunctive case. One first extendssimplicity.

    15The fourth rule anticipates on the next chapter : it a commutation corresponding tosystem F.

  • 7/29/2019 Coursang2.PDF

    19/70

    130 CHAPTER 5. FUNCTIONAL INTERPRETATIONS

    Definition 9 (Simplicity)

    t is simple when it does not begins with , ou (, ).

    One adapts too the definition of reducibility :

    Conjunction : A term t of type A B is reductible iff lt and rt are redu-cible.

    Everything adapts, mutatis mutandis : this is the sign of a well-lubricatedmachinery.

    As to disjunction (and marginally, absurdity), everything complicates be-cause of commutative reductions. I didnt find a proof really nice, and takinglittle space. Then since it is an extremely marginal and outdated question strong normalisation for disjunction , a technique closed on itself, I proposeto ignore the question.

    5.D Martin-Lfs type theory

    Martin-Lfs system [76] is the only logical system integrating the Curry-Howard isomorphism in syntax. Indeed, it is based upon dependent types (com-ing from the system Automath of de Bruijn), x A B[x] and x A B[x].There is an intended ambiguity between two readings :

    Logic : x A B[x], x A B[x], two most welcome combinations / ,/. The formula t A reads t is a proof ofA .

    Functional : It is a matter of dependent products and sums, therefore subject

    to the usual functional interpretations.

    The main originality of the system is therefore its handling of first orderterms. They dont refer to an external domain, but to the proofs themselves.

    [x A]

    t B[x](I)

    xt x A B[x]

    u A

    t x A B[x](E)

    (t)u B[u]

  • 7/29/2019 Coursang2.PDF

    20/70

    5.D. MARTIN-LFS TYPE THEORY 131

    which yields the immediate reduction :

    u A

    [x A]

    t B[x](I)

    xt x A B[x](E)

    (xt)u B[u]

    ;

    u A

    t[u/x] B[u]

    The same for the dependent sum :

    t A

    u B[t](I)

    (t, u) x A B[x]

    t x A B[x]

    [x A] [y B[x]]

    v C(E)

    (xyv)t C

    which yields the immediate reduction :

    t A

    u B[t](I)

    (t, u) x A B[x]

    [x A] [y B[x]]

    v C

    (E)(xyv)(t, u) C

    ;

    t A

    u B[t]

    v[t/x, u/y] C

    As well as, if one insists, the appropriate commutative reductions.Originally, Martin-Lfs system contained primitives coming from system

    F. After I found an antinomy in the system (1971), the second order featureswere removed. In order to compensate for this want of expressivity, Martin-Lf added other primitives (universes, etc.), much less original than dependentproducts and sums.

    In 1985, Coquand proposed a theory of constructions [14] more in conform-ity with the original intentions, e.g., encompassing system F. This system iswell-adapted to tasks of formalisation and verification, and served as a basisfor project Coq launched by Huet at INRIA.

  • 7/29/2019 Coursang2.PDF

    21/70

    Chapter 6

    System F

    My first work in logic [30, 31] is freely inspired from the system T of Gdel,that one will find in annex, see 6.C.

    6.1 System F

    6.1.1 Generalities

    System F, contrarily to simply typed -calculus, is constructed around Curry-

    Howard. It is the isomorphic image of intuitionistic second order propositionalcalculus. The only ambiguity, when speaking of system F, is the choice ofconnectives : one can opt for a minimal system (based on , ) or richersystems, comprising the connectives , , 0, . We shall follow the minimaloption, and this for two reasons :

    As usual, the addition of other connectives produces bureaucratic com-plications.

    System F is so expressive that the missing connectives can be translatedin the basic

    version, provided to dispense from commutative con-

    versions1

    ; remember that we dont need them to get the properties ofexistence and disjunction.

    The types of system F are built from type variables X , Y , Z , . . . by means ofimplication and universal quantification : for instance, X(X X). The rulesof term formation are those of the simply typed calculus, see 5.3.1, to whichhave been added :

    Generalisation : If t is a term of type A, and if the type variable X is notfree in the type of a free variable of t, then Xt is a term of type XA.

    1This is not the case at first order where all connectives are independent.

    132

  • 7/29/2019 Coursang2.PDF

    22/70

    6.1. SYSTEM F 133

    Extraction : If t is a term of type XA and if B is a type, ten {t}B is a

    term of type A[B/X].

    The restriction on generalisation is a direct consequence of Curry-Howard.Indeed, one can pass from A to XA only if X is not free in . Andremember that the left part of the sequent correspond to active hypotheses, inother terms to free variables. By the way, what could be the meaning ofXxX

    where x is free, but without type (since X is a bound variable) ? One can onthe other hand form XxXx, the universal identity

    of type X(X X).

    This system is equipped with an immediate reduction, given by (5.6) and :

    {Xt}B ; t[B/X] (6.1)

    which satisfies the Church-Rosser property : one has therefore unicity of thenormal forms ; existence is clearly less obvious.

    6.1.2 The forgetful functor

    To each term of system F one can associate a pure -term. For this, it suf-fices to erase anything connected to typing. In other terms, erase the types of

    variables : xA

    , yB

    , zC

    becoming x,y,z, erase generalisations and extractions.Thus the term (xX(XX)({x}X(XX))x)XxXx, of typeX(X X), and which reduces in three steps in XxXx, becomes (x(x)x)xx,which reduces in two steps in xx. One sees on this example that oblivionpreserves normalisation : the only thing that happens is that the steps (6.1)disappear.

    A contrario, one can see a term of F as a typing of its underlying -term .If one considers the typing as a superego

    designed to avoid non-termination,

    the example we just gave shows that it surely does not prevent incest, since itbriskly types

    (x)x : the worst can be feared.

    6.1.3 Translation of connectives

    We shall translate the logical connectives a certain data types. As to this mat-ter, a very amazing phenomenon occurs : for all the cases under consideration,there is a logical tradition (going back to Dedekind or Russell, sometimes toPrawitz), enabling us to translate proofs in second order, here in system F ;one has, on the other hand, an independent tradition of coding in pure -calculus. Modulo Curry-Howard, one can see the translation in F as a typingof the codings of -calculus.

  • 7/29/2019 Coursang2.PDF

    23/70

    134 CHAPTER 6. SYSTEM F

    Conjunction

    One translates conjunction by A B := X((A (B X)) X). Thecorresponding operations become :

    (t, u) := Xx(A(BX)((x)t)u

    lt := ({t}A)xAyBx

    rt := ({t}B)xAyBy

    (6.2)

    This translation respects the rules of reduction of conjunction (5.10). This isalso a typing of the pairs of pure -calculus, see 5.2.2.

    Disjunction

    One translates disjunction by A B := X((A X) ((B X) X)). Thecorresponding operations become :

    lt := XxAXyBX(x)t

    rt := XxAXyBX(y)t

    (xAu)(yBv)t := (({t}C)xAu)yBv

    (6.3)

    This translation respects the first two reduction rules of disjunction (5.11), butnot commutative reductions. It is also a typing of the sum of pure -calculus,that we didnt introduce, but who would have been :

    lt := xy(x)t

    rt := xy(y)t

    (xu)(yv)t := ((t)xu)yv

    (6.4)

    Absurdity

    One translates0

    := XX. And :

    At := {t}A (6.5)

    This translation verifies nothing (there are only commutative rules) ; its onlyvirtue is to exist !

    Existence

    Existential quantification is translated by XA := Y(X(A Y) Y).Existential types will not attract enough our attention so that we lose time

  • 7/29/2019 Coursang2.PDF

    24/70

    6.1. SYSTEM F 135

    with them : one can toy at writing schemas of term construction corresponding

    to the rules :

    A[B/X](2I)

    XA

    XA

    [A]

    B(2E)

    B

    and the reduction corresponding to :

    A[B/X] (2I)XA

    [A]

    C

    (2E)C

    ;

    A[B/X]

    C

    6.1.4 Another forgetful functor

    Instead of resting upon a propositional system, one could have taken the secondorder predicate calculus of Takeuti, see 3.B.2 and 6.A.1, whose atoms are of

    the form t X, and which therefore uses two universal quantifications, a firstorder one, another on predicates. This variant possesses a forgetful functortowards F which erases the first order : the atoms become type variables, firstorder quantification disappears. In other terms, one can successively forgetthe first order (which brings us in F), then the typing for good (one arrives inpure -calculus).

    6.1.5 Translation of free structures

    The second order definition of integers : the smallest set containing 0 andclosed under S

    is due to Dedekind ; it generalises to the definition of the free2

    structure generated by functions f1, . . . , f k of arbitrary arities, and perhapstaking their arguments in auxiliary types. Let us take an example, the freestructure S generated by a constant a S, a binary function f : S S; S,and a binary function g : S T ; S, where T is an auxiliary type. FollowingDedekind, one would write :

    x S : X(a X (yz(y X (zX f(y, z) X))

    (yz(y X (zT g(y, z) X)) x X)))(6.6)

    2System F, so comfortable with free structures, is on the other hand rather helpless infront of quotients.

  • 7/29/2019 Coursang2.PDF

    25/70

    136 CHAPTER 6. SYSTEM F

    In fact, to translate this free structure, it is enough to take the underlying

    proposition :

    X(X ((X (X X)) ((X (T X)) X))) (6.7)

    In fact, it is what we already did for first order connectives :

    Conjunction : It is the free structure S generated by a binary function g :T U; S, where T, U are given.

    Disjunction : It is the free structure generated by two unary functionsf : T ; S and g : U; S.

    Absurdity : It is the free structure generated by. . . nothing at all.

    6.1.6 Translation of data types

    The current data types (lists, trees, etc.) can be translated in system F, with,in each case, several constructors and one destructor.

    Booleans

    The free structure S generated by two constants a, b S :

    bool := X(X (X X)). The constructors are typings of the booleans of-calculus, XxXyXx and XxXyXy. The destructor types the condi-tional : ifv,a,b are of types bool, C , C , then ifv then a else b

    is expressedby ({v})a)b, of type C.

    By the way, observe that the type X(X X) corresponds to a space withone point.

    Natural numbers

    Dedekinds definition, once first order has been forgotten, yields :nat := X(X ((X X) X)). The constructors are :

    Zero : 0 := XxXXyXy of type nat.

    Successor : If t is of type nat, St := XxXXyX(x)(({t}X)x)y is of typenat.

    The destructor enables one, given t,a,b of respective types nat, C , C C toform (({t}C)b)a of type C : this is the iterator.

    One will remark the close relationship of this typing with our coding ofintegers in the simply typed calculus 5.3.2. In fact our type could be written3

    3Almost : X and XX have been permuted for technical reasons, see section 7.4.2.

  • 7/29/2019 Coursang2.PDF

    26/70

    6.1. SYSTEM F 137

    XX + 2 ; but while the simply typed calculus cannot type exponential as

    a binary function sending a type in itself, it is childs play for system F :for instance, if x, y are of type nat, xy := X({y}(X X)){x}X types theexponential at the same type nat.

    Binaries

    The previous integers are Cro-Magnon integers

    , anterior to Babyloniannumeration. A more modern version of integers requires finite sequences ofzeros and ones. They can be represented by means of the type :bin := X(X ((X X) ((X X) X))). This case is very close to the

    previous one : one has two successors

    add a 0

    ,

    add a 1

    , instead of thesole add a stroke

    .

    Lists

    Finite lists of objects of type A can be represented by :list(A) := X(X ((X (A X)) X)).This type will be studied in details in next section.

    Binary trees

    A last example, binary trees with leaves of type A :bintree(A) := X(A ((X (X X)) X)).

    6.1.7 Properties of the translations

    We shall study the translations of connectives (existence excepted) and freestructures. One will do it on one example, the most complex we considered,lists.

    Constructors et destructors

    Lists admit the following operations :

    Empty list : Encoded by the term := XxXyX(AX)x.

    Concatenation : If t is of type list(A) and a is of type A, one can form taof type list(A) : ta := XxXyX(AX)((y)(({t}X)x)y)a.

    Destruction : Given a type C and terms t,u,v of respective types list(A),C, C (A C), one can form a term of type C by destruction of t, i.e.(({t}C)u)v.

  • 7/29/2019 Coursang2.PDF

    27/70

    138 CHAPTER 6. SYSTEM F

    Constructors encode, modulo oblivion and Curry-Howard, the fact that the

    definition la Dedekind of the structure S is actually a structure of the desiredkind. The destructor codes the fact that this structure is free : ifC is equippedwith two constructors of the kind empty list

    and concatenation

    , the freestructure embeds (uniquely) in C. More modestly one will see in the destructora process of iteration on lists. It is important to remark that destructioninvolves a use of extraction.

    One verifies the following reductions linked to the destructor :

    (({}C)u)v ; u

    (({ta}C)u)v ; ((u)(({t}C)u)v)a(6.8)

    Representable objects

    Still speaking of lists, observe that the list < a1, . . . , ak > of terms of type Awill naturally be encoded by the term :XxXyX(AX)((y)((y) . . . ((y)x)a1 . . .)ak1)ak.Conversely, assume that t is a term of type list(A) ; is it the case that t is ofthe form < a1, . . . , ak > ? One cannot say much, unless t is normal and closed.It will also be necessary to require A to be 1 : remember that A is 1 whenuniversal quantifiers occur only positively in it.

    Let us introduce the notion of head variable, analogue celle dhypothse

    de tte : when a normal term does not begin with a or a , either it is avariable, and we are done, or it is of the form (t)u or {t}B and one proceedswith t ; graphically, the head variable is the leftmost occurrence of a variablein the term.

    Suppose that the type A is 1 (and closed) and that t, of type list(A), isnormal and closed. t begins with an introduction (a ) since it has no headvariable, say t = Xu, and the same for u, say t = XxXv. The variablexX being of atomic type, it cannot play the role of head variable for v : onetherefore gets t = XxXyX(AX)w. w is of atomic type X and thereforehas necessarily a head variable. There are two possibilities, either w = xX,

    and t =, and we are done. Or the head variable is y

    X(AX)

    in which casew = ((y)w)a for a certain a of type A. Since A is 1, a cannot contain thevariables x, y4.

    Lemma 18.1Let s be a normal term whose type is 1 and depending of variables whosetype is 1 and maybe of other variables

    of respective types X, A X or

    X (A X) where X is a variable occurring neither in the type of s, nor inthe other variables. Then s does not depend on the other variables .

    4On the other hand, zYY({z}(X Y Y))x yields an example of a normal of (non 1)type Y Y Y Y containing x.

  • 7/29/2019 Coursang2.PDF

    28/70

    6.2. THE NORMALISATION THEOREM 139

    Proof : Recurrence on s. The case where s begins with a or a is immediate.

    Ifs admits a head variable z, then its type cannot be X, A X, X (A X),since otherwise the type of the conclusion would contain X. It is therefore onethe non other

    variables, whose 1 type is of the form B1 (. . . (Bn Y)),with Y = X. s (((z)s1) . . .)sl, with l n. By induction hypothesis, no variableof type X, A X or X (A X) occur in the terms s1, . . . , sl, whose 1

    types do not contain X. 2

    a is therefore closed and t = XxXwa. One proceeds with w, etc. Weeventually proved the :

    Theorem 18 (Representability)

    If A is 1 and closed, any closed normal term of type list(A) can be writtenas a list < a1, . . . , ak > (closed normal) terms of type A.

    This result is made more interesting by the remark that, ifA is 1, the same istrue oflist(A). Representability results hold for our other codings ; this worksin the same way, except that we must be cautious with a small and irritatingtechnicality, see section 7.4.2.

    Remark about conjunction

    Applying literally our machinery to conjunction, one would indeed get the fol-lowing destructor : given t, a of respective types AB, C, form ({t}C)xAyBa.The two projections are much more sympathetic. This exception

    to the rule

    can be understood through linear logic : conjunction is translated in the spiritof the tensor product , but since we are in a non-linear mode, intuitionism,one can cheat

    and formulate destruction with the direct product &.

    6.2 The normalisation theorem

    Normalisation for system F is a big piece to swallow. I therefore begin with

    the simply typed case.

    6.2.1 Simply typed case

    One defines, for each type A the notion of reducible term of type A (notiondue to Tait, see [92]) :

    Atoms : For A atomic, a term t of type A is reducible iff it is sN.

    Implication : A term t of type A B is reducible iff for all reducible termu of type A, (t)u (which is of type B) is reducible.

  • 7/29/2019 Coursang2.PDF

    29/70

    140 CHAPTER 6. SYSTEM F

    One will prove properties (R1)-(R3) of reducibility. (R1) and (R2) are sorts

    of eliminations ; (R3) is rather an introduction, the idea being that if allimmediate reducts of t are reducible, the same is true of t. Which is nottenable : this, combined with (R1), would yield an immediate equivalencebetween reducible

    and sN5. This is why (R3) is restricted to simple terms.

    Definition 10 (Simplicity)A term t is simple when it does not begin with a .

    Proposition 2Reducibility satisfies the following properties :

    (R1) : Every reducible term is sN.

    (R2) : Ift is reducible andt ; t, then t is reducible.

    (R3) : If t is simple and all immediate reducts of t are reducible, then t isreducible.

    Proof : By induction on the type ; the atomic case being obvious, on proceedswith the case of an implication A B, assuming (R1)-(R3) to hold for thetypes A and B.

    (R1) : Condition (R3) applied to type A shows that a variable x

    A

    is reducible.If t of type A B is reducible, then (t)xA is reducible too, and by (R1)sN. But |t| |(t)xA|, hence t is sN.

    (R2) : If t is reducible and t ; t, and if u of type A is reducible, then (t)uis reducible and since (t)u ; (t)u, (R2) yields (t)u reducible. t istherefore reducible.

    (R3) : Ift does not begin with a and all immediate reducts of t are reduct-ible, take u reducible of type A ; u is sN by (R1). By induction on |u|,one shows that (t)u is reducible, which will establish that t est reducible.

    Since t does not begin with a , the immediate reducts of (t)u are ofthe form (t)u, where t is an immediate reduct of t or (t)u, where u isan immediate reduct of u. (t)u is reducible by hypothesis, and (t)u isreducible by induction hypothesis, since |u| < |u|. One concludes that(t)u is reducible by (R3).

    2

    En particulier, one gets :

    5Indeed all terms are reducible, so that the equivalence actually holds ; but it is notprovable. See also section 6.E.2.

  • 7/29/2019 Coursang2.PDF

    30/70

    6.2. THE NORMALISATION THEOREM 141

    Proposition 3

    Ift a term of type B, and if for all reducible u of typeA, t[u/xA] is reducible,then xAt is reducible.

    Proof : Let u be reducible of type A ; we must show that (xAt)u is reducible.Observe that t is reducible (take u := xA), hence sN, just like u : one canwork by induction on |t| + |u|. Since (xAt)u does not begin with a , onecan try (R3) : the immediate reducts of this term are of the form (xAt)uavec |t| < |t|, (xAt)u with |u| < |u|, reducible by induction hypothesis, ort[u/xA], reducible by hypothesis. One concludes with (R3). 2

    Theorem 19 (Reducibility)

    All simply typed terms are reducible.

    Proof : One indeed shows, by induction on the term t, that, if one substitutesreducible terms of appropriate types for the free variables of t, then the resultis reducible.

    Variable : Immediate.

    -abstraction : By proposition 3.

    Application : By definition of reducibility.

    This property really establishes the theorem, since, variables being reducibleby (R3), the identical substitution yields a reducible term, t itself. 2

    Corollary 19.1 (Strong normalisation)All simply typed terms are normalisable.

    Proof : Apply (R1). 2

    6.2.2 A faulty generalisation

    We shall now

    extend

    the previous proof to system F ; this faulty general-isation is indeed my first version of the proof.

    The idea is to define reducibility for universal types by :

    Universal quantification : t of type XA is reducible iff for all B {t}B isreducible.

    and prove the same properties as in the simply typed case. Of course, onemust adapt simplicity : a simple term can begin neither with a , nor with a.

    Indeed, the structure of the proof seems to work swell :

  • 7/29/2019 Coursang2.PDF

    31/70

    142 CHAPTER 6. SYSTEM F

    Proposition 4

    Reducibility enjoys (R1)-(R3).For instance (R3) is rather simplified, since there are less immediate reductsfor a term {t}B than for a term (t)u. One would proceed with an analogue ofproposition 3 :

    Proposition 5If t is a term of type A whose free variables do not contain X, and if t[B/X]is reducible for allB, then Xt is reducible.

    that would be established without problem. One would end with a proof inthe style of theorem 19. If t is a term of F, one substitutes types for itstype variables, which yields u := t[B1, . . . , Bk/X1, . . . , X k]. Then, in u, onesubstitutes reducible terms for typed variables. And everything works swell,one must only consider two new cases :

    -abstraction : By proposition 5.

    Extraction : By definition of reducibility.

    6.2.3 The fault

    This definition is faulty ; indeed one applies inductions on non well-foundedstructures. More precisely one stumbles on the fact that, at second order, thereis no subformula property : the definition

    makes no sense, since, if t is of

    type X(X X), {t}B is of type B B. One tried to say :

    t is reducible iff for any type B and any reducible term u of type B, ({t}B)uis reducible.

    But one ends in a circle : the reducibility of a single universal presupposes thereducibility of all types.

    Even if we could define reducibility, the proof of (CR3) would stumbleon the fact that we use an induction hypothesis on the types A[B/X], morecomplicated than XA. In other terms, one would make a locally correctdeductive chaining, but an erroneous induction.

    6.2.4 Reducibility candidates

    There is a problem with substitution ; the idea will be to define reducibility oftype A[B/X], not as the real reducibility (that we dont yet know), but froman arbitrary definition

    of reducibility of type B. Later on, once defined

    the real

    reducibility of type B, one will be able to use this notion andeverything will fall into line (substitution lemma).

  • 7/29/2019 Coursang2.PDF

    32/70

    6.2. THE NORMALISATION THEOREM 143

    Definition 11 (Candidates)

    Let A be a type ; areducibility candidate (CR) of type A is a set C of termsof type A enjoying the following conditions :

    (CR1) : Every term of type C is sN.

    (CR2) : If t C and t ; t, then t C.

    (CR3) : If t is simple et if all the immediate reducts of t are in C, then t isin C.

    Observe that, for any type A, including type variables, there is a reducibilitycandidate, precisely sNA, the set of strongly normalising terms of type A.

    Let A be a type, and let, for each free variable Xi ofA, Ci be a type and Cibe a CR of type Ci. One defines the parametric reducibility redA[. . . Ci/Xi . . .],a property of terms of type A[. . . C i/Xi . . .]. For reasons of legibility, thefollowing definition is restricted to the case of a single variable X :

    Variable : t of type C satisfies redX[C/X] iff t C.

    Implication : t of type A[C/X] B[C/X] satisfies redAB[C/X] iff for allu such that redA[C/X], (t)u satisfies redB[C/X].

    Quantification : t of type Y A[C/X] satisfies redY A[C/X] iff for all D and

    all CR D of type D, {t}D satisfies redA[C/X, D/Y].

    Let us see what our definition says in the case of X(X X) :

    t is rductible ssi for all type B and all CR B of type B, if u B, then({t}B)u B.

    a mathematically quite correct definition.

    Proposition 6Parametric reducibility enjoys (R1)-(R3).

    Proof : Let us establish it on one example, the type X(X X) :X : Reducibility redX[C/X] is exactly the appurtenance to the CR C, and

    (R1)-(R3) are then satisfied.

    X X : t satisfies redXX[C/X] iff for all u C, (t)u C. (R1)-(R3) resultfrom the previous case, just as the proof of proposition 2.

    X(X X) : Properties (R1)-(R3) result from the previous case, like in pro-position

    4, the faulty generalisation of proposition 2.

    2

  • 7/29/2019 Coursang2.PDF

    33/70

    144 CHAPTER 6. SYSTEM F

    6.2.5 The real reducibility

    When A is closed, the parametric definition becomes absolute. Now, observethat, by the comprehension schema6, reducibility (a property) will become aset (indeed a CR by proposition 6). If A[B/X] is closed, one has a choicebetween the direct definition of reducibility and the definition parametrised bythe real reducibility of type B. These two definitions coincide, as a consequenceof a more general property :

    Theorem 20 (Substitution lemma)The reducibilitiesredA[B/Y][C/X] andredA[C/X, redB[C/X]/Y] are equivalent.

    Proof : More complex to write correctly than to prove, here I also restricted toa single parameter X. This is trivial7, but this formally uses the comprehensionschema, which ensures that redB[C/X] defines a set of terms. 2

    The monstrous algorithmic complexity of system F is located in extraction, andnormalisability of extraction come from the substitution lemma, and thereforeof comprehension.

    6.2.6 The proof

    An imitation of proposition 3 yields :

    Proposition 7If t is a term of type A[C/X], and if for all type D and all CR D of type D,t[D/Y] enjoys redA[C/X, D/Y], then Y t enjoysredY A[C/X].

    One can conclude :

    Theorem 21 (Strong normalisation for F)All terms ofF are strongly normalisable.

    Proof : The theorem is a consequence of a general result of parametric redu-cibility. Suppose that t is of type A, with free variables of types B1, . . . , Bk,

    and for each type variable, Xi, let us choose a type Ci and a CR Ci of thistype. One performs the substitution Ci/Xi in t, and let b1, . . . , bk be termsof respective types B1[. . . C i/Xi . . .], . . . , Bk[. . . C i/Xi . . .], and reducible in thesense of redB1 [. . . Ci/Xi . . .], . . . , redB1[. . . Ci/Xi . . .]. Thent[. . . C i/Xi . . . , b1/x

    B1[...Ci/Xi...], . . . , bk/xBk[...Ci/Xi...]] is reducible in the sense of

    redA[. . . Ci/Xi . . .].

    6I pinpoint its formal use, it is the sort of things one does not see otherwise..7The proof of normalisation has been formally checked by Berardi. Against all expecta-

    tions, the trivial substitution lemma posed difficulties to the machine. . . These animalsdefinitely dont see the world like us !

  • 7/29/2019 Coursang2.PDF

    34/70

    6.A. TYPE THEORIES 145

    This is extremely painful to formulate, but it is nothing but what we did

    in the simply typed case : we only had to use a parametric reducibility. Theproof follows without problem the five possible cases :

    Variable : Trivial.

    : Uses proposition 3.

    Application : Uses the definition of parametric reducibility for implication.

    : Uses proposition 7.

    Extraction : Uses the definition of parametric reducibility for quantification

    as well as the substitution lemma. Formally, this part makes use of thecomprehension axiom, since we must replace a property with the set ofterms satisfying it.

    2

    6.A Type theories

    6.A.1 Takeutis conjecture

    The effective version of Takeutis conjecture, see section 3.B.2, is the ques-tion of determining whether the replacement of a cut on XA with a cut onA[T /X], in the key case corresponding to second order quantification, pro-duces a converging algorithm. Modulo appropriate translations in the style ofGdel, one can concentrate on second order intuitionistic logic. And, moduloCurry-Howard, on an obvious analogue of system F, based on second orderpredicate calculus instead of propositional calculus. In this variant, there is afirst order generalisation xt and a first order extraction du {t}d where x andd respectively stand for a first order variable and term, and the immediatereduction {xt}d ; t[d/x].

    One can bluntly imitate the proof of strong normalisation of F in this(slightly) more general setting. One can also protest against this sort of un-imaginative generalisation, and reduce Takeutis conjecture to normalisationof system F. Starting with t of type A in the system with 1 , one forms t

    of type A in F by forgetting first order. If t = t0 ; t1 ; . . . ; tn ; . . . is asuccession of immediate reductions, one sees thatt = t0 ; t

    1 ; . . . ; t

    n ; . . ., a succession of immediate reductions or

    non-reductions

    in F. But the clusters of non-reductions come from finite con-figurations {. . . {{xn . . . x2x1}t1}t2 . . .}tn and are therefore of boundedlength. One concludes that the sequence t = t0 ; t1 ; . . . ; tn ; . . . is offinite length, hence that t is sN.

  • 7/29/2019 Coursang2.PDF

    35/70

    146 CHAPTER 6. SYSTEM F

    6.A.2 More on first order quantification

    I didnt try to extend Curry-Howard to this case, since this leads to a faultyreading, in the style quantification = infinite sum/product . Because, if oneactually proves a conjunction by proving both components, a quantificationis not proved by establishing each particular case : otherwise we would neverhad witnessed the slightest proof ! In other terms, x does not generalise ;although there is a strong resemblance.

    I propose8 to use a variable of domain, say D, and to consider that a firstorder quantification is implicitly restricted to D. Thus xyA would indeedmean Dx Dy DA. This enables one to accept without reticence the

    interpretation by sum and product indexed by D : the universal quantificationon D will eventually, because of the uniformity it supposes, make disappearthe infinite and unpleasant aspects of sum and product.

    Of course, nothing opposes the consideration of several variables of domain,which corresponds to several types of objects. As to this matter, one must beprepared to empty domains, what is usually forbidden, but this is only a matterof syntactical adjustments.

    One can also step out of implicit quantification and quantify explicitly, forinstance existentially, on domains.

    6.A.3 Type theory la Russell

    Whitehead & Russells type theory, the Principia Mathematica [97], is com-pletely forgotten nowadays ; not by historians, but by mathematicians, andeven by those specialised in logic. One only remembers the idea of avoidingantinomies in the style of. . . Russell by typing, what can be expressed bya predicate calculus of finite type. For instance, besides predicate variables,we could have variables for predicates on predicates

    , etc. By writing the

    appropriate abstraction terms, for instance {X; a X}, one gets a predicatecalculus, which essentially corresponds to the theory of finite types la Rus-sell [86]. The method of reducibility candidates allows one to extend, withoutthe least difficulty nor the least creativity , Takeutis conjecture to thissetting.

    Modulo propositional oblivion, one obtains an extension not quite deli-rious of system F : besides propositional variables, we shall have variablesof connectives, etc.

    8At least in the absence of functional symbols : I didnt push this idea.

  • 7/29/2019 Coursang2.PDF

    36/70

    6.A. TYPE THEORIES 147

    6.A.4 Gentzen at his worst

    We just mentioned Russells type theory. the basic type o is the type of naturalnumbers. This being said, if one does not specify the basic type, it becomesobvious that the theory is consistent : indeed, the type o can be interpretedby a one element set {a}, the type 1 by its power set {a}, the type 2 by thepowerset {a} of the previous, etc. Which yields a finite model, at least ifone restricts to finitely many types.

    To say that type theory without axioms at type o is consistent istherefore a triviality of little interest. This is however the object of a paperby Gentzen, [29], obviously a very bad one. This paper has nevertheless its

    place in our reflexion. If Gentzen had written

    let us take the finite iterationof the power set of {a}, this yields a model , the paper would not have beenpublished. He instead associated in a sort of cabalistic way numbers toproofs, so as to show that the empty sequent cannot be proved. However, itis not too difficult to see that he actually enumerates the set . . . {a},performs substitutions : all this amounts at a truth computation, withoutsaying it.

    From a formal viewpoint, this proof

    respects a formalist ideal, which isto avoid the notion of truth, considered as suspect. But this is however whathe constructs without using the word : this is styled hypocrisy. This is

    especially ridiculous since it is hard to see what is dubious in truth in a finitemodel. This is no longer ideas that govern us, this is the words one uses tospeak of them : call the dog a cat and she will start to meow.

    6.A.5 From Martin-Lf to constructions

    One will observe that abstraction terms in the theory of types la Russell lookvery close to the terms of the simply typed calculus : compare t {x; A} :=A[t/x] and (xu)t = t[u/x]. One could therefore try to make type theory laRussell benefit

    from a typing in the style of F. In other terms, one would

    type sets like in system F and not uniquely by finite types. This is what Itried in 1971 in an unpublished work this for an excellent reason : I foundthere an antinomy in the style of Burali-Forti.

    This what Martin-Lf was simultaneously doing with the first version ofhis system, in which I had no problem in interpreting the contradiction I hadfound in my prototype.

    The theory of constructions [14] appears as a reasonable compromise : itis a variant of Russell la Martin-Lf, in which sets are types by means ofdependent quite simple sums and products, i.e., fundamentally of the samenature as usual simple types, but more flexible.

  • 7/29/2019 Coursang2.PDF

    37/70

    148 CHAPTER 6. SYSTEM F

    6.B Heytings arithmetic

    6.B.1 Second order translation

    Heytings arithmetic translates into second order logic by relativising first orderquantifier to N, i.e., to Dedekinds definition of integers : which freely yieldsthe induction schema. To be remarked that only a marginal fringe of theabstraction terms is used, namely those translating arithmetical formulas.

    Let us add to the system the axioms of RR, except what deals with theinequality

  • 7/29/2019 Coursang2.PDF

    38/70

    6.C. SYSTEM T 149

    6.C.1 The Dialectica interpretation

    Published in 1958 in a rather obscure journal, Dialectica [51], Gdels func-tional interpretation dates back to the years 1943. This is an interpretation ofinteractive, game

    , style, but the result hardly matches the ambitions.

    The idea is to associate to a formula A of AH an interpretation of theform xSyTa = 0, where the quantifiers xS, yT refer to finite type func-tionals above the integers. The types increase with the connectives, thus, ifB has been interpreted by zUwVb = 0, the implication A B becomesZSUYS(VT)xSwV(a[((Y)x)w/y] = 0 b[(Z)w/x] = 0). One can, ifone wants, regroup quantifiers of the same nature with the help of a product

    type ; one can also bring back the implication . . . = 0 . . . = 0 to an equality. . . = 0.

    The main drawback of this interpretation is a bad global structure. Theexistential quantifier proposes something against the refutations that couldbe brought by the universal quantifier. It is therefore a positive game, sincethe existential comes first ; this is different from a negative game where theuniversal would come first, yTxSa = 0. This writing is well-adapted to thepositive connectives , . But it works not that well in the negative case :indeed, an expression yTxSa = 0 is replaced with XSTyTa[(X)y/x] = 0.

    If polarity is taken into account, the implication between xSyTa = 0

    (positive) and zUwVb = 0 (negative) can more modestly be writtenxSzUyTwV(a = 0 b = 0) without introducing those illegible functionaldependencies which render Dialectica unmanageable. But should one try tofix half-baked ideas ?

    6.C.2 System T

    System T, originally introduced for the sake of the Dialectica interpretationsurvived, while Gdels interpretation no longer interests anybody. It is a

    simply typed calculus, based on a primitive type nat. The type nat has twoconstructors, corresponding to zero and successor ; there is also a destructor,the recursor RECat, for each type A, see infra.

    This system almost immediately translates into F. By the way, let us seehow the induction schema of AH translates in second order. The induction onA is done by means of z(A[z] A[Sz]), what translates into zN(A[z] A[Sz]), what one can transform, using B := zN A, into z(B[z] B[Sz]).In other terms, induction on A is established by means of a comprehension onB.

    When one forgets first order, induction becomes recurrence : from a, t of

  • 7/29/2019 Coursang2.PDF

    39/70

    150 CHAPTER 6. SYSTEM F

    types A, nat (A A), construct u := RECat of type nat A such that :

    (u)0 ; a

    (u)Sv ; ((t)v)(u)v(6.9)

    Which does not quite correspond to the iterator, the official destructor of natin system F. This being said, the recursor of type A, which corresponds toinduction via oblivion, can be reduced to the iterator of type nat A... Onlyroughly, since there is however a small leakage : typically, the recursor enablesone to define a predecessor function satisfying (p)Sx ; x one step prede-cessor

    , while the coding by the iterator only yields (p)n ; n, a computation

    in n steps.But, apart from this nuance between iterator and recursor, it is fair to saythat T is translatable in F. In particular, T enjoys strong normalisation. Infact, this system is the prototype of F.

    6.C.3 Realisability

    One can try to make the functional interpretation of proofs of section 5.1.2 pre-cise by means of a notion ofrealisability, a technique mainly due to Kleene [62].One simply takes the definition is a proof of A given in 5.1.2 and onereplaces the notions with their precise definitions in -calcul : one knows howto code integers, ordered pairs. One thence defines A when is a -term,for instance :

    Implication : A B : ( A () B).

    Universal quantification : xA : n ()n A[n/x].

    One can also used a typed, modified

    , realisability ; the types Ar of therealisers are as follow :

    (A B)r = Ar Br

    (A B)r

    = Ar

    Br

    (A B)r = Ar Br

    (xA)r = nat Ar

    (xA)r = nat Ar

    (6.10)

    Observe that the type of the realiser is nothing but, once translated in F, theterm obtained by forgetting first-order ; and, given a proof, the associatedrealiser is the forgetful term corresponding the proof. At least if we dont looktoo carefully at what happens at the level of atoms. To sum up, neglecting afew technicalities linked to atomic formulas :

  • 7/29/2019 Coursang2.PDF

    40/70

    6.D. EXPRESSIVE POWER 151

    The typed realisability of AH in T is first-order oblivion.

    The realisability of AH in -calculus is type oblivion.

    Would there be a tendency of logic at running into circles ?

    6.D Expressive power

    6.D.1 Provably recursive functions

    One one can prove in AH that a recursive function is total, then the 0

    2 formulaexpressing this fact is provable ; one extracts10 then a definition of the functionin system T.

    Theorem 23 (Provably recursive functions of AH)The provably recursive functions (see 2.1.7) ofAH are exactly the functionsdefined by a closed term of type nat nat ofT.

    Proof : In one sense, by realisability. Conversely, given a closed term of typenat nat, one can formalise the reducibility proof given in the setting of F ;due to the peculiarity of the situation, this formalisation can indeed be madein AH. 2

    Heyting11 arithmetic is a very expressive system ; and, as its second orderextension, most mathematics can formalised in them if one excepts resultsconfined to set theory. It is indeed extremely difficult to find a computablefunction which cannot be expressed in T ; indeed the functions vertiginouslyincrease with the game of iteration :

    (i) The iteration of function n + 2 yields n.2.

    (ii) The iteration of function n.2 yields 2n.

    (iii) The iteration of function 2n yields a tower of exponentials of variableheight n. This function is already beyond the expressive power of thesimply typed calculus.

    (iv) The iteration of the previous function yields a monster which no longermakes much sense.

    10The methods are manifold, including those coming from the second proof of Gentzen [27]11Or Peano, see infra.

  • 7/29/2019 Coursang2.PDF

    41/70

    152 CHAPTER 6. SYSTEM F

    But one can do much worse, instead of iterating a function, one can iterate

    the functional of iteration, this is the Ackermann function :

    (x, 0) := x + 2

    (0, y + 1) := 1

    (x + 1, y + 1) := ((x, y + 1), y)

    (6.11)

    This monster12 uses iteration at type nat nat, a minuscule part of thepossibilities ! One understands that it is very difficult to find total recursivefunctions non representable in T, not to speak of F. The only way to do sois based on an abstract nonsense : the function, which, to the code t of a

    closed term of type type nat of F associates n such that t ; n, cannot berepresented in F (diagonalisation exercise).

    6.D.2 Peano vs. Heyting

    One could think that Peano arithmetic is much weaker than Peano. This istrue in a certain sense : for instance, a 02 formula provable in AP ofthe kind the equation t = u has only finitely many solutions

    has little

    chances to be provable in AH : one would indeed need an effective proof,yielding or rather inducing a bound on the number N of solutions. But

    this is not a genuine weakness of AH, it is rather that formulas take a subtlersense.Such a thing does not happen with simpler complexities, i.e., 01,

    01 and

    even 02 : the two systems prove the same theorems of these shapes :

    01 : One easily verifies that, if A uses only bounded quantifiers, then A A is provable in AH ; therefore A is provably equivalent to its Gdeltranslation Ag. Remembering that the Gdel translation does not require before the negative connectives , , , one concludes that any 01formula is provably equivalent (in AH) to its Gdel translation. Sincethe Gdel translations of the induction axioms are still induction axioms,

    it follows that any 01 theorem of AP is provable in AH.

    01 : In the same way, if the closed formula yA is provable in AP, one de-duces that nA is provable in AH. Here an interesting remark ofH. Friedman : one can replace, in Gdels translation, the negation Bwith 0B := B A0, where A0 is an arbitrary formula, in particular,A0 := yA. One deduces that 00yA, i.e., (yA yA) yA isprovable in AH, and therefore yA as well.

    12In the etymological sense of a thing that one shows : one does not use it, one shows itas an illustration of the expressive power of system T.

  • 7/29/2019 Coursang2.PDF

    42/70

    6.D. EXPRESSIVE POWER 153

    02 : This extends to 02 formulas : ifxyA[x, y] is provable in AH and

    therefore in a finitely axiomatised subsystem T , then for each integern, one can prove, in the same T, yA[n, y] ; hence, by what precedes,yA[n, y]. This is formally provable in AH, hence, by reflexion of Tin AH (section 3.B.4, on uses here the inuitionistic version), one form-ally deduces that yA[n, y] is true. What is a formal proof in AH ofxyA[x, y].

    In particular, the provably recursive functions of AP are the same as those ofAH, i.e., they are the terms of type nat nat of T.

    6.D.3 Formalisation

    Let us come back to the proof of strong normalisation in the simply typed case,section 6.2.1. This proof is not combinatoric since it uses a logically complexnotion, reducibility. One even sees that this notion is a priori as complicatedas a truth predicate, since one cannot write it with a fixed alternation ofquantifiers : if reducibility of type A is 0n, the reducibility of type A A isof the form (0n

    0n), hence

    0n+1.

    Reducibility does not use, for a given term, any induction on types. Indeed,when one proves (R1)-(R3), one does it separately, type after type, for instancein 981 steps. To sum up, we have a schema of proof, for each term t, of the

    fact that t is sN, this only using induction on formulas of arithmetic, i.e., inAP (or AH).

    On the other hand, for each type, one uses induction on the reducibility ofthis type, in relation to property (R3). We shall give an alternative version ofthis property, for which induction on reducibility is not needed.

    Let E be a finite set ofsimple terms ; immediate E-reduction is immediatereduction t ; u, restricted to the case where t E ; E-reduction t ;E u is itsreflexive-transitive closure. A E-normal form for t is any u such that t ;E uand u E. If t is E-sN, i.e., if all E-reduction sequences starting from t arebounded by an integer |t|E, then t has finitely many E-normal forms.

    (R3) : If E is a finite set of simple terms, if t E is E-sN, and all itsE-normal forms are reducible, then t is reducible.

    This condition generalises (R3) which is its the particular case E = {t} ;conversely, (R3) is an iterated version of (R3).

    One can replace (R3) with (R3) ; for this we must show two lemmas onE-reductions :

    Lemma 8.1If t and u are respectively E-fN and fN, then (t)u isF-fN, withF := {(t)u; t E, u ; u} and its F-normal forms are the (t)u, where t isaE-normal form oft and u is the normal form of u.

  • 7/29/2019 Coursang2.PDF

    43/70

    154 CHAPTER 6. SYSTEM F

    Lemma 8.2

    Ift and u are respectively E-fN and fN, then (xt)u isF-fN, withF := {(xt)u; t E, u ; u} and itsF-normal forms are the t[u/x], wheret is a E-normal form oft and u is the normal form of u.

    These two lemmas can be established without difficulty, by induction onvery simple formulas. This enables one to obtain the following result :

    Proposition 8The strong normalisation theorem is provable, for each term t, in the samefinitely axiomatisable subsystem T ofAP (or AH).

    Proof : Essentially in any system in which we can perform the simple induc-tions of the two previous lemmas. 2

    Corollary 8.1The strong normalisation theorem is provable in AP (or AH).

    Proof : The coding techniques used for the second incompleteness theoremenable one to prove an arithmetical formula which formalises the previousproposition, and therefore says : for each term t one can prove in T strongnormalisation for t

    . By the reflexion schema, see 3.B.4, one deduces a uniform

    proof in AP (or AH). 2

    In general, if one takes a subsystem of T (resp. F) generated by finitelymany recursions (resp. extractions), the previous technique can be appliedmutatis mutandis to yield a global proof of strong normalisation in AP (resp.in second order logic). The more recursors we use, the more inductions we shallneed ; in the same way, the more extractions we have, the more comprehensionswe need.

    6.D.4 The Gandy method

    The Gandy method consists in modifying immediate reduction in system T so

    as to make it

    increasing

    . One begins by defining, for any type, the successorand the sum pointwise, e.g., t + u := x(t)x + (u)x. Reduction then becomes :

    (xt)u ;g t[u/x] + SSSSSu (6.12)

    One verifies that it is confluent. Moreover, it is strictly increasing, in the sensethat the size of the term increases : here from size of t

    + size of u

    +4

    to at least size of t

    + size of u

    +5. In particular if Gandy reduction isweakly normalising, it will also be strongly normalising, because of confluence.

    This is sufficient in the absence of the recursor : weak normalisability comesfrom the possibility of recursively translating xt into xt+SSSSSx, and from

  • 7/29/2019 Coursang2.PDF

    44/70

    6.E. SUBTYPING 155

    weak normalisation of the simply typed calculus. Observe that S and + need

    not be the actual S and +, they could be variables ; in particular the methodextends modulo Church-Rosser to natural deduction. By the way, theGandy method shows that the bounds on strong normalisation are of the sameorder as the bounds on weak normalisation.

    But the original method was devised for system T ; in case, one must alsomodify the reduction of the recursor so as to make it increasing. See alsosection 7.B.2.

    6.E Subtyping

    6.E.1 Polymorphism

    Polymorphism is the observation that the same -term can admit several types.For instance, in the simply typed calculus, Church integers admit the typesn+2.

    This is exploited in a typed programming language such as ML. The typesare universally quantified simple types. When a -term is typable, one can giveit a principal type

    . Polymorphism la ML allows one to type functions

    such as the exponential by unification of the principal types. For instance,

    in order to type (y)x where x, y are of type nat, one will solve the equation(X+2) Z = Y+2, whose solution is Z = X+2, Y = X+1.

    6.E.2 Subtyping

    In system F, Church integers admit much more types than in ML, for instancenat+2. One observes that, from the viewpoint of typable -terms,nat nat + 2. There are therefore inclusions between types, this is subtyping.

    It is legitimate to present second order quantification as an intersection,the intersection of all T + 2. One can, and that is what has been done by the

    l

    Torino school , enrich the language by means of intersection types.An interpretation of system F in -calcul : one appelle type candidate any

    set T of -terms enjoying :

    (T1) : Any term of T is sN.

    (T2) : If t T and t ; t, then t T.

    (T3) : If t is simple and if all the immediate reducts of t are in T, then t isin T.

  • 7/29/2019 Coursang2.PDF

    45/70

    156 CHAPTER 6. SYSTEM F

    a definition strictly inspired by reducibility candidates. If T,U are type can-

    didates, one defines :

    T U := {v; t T (v)t U} (6.13)

    And one proves that this is still a type candidate.Type candidates are also closed under arbitrary intersections : this is ob-

    vious from the shape of the definition. Which enables one to define XA asintersection of all candidates A[T/X]. There is an obvious room for otherkinds of intersections.

    The reducibility proof can be seen as the fact that, if t closed is of typeA, then t belongs to the candidate A. Conversely, if t is a closed -term