CS 6110 S14 Hanout 2 Proof of Conflunc 27 January 2014 In this supplmntary lctur w prov that th λ-calculus is conflunt. This is rsult is u to lonzo Church (1903 1995) an J. arkly Rossr (1907 1989) an is known as th Church Rossr thorm. Th proof givn hr taks an altrnativ approach to th stanar proof u to Tait an Martin-Löf as givn for xampl in arnrgt [1] (s also [2, 3]). 1 Trms as Labl Trs In th proof of conflunc, w will n to talk about occurrncs of subtrms in a trm as signat by a path from th root. Thus w n to vlop notation for trms viw as labl trs. W will rfr to this viw of trms as th coalgbraic viw, although th rational for this trminology will only bcom clar much latr in th cours. 1.1 lgbraic Viw of Trms rank alphabt is a st Σ togthr with an arity function arity : Σ N. Th lttrs f Σ ar viw as oprator symbols, an arity f N nots th arity of f, or th numbr of inputs of f. Th symbol f is call unary, binary, trnary, or n-ary accoring as its arity is 1, 2, 3, or n, rspctivly. It is call a constant if its arity is 0. Finit trms ovr Σ can b fin by inuction: If t 0,..., t n 1 ar trms an f Σ with arity f = n, thn f t 0..., t n 1 is a trm. Not th bas cas n = 0 is inclu; th first prmis is vacuous in that cas. This fins trms in prfix notation, but rally w ar intrst in th abstract syntax. 1.2 Coalgbraic Viw of Trms ltrnativly, w can fin trms as labl trs. Trms rprsnt in this way ar call cotrms. Lt N not th st of finit-lngth strings of natural numbrs. subst t N is a tr if it is nonmpty an prfix-clos (that is, if αβ t, thn α t). ny tr must contain th mpty string, which is th root of th tr. cotrm is thn a partial function : N Σ such that om is a tr; if α om, thn α i om iff i < arity (α). Th scon conition says that a no α of th tr has xactly n chilrn if th arity of its labl is n. cotrm is finit if its omain is a finit st. Thus on avantag of this finition is that it amits infinit trms. 1 1 Infinit trms xist in OCaml. Typ th following at th intrprtr an s what happns: typ x = C of x;; lt rc x = C x;; 1
α α λx c c x x Figur 1: β-ruction at α If α om, th subtrm of root at α is th cotrm α = λβ. (αβ). 2 {β αβ om }. Not that if α is a prfix of β, thn β is a subtrm of α. Th omain of α is 1.3 Substitution nothr avantag of th coalgbraic viw is that w hav a mor gnral notion of substitution. W can spak of substituting a trm for a singl occurrnc of a subtrm of as spcifi by its location in th tr. Formally, if α om an is a trm, fin { (γ), if β = αγ, [/α] = λβ. (β), if α is not a prfix of β. This is not saf substitution, but raw substitution; w mrly rplac th subtrm of at α with. 2 λ-cotrms λ-cotrm is just a labl tr as scrib in th prcing sction ovr a rank alphabt consisting of variabls x of arity 0, unary bining oprators λx, an th binary application oprator. Orinary λ-trms ar just finit λ-cotrms. Now th β-ruction rul taks th following form. Suppos α is a rx in, say α = (λx. c). Th corrsponing contractum obtain by applying th β-ruction rul is c{/x}, which w substitut for th rx at α. Th nw trm is [c{/x}/α]. This is illustrat in Fig. 1. 2.1 ccptabl Orrings If α an β ar both rxs in an α is a propr prfix of β, thn β is a propr subtrm of α. If w ruc α bfor rucing β, thn β will in gnral no longr b a rx; in, it may no longr vn xist in th rsulting tr. Howvr, if w ruc β first, thn α is still a rx in th rsulting tr (although th subtrm root at α may hav chang), an w can ruc it. Mor gnrally, if om is a st of rxs in, an w ruc th rxs in in som orr consistnt with th subtrm rlation that is, w ruc α only if all propr xtnsions αβ hav alray bn ruc thn vry rx in will still b availabl whn it is tim to ruc it, an it will b possibl to ruc all of thm. Morovr, th actual orr os not mattr, as long as it is consistnt with th subtrm rlation. 2 Hr w ar using λ as a mta-oprator. Thus λβ. (αβ) is th function that on input β N rturns th valu of appli to αβ. 2
Formally, w say that a linar orring α 1,..., α n of th lmnts of is accptabl if α i = α j β implis i j. In othr wors, th squnc α 1,..., α n is a subsqunc of som total xtnsion of th partial orr {(αβ, α) α, β N } (or, if you lik, a topological sort of with rspct to th gs (αβ, α)). ccptabl orrings of a givn st of rxs ar not uniqu. Howvr, it os not mattr which on w pick. On can asily prov inuctivly that for all accptabl orrings of, th lngth of th ruction squnc will b th sam, namly th carinality of, an th rsulting trms will b intical. Lt us call this trm θ (), as it pns only on th starting trm an th st of rxs, not on th orr of th ructions. For α N, lt α = {αβ β N }. If α om, thn α om rprsnts th st of subtrms of α. For, X N, writ X if thr xists an α such that α an α X =. If X, thn an X ar isjoint, an thr xists an accptabl orring of X such that all lmnts of com bfor all lmnts of X. 3 Conflunc W start by proving conflunc in som spcial cass, builing up to th gnral rsult. Lmma 1. Lt an b two sts of rxs of such that all lmnts of ar prfix-incomparabl to all lmnts of. Thn θ (θ ()) an θ (θ ()) both xist an ar qual. This givs th conflunt iagram illustrat in Fig. 2. Proof. oth θ (θ ()) an θ (θ ()) rprsnt th ruction of th rxs in in iffrnt accptabl orrs, thus both trms ar qual to θ (). Lmma 2. Lt α b a rx of, an lt b a st of rxs of such that α. Thn thr xists a st of rxs of θ α () such that α an θ C (θ ()) = θ (θ α ()), θ () θ (θ ()) = θ (θ ()) Figur 2 whr C = {α} if α an C = if α. This givs th conflunt iagram illustrat in Fig. 3. θ () θ () C θ C(θ ()) = θ (θ α()) Figur 3 α θ α() Proof. Suppos first that α. Lt α = (λx. c). Th st may contain rxs in c an. Rucing α first, a copy of rplacs ach fr occurrnc of x in c (s Fig. 1). If w thn ruc th rxs in ths copis of in som accptabl orr, thn ruc th rmaining rxs in c in som accptabl orr, this yils th sam rsult as rucing th rxs in an c in som accptabl orr bfor rucing α, thn rucing α. Formally, tak = {αγ i 1 i m} {αδ i β j 1 i k, 1 j n}, whr = {α00γ i 1 i m} {α1β j 1 j n} an th fr occurrncs of x in c ar locat at {α00δ 1,..., α00δ k }. Th lmnts of of th form α00γ i rprsnt th rxs in c, which aftr rucing α bcom th lmnts of of th form αγ i. Th lmnts of of th form α1β j rprsnt th rxs in, which aftr rucing α bcom th lmnts of of th form αδ i β j rprsnting th corrsponing rxs in th copis of that rplac th fr occurrncs of x in c. Fig. 1 illustrats th cas k = 2. 3
If α, thn it must appar last in any accptabl orring of. y th prvious argumnt, thr xists α such that θ α (θ {α} ()) = θ (θ α ()), thrfor θ (θ ()) = θ α (θ {α} ()) = θ (θ α ()). Lmma 3. Lt an X b sts of rxs of such that X. Thr xists a st of rxs of θ X () such that θ X (θ ()) = θ (θ X ()). = 0 β 1 1 β 2 θ () X 0 = X X 1 Proof. This follows asily by inuction on th carinality of X using Lmmas 1 an 2. Starting with X 0 = X an 0 =, construct a squnc of sts X i an i by taking th lmnts of X on at a tim in som accptabl orr, maintaining th invariant i X i. Fig. 4 illustrats th cas X = {β 1, β 2, β 3 }. Lmma 4. Lt b an arbitrary st of rxs of, an lt α b a rx of. Thn thr xist rx sts C of θ () an of θ α () such that θ C (θ ()) = θ (θ α ()). β 1 β 2 β 3 2 β 3 3 θ X(θ ()) = θ (θ X()) Figur 4 This givs th conflunt iagram illustrat in Fig. 3 (th sam iagram as for Lmma 2, but with a iffrnt intrprtation of th symbols.) θ X() Proof. Partition into 1 = α an 2 = 1. Thn 1 2. y Lmma 2, thr xist a st 1 α of rxs of θ α () an C 1 {α} such that θ C1 (θ 1 ()) = θ 1 (θ α ()). (1) Tak = 1 2. Sinc 1 α, C 1 α, an α 2 =, w hav 1 2 an C 1 2. y Lmma 3, thr xists a st C of rxs of θ 2 (θ 1 ()) = θ () such that Thn θ C (θ 2 (θ 1 ())) = θ 2 (θ C1 (θ 1 ())). (2) θ C (θ ()) = θ C (θ 2 (θ 1 ())) sinc 1 2 = θ 2 (θ C1 (θ 1 ())) by (2) = θ 2 (θ 1 (θ α ())) by (1) = θ (θ α ()) sinc 1 2. Lmma 5. Lt by som arbitrary squnc of ructions, an lt b a st of rxs of. Thn thr xists a st of rxs of such that θ () θ ( ). Proof. This follows in a straightforwar fashion by inuction on th lngth of th ruction by composing th ructions of Lmma 4. Thorm 6 (Church Rossr Thorm). Lt 1 an 2 by som arbitrary squncs of ructions. Thn thr xists an 3 such that 1 3 an 2 3. Proof. Dcompos th ruction squnc 1 into maximal sgmnts such that th orring of rxs is accptabl in ach sgmnt. Lmma 5 givs a conflunt iagram for ach sgmnt, an ths can b compos to gt a conflunt iagram for th ntir ruction squnc 1. 4
Rfrncs [1] H. P. arnrgt. Th Lamba Calculus, Its Syntax an Smantics. North-Hollan, 2n ition, 1984. [2] Robrt Pollack. Polishing up th Tait Martin-Löf proof of th Church Rossr thorm. In Proc. D Wintrmöt 95. Dpartmnt of Computing Scinc, Chalmrs Univrsity, Götborg, Swn, January 1995. [3] Masako Takahashi. Paralll ructions in λ-calculus (rvis vrsion). Information an Computation, 118(1):120 127, pril 1995. 5