Prerequisites. Direct starred prerequisites: none. No later core chapter depends on this route.
In the calculi of this book, substitution is an operation of the metalanguage: 𝛽-contraction rewrites (𝜆𝑥. 𝑎) 𝑏 to 𝑎[𝑏/𝑥] in one step, and the whole traversal of 𝑎 happens outside the calculus. An implementation cannot take that step; it must walk the term, and it must be able to stop part-way. Making the traversal into syntax means adding a term former for “𝑎 under a pending substitution” and rules that push the pending substitution one layer inward.
Adding those rules costs nothing by itself. The interesting decision is whether to add one more rule, which composes two pending substitutions into one: 𝑎[𝑠][𝑡]⟶𝑎[𝑠∘𝑡]. The rule is desirable. It makes substitutions an algebra with an associative composition, it lets a machine merge two environments instead of carrying both, and it is what turns the calculus into the algebraic structure that chapter 54 takes as primitive. It is also what this chapter’s central counterexample destroys: with composition, there is a simply typed term, strongly normalizing under ordinary 𝛽-reduction, that admits an infinite reduction (theorem 148.8).
Two calculi are therefore developed separately. The first, 𝜆𝜎, has full composition and is confluent, and the counterexample applies to it. The second, 𝜆ex, has a composition rule guarded by a side condition together with an explicit rule that deletes a substitution nobody uses, and it preserves strong normalization. No theorem proved for one is transferred to the other.
The 𝜆𝜎-calculus
Fix de Bruijn notation: a variable occurrence is a positive integer, and 𝐧 refers to the variable bound by the 𝑛-th enclosing 𝜆. The raw expressions of 𝜆𝜎 are two mutually recursive sorts, terms𝑎,𝑏::=𝟏∣𝑏𝑎∣𝜆𝑎∣𝑎[𝑠],substitutions𝑠,𝑡::=𝗂𝖽∣↑∣𝑎⋅𝑠∣𝑠∘𝑡. A term 𝑎[𝑠] is a closure.
Referenced from 5 locations
The intended readings fix every rule below. The substitution 𝗂𝖽 is {𝐢/𝐢}; the substitution ↑ is {𝐢+𝟏/𝐢}, so that 𝟏[ ↑] =𝟐 and the index 𝐧+𝟏 is written 𝟏[ ↑𝑛]; the substitution 𝑎 ⋅𝑠 is {𝑎/𝟏, 𝑠(𝐢)/𝐢+𝟏}; and 𝑠 ∘𝑡 is the substitution with 𝑎[𝑠 ∘𝑡] =𝑎[𝑠][𝑡]. Only the index 𝟏 is a primitive term.
The relation ⟶ on raw expressions is the compatible closure of 𝐵𝑒𝑡𝑎(𝜆𝑎)𝑏⟶𝑎[𝑏⋅𝗂𝖽]𝑉𝑎𝑟𝐼𝑑𝟏[𝗂𝖽]⟶𝟏𝑉𝑎𝑟𝐶𝑜𝑛𝑠𝟏[𝑎⋅𝑠]⟶𝑎𝐴𝑝𝑝(𝑏𝑎)[𝑠]⟶𝑏[𝑠]𝑎[𝑠]𝐴𝑏𝑠(𝜆𝑎)[𝑠]⟶𝜆𝑎[𝟏⋅(𝑠∘↑)]𝐶𝑙𝑜𝑠𝑎[𝑠][𝑡]⟶𝑎[𝑠∘𝑡]𝐼𝑑𝐿𝗂𝖽∘𝑠⟶𝑠𝑆ℎ𝑖𝑓𝑡𝐼𝑑↑∘𝗂𝖽⟶↑𝑆ℎ𝑖𝑓𝑡𝐶𝑜𝑛𝑠↑∘(𝑎⋅𝑠)⟶𝑠𝑀𝑎𝑝(𝑎⋅𝑠)∘𝑡⟶𝑎[𝑡]⋅(𝑠∘𝑡)𝐴𝑠𝑠(𝑠1∘𝑠2)∘𝑠3⟶𝑠1∘(𝑠2∘𝑠3) The ten rules other than Beta are called 𝜎 collectively, and ⟶𝜎 is the relation they generate.
Referenced from 7 locations
Beta is the only rule that removes a 𝜆; every other rule removes or relocates a substitution. The rule Abs is not a design choice but a calculation. Pushing 𝑠 ={𝑠(𝐢)/𝐢} under a 𝜆 must leave 𝟏 alone and must protect the free indices of each 𝑠(𝐢) from the new binder: (𝜆𝑐)[𝑠]𝑢𝑛𝑑𝑒𝑟𝜆=𝜆𝑐{𝟏/𝟏, 𝑠(𝐢){𝐢+𝟏/𝐢}/𝐢+𝟏}𝑑𝑒𝑓. ↑=𝜆𝑐{𝟏/𝟏, 𝑠(𝐢)[↑]/𝐢+𝟏}𝑑𝑒𝑓. ⋅,∘=𝜆𝑐[𝟏⋅(𝑠∘↑)]. This one rule uses every operator except 𝗂𝖽, which is what makes the four-operator syntax of definition 148.1 the natural choice rather than an arbitrary one.
In (𝜆 𝟏[𝟐 ⋅𝗂𝖽])[𝑎 ⋅𝗂𝖽] the occurrence of 𝟏 is not bound by the displayed 𝜆. The inner substitution intercepts it and returns 𝟐; crossing the 𝜆 renames 𝟐 to 𝟏, which the outer substitution sends to 𝑎. Reading binding structure off an explicit-substitution term therefore requires computing, not inspecting.
Referenced from 2 locations
The relation ⟶𝜎 is terminating and confluent, so every raw expression 𝑎 has a unique 𝜎-normal form, written 𝜎(𝑎).
Referenced from 4 locations
Proof of Proposition 148.4 — σ terminates and is confluent
Proof. Termination is imported. Merging the two sorts and identifying −[ −] with ∘ translates 𝜎 into the rewriting system SUBST of categorical combinators, one 𝜎-step to one SUBST-step; termination of SUBST is the theorem of Hardin and Laville cited by the source (section 148.3). Nothing else in this chapter depends on that import.
Given termination, local confluence suffices, and local confluence is checked on critical pairs. For instance the pair 𝟏[𝗂𝖽][𝑠]𝑉𝑎𝑟𝐼𝑑⟶𝟏[𝑠],𝟏[𝗂𝖽][𝑠]𝐶𝑙𝑜𝑠⟶𝟏[𝗂𝖽∘𝑠]𝐼𝑑𝐿⟶𝟏[𝑠] closes with IdL. The remaining overlaps close in the same way, each by one of IdL, ShiftCons, Map or Ass. ◻
Proof of Proposition 148.5 — σ -normal forms are ordinary terms
Proof. A normal substitution cannot be a composition: the outermost composition 𝑠 ∘𝑡 is a redex for one of IdL, ShiftId, ShiftCons, Map or Ass according to the shape of 𝑠, and these five cases exhaust the productions for 𝑠. So a normal substitution is 𝗂𝖽, ↑, or 𝑎 ⋅𝑠 with 𝑎,𝑠 normal, and iterating the last clause gives the displayed grammar with ↑𝑛 written for the 𝑛-fold composition, itself normal only when its associativity has been fixed. A normal term cannot be a closure 𝑎[𝑠] unless 𝑎 =𝟏 and 𝑠 is a composition of shifts: if 𝑎 is an application, an abstraction or a closure, one of App, Abs, Clos applies, and if 𝑎 =𝟏 then VarId or VarCons applies unless 𝑠 is ↑𝑛. ◻
Let 𝑎{𝑎1/𝟏,𝑎2/𝟐,…} =𝑏 be derivable in the metalevel substitution calculus for de Bruijn terms, and suppose there are 𝑚 and 𝑝 with 𝑎𝑚+𝑞 =𝐩+𝐪 for all 𝑞 ≥1. Then 𝜎(𝑎[𝑎1⋅𝑎2⋯𝑎𝑚⋅↑𝑝])=𝑏. Consequently one 𝛽-step is simulated by one Beta-step followed by 𝜎-reduction to normal form.
Referenced from 6 locations
Proof of Theorem 148.6 — Simulation of β
Proof. Induction on the derivation, strengthening the claim so that every intermediate expression satisfies the hypothesis on the 𝑎𝑖.
Index. For 𝐧{𝑎1/𝟏,…} =𝑎𝑛: if 𝑛 ≤𝑚 then 𝐧[𝑎1⋯𝑎𝑚 ⋅ ↑𝑝] 𝜎-reduces to 𝑎𝑛 by 𝑛 −1 uses of ShiftCons followed by VarCons; if 𝑛 >𝑚 it reduces to 𝐧−𝐦+𝐩, and the hypothesis gives 𝑎𝑛 =𝑎𝑚+(𝑛−𝑚) =𝐧−𝐦+𝐩.
Application. Both sides distribute by App and the two induction hypotheses apply to the immediate subterms.
Abstraction. For (𝜆𝑎){𝑎1/𝟏,…} =𝜆𝑎′, the metalevel rule first lifts each 𝑎𝑖, giving 𝑎′𝑖 with 𝜎(𝑎𝑖[ ↑]) =𝑎′𝑖 by the induction hypothesis at 𝑚 =0, 𝑝 =1. The induction hypothesis for 𝑎 at 𝑚 +1 and 𝑝 +1 gives 𝜎(𝑎[𝟏 ⋅𝑎′1⋯𝑎′𝑚 ⋅ ↑𝑝+1]) =𝑎′. On the other side, Abs produces 𝑎[𝟏 ⋅((𝑎1⋯𝑎𝑚 ⋅ ↑𝑝) ∘ ↑)], and repeated Map gives (𝑎1⋯𝑎𝑚⋅↑𝑝)∘↑𝑀𝑎𝑝⟶∗𝑎1[↑]⋯𝑎𝑚[↑]⋅↑𝑝+1, whose 𝜎-normal form is 𝑎′1⋯𝑎′𝑚 ⋅ ↑𝑝+1. The two sides therefore have the same 𝜎-normal form. ◻
The relation generated by Beta together with 𝜎 is confluent.
Referenced from 5 locations
Proof of Theorem 148.7 — Confluence of λ σ
Proof. The proof does not go through the Knuth–Bendix test, which 𝐵𝑒𝑡𝑎 +𝜎 fails, and instead uses Hardin’s interpretation method: if 𝑅 is terminating and confluent with normal-form map 𝑅( −), if 𝑆𝑅 is a relation on 𝑅-normal forms contained in (𝑅 ∪𝑆)∗, and if 𝑆(𝑥,𝑦) implies 𝑆∗𝑅(𝑅(𝑥),𝑅(𝑦)), then confluence of 𝑆𝑅 gives confluence of 𝑅 ∪𝑆.
Take 𝑅:=𝜎, which is terminating and confluent by proposition 148.4, and 𝑆𝑅:=𝛽 on 𝜎-normal forms. Two facts are then needed. First, 𝛽 is confluent on 𝜎-normal forms: by proposition 148.5 those are ordinary 𝜆-terms, on which 𝛽 is the ordinary 𝛽 by theorem 148.6, and ordinary 𝛽 is confluent; on substitutions in normal form the reductions are independent reductions in the components. Second, a Beta-step projects: if 𝑎 𝐵𝑒𝑡𝑎⟶𝑏 then 𝜎(𝑎) ⟶∗𝛽𝜎(𝑏), and likewise for substitutions. That projection is proved by induction on the pair consisting of the length of the longest 𝜎-reduction out of the expression and its size, with cases for applications, abstractions, closures and compositions; the source carries it out in full. Hardin’s method then yields the theorem. ◻
★☆☆ Reduce (𝜆(𝟐 𝟏))[𝑎 ⋅𝗂𝖽] to 𝜎-normal form, naming the rule at each step. Recall that 𝟐 abbreviates 𝟏[ ↑].
Referenced from 2 locations
★★☆ Check local confluence for the critical pair between Map and Ass on ((𝑎 ⋅𝑠1) ∘𝑠2) ∘𝑠3, displaying both reducts and their common reduct.
Referenced from 2 locations
★★☆ Show that 𝜎 alone does not prove 𝟏[𝑠] ⋅( ↑ ∘𝑠) =𝑠 for an arbitrary substitution variable 𝑠, although the equation holds for every closed normal 𝑠. Which rule would have to be added, and what does its absence say about the difference between the equational theory and the rewriting system?
Referenced from 2 locations
Composition destroys strong normalization
𝜆𝜎 is confluent. It does not follow that a term which cannot diverge under ordinary 𝛽-reduction cannot diverge in 𝜆𝜎, and it is false.
The failure is easiest to display with named variables, in a calculus with single substitutions. Write 𝑡⟨𝑥 : =𝑢⟩ for a pending substitution and consider the single composition rule 𝑡⟨𝑥:=𝑢⟩⟨𝑦:=𝑣⟩⇝𝑡⟨𝑥:=𝑢⟨𝑦:=𝑣⟩⟩if 𝑦∉FV(𝑡). The side condition says the outer substitution is garbage for 𝑡: nothing in 𝑡 uses 𝑦. The rule does not delete it; it pushes it into the body of the inner substitution. Equation 148.1 is weaker than the Clos/Map pair of definition 148.2, which implement the parallel form of the same move, so a divergence built from it is a divergence of 𝜆𝜎.
There is a term, strongly normalizing under 𝛽-reduction, that admits an infinite reduction using 𝛽, the substitution-propagation rules, and (148.1).
Referenced from 14 locations
Proof of Theorem 148.8 — Composition breaks preservation of strong normalization
Proof. Let 𝑎,𝑏,𝑦,𝑦′ be four distinct variables and define 𝑆0:=⟨𝑦:=(𝜆𝑦.𝑎)𝑏⟩,𝑆𝑛+1:=⟨𝑦:=𝑏𝑆𝑛⟩. Start from 𝑀:=(𝜆𝑦. (𝜆𝑦′. 𝑎) ((𝜆𝑦. 𝑎) 𝑏)) ((𝜆𝑦. 𝑎) 𝑏) and compute: 𝑀⟶𝑎⟨𝑦′:=(𝜆𝑦.𝑎)𝑏⟩⟨𝑦:=(𝜆𝑦.𝑎)𝑏⟩two Beta steps⇝𝑎⟨𝑦′:=((𝜆𝑦.𝑎)𝑏)⟨𝑦:=(𝜆𝑦.𝑎)𝑏⟩⟩(148.1), since 𝑦∉FV(𝑎)⟶𝑎⟨𝑦′:=(𝜆𝑦.𝑎𝑆0)(𝑏𝑆0)⟩propagation into the application⟶𝑎⟨𝑦′:=𝑎𝑆0⟨𝑦:=𝑏𝑆0⟩⟩Beta, and the last expression is 𝑎⟨𝑦′ : =𝑎 𝑆0𝑆1⟩. The same four moves applied to 𝑎 𝑆0𝑆𝑚+1 give 𝑎𝑆0𝑆𝑚+1⇝⋯⟶𝑎⟨𝑦′:=𝑎𝑆𝑚+1𝑆𝑚+2⟩, and for the mixed indices 𝑎𝑆𝑚+1𝑆𝑛+1=𝑎⟨𝑦′:=𝑏𝑆𝑚⟩⟨𝑦:=𝑏𝑆𝑛⟩⇝𝑎⟨𝑦′:=𝑏𝑆𝑚⟨𝑦:=𝑏𝑆𝑛⟩⟩=𝑎⟨𝑦′:=𝑏𝑆𝑚𝑆𝑛+1⟩. Chaining these three schemes produces 𝑀⟶⋯𝑆0𝑆1⋯⟶⋯𝑆1𝑆2⋯⟶⋯𝑆0𝑆2⋯⟶⋯𝑆2𝑆3⋯⟶⋯𝑆1𝑆3⋯⟶⋯𝑆0𝑆3⋯⟶⋯, an infinite reduction, since the index pair strictly increases along the displayed schedule and no expression repeats.
The term 𝑀 is strongly normalizing under 𝛽: every 𝛽-redex of 𝑀 has a body in which the bound variable does not occur, so each contraction erases its argument and strictly decreases the number of 𝜆’s. The original counterexample uses the simply typable term 𝜆𝑥. (𝜆𝑦. 𝐼 (𝐼 𝑦)) (𝐼 𝑥) with 𝐼:=𝜆𝑧. 𝑧, for which the same schedule runs and the type assignment is displayed in the source. ◻
Safe composition: the 𝜆ex-calculus
Terms are generated by 𝑇 ::=𝑥 ∣𝑇 𝑇 ∣𝜆𝑥. 𝑇 ∣𝑇[𝑥/𝑇], with 𝜆𝑥. 𝑡 and 𝑡[𝑥/𝑢] both binding 𝑥 in 𝑡; free variables are as usual, with FV(𝑡[𝑥/𝑢]) =(FV(𝑡) ∖{𝑥}) ∪FV(𝑢). Metalevel substitution 𝑡{𝑥/𝑢} is defined as usual and additionally by 𝑡[𝑦/𝑢]{𝑥/𝑣}:=𝑡{𝑥/𝑣}[𝑦/𝑢{𝑥/𝑣}]. The equation 𝐶𝑡[𝑥/𝑢][𝑦/𝑣]=𝑡[𝑦/𝑣][𝑥/𝑢]if 𝑦∉FV(𝑢) and 𝑥∉FV(𝑣) together with 𝛼-conversion generates an equivalence =𝑒 on terms.
Referenced from 5 locations
𝐵(𝜆𝑥.𝑡)𝑢⟶𝑡[𝑥/𝑢]𝑉𝑎𝑟𝑥[𝑥/𝑢]⟶𝑢𝐺𝑐𝑡[𝑥/𝑢]⟶𝑡if 𝑥∉FV(𝑡)𝐴𝑝𝑝(𝑡𝑢)[𝑥/𝑣]⟶𝑡[𝑥/𝑣]𝑢[𝑥/𝑣]𝐿𝑎𝑚𝑏(𝜆𝑦.𝑡)[𝑥/𝑣]⟶𝜆𝑦.𝑡[𝑥/𝑣]𝐶𝑜𝑚𝑝𝑡[𝑥/𝑢][𝑦/𝑣]⟶𝑡[𝑦/𝑣][𝑥/𝑢[𝑦/𝑣]]if 𝑦∈FV(𝑢) Write ⟶x for the relation generated by the five rules other than B, and let ⟶𝜆ex be ⟶ modulo =𝑒: that is, 𝑡 ⟶𝜆ex𝑡′ when 𝑡 =𝑒𝑠 ⟶𝑠′ =𝑒𝑡′ for some 𝑠,𝑠′.
Referenced from 6 locations
Two features distinguish definition 148.12 from definition 148.2. The composition rule Comp fires only when 𝑦 ∈FV(𝑢), that is, only when the outer substitution has something to do inside the inner one. And Gc deletes a substitution whose variable does not occur. Together they remove exactly the move (148.1) used in theorem 148.8: when 𝑦 ∉FV(𝑡) and 𝑦 ∉FV(𝑢) the substitution is deleted, and when 𝑦 ∈FV(𝑢) it is composed, which is not pushing into garbage.
For all terms 𝑡,𝑢, 𝑡[𝑥/𝑢] ⟶∗𝜆ex𝑡{𝑥/𝑢}.
Referenced from 6 locations
Proof of Theorem 148.13 — Full composition
Proof. Induction on 𝑡.
𝑡 =𝑥. 𝑥[𝑥/𝑢] 𝑉𝑎𝑟⟶𝑢 =𝑥{𝑥/𝑢}.
𝑡 =𝑦 ≠𝑥. 𝑥 ∉FV(𝑦), so 𝑦[𝑥/𝑢] 𝐺𝑐⟶𝑦 =𝑦{𝑥/𝑢}.
𝑡 =𝑡1𝑡2. By App, (𝑡1𝑡2)[𝑥/𝑢] ⟶𝑡1[𝑥/𝑢] 𝑡2[𝑥/𝑢]; the two induction hypotheses then give ⟶∗𝑡1{𝑥/𝑢} 𝑡2{𝑥/𝑢}, which is (𝑡1𝑡2){𝑥/𝑢}.
𝑡 =𝜆𝑦. 𝑠. Choose 𝑦 ∉FV(𝑢) ∪{𝑥} by 𝛼-conversion. Then (𝜆𝑦.𝑠)[𝑥/𝑢]𝐿𝑎𝑚𝑏⟶𝜆𝑦.𝑠[𝑥/𝑢]𝐼𝐻⟶∗𝜆𝑦.𝑠{𝑥/𝑢}=(𝜆𝑦.𝑠){𝑥/𝑢}.
𝑡 =𝑠[𝑦/𝑣]. Choose 𝑦 ∉FV(𝑢) ∪{𝑥}. Two cases. If 𝑥 ∈FV(𝑣), then Comp applies to 𝑠[𝑦/𝑣][𝑥/𝑢] and gives 𝑠[𝑥/𝑢][𝑦/𝑣[𝑥/𝑢]]; the induction hypotheses for 𝑠 and 𝑣 reduce this to 𝑠{𝑥/𝑢}[𝑦/𝑣{𝑥/𝑢}], which is (𝑠[𝑦/𝑣]){𝑥/𝑢} by definition 148.11. If 𝑥 ∉FV(𝑣), then 𝑣{𝑥/𝑢} =𝑣 and the equation C applies, since 𝑦 ∉FV(𝑢) and 𝑥 ∉FV(𝑣): 𝑠[𝑦/𝑣][𝑥/𝑢]=𝑒𝑠[𝑥/𝑢][𝑦/𝑣]⟶∗𝑠{𝑥/𝑢}[𝑦/𝑣]=(𝑠[𝑦/𝑣]){𝑥/𝑢}. ◻
If 𝑡 ⟶𝛽𝑡′ for 𝜆-terms 𝑡,𝑡′, then 𝑡 ⟶∗𝜆ex𝑡′.
Referenced from 4 locations
Proof of Corollary 148.14 — Simulation
Proof. A 𝛽-step contracts (𝜆𝑥. 𝑠) 𝑢 to 𝑠{𝑥/𝑢} in some context. By B the same context reduces to 𝑠[𝑥/𝑢], and by theorem 148.13 that reduces to 𝑠{𝑥/𝑢}. Reduction is compatible with contexts. ◻
In 𝜆ex the term 𝑀 of theorem 148.8 reduces in four steps to the normal form 𝑎.
Referenced from 4 locations
Proof of Proposition 148.15 — The counterexample is blocked
Proof. Two B steps are available; take the outer one first: 𝑀𝐵⟶((𝜆𝑦′.𝑎)((𝜆𝑦.𝑎)𝑏))[𝑦/(𝜆𝑦.𝑎)𝑏]. Now FV((𝜆𝑦′. 𝑎) ((𝜆𝑦. 𝑎) 𝑏)) ={𝑎,𝑏}, which does not contain 𝑦, so Gc applies and Comp does not: Comp would require a substitution immediately inside, and the body is an application. Hence 𝐺𝑐⟶(𝜆𝑦′.𝑎)((𝜆𝑦.𝑎)𝑏)𝐵⟶𝑎[𝑦′/(𝜆𝑦.𝑎)𝑏]𝐺𝑐⟶𝑎, the last step because 𝑦′ ∉FV(𝑎) ={𝑎}. The divergence of theorem 148.8 is created by the step from 𝑎⟨𝑦′ : =⋯⟩⟨𝑦 : =⋯⟩ to 𝑎⟨𝑦′ : =⋯⟨𝑦 : =⋯⟩⟩. In 𝜆ex that redex would be Comp at the term 𝑎[𝑦′/(𝜆𝑦. 𝑎)𝑏][𝑦/(𝜆𝑦. 𝑎)𝑏], and its side condition asks for 𝑦 ∈FV((𝜆𝑦. 𝑎) 𝑏), a set equal to {𝑎,𝑏}; the condition fails. ◻
The following hold for 𝜆ex and are imported at the exact signature stated.
Perpetuality. There is a deterministic many-step strategy ⇉ on terms such that 𝑡 ⇉𝑡′ implies 𝑡 ⟶+𝜆ex𝑡′, and such that 𝑡 ⇉𝑡′ with 𝑡′ strongly normalizing implies 𝑡 strongly normalizing.
Preservation of strong normalization. If a 𝜆-term 𝑡 is strongly normalizing for 𝛽, then 𝑡 is strongly normalizing for 𝜆ex.
Confluence. The relation ⟶𝜆ex is confluent on metaterms, that is, on terms extended by metavariables carrying a list of delayed substitutions.
Typed strong normalization. Every simply typed 𝜆ex-term is strongly normalizing.
Referenced from 3 locations
The proofs are not reproduced. Clause (1) is proved by induction on the strategy and depends on a separate property of the substitution calculus; clause (2) follows from (1) through an inductive characterization of the strongly normalizing terms; clause (3) is proved by exhibiting a superdevelopment map with van Oostrom’s Z-property, and clause (4) by a modular normalization theorem applied to a translation into a calculus with weakening. Locators for all four are in section 148.3. What is proved locally is theorem 148.13, corollary 148.14 and proposition 148.15; these do not depend on clauses (1)–(4), and clauses (1)–(4) are not transferred to 𝜆𝜎, where (2) is false by theorem 148.8.
★★☆ Show that Gc is not derivable from the other five rules of definition 148.12: exhibit a term 𝑡[𝑥/𝑢] with 𝑥 ∉FV(𝑡) that is a normal form for {𝐵,𝑉𝑎𝑟,𝐴𝑝𝑝,𝐿𝑎𝑚𝑏,𝐶𝑜𝑚𝑝} modulo =𝑒.
Referenced from 2 locations
★★☆ Drop the side condition 𝑦 ∈FV(𝑢) from Comp and show that the resulting calculus admits the infinite reduction of theorem 148.8, by writing the first four steps in the notation of definition 148.12.
Referenced from 2 locations
★★☆ State and prove the analogue of theorem 148.13 for 𝜆𝜎: for every term 𝑎, 𝜎(𝑎[𝑏 ⋅𝗂𝖽]) is the de Bruijn metasubstitution of 𝑏 into 𝑎. Which theorem of section 148.1 is this?
Referenced from 2 locations
Suggested first pass.
Begin with exercise 148.7 and exercise 148.8, then complete exercise 148.11.
★★☆ Reduce (𝜆(𝜆(𝟐 𝟏)))[𝑎 ⋅𝗂𝖽] to 𝜎-normal form in 𝜆𝜎, naming every rule. Then perform the same computation with named variables in 𝜆ex and compare the number of steps.
Referenced from 3 locations
★★★ Verify the schedule displayed at the end of the proof of theorem 148.8 by computing the first three transitions ⋯𝑆0𝑆1⋯ ⟶⋯𝑆1𝑆2⋯ ⟶⋯𝑆0𝑆2⋯ in full, and prove that no expression occurs twice, using the pair (𝑚,𝑛) of indices as a measure.
Referenced from 3 locations
★★☆ Theorem 148.7 is proved for the untyped calculus. Explain why adding the simple typing rules of chapter 2 to 𝜆𝜎 does not by itself repair theorem 148.8, and identify the exact clause of the counterexample that typing would have to exclude.
Referenced from 2 locations
★★★ Compare definition 148.2 with the CwF equations of definition 54.16: match 𝗂𝖽, ↑, 𝑎 ⋅𝑠 and 𝑠 ∘𝑡 with the identity, 𝐩, ⟨𝛾,𝑎⟩ and composition, and identify which of the ten 𝜎 rules become CwF equations and which become derived facts. State precisely one 𝜎 rule that is an orientation choice with no counterpart in definition 54.16, and say what is lost by orienting it the other way.
Referenced from 2 locations
★★★ Practical project.explicit-substitution-reducer Implement a reducer for both calculi and a divergence detector. The program takes a term in one of two input syntaxes — de Bruijn 𝜆𝜎 expressions over the grammar of definition 148.1, or named-variable 𝜆ex terms over the grammar of definition 148.11 — a rule set, a reduction strategy (leftmost-outermost or a supplied rule order), and a step budget.
Invariant. Every state is a well-formed expression of the declared sort: in 𝜆𝜎, terms and substitutions are never confused, and every rule instance is applied at a subexpression of the matching sort; in 𝜆ex, the side conditions of Gc and Comp are recomputed from the current free-variable sets at each step and never cached across a rewrite. The program checks the invariant before each step and aborts, printing the offending subexpression, rather than continuing.
Concrete result. The program prints the numbered trace, each line carrying the rule name and the redex position, and terminates with normal form: followed by the expression, or with budget exhausted followed by the last expression and the multiset of rule names used.
Acceptance test. In 𝜆𝜎, reducing (𝜆(𝟐 𝟏))[𝑎 ⋅𝗂𝖽] with the 𝜎 rules must reach a normal form containing no closure other than the codings 𝟏[ ↑𝑛], as proposition 148.5 requires. Running the term 𝑀 of theorem 148.8 in 𝜆ex under the leftmost-outermost strategy must print normal form: a after exactly four steps, with the rule sequence B, Gc, B, Gc, matching proposition 148.15. Finally, run the same 𝑀 under the rule order that deletes the side condition 𝑦 ∈FV(𝑢) from Comp, removes Gc, and prefers Comp to every congruence step; that is the calculus of (148.1), and the run must print budget exhausted. A run that still reports a normal form under that order has cached a free-variable set instead of recomputing it, or has kept Gc; either is the defect this test detects.
The divergence of theorem 148.8 is one reduction sequence, not every one, so no acceptance clause asks a leftmost-outermost reducer to find it in 𝜆𝜎: the rule order is part of the input for exactly this reason.
Referenced from 3 locations
Sources. Definition 148.1, Definition 148.2, proposition 148.4, proposition 148.5, theorem 148.6 and theorem 148.7 follow M. Abadi, L. Cardelli, P.-L. Curien and J.-J. Lévy, Explicit substitutions, Journal of Functional Programming 1 (1991), 375–416. The de Bruijn discussion and the derivation of Abs are on physical pages 4–7 of the authors’ preprint; the rule table of definition 148.2 is on physical page 12; the simulation statement proved here as theorem 148.6 is their Proposition 3.1 on physical page 13; confluence is their Theorem 3.2 and the termination and confluence of 𝜎 their Proposition 3.3, both on physical page 14, the termination being credited there to Hardin and Laville; the normal-form grammar of proposition 148.5 and Hardin’s interpretation method are on physical pages 14–15. Theorem 148.8 is P.-A. Melliès, Typed lambda-calculi with explicit substitutions may not terminate, TLCA 1995, LNCS 902, 328–334 [Mel95]; the simplified form displayed here, together with the schedule and the remark that the original term is the typable 𝜆𝑥. (𝜆𝑦. 𝐼 (𝐼 𝑦)) (𝐼 𝑥), is Figure 1.2 and Remark 1.2.1 of K. H. Rose, Explicit substitution: tutorial and survey, BRICS Lecture Series LS-96-3, 1996 [Ros96], physical pages 26–28. Definition 148.11, Definition 148.12 are Figure 1 of D. Kesner, A theory of explicit substitutions with safe and full composition, Logical Methods in Computer Science 5(3:1) (2009), 1–29, physical pages 5–6; theorem 148.13 and corollary 148.14 are her full-composition property and Lemma 2.3 on physical page 7; the four imported clauses of theorem 148.16 are her Theorem 3.3 (physical page 7), Theorem 3.6 (physical page 8), Corollary 8.13 (physical page 24) and the typed strong-normalization result of Section 7 (physical page 20). The algebraic reading of the same operators, in which the 𝜎 equations become the equations of a category with families rather than rewrite rules, is chapter 54; the telescopic presentation that preceded both is de Bruijn’s.