Consider a context 𝑥:𝐴,𝑦:𝐵(𝑥). The second declaration may use the first variable. Thus a context is not a bag of assumptions: its order carries mathematical information. Substituting an element 𝑎:𝐴 must remove the declaration 𝑥:𝐴 and simultaneously change 𝐵(𝑥) to 𝐵(𝑎). The syntax and rules must make both operations exact while preserving the order on which the second operation depends.
The metamathematics in this part is carried out in ZFC. In particular, raw expressions and derivation trees form sets, quotients are set-theoretic quotients, and induction on a least rule-closed collection is ordinary well-founded induction in the metatheory. Later model constructions state their additional size or large-cardinal hypotheses where those hypotheses are used; the syntactic arguments of this chapter use none of them.
Renaming the binder in 𝐿(𝑥.𝑃(𝑥;𝑧)) must change the bound occurrences of 𝑥 without changing the free occurrence of 𝑧. A syntax tree must therefore record, for each argument of an operator, which variables that operator binds. A binding tree carries exactly this per-argument binding information.
Fix a countably infinite set V of variables𝑥,𝑦,𝑧,…. Its infinitude guarantees that a variable outside any prescribed finite set of names can always be chosen.
A binding signatureΣ is a set of operators, each equipped with an arity: a finite list (𝑛1,…,𝑛𝑘) of natural numbers. An operator of arity (𝑛1,…,𝑛𝑘) takes 𝑘 arguments and binds 𝑛𝑖 variables in its 𝑖-th argument.
The raw expressions over Σ are generated inductively: every variable 𝑥∈V is a raw expression; and if 𝑜∈Σ has arity (𝑛1,…,𝑛𝑘), if 𝑒1,…,𝑒𝑘 are raw expressions, and if ⃗𝑥𝑖=𝑥𝑖,1,…,𝑥𝑖,𝑛𝑖 is a list of 𝑛𝑖 pairwise distinct variables for each 𝑖, then 𝑜(⃗𝑥1.𝑒1;…;⃗𝑥𝑘.𝑒𝑘) is a raw expression, in which the variables ⃗𝑥𝑖 are bound in 𝑒𝑖.
For the calculations in this section, take a constant 𝐶 of arity (), a binary operator 𝑃 of arity (0,0), and a unary binder 𝐿 of arity (1). Thus 𝑃(𝐶;𝑥) and 𝐿(𝑥.𝑃(𝑥;𝑧)) are raw expressions. The second occurrence of 𝑥 in the latter expression is bound by 𝐿; the occurrence of 𝑧 is free. No typing meaning is assigned to 𝐶,𝑃,𝐿. They are marks on which the binding operations can be seen.
The size, displayed bound names, and free variables of a raw expression are defined by |𝑥|:=1,|𝑜(⃗𝑥1.𝑒1;…;⃗𝑥𝑘.𝑒𝑘)|:=1+∑𝑖|𝑒𝑖|,BN(𝑥):=∅,BN(𝑜(⃗𝑥1.𝑒1;…;⃗𝑥𝑘.𝑒𝑘)):=⋃𝑖({⃗𝑥𝑖}∪BN(𝑒𝑖)),FV(𝑥):={𝑥},FV(𝑜(⃗𝑥1.𝑒1;…;⃗𝑥𝑘.𝑒𝑘)):=⋃𝑖(FV(𝑒𝑖)∖{⃗𝑥𝑖}). A raw context is a finite list 𝑥1:𝐴1,…,𝑥𝑛:𝐴𝑛 whose declared variables are pairwise distinct and whose 𝐴𝑖 are raw expressions. Write dom(Γ) for its set of declared variables, ⋅ for the empty context, and Γ,Δ for concatenation when the domains are disjoint. A raw context used to extend another is also called a telescope, a context extension whose later declaration types may use earlier declared variables.
For the running expression, |𝐿(𝑥.𝑃(𝑥;𝑧))|=4,BN(𝐿(𝑥.𝑃(𝑥;𝑧)))={𝑥},FV(𝐿(𝑥.𝑃(𝑥;𝑧)))={𝑧}. The list 𝑥:𝐶,𝑦:𝑃(𝑥;𝐶) is a raw context. So is the reversed list 𝑦:𝑃(𝑥;𝐶),𝑥:𝐶: raw syntax has not yet enforced dependency order. The first list is derivably well formed only if 𝐶 is a type in the empty context and 𝑃(𝑥;𝐶) is a type in the prefix 𝑥:𝐶. The reversed list fails this dependency test because 𝑥 is not declared in its first prefix.
Let 𝑦 occur nowhere in the raw expression 𝑒. The fresh renaming𝑒⟨𝑦/𝑥⟩ replaces the free occurrences of 𝑥 by 𝑦: 𝑥⟨𝑦/𝑥⟩:=𝑦,𝑢⟨𝑦/𝑥⟩:=𝑢(𝑢≠𝑥),𝑜(⃗𝑥1.𝑒1;…;⃗𝑥𝑘.𝑒𝑘)⟨𝑦/𝑥⟩:=𝑜(⃗𝑥1.𝑒′1;…;⃗𝑥𝑘.𝑒′𝑘), where 𝑒′𝑖:=𝑒𝑖 if 𝑥 occurs in the binder list ⃗𝑥𝑖, and 𝑒′𝑖:=𝑒𝑖⟨𝑦/𝑥⟩ otherwise. Thus renaming stops when it reaches a binder for 𝑥. Let the entries of each of ⃗𝑥,⃗𝑦 be pairwise distinct, let the two sets of entries be disjoint, and let every target name in ⃗𝑦 occur nowhere in 𝑒. We write 𝑒⟨⃗𝑦/⃗𝑥⟩ for the successive renamings.
For 𝑤 fresh, the two possible behaviours are 𝐿(𝑥.𝑃(𝑥;𝑧))⟨𝑤/𝑧⟩=𝐿(𝑥.𝑃(𝑥;𝑤)),𝐿(𝑥.𝑃(𝑥;𝑧))⟨𝑤/𝑥⟩=𝐿(𝑥.𝑃(𝑥;𝑧)). The second renaming stops at 𝐿. By contrast, the body is a raw expression in which 𝑥 is free, so 𝑃(𝑥;𝑧)⟨𝑟/𝑥⟩=𝑃(𝑟;𝑧). This last calculation is what permits us to compare two displayed binders.
Proof of Lemma 26.5 — Free variables after fresh renaming
Proof. Induct on 𝑒. The two variable cases are the displayed alternatives. At 𝑜(⃗𝑥1.𝑒1;…;⃗𝑥𝑘.𝑒𝑘), renaming stops in precisely those arguments whose binder list contains 𝑥. In every other argument apply the induction hypothesis, remove its binder list from the resulting free-variable set, and take the union over the arguments. Since 𝑦 occurs nowhere in the original expression, it belongs to no binder list. The same induction, with the defining equation for size, proves |𝑒⟨𝑦/𝑥⟩|=|𝑒|. If 𝑥 is not free, a variable 𝑧 cannot equal 𝑥, so 𝑧⟨𝑦/𝑥⟩=𝑧; at an operator the renaming either stops at a binder for 𝑥 or the induction hypothesis leaves the body unchanged. This proves the final assertion. ◻
The alpha-equivalence relation =𝛼 on raw expressions is generated inductively by the two clauses:
𝑥=𝛼𝑥 for every variable 𝑥;
𝑜(⃗𝑥1.𝑒1;…;⃗𝑥𝑘.𝑒𝑘)=𝛼𝑜(⃗𝑦1.𝑓1;…;⃗𝑦𝑘.𝑓𝑘) (the same operator 𝑜 on both sides) whenever for each 𝑖 there is a list ⃗𝑧𝑖 of pairwise distinct variables, disjoint from ⃗𝑥𝑖,⃗𝑦𝑖 and occurring in neither 𝑒𝑖 nor 𝑓𝑖, such that 𝑒𝑖⟨⃗𝑧𝑖/⃗𝑥𝑖⟩=𝛼𝑓𝑖⟨⃗𝑧𝑖/⃗𝑦𝑖⟩.
Let 𝑟 occur nowhere in the displayed expressions. Opening both binders with 𝑟 gives the identical body 𝑃(𝑟;𝑧), and hence 𝐿(𝑥.𝑃(𝑥;𝑧))=𝛼𝐿(𝑦.𝑃(𝑦;𝑧)). The tempting expression 𝐿(𝑧.𝑃(𝑧;𝑧)) is not alpha-equivalent to either one: their common openings are 𝑃(𝑟;𝑧) and 𝑃(𝑟;𝑟), which differ at the second variable. Renaming a binder to a free name is capture, not alpha-conversion.
Proof. We first record the raw calculation used in every clause. Let ⃗𝑥,⃗𝑧,⃗𝑤 have the same length, let the three lists be pairwise disjoint with distinct entries internally, and suppose ⃗𝑧,⃗𝑤 occur nowhere in 𝑒. Structural induction gives 𝑒⟨⃗𝑧/⃗𝑥⟩⟨⃗𝑤/⃗𝑧⟩=𝑒⟨⃗𝑤/⃗𝑥⟩. The variable case is immediate. At an operator, each renaming either stops at the argument’s binder list or passes into its body; in the latter case use the induction hypothesis for that body. The free-variable calculation needed below is lemma 26.5.
The companion commutation calculation is also needed. Let 𝑧,𝑤 be distinct from one another and from the equally long, disjoint lists ⃗𝑥,⃗𝑣, suppose ⃗𝑣,𝑤 occur nowhere in 𝑒, and suppose 𝑧∉{⃗𝑥}. Structural induction gives 𝑒⟨⃗𝑣/⃗𝑥⟩⟨𝑤/𝑧⟩=𝑒⟨𝑤/𝑧⟩⟨⃗𝑣/⃗𝑥⟩. At an operator both renamings stop or pass independently in each argument; when they pass, apply the induction hypothesis to that body.
Alpha-equivalent expressions have equal size. Indeed, rule induction on a derivation of 𝑒=𝛼𝑒′ shows |𝑒|=|𝑒′|. The variable clause is immediate. In the operator clause, the induction hypotheses say that every pair of common opened bodies has equal size; fresh renaming preserves size by lemma 26.5, so the corresponding original bodies have equal size. Both expressions use the same operator and arity, and the defining size equation therefore gives equal total sizes.
Complete induction on this common size proves four strengthened assertions simultaneously: independence of the fresh opening, compatibility with fresh renaming, the equivalence laws, and preservation of free variables. Every induction hypothesis below concerns an alpha-equivalent pair of strictly smaller common size.
Independence of the fresh opening. Suppose a common opening with ⃗𝑧𝑖 witnesses clause 2, and let ⃗𝑤𝑖 be any other allowable lists. The induction hypothesis for renaming compatibility renames the smaller related bodies from ⃗𝑧𝑖 to a third fresh list ⃗𝑢𝑖. Equation (26.1) gives the same expressions as opening the original bodies directly at ⃗𝑢𝑖. Repeat the renaming-compatibility step with ⃗𝑢𝑖 in place of ⃗𝑧𝑖 and ⃗𝑤𝑖 in place of ⃗𝑢𝑖. Hence the comparison holds at every common fresh opening.
The later renaming step has the following exhaustive binder case split for one external name 𝑧:
free-variable preservation removes 𝑧 on the right after opening
no
yes
exchange the two displays in the preceding case
Compatibility with fresh renaming. It is enough to treat one renaming ⟨𝑤/𝑧⟩; repeat the argument for a list. For an operator pair, fresh-opening independence permits common opening lists fresh for 𝑧 and 𝑤. Consider one pair of corresponding arguments. If neither binder list contains 𝑧, opening and the external renaming commute by (26.2); the induction hypothesis for renaming compatibility applies to the smaller opened bodies. If both binder lists contain 𝑧, the external renaming stops on both sides, and the original common-opening comparison applies. Suppose, finally, that only one binder list contains 𝑧. After that binder is opened at the fresh common list, 𝑧 is not free on that side. The induction hypothesis for free-variable preservation says it is not free on the other side either. On the side whose binder did not contain 𝑧, the fresh-renaming formula implies 𝑧∉FV(𝑓𝑖): opening at names disjoint from 𝑧 neither creates nor removes a free 𝑧. Thus lemma 26.5 gives 𝑓𝑖⟨𝑤/𝑧⟩=𝑓𝑖 before the opening. On the first side the external renaming stops at the binder. Both results are therefore the original common openings. Clause 2 of definition 26.6 rebuilds the operator and proves renaming compatibility. This case shows why one must prove, rather than assert, that an external renaming commutes with every opening.
Equivalence laws. Reflexivity is structural induction: at an operator choose fresh common openings and use reflexivity for the smaller opened bodies. Symmetry follows by reversing the comparisons in clause 2. For transitivity, suppose 𝑜(⃗𝑥1.𝑒1;…;⃗𝑥𝑘.𝑒𝑘)=𝛼𝑜(⃗𝑦1.𝑓1;…;⃗𝑦𝑘.𝑓𝑘),𝑜(⃗𝑦1.𝑓1;…;⃗𝑦𝑘.𝑓𝑘)=𝛼𝑜(⃗𝑢1.𝑔1;…;⃗𝑢𝑘.𝑔𝑘). Choose one list ⃗𝑤𝑖 fresh for all three 𝑖-th bodies and disjoint from the three binder lists ⃗𝑥𝑖,⃗𝑦𝑖,⃗𝑢𝑖. Fresh-opening independence opens both hypotheses with that same list. Transitivity for the smaller opened bodies, by the induction hypothesis, gives 𝑒𝑖⟨⃗𝑤𝑖/⃗𝑥𝑖⟩=𝛼𝑔𝑖⟨⃗𝑤𝑖/⃗𝑢𝑖⟩; clause 2 rebuilds the operator.
Preservation of free variables. Variables are immediate. In the operator case, open the two 𝑖-th bodies with one fresh list ⃗𝑧𝑖. The induction hypothesis gives the exact equality FV(𝑒𝑖⟨⃗𝑧𝑖/⃗𝑥𝑖⟩)=FV(𝑓𝑖⟨⃗𝑧𝑖/⃗𝑦𝑖⟩). Remove the fresh variables ⃗𝑧𝑖 from this equality and use the fresh-renaming formula recorded above; the result is FV(𝑒𝑖)∖{⃗𝑥𝑖}=FV(𝑓𝑖)∖{⃗𝑦𝑖}. Taking the union over 𝑖 is precisely the free-variable equation for the two operator expressions. ◻
★☆☆ For an operator 𝐿 of arity (1), use two successive common openings to verify directly that 𝐿(𝑥.𝑒)=𝛼𝐿(𝑦.𝑓) and 𝐿(𝑦.𝑓)=𝛼𝐿(𝑢.𝑔) imply 𝐿(𝑥.𝑒)=𝛼𝐿(𝑢.𝑔). Mark where fresh-opening independence is used.
An expression is an alpha-equivalence class of raw expressions, and = between expressions means 𝛼-equivalence of representatives. To write an expression, choose a representative whose bound variables are pairwise distinct and distinct from all free variables in sight (the Barendregt convention). Raw contexts are not quotiented: the declared variables of a context are significant.
Proof. Use complete induction on size. Alpha-equivalent variables are the same variable, so there is nothing to choose. For operator expressions, choose for each pair of corresponding arguments one common binder list ⃗𝑧𝑖 outside 𝑋, outside every name occurring in either body, and disjoint from the two original binder lists ⃗𝑥𝑖,⃗𝑦𝑖. This is permitted by proposition 26.7.1. The common openings 𝑒𝑖⟨⃗𝑧𝑖/⃗𝑥𝑖⟩and𝑓𝑖⟨⃗𝑧𝑖/⃗𝑦𝑖⟩ are alpha-equivalent and smaller than the original expressions. Apply the induction hypothesis to each pair, enlarging the forbidden set to include all the newly chosen ⃗𝑧𝑖, and rebuild the operator with those common binder lists. For this rebuilding step, suppose ¯𝑝𝑖=𝛼𝑒𝑖⟨⃗𝑧𝑖/⃗𝑥𝑖⟩, open both proposed outer binders at a further fresh list ⃗𝑢𝑖. Then ¯𝑝𝑖⟨⃗𝑢𝑖/⃗𝑧𝑖⟩𝑝𝑟𝑜𝑝𝑜𝑠𝑖𝑡𝑖𝑜𝑛26.7.4=𝛼𝑒𝑖⟨⃗𝑧𝑖/⃗𝑥𝑖⟩⟨⃗𝑢𝑖/⃗𝑧𝑖⟩(26.1)=𝑒𝑖⟨⃗𝑢𝑖/⃗𝑥𝑖⟩. Clause 2 of definition 26.6 now shows that the rebuilt representative is alpha-equivalent to the original. Corresponding bodies remain alpha-equivalent by construction. Taking 𝑒′=𝑒 gives the final assertion. ◻
The need for a fresh representative is already visible with 𝐿 and 𝑃. Replacing 𝑥 by 𝑃(𝑦;𝑧) in 𝐿(𝑦.𝑃(𝑥;𝑦)) must not capture the inserted 𝑦. With a naive recursion one would obtain 𝐿(𝑦.𝑃(𝑃(𝑦;𝑧);𝑦)), where the first inserted 𝑦 has become bound. With a fresh 𝑟, first choose the alpha-equivalent representative 𝐿(𝑟.𝑃(𝑥;𝑟)); capture-avoiding substitution gives 𝐿(𝑟.𝑃(𝑃(𝑦;𝑧);𝑟)).
Let 𝑒,𝑎 be expressions and 𝑥 a variable. Choose a representative of 𝑒 whose bound variables avoid 𝑥 and FV(𝑎). The capture-avoiding substitution𝑒[𝑎/𝑥] is defined by recursion: 𝑥[𝑎/𝑥]:=𝑎,𝑦[𝑎/𝑥]:=𝑦(𝑦≠𝑥),𝑜(⃗𝑥1.𝑒1;…)[𝑎/𝑥]:=𝑜(⃗𝑥1.𝑒1[𝑎/𝑥];…). More generally, let 𝑥1,…,𝑥𝑛 be pairwise distinct. Choose a display whose bound names avoid every 𝑥𝑖 and every FV(𝑎𝑗). The simultaneous substitution𝑒[𝑎1/𝑥1,…,𝑎𝑛/𝑥𝑛] is the recursion that sends a variable 𝑥𝑖 to 𝑎𝑖, leaves every other variable fixed, and passes once through every operator argument. Thus an inserted 𝑎𝑖 is not subsequently changed by another entry of the same substitution. The synchronized-display argument in proposition 26.11.1 proves that this operation is independent of the chosen display and of the representatives of all 𝑎𝑖. For a raw context Δ=𝑦1:𝐵1,…,𝑦𝑚:𝐵𝑚 whose declared variables avoid 𝑥 and FV(𝑎) we write Δ[𝑎/𝑥]:=𝑦1:𝐵1[𝑎/𝑥],…,𝑦𝑚:𝐵𝑚[𝑎/𝑥].
For a deterministic named implementation one may fix 𝑥0,𝑥1,… and choose the least name outside the finite forbidden set. The mathematical operation remains the alpha-class specified above; proposition 26.11(1) proves independence from this choice.
If 𝑒=𝛼𝑒′ and 𝑎=𝛼𝑎′ then 𝑒[𝑎/𝑥]=𝛼𝑒′[𝑎′/𝑥]; substitution is well defined on expressions. More generally, simultaneous substitution is independent of the display of 𝑒 and of the representatives of all its substituends.
If 𝑥∉FV(𝑒) then 𝑒[𝑎/𝑥]=𝑒.
FV(𝑒[𝑎/𝑥])=(FV(𝑒)∖{𝑥})∪FV(𝑎) if 𝑥∈FV(𝑒), and FV(𝑒[𝑎/𝑥])=FV(𝑒) otherwise.
(Substitution lemma.) If 𝑥≠𝑦 and 𝑥∉FV(𝑐), then 𝑒[𝑎/𝑥][𝑐/𝑦]=𝑒[𝑐/𝑦][𝑎[𝑐/𝑦]/𝑥].
If 𝑦 occurs nowhere in 𝑒, then ordinary substitution by the fresh variable coincides with fresh renaming: 𝑒[𝑦/𝑥]=𝑒⟨𝑦/𝑥⟩.
Proof. For claim 1, proposition 26.7.3 gives FV(𝑎)=FV(𝑎′). Set 𝑋={𝑥}∪FV(𝑎). Apply lemma 26.9 to 𝑒=𝛼𝑒′ with forbidden set 𝑋. We may therefore calculate with synchronized representatives whose corresponding binder lists are identical and safe for both inserted expressions. Structural induction on their common operator tree now proves ¯𝑒[𝑎/𝑥]=𝛼¯𝑒′[𝑎′/𝑥]. At a variable, the only nontrivial case is 𝑥, where the assertion is 𝑎=𝛼𝑎′. At an operator, apply the induction hypotheses to all corresponding bodies. To rebuild the common binder lists, open the two substituted bodies with one new list. Their alpha-equivalence is preserved by this fresh renaming by proposition 26.7.4, so clause 2 of definition 26.6 applies. This proves representative and substituend independence; no commutation of an opening with substitution is being assumed.
For simultaneous substitution, forbid all source variables and the union of the free-variable sets of all substituends, and apply lemma 26.9 once. The same induction on the synchronized operator trees has variable case 𝑥𝑖↦𝑎𝑖 and otherwise passes through each argument once. Reattachment is exactly the preceding argument. This proves the final assertion of claim 1.
Claims 2 and 3 are structural inductions on one clean representative. The variable cases are immediate. For 𝑜(⃗𝑥1.𝑒1;…;⃗𝑥𝑘.𝑒𝑘), the binder names avoid 𝑥 and FV(𝑎), so the induction hypotheses give FV(𝑒𝑖[𝑎/𝑥])={(FV(𝑒𝑖)∖{𝑥})∪FV(𝑎),𝑥∈FV(𝑒𝑖),FV(𝑒𝑖),𝑥∉FV(𝑒𝑖). Remove the argument’s binder list ⃗𝑥𝑖 and take the union over 𝑖. Because those binders occur in neither {𝑥} nor FV(𝑎), this is exactly claim 3. If 𝑥 is absent from the free variables of the whole operator expression, it is absent from every body after bound names are excluded; claim 2 follows from the body induction hypotheses.
For compatibility with substitution, the variable cases contain the reason for its side conditions. If 𝑒=𝑥: the left side is 𝑥[𝑎/𝑥][𝑐/𝑦]=𝑎[𝑐/𝑦], and the right side is 𝑥[𝑐/𝑦][𝑎[𝑐/𝑦]/𝑥]=𝑥[𝑎[𝑐/𝑦]/𝑥]=𝑎[𝑐/𝑦], using 𝑥≠𝑦. If 𝑒=𝑦: the left side is 𝑦[𝑎/𝑥][𝑐/𝑦]=𝑦[𝑐/𝑦]=𝑐, and the right side is 𝑐[𝑎[𝑐/𝑦]/𝑥]=𝑐 by claim 2, since 𝑥∉FV(𝑐). If 𝑒=𝑧 with 𝑧≠𝑥,𝑦, both sides are 𝑧.
For the operator case put 𝑋={𝑥,𝑦}∪FV(𝑎)∪FV(𝑐)∪FV(𝑎[𝑐/𝑦]). Choose one representative of the outer expression whose bound names avoid 𝑋. By lemma 26.9 and representative independence, choose representatives of 𝑎 and 𝑐 whose bound names also avoid 𝑋. Every substitution below therefore passes through every binder in the chosen representatives. On the 𝑖-th body the induction hypothesis gives 𝑒𝑖[𝑎/𝑥][𝑐/𝑦]=𝑒𝑖[𝑐/𝑦][𝑎[𝑐/𝑦]/𝑥]. Reattaching the unchanged operator and binder lists makes the left and right sides of claim 4 identical argument by argument. Claim 5 is the same structural induction: both operations send 𝑥 to 𝑦, fix every other free variable, and pass through the common clean binder display. This completes the induction. ◻
We do not divide raw expressions into raw types and raw terms: the judgments of section 26.2 do the sorting. In a theory with a universe, one expression may itself be classified as a type, so a two-sorted raw grammar would have to be merged again. The signature is likewise open-ended: adding an operator does not change the uniform definitions of alpha-equivalence and substitution.
★☆☆ Let 𝐿 have arity (1) and 𝑃 arity (0,0). With all displayed variables distinct, calculate 𝐿(𝑦.𝑃(𝑥;𝑦))[𝑃(𝑦;𝑧)/𝑥] from two different clean binder choices and verify their alpha-equivalence by common opening.
★☆☆ Specialize the substitution lemma to a unary binder 𝐿(𝑥.𝑒). Write the operator calculation in full and identify the hypothesis that prevents the term substituted for 𝑦 from reintroducing a free 𝑥.
★★☆ Suppose 𝑥𝑖∉FV(𝑎𝑗) for all 𝑖,𝑗. Show that 𝑒[𝑎1/𝑥1,…,𝑎𝑛/𝑥𝑛]=𝑒[𝑎1/𝑥1]⋯[𝑎𝑛/𝑥𝑛]. First calculate both operations on 𝑃(𝑥1;𝐿(𝑢.𝑃(𝑥2;𝑢))) for 𝑛=2 and clean displayed binders; then prove the general statement by induction on an alpha-equivalent representative of 𝑒 whose bound variables avoid the substituted expressions.
Raw syntax cannot yet say that an expression is a type, that a term has a type, or that two of either are equal. Each assertion is relative to a context of typed variables, so five judgment forms are needed, not one.
Γ⊢𝐴≡𝐵𝗍𝗒𝗉𝖾 — “𝐴 and 𝐵 are judgmentally equal types in context Γ.”
Γ⊢𝑎≡𝑏:𝐴 — “𝑎 and 𝑏 are judgmentally equal elements of type 𝐴 in context Γ.”
Here Γ is a raw context and 𝐴,𝐵,𝑎,𝑏 are expressions. These notions were fixed in definition 26.1, definition 26.3, convention 26.8. The symbol ≡ is reserved for judgmental equality throughout the book.
The presuppositions of a judgment form are the well-formedness obligations of its parts listed below:
judgment
presupposes
Γ,𝑥:𝐴𝖼𝗍𝗑
Γ𝖼𝗍𝗑 and Γ⊢𝐴𝗍𝗒𝗉𝖾
Γ⊢𝐴𝗍𝗒𝗉𝖾
Γ𝖼𝗍𝗑
Γ⊢𝑎:𝐴
Γ⊢𝐴𝗍𝗒𝗉𝖾
Γ⊢𝐴≡𝐵𝗍𝗒𝗉𝖾
Γ⊢𝐴𝗍𝗒𝗉𝖾 and Γ⊢𝐵𝗍𝗒𝗉𝖾
Γ⊢𝑎≡𝑏:𝐴
Γ⊢𝑎:𝐴 and Γ⊢𝑏:𝐴
(and, transitively, everything these presuppose). The first row is recursive; the empty context has no presupposition. We adopt two disciplines. (i) Asserting a judgment, in prose or as the premise of a rule, implicitly asserts its presuppositions. (ii) In displayed rules we compress premises: a premise is omitted when its derivability follows from the presuppositions of the displayed premises and conclusion. This convention is cited by number whenever compression is used.
The five judgment forms are generated simultaneously. Context extension requires a type in the preceding context, so context formation and type formation cannot be defined independently. An extension Γ,𝑥:𝐴 is always a raw context, so 𝑥∉dom(Γ).
The rule Ctx-Emp is a complete derivation of ⋅𝖼𝗍𝗑. Given a derivation D of ⋅⊢𝐴𝗍𝗒𝗉𝖾, Ctx-Ext forms the one-declaration context:
D:⋅⊢𝐴𝗍𝗒𝗉𝖾
𝑥:𝐴𝖼𝗍𝗑
Ctx-Ext
Conversely, Presup-Ext extracts the same type-formation judgment from any derivation of 𝑥:𝐴𝖼𝗍𝗑. Context extension and context inversion are thus two visible operations, not two implicit side conditions.
For example, from 𝑎≡𝑏:𝐴 and 𝑐≡𝑏:𝐴 we obtain 𝑎≡𝑏:𝐴,𝑏≡𝑐:𝐴⟹𝑎≡𝑐:𝐴, first by Tm-Sym on the second judgment and then by Tm-Trans. The type-equality calculation is identical with the prefix Ty-.
The letter J ranges over the four judgment theses, the parts of an expression judgment that follow its context: 𝐴𝗍𝗒𝗉𝖾,𝐴≡𝐵𝗍𝗒𝗉𝖾,𝑎:𝐴,𝑎≡𝑏:𝐴. Thus Γ⊢J abbreviates four judgments. Substitution in J acts on every constituent expression, and FV(J) is the union of their free-variable sets.
The type of a declared variable may be replaced by a judgmentally equal type:
Γ⊢𝐴≡𝐴′𝗍𝗒𝗉𝖾Γ,𝑥:𝐴,Δ⊢J
Γ,𝑥:𝐴′,Δ⊢J
Ctx-Conv
The rule acts on every thesis abbreviated by J. Its first premise is indispensable: changing a declaration to a merely well-formed, but unequal, type would change the mathematical assumption.
For example, if Γ⊢𝐴≡𝐴′𝗍𝗒𝗉𝖾 and Γ,𝑥:𝐴⊢𝑥:𝐴, context conversion followed by term conversion gives Γ⊢𝐴≡𝐴′𝗍𝗒𝗉𝖾Γ,𝑥:𝐴⊢𝑥:𝐴Γ,𝑥:𝐴′⊢𝑥:𝐴Ctx−Conv,Γ,𝑥:𝐴′⊢𝑥:𝐴′. Without 𝐴≡𝐴′, the putative conclusion could assert 𝑥:𝟐⊢𝑥:ℕ merely because both declaration types are formed; no structural rule can supply that judgment.
Let Γ⊢𝐴𝗍𝗒𝗉𝖾. A family of types over 𝐴 is a type Γ,𝑥:𝐴⊢𝐵𝗍𝗒𝗉𝖾, and a section is an element Γ,𝑥:𝐴⊢𝑏:𝐵. For Γ⊢𝑎:𝐴, the expression 𝐵[𝑎/𝑥] is the fiber at 𝑎. We also write 𝐵(𝑥) for the family and 𝐵(𝑎) for the fiber, and set 𝑏(𝑎):=𝑏[𝑎/𝑥].
Substitution removes a declaration by replacing its variable with an element:
Γ⊢𝑎:𝐴Γ,𝑥:𝐴,Δ⊢J
Γ,Δ[𝑎/𝑥]⊢J[𝑎/𝑥]
Subst
Γ⊢𝑎≡𝑎′:𝐴Γ,𝑥:𝐴,Δ⊢𝐵𝗍𝗒𝗉𝖾
Γ,Δ[𝑎/𝑥]⊢𝐵[𝑎/𝑥]≡𝐵[𝑎′/𝑥]𝗍𝗒𝗉𝖾
Subst-Eq-Ty
Γ⊢𝑎≡𝑎′:𝐴Γ,𝑥:𝐴,Δ⊢𝑏:𝐵
Γ,Δ[𝑎/𝑥]⊢𝑏[𝑎/𝑥]≡𝑏[𝑎′/𝑥]:𝐵[𝑎/𝑥]
Subst-Eq-Tm
In these schemes the declared names of Δ are chosen outside FV(𝑎), and outside FV(𝑎′) in the two equality schemes, so every displayed context substitution is defined as in definition 26.10. The first rule acts on all four theses. The other two say that substituting equal elements gives equal types and equal terms in the common context obtained with 𝑎.
★☆☆ Derive the two-variable substitution rule: from Γ⊢𝑎:𝐴, Γ⊢𝑏:𝐵[𝑎/𝑥], and Γ,𝑥:𝐴,𝑦:𝐵,Δ⊢J, conclude Γ,Δ[𝑎/𝑥][𝑏/𝑦]⊢J[𝑎/𝑥][𝑏/𝑦]. Choose the declared names of Δ outside FV(𝑎)∪FV(𝑏) and choose 𝑦∉FV(𝑎), so all displayed context substitutions are defined.
The context, equality, declaration-conversion, substitution, weakening, and variable rules just displayed are collectively called the structural rules. Their premises are compressed according to convention 26.14.
The five judgments are the least classes closed under all structural rules and under the chosen formation, introduction, elimination, and equality rules. They are generated simultaneously because Ctx-Ext has a type judgment as its premise and a context judgment as its conclusion. Rule induction over this simultaneous generation proves one property for each of the five judgment forms (theorem 1.15).
Proof. Use the presupposition and equality rules. From Γ⊢𝑎:𝐴, Presup-Ty gives Γ⊢𝐴𝗍𝗒𝗉𝖾, and then Presup-Ctx gives Γ𝖼𝗍𝗑. From Γ⊢𝐴≡𝐵𝗍𝗒𝗉𝖾, Presup-Eq-Ty gives Γ⊢𝐴𝗍𝗒𝗉𝖾; composing Ty-Sym with Presup-Eq-Ty gives Γ⊢𝐵𝗍𝗒𝗉𝖾; and Presup-Ctx gives Γ𝖼𝗍𝗑. From Γ⊢𝑎≡𝑏:𝐴, Presup-Eq-Tm gives Γ⊢𝑎:𝐴, composing Tm-Sym with Presup-Eq-Tm gives Γ⊢𝑏:𝐴, and the previous case finishes. From Γ⊢𝐴𝗍𝗒𝗉𝖾, Presup-Ctx gives Γ𝖼𝗍𝗑. Finally, from Γ,𝑥:𝐴𝖼𝗍𝗑, Presup-Ext gives Γ⊢𝐴𝗍𝗒𝗉𝖾 and then Presup-Ctx gives Γ𝖼𝗍𝗑. Iterating these five derivations establishes every transitive presupposition in convention 26.14. ◻
Assume that no added rule concludes a context judgment and that every added rule has, among its full premises, the context judgment presupposed by its conclusion. Let Γ=𝑥1:𝐴1,…,𝑥𝑛:𝐴𝑛 be a raw context. The judgment Γ𝖼𝗍𝗑 is derivable if and only if for each 1≤𝑘≤𝑛 the judgment 𝑥1:𝐴1,…,𝑥𝑘−1:𝐴𝑘−1⊢𝐴𝑘𝗍𝗒𝗉𝖾 is derivable.
Proof of Proposition 26.25 — Characterization of contexts
Proof. (⇐) For 𝑛=0 apply Ctx-Emp; for 𝑛≥1 apply Ctx-Ext to the 𝑘=𝑛 judgment.
(⇒) We prove two assertions simultaneously by rule induction. If Γ𝖼𝗍𝗑 is derivable, every declaration of Γ has a derivable type judgment in its preceding prefix. If Γ⊢J is derivable, the same prefix property holds for its ambient context Γ. We treat each structural rule and then the added rules.
For Ctx-Emp the assertion is empty. For Ctx-Ext, the premise is 𝑥1:𝐴1,…,𝑥𝑛−1:𝐴𝑛−1⊢𝐴𝑛𝗍𝗒𝗉𝖾; the inductive hypothesis for it yields the type judgments for all 𝑘<𝑛, and the premise itself is the case 𝑘=𝑛.
Every presupposition rule either keeps the context or removes its last declaration. In the first case its premise induction hypothesis is exactly the desired prefix property; in the second, Presup-Ext, take the proper prefixes established for Γ,𝑥:𝐴. Each equality rule has a premise in the same context as its conclusion, so its induction hypothesis applies unchanged.
For Ctx-Conv, suppose the conclusion context is Γ,𝑥:𝐴′,Δ. From the equality premise Γ⊢𝐴≡𝐴′𝗍𝗒𝗉𝖾, rule Ty-Sym gives Γ⊢𝐴′≡𝐴𝗍𝗒𝗉𝖾, and Presup-Eq-Ty then gives Γ⊢𝐴′𝗍𝗒𝗉𝖾. Fix a prefix Δ′ of Δ whose following declaration is 𝑦:𝐵. The induction hypothesis for the judgment premise gives Γ,𝑥:𝐴,Δ′⊢𝐵𝗍𝗒𝗉𝖾. Apply Ctx-Conv with the same equality premise to derive Γ,𝑥:𝐴′,Δ′⊢𝐵𝗍𝗒𝗉𝖾. Prefixes wholly inside Γ come from the equality premise’s induction hypothesis.
For Subst, from Γ⊢𝑎:𝐴 and Γ,𝑥:𝐴,Δ⊢J, prefixes of Γ come from the first induction hypothesis. For a prefix reaching into Δ[𝑎/𝑥], with next type 𝐵[𝑎/𝑥], the second induction hypothesis gives Γ,𝑥:𝐴,Δ′⊢𝐵𝗍𝗒𝗉𝖾; one application of Subst gives Γ,Δ′[𝑎/𝑥]⊢𝐵[𝑎/𝑥]𝗍𝗒𝗉𝖾. For Subst-Eq-Ty, apply Subst to both type premises with substitution [𝑎/𝑥]; for Subst-Eq-Tm, apply it to the common classifier premise. Both yield the displayed conclusion context Γ,Δ′[𝑎/𝑥].
For Wk, from Γ⊢𝐴𝗍𝗒𝗉𝖾 and Γ,Δ⊢J to Γ,𝑥:𝐴,Δ⊢J. The prefixes of Γ are handled by the inductive hypothesis of the first premise, the prefix ending in 𝐴 by the first premise itself. For a prefix reaching into Δ, say with next type 𝐵, the inductive hypothesis of the second premise gives Γ,Δ′⊢𝐵𝗍𝗒𝗉𝖾 for the corresponding prefix Δ′ of Δ, and one application of Wk (with the first premise) gives Γ,𝑥:𝐴,Δ′⊢𝐵𝗍𝗒𝗉𝖾.
For Var, the type premise gives all prefixes of Γ by its inductive hypothesis and gives the final declaration type 𝐴 itself. Finally, an added rule cannot conclude a context judgment. For its non-context conclusion, the hypothesis of the proposition gives a context premise for the conclusion context. Its induction hypothesis gives the prefix property. These cases exhaust the simultaneous rule set. ◻
Under the hypotheses on added rules in proposition 26.25, if Γ,𝑥:𝐴,Δ𝖼𝗍𝗑 is derivable, then so are Γ𝖼𝗍𝗑 and Γ⊢𝐴𝗍𝗒𝗉𝖾. More generally the same follows, via proposition 26.24, from any derivable judgment Γ,𝑥:𝐴,Δ⊢J.
Assume both hypotheses on added rules in proposition 26.25. Let Γ⊢𝑎≡𝑎′:𝐴 and let Γ,𝑥:𝐴,Δ⊢J. Then both Γ,Δ[𝑎/𝑥]⊢J[𝑎/𝑥]andΓ,Δ[𝑎/𝑥]⊢J[𝑎′/𝑥] are derivable. In the second judgment every declared type and every constituent of J is substituted with 𝑎′, but the displayed context is the one obtained with 𝑎.
Proof of Lemma 26.27 — The common context for equal substitution
Proof. The first judgment is Subst. Ordinary substitution with 𝑎′ gives the second thesis over Γ,Δ[𝑎′/𝑥]; we convert that context one declaration at a time. Write Δ=𝑦1:𝐵1,…,𝑦𝑚:𝐵𝑚, and let Δ𝑖−1 denote its first 𝑖−1 declarations. Suppose those declarations have already been converted from their 𝑎′-forms to their 𝑎-forms. Context inversion applied before substitution gives Γ,𝑥:𝐴,𝑦1:𝐵1,…,𝑦𝑖−1:𝐵𝑖−1⊢𝐵𝑖𝗍𝗒𝗉𝖾. The rule Subst-Eq-Ty, instantiated with the telescope Δ𝑖−1, gives directly Γ,Δ𝑖−1[𝑎/𝑥]⊢𝐵𝑖[𝑎/𝑥]≡𝐵𝑖[𝑎′/𝑥]𝗍𝗒𝗉𝖾. Apply Ty-Sym, then Ctx-Conv at the 𝑖-th declaration: the context being transported currently contains 𝐵𝑖[𝑎′/𝑥], and the desired context contains 𝐵𝑖[𝑎/𝑥]. Induction on 𝑖 converts the whole telescope and transports the thesis to the common context. The case 𝑚=0 requires no conversion. ◻
In the absence of type formers the structural rules generate exactly one derivable judgment, namely ⋅𝖼𝗍𝗑: every other rule has a premise requiring some type to exist. Any type-formation axiom populates the calculus.
★★☆ Call a rule instance directly expanded when it explicitly lists the displayed premises and every direct presupposition of those premises and the conclusion; do not recursively expand the resulting context judgments. Directly expand Var, the type-formation instance of Wk, and Subst-Eq-Ty. Mark each entry omitted under convention 26.14 and the premise or conclusion that supplies it.
★★☆ Take Δ=𝑦:𝐶. Starting from Γ⊢𝑎≡𝑎′:𝐴 and Γ,𝑥:𝐴,𝑦:𝐶⊢𝐵𝗍𝗒𝗉𝖾, write the context-conversion calculation that types 𝐵[𝑎′/𝑥] in the common context Γ,𝑦:𝐶[𝑎/𝑥].
★★★ Set up the simultaneous induction that will apply after type-former rules are added, and verify for each structural-rule case that Γ⊢J would imply FV(J)⊆dom(Γ) and that, in a derivable context, each declared type has free variables only among earlier declarations. The empty structural theory has no non-context example, so these are induction steps rather than a nonvacuous closed theorem. An added type-former rule may be included in the induction only after checking the same scoping property for that rule; explain why no conclusion is possible for an arbitrary added rule.
Everyday derivations use renaming, exchange, general variables, and the two conversion rules as single steps. Each must first be derived from the primitive structural rules. Recall that a rule is derivable when its conclusion has a derivation from its premises taken as axioms (definition 1.32).
Expressions in a judgment are alpha-classes, but a judgment is not quotiented by renaming variables declared in its context: those variables occur free in the declarations and thesis to their right. Such a change is a derivation, not an identification. The following lemma constructs it.
Proof. A type thesis uses Presup-Ctx; a term thesis uses Presup-Ty and then Presup-Ctx; a type equality uses Presup-Eq-Ty and then Presup-Ctx; and a term equality uses Presup-Eq-Tm, Presup-Ty, and Presup-Ctx. These cases derive Γ,𝑥:𝐴,Δ𝖼𝗍𝗑. Repeatedly apply Presup-Ext followed by Presup-Ctx to peel the declarations of Δ; one final Presup-Ext derives Γ⊢𝐴𝗍𝗒𝗉𝖾. Every step is a node over the original hypothesis axiom, so the calculation is valid in hypothetical derivability. ◻
Proof. Apply lemma 71.31 to the premise and call the resulting derivation of Γ⊢𝐴𝗍𝗒𝗉𝖾 by D. Then
Γ⊢𝐴𝗍𝗒𝗉𝖾
Γ,𝑥′:𝐴⊢𝑥′:𝐴
Var
Γ⊢𝐴𝗍𝗒𝗉𝖾Γ,𝑥:𝐴,Δ⊢J
Γ,𝑥′:𝐴,𝑥:𝐴,Δ⊢J
Wk
Γ,𝑥′:𝐴,Δ[𝑥′/𝑥]⊢J[𝑥′/𝑥]
Subst
where both undischarged leaves Γ⊢𝐴𝗍𝗒𝗉𝖾 stand for D. The final step is the instance of Subst with ambient context Γ,𝑥′:𝐴, substituted element 𝑥′, and telescope Δ; its side conditions hold since 𝑥′ is globally fresh. ◻
Proof of Lemma 71.33 — Substitute while retaining the source declaration
Proof. Apply Subst to obtain Γ,Δ[𝑎/𝑥]⊢J[𝑎/𝑥]. Because 𝑎 is typed in Γ, the result contains no free 𝑥. Apply Wk at the cut after Γ to reinsert 𝑥:𝐴. For context formation, induct on Δ. After Subst forms the next declaration over Γ,Δ′[𝑎/𝑥], Wk reinserts 𝑥:𝐴 at the cut after Γ, and Ctx-Ext appends that declaration to Γ,𝑥:𝐴,Δ′[𝑎/𝑥]. ◻
Proof. From the second premise, Γ⊢𝐴′𝗍𝗒𝗉𝖾 is derivable by Ty-Sym and Presup-Eq-Ty. Choose 𝑥 to occur nowhere in Γ,𝐴,𝐴′,𝑎. Then 𝑥∉FV(𝐴′), so 𝐴′[𝑎/𝑥]=𝐴′, and the tree
Γ⊢𝑎:𝐴
Γ⊢𝐴≡𝐴′𝗍𝗒𝗉𝖾
Γ⊢𝐴′≡𝐴𝗍𝗒𝗉𝖾
Ty-Sym
Γ⊢𝐴′𝗍𝗒𝗉𝖾
Γ,𝑥:𝐴′⊢𝑥:𝐴′
Var
Γ,𝑥:𝐴⊢𝑥:𝐴′
Ctx-Conv
Γ⊢𝑎:𝐴′
Subst
derives the conclusion: the Ctx-Conv step converts the context entry 𝑥:𝐴′ to 𝑥:𝐴 along Γ⊢𝐴′≡𝐴𝗍𝗒𝗉𝖾, and the final Subst step substitutes 𝑎 for 𝑥 in the thesis 𝑥:𝐴′. Implementations usually reverse this presentation choice: Conv is a primitive kernel rule, while the more global context-conversion operation is proved admissible. ◻
Proof. Choose 𝑥 to occur nowhere in Γ,𝐴,𝐴′,𝑎,𝑏. The proof repeats the useful part of element conversion. Symmetry of the second premise and Ctx-Conv turn the generic element at 𝐴′ into Γ,𝑥:𝐴⊢𝑥:𝐴′. Now use the first premise in Subst-Eq-Tm, with empty telescope and with the displayed judgment as its second premise:
Γ⊢𝑎≡𝑏:𝐴
Γ⊢𝐴≡𝐴′𝗍𝗒𝗉𝖾
Γ⊢𝐴′≡𝐴𝗍𝗒𝗉𝖾
Ty-Sym
Γ⊢𝐴′𝗍𝗒𝗉𝖾
Γ,𝑥:𝐴′⊢𝑥:𝐴′
Var
Γ,𝑥:𝐴⊢𝑥:𝐴′
Ctx-Conv
Γ⊢𝑎≡𝑏:𝐴′
Subst-Eq-Tm
The omitted formation leaf Γ⊢𝐴′𝗍𝗒𝗉𝖾 is the presupposition of Γ⊢𝐴≡𝐴′𝗍𝗒𝗉𝖾. ◻
★★☆ Reconstruct the derivation of lemma 26.32 with every presupposition premise restored, and mark the point at which the type of the generic element is converted.
Proof. Let 𝑦′ be globally fresh, and obtain Γ⊢𝐴𝗍𝗒𝗉𝖾 from the second premise by lemma 71.31. Rename 𝑦 to 𝑦′, weaken by 𝑦:𝐵 in the correct position, and then substitute 𝑦 for 𝑦′. Formally,
Γ⊢𝐵𝗍𝗒𝗉𝖾Γ⊢𝐴𝗍𝗒𝗉𝖾
Γ,𝑦:𝐵⊢𝐴𝗍𝗒𝗉𝖾
Wk
Γ⊢𝐵𝗍𝗒𝗉𝖾
Γ,𝑦:𝐵⊢𝑦:𝐵
Var
Γ,𝑦:𝐵,𝑥:𝐴⊢𝑦:𝐵
Wk
Γ⊢𝐵𝗍𝗒𝗉𝖾
Γ,𝑥:𝐴,𝑦:𝐵,Δ⊢J
Γ,𝑥:𝐴,𝑦′:𝐵,Δ[𝑦′/𝑦]⊢J[𝑦′/𝑦]
Rename
Γ,𝑦:𝐵,𝑥:𝐴,𝑦′:𝐵,Δ[𝑦′/𝑦]⊢J[𝑦′/𝑦]
Wk
Γ,𝑦:𝐵,𝑥:𝐴,Δ⊢J
Subst
In the left branch, the inner Wk inserts 𝑦:𝐵 under 𝐴, and the outer Wk appends 𝑥:𝐴; in the right branch, Wk inserts 𝑦:𝐵 between Γ and 𝑥:𝐴. The final Subst substitutes 𝑦 for 𝑦′; since 𝑦′ is fresh, Δ[𝑦′/𝑦][𝑦/𝑦′]=Δ and J[𝑦′/𝑦][𝑦/𝑦′]=J. ◻
★★☆ Call two adjacent declarations in Γ0,𝑥:𝐴,𝑦:𝐵,Γ1swappable when Γ0⊢𝐵𝗍𝗒𝗉𝖾 is derivable. Suppose a permutation of a derivable context is presented as a sequence of adjacent swaps, and each swap is swappable in the context reached at that stage. Use Exch at every stage to transport a derivation of Γ⊢J to the permuted context. Why would the weaker syntactic test 𝑥∉FV(𝐵) be insufficient?
Proof. Write Γ=Γ0,𝑥:𝐴,𝑦1:𝐵1,…,𝑦𝑚:𝐵𝑚. By repeated primitive Presup-Ext and Presup-Ctx steps applied to the context premise, the judgments Γ0⊢𝐴𝗍𝗒𝗉𝖾 and Γ0,𝑥:𝐴,𝑦1:𝐵1,…,𝑦𝑗−1:𝐵𝑗−1⊢𝐵𝑗𝗍𝗒𝗉𝖾 (1≤𝑗≤𝑚) are all derivable. Var applied to the first gives Γ0,𝑥:𝐴⊢𝑥:𝐴, and 𝑚 successive applications of Wk (with empty telescope), the 𝑗-th using the 𝐵𝑗 judgment, extend the context one declaration at a time until Γ⊢𝑥:𝐴 is reached. Formally, induction on 𝑚 uses the displayed derivation as its base case; the successor case is one Wk whose type-formation premise is the next judgment extracted from context well-formedness. ◻
Our rules perform substitution and weakening in one step. Both can instead be reconstructed by induction on derivations. That reconstruction is valid only when every added rule behaves uniformly under changes of context. We state this hypothesis exactly before beginning the proof.
The economical presentation of a type theory over the structural core consists of the rules Ctx-Emp, Ctx-Ext, the equivalence rules of definition 26.16, the rules Assum, Conv, and Conv-Eq of lemma 26.34, lemma 26.31, lemma 26.32, taken as primitive, and the added rules of the theory stated with full premises. The presupposition, context-conversion, substitution, weakening, and Var rules are omitted.
The structural stability of an added rule scheme is the conjunction of the following conditions; a scheme satisfying them is structurally stable.
It does not conclude a context judgment. Its full premises contain the context judgment and every direct presupposition of its conclusion, together with the formation or typing judgments for every expression parameter occurring in the conclusion.
Its ambient contexts are schematic. If one simultaneously inserts a fresh well-formed declaration at the same position in the ambient context of every premise and the conclusion, the result is another instance. The same is true when one simultaneously substitutes an element for an ambient variable, or replaces an ambient declaration by a judgmentally equal one. Local binder names are first freshened away from the inserted or substituted expressions. Repeating the insertion clause gives the same closure for an arbitrary well-formed telescope.
The expression parameters form a classified telescope, possibly with local binders. A type parameter 𝑝𝑖 has a formation judgment Γ𝑖⊢𝑝𝑖𝗍𝗒𝗉𝖾; a term parameter has a typing judgment Γ𝑖⊢𝑝𝑖:𝑃𝑖. The context Γ𝑖, and in the term case 𝑃𝑖, may depend on earlier parameters. The phrase pointwise equal means, respectively, 𝑝𝑖≡𝑝′𝑖𝗍𝗒𝗉𝖾 or 𝑝𝑖≡𝑝′𝑖:𝑃𝑖, after the primed classifier and every local context in Γ𝑖 have been transported along the equalities already obtained for earlier parameters. Every type-formation conclusion 𝐹(⃗𝑝)𝗍𝗒𝗉𝖾 has the congruence rule concluding 𝐹(⃗𝑝)≡𝐹(⃗𝑝′)𝗍𝗒𝗉𝖾 from this telescope of equalities. Every term-typing conclusion 𝑓(⃗𝑝):𝐹(⃗𝑝) has a term-congruence rule at the unprimed result type; the primed result is first converted along the type congruence.
Every premise and conclusion is well scoped: all of its free variables are declared in its displayed context. The scheme is equivariant under fresh renaming of ambient and local variables; in particular, it contains no distinguished free object variable.
These are syntactic closure conditions on rule instances. In particular, a nullary axiom allowed only in the empty context is not structurally stable: it fails condition 2. Indeed, for a fixed closed 𝐶 the scheme 𝑋⋅⊢𝑐:𝐶closed−c has no inserted-context instance 𝑥:𝐴⊢𝑐:𝐶. A weakening induction whose last rule is closed-𝑐 therefore stops: the induction hypotheses are empty, and condition 2 has no rule instance concluding 𝑥:𝐴⊢𝑐:𝐶. This is the minimal failure test for structural stability.
Add an operator 𝑄 of arity (0,1) and the formation scheme
Γ⊢𝐶𝗍𝗒𝗉𝖾Γ,𝑦:𝐶⊢𝐷𝗍𝗒𝗉𝖾
Γ⊢𝑄(𝐶;𝑦.𝐷)𝗍𝗒𝗉𝖾
Q-form
Its full instance also contains Γ𝖼𝗍𝗑. Inserting 𝑥:𝐴 in the ambient context produces the legal instance
Γ,𝑥:𝐴⊢𝐶𝗍𝗒𝗉𝖾Γ,𝑥:𝐴,𝑦:𝐶⊢𝐷𝗍𝗒𝗉𝖾
Γ,𝑥:𝐴⊢𝑄(𝐶;𝑦.𝐷)𝗍𝗒𝗉𝖾
Q-form
If instead Γ⊢𝑎:𝐸 is substituted into an instance over Γ,𝑧:𝐸, choose 𝑦 away from 𝑎 by equivariance. The resulting instance is
Γ⊢𝐶[𝑎/𝑧]𝗍𝗒𝗉𝖾Γ,𝑦:𝐶[𝑎/𝑧]⊢𝐷[𝑎/𝑧]𝗍𝗒𝗉𝖾
Γ⊢𝑄(𝐶[𝑎/𝑧];𝑦.𝐷[𝑎/𝑧])𝗍𝗒𝗉𝖾
Q-form
Finally, its dependent congruence rule is
Γ⊢𝐶≡𝐶′𝗍𝗒𝗉𝖾Γ,𝑦:𝐶⊢𝐷≡𝐷′𝗍𝗒𝗉𝖾Γ,𝑦:𝐶′⊢𝐷′𝗍𝗒𝗉𝖾
Γ⊢𝑄(𝐶;𝑦.𝐷)≡𝑄(𝐶′;𝑦.𝐷′)𝗍𝗒𝗉𝖾
Q-form-eq
The third premise forms the primed body in its own context. The second places that body in the unprimed context and compares the two bodies there, exactly the transport required by condition 3. This is the local-binder case of conditions 2 and 3.
★★☆ Give 𝑄 a term constructor 𝑞(𝐶;𝑦.𝑑):𝑄(𝐶;𝑦.𝐷) whose parameter 𝑑 has type 𝐷 in Γ,𝑦:𝐶. Write its full typing scheme, its term-congruence scheme at the unprimed 𝑄-type, and the instance obtained from a rule over Γ,𝑧:𝐸 by substituting a given Γ⊢𝑎:𝐸 for 𝑧.
Regularity and arbitrary-telescope weakening are proved mutually because the regularity case for Assum needs weakening in a different telescope. Substitution transforms a derivation and its telescope simultaneously; context conversion then compares the transformed contexts. Equal substitution combines these facts with the classified congruence condition.
Proof. For each height ℎ, prove simultaneously: (i) every direct presupposition of the conclusion of a derivation of height at most ℎ; (ii) for every split Γ,Δ of its context and every telescope Θ satisfying the displayed hypotheses, the judgment-weakening transformation of clause 2; and (iii) the corresponding context transformation of clause 3. Thus Θ is universally quantified inside the induction hypothesis. The whole well-formed telescope Θ is fixed during one recursive transformation; it is not inserted by repeated appeals to the induction hypothesis. The regularity assertion produces every direct presupposition of the conclusion.
For a context derivation, keep the insertion point between Γ and Δ. If Δ is empty, the target is the fixed derivation of Γ,Θ𝖼𝗍𝗑. If the final Ctx-Ext introduces a declaration in Δ, apply the judgment-weakening induction hypothesis to its sole type premise, inserting the entire Θ, and reapply Ctx-Ext. The regularity induction hypothesis for that same premise gives the transformed prefix context when required. The type premise is also the direct presupposition of the resulting context.
For Assum, weakening the conclusion only enlarges its well-formed context; the same declaration is still present, so Assum applies again. For regularity, write the context as Γ0,𝑦:𝐵,Γ1, where the selected declaration is 𝑦:𝐵. A context derivation in the economical system ends in iterated Ctx-Ext; its subtree at this declaration contains Γ0⊢𝐵𝗍𝗒𝗉𝖾. This subtree has smaller height. Apply the telescope-weakening induction hypothesis once, with telescope 𝑦:𝐵,Γ1, to obtain Γ0,𝑦:𝐵,Γ1⊢𝐵𝗍𝗒𝗉𝖾, the presupposition of the Assum conclusion. This is the case that forces regularity and weakening to be simultaneous.
For an equivalence rule, Conv, or Conv-Eq, transform all premises and reapply the same rule. Their presuppositions follow from the transformed typing premises, using symmetry where the right side of an equality is required. For an added scheme, condition 2 of definition 26.36 makes the weakened premises another legal instance, and condition 1 gives the direct presuppositions. Condition 4 permits an equivariant choice of local names disjoint from the inserted telescope. These are all final rules. Taking Θ=𝑥:𝐴 gives Wk. ◻
In an economical presentation with structurally stable added schemes, suppose Γ⊢𝑎:𝐴 is derivable economically. Then ordinary substitution has both of the following simultaneous clauses:
if Γ,𝑥:𝐴,Δ𝖼𝗍𝗑, then Γ,Δ[𝑎/𝑥]𝖼𝗍𝗑;
if Γ,𝑥:𝐴,Δ⊢J for any of the four judgment theses, then Γ,Δ[𝑎/𝑥]⊢J[𝑎/𝑥].
Proof of Lemma 26.39 — Ordinary substitution in the economical presentation
Proof. Induct on the second derivation, simultaneously for contexts and all four theses. In a context derivation, a final Ctx-Ext whose declaration lies in Δ is rebuilt from its transformed type premise. If it is the distinguished declaration 𝑥:𝐴 itself, then Δ is empty: substitution deletes that final Ctx-Ext, leaving Γ𝖼𝗍𝗑, a presupposition of the fixed derivation of 𝑎. The equivalence rules, Conv, and Conv-Eq are obtained by transforming their premises and reapplying the same rule. An added scheme is handled in the same way by condition 2 of definition 26.36.
Only Assum requires a calculation. If its selected variable is 𝑥, use the fixed derivation of 𝑎 and weaken it along Δ[𝑎/𝑥] by lemma 26.38. If the variable is declared in Γ, apply Assum there and weaken along the substituted telescope. If it is declared in Δ, its declaration in the new context is precisely the old one with 𝑎 substituted, so Assum applies directly. These three cases give exactly Γ,Δ[𝑎/𝑥]⊢J[𝑎/𝑥]. A simultaneous rule induction gives the scoping invariant FV(𝑎)⊆dom(Γ): check the economical structural rules directly and use condition 4 for an added rule. Since raw context concatenation makes dom(Γ) and dom(Δ) disjoint, every declared name of Δ already avoids FV(𝑎). Thus the displayed context substitution is defined; no context variable has been renamed. ◻
In an economical presentation with structurally stable added schemes, if Γ⊢𝐴≡𝐴′𝗍𝗒𝗉𝖾 and Γ,𝑥:𝐴,Δ⊢J are derivable economically, then so is Γ,𝑥:𝐴′,Δ⊢J. Simultaneously, a derivation of Γ,𝑥:𝐴,Δ𝖼𝗍𝗑 is transformed into one of Γ,𝑥:𝐴′,Δ𝖼𝗍𝗑.
Proof of Lemma 26.40 — Context conversion in the economical presentation
Proof. Induct simultaneously on context and judgment derivations, keeping the distinguished declaration marked. In a context derivation, a final Ctx-Ext to the left of 𝑥:𝐴 is retained. To the right, transform both the prefix context recovered from its type premise and the type premise itself before reapplying Ctx-Ext. At the distinguished declaration itself, use the right-hand type presupposition of 𝐴≡𝐴′ and Ctx-Ext to form Γ,𝑥:𝐴′. Transform the premises of every other nonvariable rule and reapply that rule; condition 2 of definition 26.36 gives the added-scheme instances. For Assum, variables declared in Γ or Δ are reintroduced by the same rule. For the distinguished variable, Assum gives 𝑥:𝐴′ in Γ,𝑥:𝐴′. Weaken the symmetric equality 𝐴′≡𝐴 to that context and apply primitive Conv; then weaken along Δ. Thus the transformed variable has the original type 𝐴, as the unchanged thesis requires. This completes every final-rule case. ◻
If 𝐴≡𝐴′, we may therefore carry any telescope declared after 𝑥:𝐴 over to the context declaring 𝑥:𝐴′.
In an economical presentation with structurally stable added schemes, let Γ⊢𝑎≡𝑎′:𝐴. Economical derivations of Γ,𝑥:𝐴,Δ⊢𝐵𝗍𝗒𝗉𝖾 and Γ,𝑥:𝐴,Δ⊢𝑏:𝐵 can be transformed respectively into Γ,Δ[𝑎/𝑥]⊢𝐵[𝑎/𝑥]≡𝐵[𝑎′/𝑥]𝗍𝗒𝗉𝖾, and Γ,Δ[𝑎/𝑥]⊢𝑏[𝑎/𝑥]≡𝑏[𝑎′/𝑥]:𝐵[𝑎/𝑥].
Proof of Lemma 26.41 — Equal substitution in the economical presentation
Proof. First form a finite presupposition-expanded derivation. At every node attach, as subsidiary trees, derivations of all direct presuppositions established by lemma 26.38; recursively attach the presuppositions of a nonempty context by peeling its last declaration. The regularity construction uses only proper premise subderivations (in the Assum case, a proper context subtree), while context peeling strictly shortens the context. Hence the expansion is finite and well founded. We induct on the height of this expanded tree, counting the attached subsidiary trees; every premise or presupposition invoked below is then a proper subtree. The telescope Δ is arbitrary and is not part of the measure.
Write Δ=𝑦1:𝐵1,…,𝑦𝑚:𝐵𝑚, and write Δ𝑖−1 for its first 𝑖−1 declarations. Simultaneously maintain a third assertion for a context derivation of Γ,𝑥:𝐴,Δ: for every declaration 𝑦𝑖:𝐵𝑖 it constructs Γ,Δ𝑖−1[𝑎/𝑥]⊢𝐵𝑖[𝑎/𝑥]≡𝐵𝑖[𝑎′/𝑥]𝗍𝗒𝗉𝖾.(∗) Before the marked declaration, and at Ctx-Emp, the assertion is empty. At the Ctx-Ext that introduces 𝑥:𝐴, substitution removes that declaration and still introduces no clause of (∗). At a later Ctx-Ext, the context and type premises have smaller height. The context induction hypothesis treats the earlier declarations, and the type induction hypothesis gives the next instance of (∗). Repeated use of lemma 26.40, with the symmetric orientation of each equality in (∗), therefore transports every right-hand substituted premise from Δ[𝑎′/𝑥] to the common context Δ[𝑎/𝑥]. This explains the common context in both conclusions.
Now inspect a type-formation or term-typing derivation. In the Assum case, ordinary substitution applied to the attached context presupposition Γ,𝑥:𝐴,Δ𝖼𝗍𝗑 gives Γ,Δ[𝑎/𝑥]𝖼𝗍𝗑. If the selected variable is 𝑥, the fixed equality 𝑎≡𝑎′:𝐴 is weakened along Δ[𝑎/𝑥]. Any other selected variable is reintroduced in this common context by Assum, and Tm-Refl gives the required equality directly; no conversion through Δ[𝑎′/𝑥] is needed. In the Conv case, the induction hypothesis first gives equality of the two substituted terms at the old type. Ordinary substitution of the type-equality premise gives the converted type equality, and primitive Conv-Eq moves the term equality to that type.
For an added formation or typing rule, apply the induction hypotheses to the full typing premises of all expression parameters. Condition 3 of definition 26.36 then gives the displayed type or term equality. Equality premises of the rule are substituted ordinarily on each side; no “equality between equality derivations” is required. A premise under an additional local binder still has smaller derivation height, so the induction hypothesis applies with that binder appended to the arbitrary telescope. For example, a premise Γ,𝑥:𝐴,Δ,𝑦:𝐶⊢𝐷𝗍𝗒𝗉𝖾 produces Γ,Δ[𝑎/𝑥],𝑦:𝐶[𝑎/𝑥]⊢𝐷[𝑎/𝑥]≡𝐷[𝑎′/𝑥]𝗍𝗒𝗉𝖾, after the induction hypothesis for the parameter premise has given 𝐶[𝑎/𝑥]≡𝐶[𝑎′/𝑥]. This is the binding case that a length-first induction would miss. All recursive calls are to proper premise subderivations, so height induction is well founded. ◻
Equal substitution is the last missing structural operation; all four derivation transformations can now be assembled.
In an economical presentation with structurally stable added schemes, the presupposition, weakening, substitution, context-conversion, and equal-substitution rules are admissible.
Let 𝑇 be the structural rules of definition 26.22 extended by structurally stable rule schemes in the sense of definition 26.36, and let 𝑇− be its economical presentation. Then a judgment is derivable in 𝑇 if and only if it is derivable in 𝑇−. In particular, Subst, Wk, Ctx-Conv, and the presupposition rules are admissible in 𝑇−.
Proof of Theorem 26.43 — Equivalence of presentations
Proof. (𝑇−⊆𝑇.) Every primitive rule of 𝑇− is derivable in 𝑇: Assum, Conv, and Conv-Eq by lemma 26.34, lemma 26.31, lemma 26.32; every other primitive rule is shared. Replace each use of a derived primitive by its displayed derivation. Rule induction translates the whole tree.
(𝑇⊆𝑇−.) By corollary 26.42, every omitted structural rule has a derivation transformation in 𝑇−. Translate a 𝑇-derivation by rule induction: retain a shared rule and replace each omitted structural rule by the corresponding admissibility transformation. In the Var case, the transformed premise Γ⊢𝐴𝗍𝗒𝗉𝖾 first gives Γ,𝑥:𝐴𝖼𝗍𝗑 by Ctx-Ext; primitive Assum then gives Γ,𝑥:𝐴⊢𝑥:𝐴. The transformed premises have already been obtained by the induction hypotheses, so the result is a 𝑇−-derivation of the same judgment. ◻
The structural-admissibility argument above follows the formulation surveyed by Hofmann [Hof97].
Equivalence of structural presentations is not a type-checking algorithm. For each added former a kernel still needs formation and typing generation lemmas, injectivity of type constructors, a terminating and complete conversion procedure (usually obtained from confluence and normalization), and bidirectional rules that expose the input/output modes. The concrete interface must, for example, recover the domain and codomain of a function type from its head constructor, and conversion must decide whether an inferred type agrees with an expected type. This is why a displayed declarative rule set, although complete as a specification, is not yet executable.
★★☆ Verify the direction 𝑇−⊆𝑇 of theorem 26.43 in detail: exhibit each primitive rule of 𝑇− as a derivable rule of 𝑇, and explain why derivability suffices to translate whole derivations.
In 𝑇− the rules Subst and Wk are admissible but are not primitive. The construction in theorem 26.43 is a recursive transformation of an input derivation. Its final-rule case uses exactly the stability interface of definition 26.36; the closed-only axiom above shows the transformation getting stuck when that interface is absent.
One Subst step removes one declaration. Eliminators for pair-like data must often replace an entire dependent telescope, so we package the elements needed for all declarations and then substitute them in order.
Let Γ,Δ𝖼𝗍𝗑, where Δ=𝑦1:𝐵1,…,𝑦𝑚:𝐵𝑚 is a telescope over Γ. A context substitution𝑓:Γ⇒Δ is a list (𝑏1,…,𝑏𝑚) such that no 𝑦𝑖 is free in any 𝑏𝑗 and Γ⊢𝑏𝑗:𝐵𝑗[𝑏1/𝑦1,…,𝑏𝑗−1/𝑦𝑗−1](1≤𝑗≤𝑚).
For example, if Γ,𝑥:𝐴,𝑦:𝐵𝖼𝗍𝗑, Γ⊢𝑎:𝐴, and Γ⊢𝑏:𝐵[𝑎/𝑥], then (𝑎,𝑏):Γ⇒(𝑥:𝐴,𝑦:𝐵). This is the two-declaration substitution used by dependent pair elimination.
Proof of Proposition 26.46 — Substitution by a context
Proof. Substitute 𝑏1 for 𝑦1. The next declaration becomes 𝑦2:𝐵2[𝑏1/𝑦1], exactly the type of 𝑏2 in definition 26.45; hence the next Subst applies. Continuing in order removes all 𝑚 declarations and gives the iterated substitution displayed in the conclusion. Because no inserted 𝑏𝑗 contains a target variable 𝑦𝑖, a structural induction on J identifies this iteration with the one-pass simultaneous substitution of definition 26.10. ◻
The preceding proposition is the null-source case of a more useful relative construction. Suppose that both Γ,Θ and Γ,Δ are contexts, where Δ=𝑦1:𝐵1,…,𝑦𝑚:𝐵𝑚. A relative telescope map𝑓:Θ⇒ΓΔ is a list (𝑏1,…,𝑏𝑚) satisfying Γ,Θ⊢𝑏𝑗:𝐵𝑗[𝑏1/𝑦1,…,𝑏𝑗−1/𝑦𝑗−1](1≤𝑗≤𝑚), where the displayed brackets denote one-pass simultaneous substitution. Source and target telescopes are understood up to alpha-equivalence: before composing distinct maps, choose their nonshared binders disjoint. No freshness condition is imposed on the entries. In particular, when the source is the target, an entry may be the corresponding target variable. Thus 𝑓:Γ⇒Δ in definition 26.45 is the case Θ=().
Relative telescope maps have the following operations.
The variable list (𝑦1,…,𝑦𝑚) is an identity map idΔ:Δ⇒ΓΔ.
If 𝑓:Θ⇒ΓΔ has entries 𝑏𝑖 and 𝑔:Ξ⇒ΓΘ has entries 𝑐𝑘, then 𝑓∘𝑔:=(𝑏1[𝑔],…,𝑏𝑚[𝑔]):Ξ⇒ΓΔ, where 𝑏𝑖[𝑔] is simultaneous substitution of the 𝑐𝑘 for the variables of Θ.
If Γ,Δ⊢J, then 𝑓 acts on the judgment by one-pass simultaneous substitution of the entries of 𝑓 for the variables of Δ. The result is derivable over Γ,Θ, and the action satisfies J[idΔ]=J,(J[𝑓])[𝑔]=J[𝑓∘𝑔]. Consequently composition is associative and the displayed identities are left and right units, up to alpha-equivalence of raw expressions.
Proof of Proposition 71.51 — Identity and composition of telescope maps
Proof. First choose a representative whose binders avoid every source and target variable and every free variable in the entries of 𝑓 and 𝑔. Structural induction on that representative proves 𝐸[idΔ]=𝐸,(𝐸[𝑓])[𝑔]=𝐸[𝑓∘𝑔] for every raw expression 𝐸. At a target variable the second equation is the definition 𝑏𝑖[𝑔]=(𝑓∘𝑔)𝑖; at any other variable both sides leave the variable fixed or apply the same entry of 𝑔. An operator case applies the induction hypotheses to all bodies and restores its binder lists. The synchronized-display argument of proposition 26.11.1 makes the calculation independent of the chosen representative.
For the identity, repeated use of Assum gives each 𝑦𝑗 at the type required by the relative-map definition: substituting each earlier variable for itself fixes 𝐵𝑗. For composition, apply substitution by the whole telescope 𝑔 to the typing judgment for each 𝑏𝑗. The notation (𝑓∘𝑔)<𝑗/𝑦<𝑗 abbreviates substitution of the first 𝑗−1 components of 𝑓∘𝑔 for 𝑦1,…,𝑦𝑗−1. The resulting type is 𝐵𝑗[(𝑓∘𝑔)<𝑗/𝑦<𝑗], by the raw composition equation just proved. These are exactly the premises required for 𝑓∘𝑔 to be a relative telescope map.
For the action on judgments, choose a fresh alpha-copy ̂Δ of Δ, disjoint from Γ,Θ and from every entry of 𝑓, and rename Γ,Δ⊢J to Γ,̂Δ⊢̂J. General weakening now gives Γ,Θ,̂Δ⊢̂J. Substitute the entries of 𝑓 for the fresh variables of ̂Δ in telescope order. Their typing premises are exactly the renamed telescope types after the preceding substitutions, so repeated Subst yields Γ,Θ⊢̂J[𝑓]; by construction this is the one-pass action J[𝑓]. A second choice of fresh copy gives an alpha-equivalent derivation.
The two displayed action laws are the raw identity and composition equations proved above. Applying the composition equation twice gives (𝑓∘𝑔)∘ℎ=𝑓∘(𝑔∘ℎ) componentwise; applying the identity clause gives both unit laws. Alpha-equivalence accounts only for the fresh names chosen under binders. ◻
★☆☆ For the two-declaration context substitution (𝑎,𝑏) above, write the two successive instances of Subst that transform Γ,𝑥:𝐴,𝑦:𝐵⊢J into Γ⊢J[𝑎/𝑥,𝑏/𝑦]. Indicate where the premise Γ⊢𝑏:𝐵[𝑎/𝑥] is used.
If Δ is a standalone context and Δ⊢J, the standalone form of context substitution follows from proposition 26.46: weaken the context and the judgment by the declarations of Γ in order, obtaining the relative source Γ,Δ⊢J, and then apply the proposition.
Suggested first pass.
None of these problems is a prerequisite for a later chapter. Begin with exercise 71.17, then complete exercise 71.20.
★★☆ Reconstruct the Assum case of the induction proving general weakening. Suppose the final judgment Γ,Δ⊢𝑧:𝐶 ends in Assum, and a fresh declaration 𝑥:𝐴 is inserted immediately after Γ. Separate the case in which the declaration 𝑧:𝐶 lies in Γ from the case in which Δ=Δ1,𝑧:𝐶,Δ2. In each case, identify the context-formation premise that lets Assum be replayed in the enlarged context.
★★☆ Let Δ=(𝑥:𝐴,𝑦:𝐵(𝑥)), Θ=(𝑢:𝐶,𝑣:𝐷(𝑢)), and Ξ=(𝑤:𝐸) be telescopes over the same base Γ. For 𝑓=(𝑏1,𝑏2):Θ⇒ΓΔ and 𝑔=(𝑐1,𝑐2):Ξ⇒ΓΘ, write 𝑓∘𝑔 componentwise. Derive the type of its second component from Subst. For a further map ℎ:Ω⇒ΓΞ, prove associativity by comparing both composites with one-pass capture-avoiding substitution.
★★☆ Consider the tempting definition of a relative telescope map which requires every target variable to be fresh for every component. Apply it to the identity map on Δ=(𝑢:𝐴,𝑣:𝐵(𝑢)). Give the first component at which the definition fails, and explain why alpha-renaming the target before acting on a judgment repairs the proof without imposing this false side condition on the map itself.
★★★Practical project.dtt-substitution-auditor Implement named-variable capture-avoiding substitution in Agda or Kappa, together with a checker for the local scoping invariant FV(𝑡[𝑢/𝑥])⊆(FV(𝑡)∖{𝑥})∪FV(𝑢), where the implementation first alpha-renames binders to avoid capture. Test the binder inputs 𝐿(𝑦.𝑥)[𝑦/𝑥], 𝐿(𝑦.𝑃(𝑥;𝑦))[𝑧/𝑥], and a two-declaration context substitution; the first output must be alpha-equivalent to 𝐿(𝑦′.𝑦) and every output must pass the scoping checker. Before implementing the checker, perform these three substitutions on paper and mark the binder renaming that prevents capture. These calculations are the finite specification against which the implementation is tested.
Sources. The judgment forms originate with Martin-Löf [ML98, ML84]. Abstract binding trees are developed by Harper [Har16], and the structural-admissibility and context-substitution arguments are treated by Hofmann [Hof97]. The citations record provenance and provide alternative formulations.