Unfolding ¬𝐴:=𝐴→𝟎, the term is 𝜆ℎ.𝜆𝑎.ℎ(𝜆𝑘.𝑘(𝑎)). Indeed, under ℎ:¬¬¬𝐴 and 𝑎:𝐴, the abstraction 𝜆𝑘.𝑘(𝑎) has type ¬¬𝐴; applying ℎ produces an element of 𝟎, as required for a term of ¬𝐴.
Using the argument order for 𝗋𝖾𝖼ℕ fixed in definition 28.22, put 𝗉𝗋𝖾𝖽:=𝜆𝑛.𝗋𝖾𝖼ℕ(𝟢,𝜆𝑘.𝜆𝑟.𝑘,𝑛):ℕ→ℕ. The two recursor equations give 𝗉𝗋𝖾𝖽(𝟢)≡𝟢 and 𝗉𝗋𝖾𝖽(𝗌𝗎𝖼(𝑘))≡𝑘. Truncated subtraction can now recurse on its second argument: ˙−:=𝜆𝑚.𝜆𝑛.𝗋𝖾𝖼ℕ(𝑚,𝜆𝑘.𝜆𝑟.𝗉𝗋𝖾𝖽(𝑟),𝑛):ℕ→ℕ→ℕ. Consequently 𝑚˙−𝟢≡𝑚 and 𝑚˙−𝗌𝗎𝖼(𝑛)≡𝗉𝗋𝖾𝖽(𝑚˙−𝑛), which is the usual truncated subtraction.
For a closed type 𝐶, weaken it to the constant family 𝑤:𝑊⊢𝐶. The W-elimination step therefore has type ℎ:∏𝑎:𝐴∏𝑓:𝐵(𝑎)→𝑊(𝐵(𝑎)→𝐶)→𝐶. Define 𝗋𝖾𝖼𝑊(ℎ,𝑡):=𝗂𝗇𝖽𝖶(𝑤.𝐶;ℎ,𝑡). Rule W-comp calculates 𝗋𝖾𝖼𝑊(ℎ,𝗌𝗎𝗉(𝑎,𝑓))≡ℎ(𝑎,𝑓,𝜆𝑦.𝗋𝖾𝖼𝑊(ℎ,𝑓(𝑦))):𝐶. The constant specialization erases the tree argument from the motive. It therefore cannot synthesize a result in a genuinely varying fiber 𝐶(𝑡); that dependency must already be supplied to W-elimination.
Use constructors 𝗅𝖾𝖺𝖿:𝐴→𝖳𝗋𝖾𝖾(𝐴) and 𝗇𝗈𝖽𝖾:𝖳𝗋𝖾𝖾(𝐴)2→𝖳𝗋𝖾𝖾(𝐴). The eliminator gives 𝗅𝖾𝖺𝗏𝖾𝗌(𝗅𝖾𝖺𝖿(𝑎))≡1,𝗅𝖾𝖺𝗏𝖾𝗌(𝗇𝗈𝖽𝖾(𝑙,𝑟))≡𝗅𝖾𝖺𝗏𝖾𝗌(𝑙)+𝗅𝖾𝖺𝗏𝖾𝗌(𝑟),𝗆𝗂𝗋𝗋𝗈𝗋(𝗅𝖾𝖺𝖿(𝑎))≡𝗅𝖾𝖺𝖿(𝑎),𝗆𝗂𝗋𝗋𝗈𝗋(𝗇𝗈𝖽𝖾(𝑙,𝑟))≡𝗇𝗈𝖽𝖾(𝗆𝗂𝗋𝗋𝗈𝗋(𝑟),𝗆𝗂𝗋𝗋𝗈𝗋(𝑙)). Induct on the tree. The leaf case computes to reflexivity. In the node case, the two induction hypotheses reduce the double mirror to 𝗇𝗈𝖽𝖾(𝑙,𝑟); this is precisely the constructor congruence case of the eliminator.
Let 𝜔:=𝛿(𝗋𝗈𝗅𝗅(𝛿)). Unfolding 𝛿 and then using the proposed pattern equation gives the nonempty cycle 𝜔⟶𝗎𝗇𝗋𝗈𝗅𝗅(𝗋𝗈𝗅𝗅(𝛿))(𝗋𝗈𝗅𝗅(𝛿))⟶𝛿(𝗋𝗈𝗅𝗅(𝛿))=𝜔. In the constructor argument 𝐷→𝐷, the occurrence of 𝐷 in the domain is negative. Admitting the constructor together with the displayed destructor equation therefore destroys strong normalization, which strict positivity is designed to protect.
Recall that ¬𝑋:=𝑋→𝟎. The required terms are 𝜆𝑓.𝜆𝑏.𝜆𝑎.𝑓(𝑎)(𝑏):(𝐴→¬𝐵)→(𝐵→¬𝐴) and 𝜆𝑎.𝜆𝑘.𝑘(𝑎):𝐴→¬¬𝐴. For the first, in context 𝑓:𝐴→(𝐵→𝟎),𝑏:𝐵,𝑎:𝐴, application gives 𝑓(𝑎):𝐵→𝟎, hence 𝑓(𝑎)(𝑏):𝟎; three uses of Π-intro give the displayed type. For the second, in context 𝑎:𝐴,𝑘:𝐴→𝟎, application gives 𝑘(𝑎):𝟎, and two abstractions finish the derivation. Neither construction eliminates a term of 𝟎; each merely constructs a function whose codomain is 𝟎.
Let Γ⊢𝐷𝗍𝗒𝗉𝖾. Restore the constant motive on empty elimination and define 𝜆𝑐.𝗂𝗇𝖽𝟎(𝑥.𝐷;ℎ(𝑐)):𝐶→𝐷. Indeed, in Γ,𝑐:𝐶 we have ℎ:𝐶→𝟎 by weakening, so ℎ(𝑐):𝟎. Weakening 𝐷 once more gives Γ,𝑐:𝐶,𝑥:𝟎⊢𝐷𝗍𝗒𝗉𝖾. Therefore 𝟎-elim yields Γ,𝑐:𝐶⊢𝗂𝗇𝖽𝟎(𝑥.𝐷;ℎ(𝑐)):𝐷, and Π-intro gives the claimed map. Thus a map from 𝐶 into 𝟎 permits a map from 𝐶 into every type.
For Γ⊢𝐶𝗍𝗒𝗉𝖾, the fully annotated definition is 𝖺𝖻𝗈𝗋𝗍𝐶:=𝜆𝑎:𝟎.𝗂𝗇𝖽𝟎(𝑥.𝐶;𝑎):𝟎→𝐶. Here the variable 𝑥 is bound in the motive annotation; 𝐶 does not actually depend on it. The body is the following instance of 𝟎-elim. We display the structural premises that the book’s compressed convention ordinarily suppresses: Γ⊢𝐶𝗍𝗒𝗉𝖾Γ,𝑎:𝟎𝖼𝗍𝗑Γ,𝑎:𝟎⊢𝐶𝗍𝗒𝗉𝖾WkΓ,𝑎:𝟎,𝑥:𝟎𝖼𝗍𝗑Γ,𝑎:𝟎,𝑥:𝟎⊢𝐶𝗍𝗒𝗉𝖾WkΓ,𝑎:𝟎𝖼𝗍𝗑Γ,𝑎:𝟎⊢𝑎:𝟎VarΓ,𝑎:𝟎⊢𝗂𝗇𝖽𝟎(𝑥.𝐶;𝑎):𝐶−elimΓ⊢𝜆𝑎:𝟎.𝗂𝗇𝖽𝟎(𝑥.𝐶;𝑎):𝟎→𝐶Π−intro. The two context judgments in this tree follow from Γ𝖼𝗍𝗑, 𝟎-form, and context extension. More explicitly, Γ𝖼𝗍𝗑Γ𝖼𝗍𝗑Γ⊢𝟎𝗍𝗒𝗉𝖾−formΓ,𝑎:𝟎𝖼𝗍𝗑Ctx−Ext, and the second extension is identical after weakening 𝟎 to Γ,𝑎:𝟎. Since 𝐶[𝑎/𝑥] is literally 𝐶, the conclusion of empty elimination has exactly the required type.
Orienting case analysis by the first argument, define 𝗈𝗋:=𝜆𝑎.𝜆𝑏.𝗋𝖾𝖼𝟐(𝗍𝗍,𝑏,𝑎),𝗂𝗆𝗉𝗅𝗂𝖾𝗌:=𝜆𝑎.𝜆𝑏.𝗋𝖾𝖼𝟐(𝑏,𝗍𝗍,𝑎),𝗑𝗈𝗋:=𝜆𝑎.𝜆𝑏.𝗋𝖾𝖼𝟐(𝗇𝖾𝗀(𝑏),𝑏,𝑎). In each body both branches have type 𝟐, so Boolean recursion and two uses of Π-intro give type 𝟐→𝟐→𝟐. Two function-beta steps followed by the appropriate Boolean computation rule give 𝗈𝗋(𝗍𝗍,𝑏)≡𝗋𝖾𝖼𝟐(𝗍𝗍,𝑏,𝗍𝗍)≡𝗍𝗍,𝗈𝗋(𝖿𝖿,𝑏)≡𝗋𝖾𝖼𝟐(𝗍𝗍,𝑏,𝖿𝖿)≡𝑏,𝗂𝗆𝗉𝗅𝗂𝖾𝗌(𝗍𝗍,𝑏)≡𝗋𝖾𝖼𝟐(𝑏,𝗍𝗍,𝗍𝗍)≡𝑏,𝗂𝗆𝗉𝗅𝗂𝖾𝗌(𝖿𝖿,𝑏)≡𝗋𝖾𝖼𝟐(𝑏,𝗍𝗍,𝖿𝖿)≡𝗍𝗍,𝗑𝗈𝗋(𝗍𝗍,𝑏)≡𝗋𝖾𝖼𝟐(𝗇𝖾𝗀(𝑏),𝑏,𝗍𝗍)≡𝗇𝖾𝗀(𝑏),𝗑𝗈𝗋(𝖿𝖿,𝑏)≡𝗋𝖾𝖼𝟐(𝗇𝖾𝗀(𝑏),𝑏,𝖿𝖿)≡𝑏. These are judgmental equations; no propositional equality type is involved.
Write 𝑇𝑡:=𝐶(𝗍𝗍),𝑇𝑓:=𝐶(𝖿𝖿),𝑃:=∏𝑏:𝟐𝐶(𝑏). Substitution into Γ,𝑥:𝟐⊢𝐶𝗍𝗒𝗉𝖾 forms 𝑇𝑡 and 𝑇𝑓 in Γ. Starting from the context Δ:=Γ,𝑐𝑡:𝑇𝑡,𝑐𝑓:𝑇𝑓,𝑏:𝟐, repeated weakening supplies Δ,𝑥:𝟐⊢𝐶𝗍𝗒𝗉𝖾,Δ⊢𝑐𝑡:𝐶(𝗍𝗍),Δ⊢𝑐𝑓:𝐶(𝖿𝖿), while Var supplies Δ⊢𝑏:𝟐. Thus Δ,𝑥:𝟐⊢𝐶𝗍𝗒𝗉𝖾Δ⊢𝑐𝑡:𝐶(𝗍𝗍)Δ⊢𝑐𝑓:𝐶(𝖿𝖿)Δ⊢𝑏:𝟐Δ⊢𝗂𝗇𝖽𝟐(𝑥.𝐶;𝑐𝑡,𝑐𝑓,𝑏):𝐶(𝑏)−elim. The weakening sequence can be read explicitly as Γ,𝑥:𝟐⊢𝐶𝗍𝗒𝗉𝖾⟹𝑊𝑘Γ,𝑐𝑡:𝑇𝑡,𝑥:𝟐⊢𝐶𝗍𝗒𝗉𝖾⟹𝑊𝑘Γ,𝑐𝑡:𝑇𝑡,𝑐𝑓:𝑇𝑓,𝑥:𝟐⊢𝐶𝗍𝗒𝗉𝖾. followed by weakening the resulting family by 𝑏:𝟐; exchange merely moves the fresh motive variable 𝑥 to the final displayed position. The branch terms are obtained by Var and weakened over declarations to their right.
Applying Π-intro successively to 𝑏,𝑐𝑓,𝑐𝑡 yields Γ⊢𝜆𝑐𝑡.𝜆𝑐𝑓.𝜆𝑏.𝗂𝗇𝖽𝟐(𝑥.𝐶;𝑐𝑡,𝑐𝑓,𝑏):𝑇𝑡→𝑇𝑓→𝑃. Call this term 𝐼𝐶. At the constructors, three Pi-beta steps expose the eliminator and then Boolean computation applies: 𝐼𝐶(𝑐𝑡)(𝑐𝑓)(𝗍𝗍)≡𝗂𝗇𝖽𝟐(𝑥.𝐶;𝑐𝑡,𝑐𝑓,𝗍𝗍)≡𝑐𝑡:𝐶(𝗍𝗍),𝐼𝐶(𝑐𝑡)(𝑐𝑓)(𝖿𝖿)≡𝗂𝗇𝖽𝟐(𝑥.𝐶;𝑐𝑡,𝑐𝑓,𝖿𝖿)≡𝑐𝑓:𝐶(𝖿𝖿).
Conversely, suppose for every such family 𝐶 we are given 𝐽𝐶:𝑇𝑡→𝑇𝑓→∏𝑏:𝟐𝐶(𝑏) with the two displayed constructor equations. Define the eliminator constructed from this principle by 𝗂𝗇𝖽′𝟐(𝑥.𝐶;𝑐𝑡,𝑐𝑓,𝑏):=𝐽𝐶(𝑐𝑡)(𝑐𝑓)(𝑏). Three uses of Π-elim give it type 𝐶(𝑏). Its constructor computations are exactly the assumed equations 𝐽𝐶(𝑐𝑡)(𝑐𝑓)(𝗍𝗍)≡𝑐𝑡,𝐽𝐶(𝑐𝑡)(𝑐𝑓)(𝖿𝖿)≡𝑐𝑓. Hence the binder-form principle and the primitive elimination principle construct one another. This proves equivalence of principles, not a raw-term identity between 𝐽𝐶 and the primitive eliminator.
Let 𝟐′:=𝟏+𝟏,𝗍𝗍′:=𝗂𝗇𝗅(⋆),𝖿𝖿′:=𝗂𝗇𝗋(⋆). Formation and the two introduction rules are immediate from 𝟏-form, 𝟏-intro, and the coproduct rules.
For elimination, suppose Γ,𝑧:𝟐′⊢𝐶𝗍𝗒𝗉𝖾,𝑐𝑡:𝐶(𝗍𝗍′),𝑐𝑓:𝐶(𝖿𝖿′),𝑠:𝟐′. In the left branch, the family over 𝑢:𝟏 is 𝐶(𝗂𝗇𝗅(𝑢)). The derived dependent unit eliminator therefore gives 𝑓:=𝜆𝑢.𝗂𝗇𝖽𝟏(𝑣.𝐶(𝗂𝗇𝗅(𝑣));𝑐𝑡;𝑢):∏𝑢:𝟏𝐶(𝗂𝗇𝗅(𝑢)). Here the semicolon grouping only makes the motive, base point, and scrutinee visible; by proposition 27.17 the body is the unchanged raw term 𝑐𝑡, converted from 𝐶(𝗂𝗇𝗅(⋆)) to 𝐶(𝗂𝗇𝗅(𝑢)). In the right branch, unit elimination converts the unchanged term 𝑐𝑓 from 𝐶(𝗂𝗇𝗋(⋆)) to 𝐶(𝗂𝗇𝗋(𝑢)), giving 𝑔:=𝜆𝑢.𝗂𝗇𝖽𝟏(𝑣.𝐶(𝗂𝗇𝗋(𝑣));𝑐𝑓;𝑢):∏𝑢:𝟏𝐶(𝗂𝗇𝗋(𝑢)). Define 𝗂𝗇𝖽𝟐′(𝑧.𝐶;𝑐𝑡,𝑐𝑓;𝑠):=𝗂𝗇𝖽+(𝑧.𝐶;𝑓,𝑔,𝑠):𝐶(𝑠). This has exactly the Boolean elimination rule, with 𝟐′, 𝗍𝗍′, and 𝖿𝖿′ substituted for their primitive counterparts. Its computations are judgmental: 𝗂𝗇𝖽𝟐′(𝑧.𝐶;𝑐𝑡,𝑐𝑓;𝗍𝗍′)≡𝗂𝗇𝖽+(𝑧.𝐶;𝑓,𝑔,𝗂𝗇𝗅(⋆))≡𝑓(⋆)≡𝑐𝑡,𝗂𝗇𝖽𝟐′(𝑧.𝐶;𝑐𝑡,𝑐𝑓;𝖿𝖿′)≡𝗂𝗇𝖽+(𝑧.𝐶;𝑓,𝑔,𝗂𝗇𝗋(⋆))≡𝑔(⋆)≡𝑐𝑓. The middle equations are coproduct computation; the final equations are function beta followed by the reflexive computation of the derived unit eliminator. Thus no propositional transport remains in either Boolean computation rule.
Using the case-analysis notation of definition 28.18, define 𝛼:=[[𝜆𝑎.𝗂𝗇𝗅(𝑎),𝜆𝑏.𝗂𝗇𝗋(𝗂𝗇𝗅(𝑏))],𝜆𝑐.𝗂𝗇𝗋(𝗂𝗇𝗋(𝑐))]:(𝐴+𝐵)+𝐶→𝐴+(𝐵+𝐶),𝛽:=[𝜆𝑎.𝗂𝗇𝗅(𝗂𝗇𝗅(𝑎)),[𝜆𝑏.𝗂𝗇𝗅(𝗂𝗇𝗋(𝑏)),𝜆𝑐.𝗂𝗇𝗋(𝑐)]]:𝐴+(𝐵+𝐶)→(𝐴+𝐵)+𝐶. Successive coproduct and function beta rules give the three checks: 𝛽(𝛼(𝗂𝗇𝗅(𝗂𝗇𝗅(𝑎))))≡𝛽(𝗂𝗇𝗅(𝑎))≡𝗂𝗇𝗅(𝗂𝗇𝗅(𝑎)),𝛽(𝛼(𝗂𝗇𝗅(𝗂𝗇𝗋(𝑏))))≡𝛽(𝗂𝗇𝗋(𝗂𝗇𝗅(𝑏)))≡𝗂𝗇𝗅(𝗂𝗇𝗋(𝑏)),𝛽(𝛼(𝗂𝗇𝗋(𝑐)))≡𝛽(𝗂𝗇𝗋(𝗂𝗇𝗋(𝑐)))≡𝗂𝗇𝗋(𝑐). Thus 𝛽∘𝛼 computes to the identity on each constructor form listed in the exercise. The claim is deliberately constructorwise: no coproduct eta rule is required for a generic variable.
Parenthesize the source type as ((𝐴+𝐵)→𝐶). Define 𝐹:=𝜆ℎ.(𝜆𝑎.ℎ(𝗂𝗇𝗅(𝑎)),𝜆𝑏.ℎ(𝗂𝗇𝗋(𝑏))):((𝐴+𝐵)→𝐶)→(𝐴→𝐶)×(𝐵→𝐶),𝐺:=𝜆𝑝.[𝗉𝗋1(𝑝),𝗉𝗋2(𝑝)]:(𝐴→𝐶)×(𝐵→𝐶)→((𝐴+𝐵)→𝐶). For a pair of functions, beta and the two projection rules give 𝐹(𝐺((𝑓,𝑔)))≡(𝜆𝑎.𝑓(𝑎),𝜆𝑏.𝑔(𝑏))≡(𝑓,𝑔), where the last equality uses Π-eta in each component. For a generic ℎ:(𝐴+𝐵)→𝐶, constructor computation gives 𝐺(𝐹(ℎ))(𝗂𝗇𝗅(𝑎))≡(𝜆𝑎′.ℎ(𝗂𝗇𝗅(𝑎′)))(𝑎)≡ℎ(𝗂𝗇𝗅(𝑎)),𝐺(𝐹(ℎ))(𝗂𝗇𝗋(𝑏))≡(𝜆𝑏′.ℎ(𝗂𝗇𝗋(𝑏′)))(𝑏)≡ℎ(𝗂𝗇𝗋(𝑏)). The first equation uses function eta but not coproduct eta; the latter two hold directly on the two constructors.
Recur on the second argument and use the multiplication of construction 73.26: 𝖾𝗑𝗉:=𝜆𝑚.𝜆𝑛.𝗋𝖾𝖼ℕ(――1,𝜆𝑘.𝜆𝑟.𝗆𝗎𝗅(𝑟,𝑚),𝑛). The recursive result 𝑟 has type ℕ, and the predecessor 𝑘 is unused. Hence the term has type ℕ→ℕ→ℕ. Its defining equations are immediate: 𝖾𝗑𝗉(𝑚,𝟢)≡――1,𝖾𝗑𝗉(𝑚,𝗌𝗎𝖼(𝑛))≡(𝜆𝑘.𝜆𝑟.𝗆𝗎𝗅(𝑟,𝑚))(𝑛,𝖾𝗑𝗉(𝑚,𝑛))≡𝗆𝗎𝗅(𝖾𝗑𝗉(𝑚,𝑛),𝑚). The equations use only Pi-beta and the two natural-number recursor computations.
At the constant motive 𝐶, define 𝗂𝗍𝖾𝗋(𝑐0,𝑓,𝑛):=𝗋𝖾𝖼ℕ(𝑐0,𝜆𝑘.𝜆𝑟.𝑓(𝑟),𝑛):𝐶. The step has type ℕ→𝐶→𝐶; it ignores the predecessor. Therefore 𝗂𝗍𝖾𝗋(𝑐0,𝑓,𝟢)≡𝑐0,𝗂𝗍𝖾𝗋(𝑐0,𝑓,𝗌𝗎𝖼(𝑛))≡(𝜆𝑘.𝜆𝑟.𝑓(𝑟))(𝑛,𝗂𝗍𝖾𝗋(𝑐0,𝑓,𝑛))≡𝑓(𝗂𝗍𝖾𝗋(𝑐0,𝑓,𝑛)). Addition can now be defined without mentioning 𝗋𝖾𝖼ℕ: 𝖺𝖽𝖽:=𝜆𝑚.𝜆𝑛.𝗂𝗍𝖾𝗋(𝑚,𝜆𝑟.𝗌𝗎𝖼(𝑟),𝑛). Its equations are 𝖺𝖽𝖽(𝑚,𝟢)≡𝑚 and 𝖺𝖽𝖽(𝑚,𝗌𝗎𝖼(𝑛))≡𝗌𝗎𝖼(𝖺𝖽𝖽(𝑚,𝑛)), exactly as in construction 28.23.
Put 𝑇0:=𝐶(𝟢),𝑆:=∏𝑘:ℕ𝐶(𝑘)→𝐶(𝗌𝗎𝖼(𝑘)). Substitution forms 𝑇0 and 𝑆 in Γ. In the context Δ:=Γ,𝑐0:𝑇0,𝑐𝑠:𝑆,𝑛:ℕ we need the four premises of ℕ-elim. They are obtained as follows. First weaken the original family past the two branch declarations: Γ,𝑥:ℕ⊢𝐶𝗍𝗒𝗉𝖾⟹𝑊𝑘Γ,𝑐0:𝑇0,𝑥:ℕ⊢𝐶𝗍𝗒𝗉𝖾⟹𝑊𝑘Γ,𝑐0:𝑇0,𝑐𝑠:𝑆,𝑥:ℕ⊢𝐶𝗍𝗒𝗉𝖾. and then weaken it by the scrutinee declaration 𝑛:ℕ. Up to exchange of the fresh motive variable, this is Δ,𝑥:ℕ⊢𝐶𝗍𝗒𝗉𝖾. The variable rule and weakening give Δ⊢𝑐0:𝐶(𝟢),Δ⊢𝑐𝑠:𝑆,Δ⊢𝑛:ℕ. If the rule is read with an explicit step lambda, two applications followed by two abstractions derive Δ⊢𝜆𝑘.𝜆𝑟.𝑐𝑠(𝑘)(𝑟):𝑆; by Pi-eta this is judgmentally equal to the weakened 𝑐𝑠. Hence ℕ-elim gives Δ⊢𝗂𝗇𝖽ℕ(𝑥.𝐶;𝑐0,𝜆𝑘.𝜆𝑟.𝑐𝑠(𝑘)(𝑟);𝑛):𝐶(𝑛). Abstracting in the reverse order 𝑛,𝑐𝑠,𝑐0 produces 𝗂𝗇𝖽𝐶:=𝜆𝑐0.𝜆𝑐𝑠.𝜆𝑛.𝗂𝗇𝖽ℕ(𝑥.𝐶;𝑐0,𝜆𝑘.𝜆𝑟.𝑐𝑠(𝑘)(𝑟);𝑛):𝑇0→𝑆→∏𝑛:ℕ𝐶(𝑛).
At zero, three Pi-beta steps and ℕ-comp1 give 𝗂𝗇𝖽𝐶(𝑐0,𝑐𝑠,𝟢)≡𝗂𝗇𝖽ℕ(𝑥.𝐶;𝑐0,𝜆𝑘.𝜆𝑟.𝑐𝑠(𝑘)(𝑟);𝟢)≡𝑐0. At a successor, ℕ-comp2 and two further beta steps give 𝗂𝗇𝖽𝐶(𝑐0,𝑐𝑠,𝗌𝗎𝖼(𝑘))≡(𝜆𝑘′.𝜆𝑟.𝑐𝑠(𝑘′)(𝑟))(𝑘,𝗂𝗇𝖽𝐶(𝑐0,𝑐𝑠,𝑘))≡𝑐𝑠(𝑘)(𝗂𝗇𝖽𝐶(𝑐0,𝑐𝑠,𝑘)):𝐶(𝗌𝗎𝖼(𝑘)). The motive is genuinely 𝐶(𝑛); replacing it by a constant family would lose the dependent conclusion.
Let 1:=――1, and define the base function and outer step 𝑎0:=𝜆𝑛.𝗌𝗎𝖼(𝑛):ℕ→ℕ,𝑆:=𝜆𝑚.𝜆𝑓.𝜆𝑛.𝗋𝖾𝖼ℕ(𝑓(1),𝜆𝑘.𝜆𝑟.𝑓(𝑟),𝑛):ℕ→(ℕ→ℕ)→(ℕ→ℕ). The requested function is the outer recursion at the higher type ℕ→ℕ: 𝖺𝖼𝗄:=𝜆𝑚.𝗋𝖾𝖼ℕ(𝑎0,𝑆,𝑚):ℕ→ℕ→ℕ. Writing 𝐴𝑚:=𝖺𝖼𝗄(𝑚), the outer computation equations are 𝐴𝟢≡𝑎0,𝐴𝗌𝗎𝖼(𝑚)≡𝑆(𝑚,𝐴𝑚). Consequently 𝖺𝖼𝗄(𝟢,𝑛)≡𝑎0(𝑛)≡𝗌𝗎𝖼(𝑛). For the successor row, substitute the displayed form of 𝑆 and abbreviate 𝑅𝑚(𝑛):=𝗋𝖾𝖼ℕ(𝐴𝑚(1),𝜆𝑘.𝜆𝑟.𝐴𝑚(𝑟),𝑛). Then 𝖺𝖼𝗄(𝗌𝗎𝖼(𝑚),𝟢)≡𝑅𝑚(𝟢)≡𝐴𝑚(1)=𝖺𝖼𝗄(𝑚,――1),𝖺𝖼𝗄(𝗌𝗎𝖼(𝑚),𝗌𝗎𝖼(𝑛))≡𝑅𝑚(𝗌𝗎𝖼(𝑛))≡𝐴𝑚(𝑅𝑚(𝑛))≡𝐴𝑚(𝖺𝖼𝗄(𝗌𝗎𝖼(𝑚),𝑛)). By the definition of 𝐴𝑚, the last term is 𝖺𝖼𝗄(𝑚,𝖺𝖼𝗄(𝗌𝗎𝖼(𝑚),𝑛)). The crucial point is that the outer recursive result 𝐴𝑚 is itself a function and is used both as the inner base case and as the operation iterated in the inner successor case.
First define a zero test 𝗂𝗌𝗓𝖾𝗋𝗈:=𝜆𝑛.𝗋𝖾𝖼ℕ(𝗍𝗍,𝜆𝑘.𝜆𝑟.𝖿𝖿,𝑛):ℕ→𝟐. It computes to 𝗍𝗍 at zero and to 𝖿𝖿 at every successor. Now let the outer recursion return a function ℕ→𝟐: 𝖾𝗊:=𝜆𝑚.𝗋𝖾𝖼ℕ(𝗂𝗌𝗓𝖾𝗋𝗈,𝜆𝑘.𝜆𝑒.𝜆𝑛.𝗋𝖾𝖼ℕ(𝖿𝖿,𝜆𝑗.𝜆𝑟.𝑒(𝑗),𝑛),𝑚). Here 𝑒:ℕ→𝟐 is the predecessor result: when the first argument is 𝗌𝗎𝖼(𝑘) and the second is 𝗌𝗎𝖼(𝑗), the step returns 𝑒(𝑗), thereby comparing the two predecessors. Direct computation gives the four characteristic equations 𝖾𝗊(𝟢,𝟢)≡𝗍𝗍,𝖾𝗊(𝟢,𝗌𝗎𝖼(𝑛))≡𝖿𝖿,𝖾𝗊(𝗌𝗎𝖼(𝑚),𝟢)≡𝖿𝖿,𝖾𝗊(𝗌𝗎𝖼(𝑚),𝗌𝗎𝖼(𝑛))≡𝖾𝗊(𝑚,𝑛). An induction on 𝑚, with a case split on 𝑛, now proves that closed numerals compute to 𝗍𝗍 exactly when their meta-level indices agree: the mixed zero/successor cases are false, and the successor/successor case reduces to the induction hypothesis for the predecessors. In particular, 𝖾𝗊(――2,――2)≡𝖾𝗊(――1,――1)≡𝖾𝗊(𝟢,𝟢)≡𝗍𝗍.
The term is 𝜆ℎ.ℎ(𝗂𝗇𝗋(𝜆𝑎.ℎ(𝗂𝗇𝗅(𝑎)))):¬¬(𝐴+¬𝐴). Indeed, assume ℎ:(𝐴+¬𝐴)→𝟎. In context 𝑎:𝐴, ℎ(𝗂𝗇𝗅(𝑎)):𝟎, so 𝑘:=𝜆𝑎.ℎ(𝗂𝗇𝗅(𝑎)):¬𝐴. Hence 𝗂𝗇𝗋(𝑘):𝐴+¬𝐴, and applying ℎ gives a term of 𝟎. Abstracting over ℎ proves ((𝐴+¬𝐴)→𝟎)→𝟎, which is the stated double negation.
For the first direction define 𝜆ℎ.(𝜆𝑎.ℎ(𝗂𝗇𝗅(𝑎)),𝜆𝑏.ℎ(𝗂𝗇𝗋(𝑏))):¬(𝐴+𝐵)→¬𝐴׬𝐵. If ℎ:(𝐴+𝐵)→𝟎, its restrictions along the two injections have respectively types 𝐴→𝟎 and 𝐵→𝟎, so the pair has the required product type.
For the converse, define 𝜆𝑝.[𝗉𝗋1(𝑝),𝗉𝗋2(𝑝)]:¬𝐴׬𝐵→¬(𝐴+𝐵). For 𝑝:¬𝐴׬𝐵, both projections have codomain 𝟎, so coproduct case analysis yields [𝗉𝗋1(𝑝),𝗉𝗋2(𝑝)]:𝐴+𝐵→𝟎. Its constructor computations are [𝗉𝗋1(𝑝),𝗉𝗋2(𝑝)](𝗂𝗇𝗅(𝑎))≡𝗉𝗋1(𝑝)(𝑎),[𝗉𝗋1(𝑝),𝗉𝗋2(𝑝)](𝗂𝗇𝗋(𝑏))≡𝗉𝗋2(𝑝)(𝑏).
Use clause (ii) of theorem 28.32 at the constant result type 𝐶:=ℕ, with 𝑐𝑛:=𝟢,𝑐𝑐:=𝜆𝑎.𝜆ℓ.𝜆𝑟.𝗌𝗎𝖼(𝑟):𝐴→𝐿→ℕ→ℕ. Let 𝗋𝖾𝖼𝑐𝑛,𝑐𝑐𝐿:𝐿→ℕ denote the recursor supplied by that clause, and define 𝗅𝖾𝗇𝗀𝗍𝗁:=𝗋𝖾𝖼𝑐𝑛,𝑐𝑐𝐿. Its two stipulated W-recursion computations are 𝗅𝖾𝗇𝗀𝗍𝗁(𝗇𝗂𝗅)≡𝑐𝑛≡𝟢,𝗅𝖾𝗇𝗀𝗍𝗁(𝖼𝗈𝗇𝗌(𝑎,ℓ))≡𝑐𝑐(𝑎,ℓ,𝗅𝖾𝗇𝗀𝗍𝗁(ℓ))≡𝗌𝗎𝖼(𝗅𝖾𝗇𝗀𝗍𝗁(ℓ)). The element 𝑎 and tail ℓ are available to the step, although only the recursive result is needed for length.
In the node case, clause (iii) supplies the step with the four arguments, in order, ℓ:𝑇,𝑟:𝑇,𝑢:ℕ(=𝗅𝖾𝖺𝗏𝖾𝗌(ℓ)),𝑣:ℕ(=𝗅𝖾𝖺𝗏𝖾𝗌(𝑟)). At result type ℕ, choose 𝑐𝑙:=――1,𝑐𝑛:=𝜆ℓ.𝜆𝑟.𝜆𝑢.𝜆𝑣.𝑢+𝑣:𝑇→𝑇→ℕ→ℕ→ℕ. Let 𝗋𝖾𝖼𝑐𝑙,𝑐𝑛𝑇 be the recursor furnished by the theorem and put 𝗅𝖾𝖺𝗏𝖾𝗌:=𝗋𝖾𝖼𝑐𝑙,𝑐𝑛𝑇. Then 𝗅𝖾𝖺𝗏𝖾𝗌(𝗅𝖾𝖺𝖿)≡𝑐𝑙≡――1,𝗅𝖾𝖺𝗏𝖾𝗌(𝗇𝗈𝖽𝖾(ℓ,𝑟))≡𝑐𝑛(ℓ,𝑟,𝗅𝖾𝖺𝗏𝖾𝗌(ℓ),𝗅𝖾𝖺𝗏𝖾𝗌(𝑟))≡𝗅𝖾𝖺𝗏𝖾𝗌(ℓ)+𝗅𝖾𝖺𝗏𝖾𝗌(𝑟).
Write 𝑊:=𝖶𝑥:𝐴𝐵. At the constant motive 𝟎, the W-step must have type ∏𝑎:𝐴∏𝛼:𝐵(𝑎)→𝑊(𝐵(𝑎)→𝟎)→𝟎. Using the assumed point 𝑘(𝑎):𝐵(𝑎), define ℎ:=𝜆𝑎.𝜆𝛼.𝜆𝑞.𝑞(𝑘(𝑎)). The subtree family 𝛼 is not needed; the inductive-hypothesis family 𝑞:𝐵(𝑎)→𝟎 is evaluated at the distinguished arity point 𝑘(𝑎). Therefore W-elimination gives 𝜆𝑡.𝗂𝗇𝖽𝖶(𝑤.𝟎;ℎ,𝑡):𝑊→𝟎, which is a term of ¬𝑊. Conceptually, every purported tree has at least one immediate child, and following the selected child cannot terminate in a well-founded tree.
Fix Γ⊢𝐴𝗍𝗒𝗉𝖾 and abbreviate 𝐿:=𝖫𝗂𝗌𝗍(𝐴). The formation and introduction rules generated by definition 28.34 are
Γ⊢𝐴𝗍𝗒𝗉𝖾
Γ⊢𝐿𝗍𝗒𝗉𝖾
List-form
Γ⊢𝐴𝗍𝗒𝗉𝖾
Γ⊢𝗇𝗂𝗅:𝐿
List-intro_1
Γ⊢𝑎:𝐴Γ⊢ℓ:𝐿
Γ⊢𝖼𝗈𝗇𝗌(𝑎,ℓ):𝐿
List-intro_2
For a motive Γ,𝑤:𝐿⊢𝐶𝗍𝗒𝗉𝖾, the nil case has no arguments, while the cons case receives, in the required order, the element, the recursive argument, and its inductive hypothesis: 𝑐𝑛:𝐶(𝗇𝗂𝗅),𝑐𝑐:∏𝑎:𝐴∏ℓ:𝐿𝐶(ℓ)→𝐶(𝖼𝗈𝗇𝗌(𝑎,ℓ)). For the next three displays, abbreviate 𝐼(𝑡):=𝗂𝗇𝖽𝖫𝗂𝗌𝗍(𝑤.𝐶;𝑐𝑛,𝑐𝑐;𝑡). The elimination rule is therefore
Use the constant motive 𝑤.ℕ, the nil branch 𝟢, and the cons branch that ignores the element and tail but increments the recursive result: 𝗅𝖾𝗇𝗀𝗍𝗁:=𝜆𝑡.𝗂𝗇𝖽𝖫𝗂𝗌𝗍(𝑤.ℕ;𝟢,𝜆𝑎.𝜆ℓ.𝜆𝑟.𝗌𝗎𝖼(𝑟);𝑡):𝖫𝗂𝗌𝗍(𝐴)→ℕ. Function beta followed by the two list computations gives 𝗅𝖾𝗇𝗀𝗍𝗁(𝗇𝗂𝗅)≡𝟢,𝗅𝖾𝗇𝗀𝗍𝗁(𝖼𝗈𝗇𝗌(𝑎,ℓ))≡(𝜆𝑎′.𝜆ℓ′.𝜆𝑟.𝗌𝗎𝖼(𝑟))(𝑎,ℓ,𝗅𝖾𝗇𝗀𝗍𝗁(ℓ))≡𝗌𝗎𝖼(𝗅𝖾𝗇𝗀𝗍𝗁(ℓ)). Both are judgmental equations generated by the primitive list rules.
Work in the hypothetical extension with 𝖿𝗈𝗅𝖽:(𝐷→𝟎)→𝐷 and, for every 𝐶, a recursor 𝗋𝖾𝖼𝐷(𝑒):𝐷→𝐶,𝗋𝖾𝖼𝐷(𝑒,𝖿𝗈𝗅𝖽(𝑢))≡𝑒(𝑢),𝑒:(𝐷→𝟎)→𝐶. At 𝐶:=𝐷→𝟎, the identity step 𝑒:=𝜆𝑢:𝐷→𝟎.𝑢:(𝐷→𝟎)→(𝐷→𝟎) therefore defines 𝗎𝗇𝖿𝗈𝗅𝖽:=𝗋𝖾𝖼𝐷(𝑒):𝐷→(𝐷→𝟎),𝗎𝗇𝖿𝗈𝗅𝖽(𝖿𝗈𝗅𝖽(𝑢))≡𝑢. The typing of 𝛿 is the derivation 𝑑:𝐷⊢𝗎𝗇𝖿𝗈𝗅𝖽:𝐷→(𝐷→𝟎)𝑑:𝐷⊢𝑑:𝐷𝑑:𝐷⊢𝗎𝗇𝖿𝗈𝗅𝖽(𝑑):𝐷→𝟎Π−elim𝑑:𝐷⊢𝑑:𝐷𝑑:𝐷⊢𝗎𝗇𝖿𝗈𝗅𝖽(𝑑)(𝑑):𝟎Π−elim⋅⊢𝛿:=𝜆𝑑.𝗎𝗇𝖿𝗈𝗅𝖽(𝑑)(𝑑):𝐷→𝟎Π−intro. Weakening supplies the closed constant 𝗎𝗇𝖿𝗈𝗅𝖽 in context 𝑑:𝐷, and both occurrences of 𝑑 are variable-rule instances. Next, the constructor typing rule for 𝖿𝗈𝗅𝖽 and application give ⋅⊢𝛿:𝐷→𝟎⋅⊢𝛿:𝐷→𝟎⋅⊢𝖿𝗈𝗅𝖽(𝛿):𝐷fold⋅⊢𝜔:=𝛿(𝖿𝗈𝗅𝖽(𝛿)):𝟎Π−elim.
Put 𝑑0:=𝖿𝗈𝗅𝖽(𝛿). Contextual closure of Pi-beta and of the bad recursor computation gives the nonempty cycle 𝑡0:=𝜔=𝛿(𝑑0)⟶𝑡1:=𝗎𝗇𝖿𝗈𝗅𝖽(𝑑0)(𝑑0)⟶𝑡2:=((𝜆𝑢.𝑢)(𝛿))(𝑑0)⟶𝑡3:=𝛿(𝑑0)=𝑡0. The first step unfolds the definition of 𝛿 and contracts its outer beta-redex. In the second, 𝗎𝗇𝖿𝗈𝗅𝖽(𝑑0)=𝗋𝖾𝖼𝐷(𝑒,𝖿𝗈𝗅𝖽(𝛿)) contracts to 𝑒(𝛿)=(𝜆𝑢.𝑢)(𝛿) inside function position. The third contracts that identity beta-redex. Each term has type 𝟎: in 𝑡1, 𝗎𝗇𝖿𝗈𝗅𝖽(𝑑0):𝐷→𝟎; in 𝑡2, (𝜆𝑢.𝑢)(𝛿):𝐷→𝟎; and 𝑡3=𝑡0 was typed above.
Repeating the three arrows gives an infinite reduction sequence starting at 𝜔, so 𝜔 is not strongly normalizing. Moreover, no term on the cycle is a normal form. Term 𝑡0=𝑡3 has the outer beta-redex 𝛿(𝑑0); 𝑡1 contains the recursor redex 𝗎𝗇𝖿𝗈𝗅𝖽(𝖿𝗈𝗅𝖽(𝛿)); and 𝑡2 contains the beta redex (𝜆𝑢.𝑢)(𝛿). Thus every node on the exhibited cycle has an outgoing one-step reduction.
Normalize the two inner operators first. A convenient choice for 𝐾×𝑋 is the container with shapes 𝐾 and one position at every shape. A convenient choice for 𝐿+𝑋 has shapes 𝐿+𝑁1, no positions at 𝗂𝗇𝗅(ℓ), and one position at 𝗂𝗇𝗋(⋆). The product clause of lemma 73.51 therefore gives 𝐴=𝐾×(𝐿+𝑁1),𝐵(𝑘,𝗂𝗇𝗅(ℓ))=𝑁1,𝐵(𝑘,𝗂𝗇𝗋(⋆))=𝑁1+𝑁1. On the two forms of element, the forward isomorphism is 𝜈𝑋((𝑘,𝑥),𝗂𝗇𝗅(ℓ))=((𝑘,𝗂𝗇𝗅(ℓ)),𝜆_.𝑥),𝜈𝑋((𝑘,𝑥),𝗂𝗇𝗋(𝑥′))=((𝑘,𝗂𝗇𝗋(⋆)),𝑞), where 𝑞(𝗂𝗇𝗅(⋆))=𝑥 and 𝑞(𝗂𝗇𝗋(⋆))=𝑥′. The inverse reads the shape tag. It returns ((𝑘,𝑞(⋆)),𝗂𝗇𝗅(ℓ)) at a left shape, and ((𝑘,𝑞(𝗂𝗇𝗅(⋆))),𝗂𝗇𝗋(𝑞(𝗂𝗇𝗋(⋆)))) at a right shape. Sum and unit eta prove the two inverse equations in TD.
Naturality of 𝜈 at 𝖿𝗈𝗅𝖽𝑒:𝑊→𝐶 is the equation 𝜈𝐶∘Φ(𝖿𝗈𝗅𝖽𝑒)=((𝑎,𝑏)↦(𝑎,𝖿𝗈𝗅𝖽𝑒∘𝑏))∘𝜈𝑊. Applying the equation to 𝑥 with 𝜈𝑊(𝑥)=(𝑎,𝑏) gives 𝜈𝐶(Φ(𝖿𝗈𝗅𝖽𝑒)(𝑥))=(𝑎,𝖿𝗈𝗅𝖽𝑒∘𝑏). Since 𝜄Φ(𝑥)=𝗌𝗎𝗉(𝑎,𝑏), W-computation yields 𝖿𝗈𝗅𝖽𝑒(𝜄Φ(𝑥))=𝑒(𝜈−1𝐶(𝑎,𝖿𝗈𝗅𝖽𝑒∘𝑏))=𝑒(Φ(𝖿𝗈𝗅𝖽𝑒)(𝑥)), where the second equality applies 𝜈−1𝐶 to the naturality equation. This is the algebra-morphism square.
For a variable 𝑦, both 𝑦 and 𝜆𝑥.𝑦(𝑥) are beta-normal, as are 𝑦 and 𝜆𝑥.𝗋𝖾𝖼𝟎(𝑥) when the domain is empty. Beta reduction therefore cannot establish either function equality. The 𝑋 case of the container lemma needs uniqueness for maps 𝑁1→𝑋; the constant 𝐾 case needs uniqueness for maps 𝑁0→𝑋.
Pointwise empty elimination gives 𝑦(𝑥)=𝗋𝖾𝖼𝟎(𝑥) under 𝑥:𝑁0. Unit elimination gives 𝑦(𝑥)=𝑦(⋆) under 𝑥:𝑁1. Function extensionality turns these pointwise equalities into 𝑦=𝜆(𝑥:𝑁0).𝗋𝖾𝖼𝟎(𝑥)and𝑦=𝜆(𝑥:𝑁1).𝑦(⋆), respectively. The source calculus includes the corresponding extensional uniqueness laws; the beta-only intensional core does not make either equation judgmental.