Prerequisites. Direct starred prerequisites: Chapter 129. No later core chapter depends on this route.
A generator for vectors should return code whose type records the generated length. If a present-stage natural 𝑛 occurs in the future type 𝖵𝖾𝖼𝐴𝑛, ordinary modal code rejects it as an ordinary free variable. Allowing the occurrence without changing substitution is worse: substituting for 𝑛 can change a type across a quotation boundary while leaving the term unchanged. Dependent staging needs one calculus whose stages, types, substitutions, and reductions agree.
The published card and its inversion-stable correction
A stage is a finite word 𝐴 of stage variables; append is written 𝐴𝛼. Kinds and the selected source calculus have the grammars 𝐾::=∗∣Π𝑥:𝜏.𝐾,𝜏,𝜎::=𝑋∣Π𝑥:𝜏.𝜎∣𝜏𝑀∣▹𝛼𝜏∣∀𝛼.𝜏,𝑀,𝑁::=𝑐∣𝑥∣𝜆𝑥:𝜏.𝑀∣𝑀𝑁∣⟨𝑀⟩𝛼∣∼𝛼𝑀∣Λ𝛼.𝑀∣𝑀𝐴∣%𝛼𝑀. A signature declares type constants and term constants. A context entry 𝑥:𝜏@𝐴 makes 𝑥 available exactly at stage 𝐴. Judgments include Γ⊢𝑀:𝜏@𝐴, Γ⊢𝜏::𝐾@𝐴, and Γ⊢𝐾𝗄𝗂𝗇𝖽@𝐴. The empty signature is well formed; 𝑋::𝐾 may be added when 𝐾 is a kind at the empty stage, and 𝑐:𝜏 may be added when 𝜏::∗ at the empty stage. A context may append fresh 𝑥:𝜏@𝐴 when 𝜏::∗@𝐴.
Kinds and types use these complete formation and checking rule families.
Γ⊢∗𝗄𝗂𝗇𝖽@𝐴
MD-Kind-Star
Γ⊢𝜏::∗@𝐴Γ,𝑥:𝜏@𝐴⊢𝐾𝗄𝗂𝗇𝖽@𝐴
Γ⊢Π𝑥:𝜏.𝐾𝗄𝗂𝗇𝖽@𝐴
MD-Kind-Pi
𝑋::𝐾∈Σ
Γ⊢𝑋::𝐾@𝐴
MD-TConst
Γ⊢𝜎::Π𝑥:𝜏.𝐾@𝐴Γ⊢𝑀:𝜏@𝐴
Γ⊢𝜎𝑀::𝐾[𝑀/𝑥]@𝐴
MD-TApp
Γ⊢𝜏::∗@𝐴𝛼
Γ⊢▹𝛼𝜏::∗@𝐴
MD-TCode
Γ⊢𝜏::𝐾@𝐴𝛼∉FTV(Γ)∪FTV(𝐴)
Γ⊢∀𝛼.𝜏::𝐾@𝐴
MD-TForall
Γ⊢𝜏::∗@𝐴
Γ⊢𝜏::∗@𝐴𝛼
MD-TCSP
Γ⊢𝜏::𝐾@𝐴Γ⊢𝐾≡𝐽@𝐴
Γ⊢𝜏::𝐽@𝐴
MD-TConv
The rule MD-Pi below is the remaining type-formation family. There is no kind above ∗. Thus a proposed derivation of Γ⊢∗::∗@𝐴 fails: MD-Kind-Star forms a kind and no kinding rule has ∗ as its subject.
Dependent functions use formation, introduction, elimination, and beta conversion in the usual order, with every premise at the same stage:
Γ⊢𝜏::∗@𝐴Γ,𝑥:𝜏@𝐴⊢𝜎::∗@𝐴
Γ⊢Π𝑥:𝜏.𝜎::∗@𝐴
MD-Pi
Γ⊢𝜏::∗@𝐴Γ,𝑥:𝜏@𝐴⊢𝑀:𝜎@𝐴
Γ⊢𝜆𝑥:𝜏.𝑀:Π𝑥:𝜏.𝜎@𝐴
MD-Abs
Γ⊢𝑀:Π𝑥:𝜏.𝜎@𝐴Γ⊢𝑁:𝜏@𝐴
Γ⊢𝑀𝑁:𝜎[𝑁/𝑥]@𝐴
MD-App
Variables require an exact stage match:
𝑐:𝜏∈Σ
Γ⊢𝑐:𝜏@𝐴
MD-Const
𝑥:𝜏@𝐴∈Γ
Γ⊢𝑥:𝜏@𝐴
MD-Var
Γ⊢𝑀:𝜏@𝐴Γ⊢𝜏≡𝜎::∗@𝐴
Γ⊢𝑀:𝜎@𝐴
MD-Conv
Thus 𝑥:𝜏@𝐴 does not justify 𝑥:𝜏@𝐴𝛼. The failed inference is the first-stage error in the naive vector generator. More explicitly, the only possible variable leaf would be 𝑛:𝖭𝖺𝗍@𝜀∈ΓΓ⊢𝑛:𝖭𝖺𝗍@𝛼MD−Var, but the premise required by MD-Var is instead 𝑛:𝖭𝖺𝗍@𝛼∈Γ. The displayed tree is therefore not a derivation. The same failed lookup occurs when the future result type is 𝖵𝖾𝖼𝐴𝑛.
Quotation and escape move in opposite directions.
Γ⊢𝑀:𝜏@𝐴𝛼
Γ⊢⟨𝑀⟩𝛼:▹𝛼𝜏@𝐴
MD-Quote
Γ⊢𝑀:▹𝛼𝜏@𝐴
Γ⊢∼𝛼𝑀:𝜏@𝐴𝛼
MD-Escape
Stage abstraction and application quantify the stage name.
Γ⊢𝑀:𝜏@𝐴𝛼∉FTV(Γ)∪FTV(𝐴)
Γ⊢Λ𝛼.𝑀:∀𝛼.𝜏@𝐴
MD-SAbs
Γ⊢𝑀:∀𝛼.𝜏@𝐴
Γ⊢𝑀𝐵:𝜏[𝐵/𝛼]@𝐴
MD-SApp
Finally, cross-stage persistence is the source rule
Γ⊢𝑀:𝜏@𝐴
Γ⊢%𝛼𝑀:𝜏@𝐴𝛼
MD-CSP
It persists a term syntactically; it is not the unrestricted persistence of references in an effectful host.
The displayed rules form the published 𝜆𝖬𝖣 card. Its unrestricted type-equivalence CSP rule MD-QT-CSP does not preserve code-body inversion when stage words are noncommutative: from a body at 𝐴𝛼, lifting the code equality to 𝐴𝛽 does not produce a body equality at 𝐴𝛽𝛼. The metatheorems below therefore use the inversion-stable fragment𝜆𝖬𝖣𝗂𝗌, which deletes MD-QT-CSP and changes no typing, term-equivalence, or reduction rule. The source rule remains displayed to make the delta auditable; no theorem below silently applies it. This corrected book-local system is a strict subsystem of the published typing/equality card, not the exact published calculus. The source’s preservation, normalization, confluence, and progress statements are therefore historical proof guides, not exact-signature imports. Each theorem below is proved for the corrected system from explicitly named source lemmas or local arguments.
The three mutually defined equivalence judgments are Γ⊢𝐾≡𝐽@𝐴, Γ⊢𝜏≡𝜎::𝐾@𝐴, and Γ⊢𝑀≡𝑁:𝜏@𝐴. Kind equivalence has five rules:
Γ⊢𝜏≡𝜎::∗@𝐴Γ,𝑥:𝜏@𝐴⊢𝐾≡𝐽@𝐴
Γ⊢Π𝑥:𝜏.𝐾≡Π𝑥:𝜎.𝐽@𝐴
MD-QK-Pi
Γ⊢𝐾≡𝐽@𝐴
Γ⊢𝐾≡𝐽@𝐴𝛼
MD-QK-CSP
Γ⊢𝐾𝗄𝗂𝗇𝖽@𝐴
Γ⊢𝐾≡𝐾@𝐴
MD-QK-Refl
Γ⊢𝐾≡𝐽@𝐴
Γ⊢𝐽≡𝐾@𝐴
MD-QK-Sym
Γ⊢𝐾≡𝐽@𝐴Γ⊢𝐽≡𝐼@𝐴
Γ⊢𝐾≡𝐼@𝐴
MD-QK-Trans
Type equivalence is the least equivalence closed by every type constructor and implicit type-level CSP:
Γ⊢𝜏≡𝜎::∗@𝐴Γ,𝑥:𝜏@𝐴⊢𝜌≡𝜋::∗@𝐴
Γ⊢Π𝑥:𝜏.𝜌≡Π𝑥:𝜎.𝜋::∗@𝐴
MD-QT-Pi
Γ⊢𝜏≡𝜎::Π𝑥:𝜌.𝐾@𝐴Γ⊢𝑀≡𝑁:𝜌@𝐴
Γ⊢𝜏𝑀≡𝜎𝑁::𝐾[𝑀/𝑥]@𝐴
MD-QT-App
Γ⊢𝜏≡𝜎::∗@𝐴𝛼
Γ⊢▹𝛼𝜏≡▹𝛼𝜎::∗@𝐴
MD-QT-Code
Γ⊢𝜏≡𝜎::∗@𝐴𝛼∉FTV(Γ)∪FTV(𝐴)
Γ⊢∀𝛼.𝜏≡∀𝛼.𝜎::∗@𝐴
MD-QT-Forall
Γ⊢𝜏≡𝜎::∗@𝐴
Γ⊢𝜏≡𝜎::∗@𝐴𝛼
MD-QT-CSP
Γ⊢𝜏::𝐾@𝐴
Γ⊢𝜏≡𝜏::𝐾@𝐴
MD-QT-Refl
Γ⊢𝜏≡𝜎::𝐾@𝐴
Γ⊢𝜎≡𝜏::𝐾@𝐴
MD-QT-Sym
Γ⊢𝜏≡𝜎::𝐾@𝐴Γ⊢𝜎≡𝜌::𝐾@𝐴
Γ⊢𝜏≡𝜌::𝐾@𝐴
MD-QT-Trans
Term congruence follows every term constructor:
Γ⊢𝜏≡𝜎::∗@𝐴Γ,𝑥:𝜏@𝐴⊢𝑀≡𝑁:𝜌@𝐴
Γ⊢𝜆𝑥:𝜏.𝑀≡𝜆𝑥:𝜎.𝑁:Π𝑥:𝜏.𝜌@𝐴
MD-Q-Abs
Γ⊢𝑀≡𝐿:Π𝑥:𝜎.𝜏@𝐴Γ⊢𝑁≡𝑂:𝜎@𝐴
Γ⊢𝑀𝑁≡𝐿𝑂:𝜏[𝑁/𝑥]@𝐴
MD-Q-App
Γ⊢𝑀≡𝑁:𝜏@𝐴𝛼
Γ⊢⟨𝑀⟩𝛼≡⟨𝑁⟩𝛼:▹𝛼𝜏@𝐴
MD-Q-Quote
Γ⊢𝑀≡𝑁:▹𝛼𝜏@𝐴
Γ⊢∼𝛼𝑀≡∼𝛼𝑁:𝜏@𝐴𝛼
MD-Q-Escape
Γ⊢𝑀≡𝑁:𝜏@𝐴𝛼∉FTV(Γ)∪FTV(𝐴)
Γ⊢Λ𝛼.𝑀≡Λ𝛼.𝑁:∀𝛼.𝜏@𝐴
MD-Q-SAbs
Γ⊢𝑀≡𝑁:∀𝛼.𝜏@𝐴
Γ⊢𝑀𝐵≡𝑁𝐵:𝜏[𝐵/𝛼]@𝐴
MD-Q-SApp
Γ⊢𝑀≡𝑁:𝜏@𝐴
Γ⊢%𝛼𝑀≡%𝛼𝑁:𝜏@𝐴𝛼
MD-Q-CSP
Γ⊢𝑀:𝜏@𝐴
Γ⊢𝑀≡𝑀:𝜏@𝐴
MD-Q-Refl
Γ⊢𝑀≡𝑁:𝜏@𝐴
Γ⊢𝑁≡𝑀:𝜏@𝐴
MD-Q-Sym
Γ⊢𝑀≡𝑁:𝜏@𝐴Γ⊢𝑁≡𝐿:𝜏@𝐴
Γ⊢𝑀≡𝐿:𝜏@𝐴
MD-Q-Trans
Its four computational axioms are:
Γ,𝑥:𝜎@𝐴⊢𝑀:𝜏@𝐴Γ⊢𝑁:𝜎@𝐴
Γ⊢(𝜆𝑥:𝜎.𝑀)𝑁≡𝑀[𝑁/𝑥]:𝜏[𝑁/𝑥]@𝐴
MD-Q-Beta
Γ⊢𝑀≡𝑁:𝜏@𝐴𝛼
Γ⊢∼𝛼⟨𝑀⟩𝛼≡𝑁:𝜏@𝐴𝛼
MD-Q-Splice
Γ⊢Λ𝛼.𝑀:∀𝛼.𝜏@𝐴
Γ⊢(Λ𝛼.𝑀)𝐵≡𝑀[𝐵/𝛼]:𝜏[𝐵/𝛼]@𝐴
MD-Q-StageBeta
Γ⊢𝑀:𝜏@𝐴𝛼Γ⊢𝑀:𝜏@𝐴
Γ⊢%𝛼𝑀≡𝑀:𝜏@𝐴𝛼
MD-Q-Percent
The general stage word 𝐵 in MD-Q-StageBeta follows the full-rule appendix of the cited source. Its main-text Q-Λ display restricts the same equation to the empty word; this chapter uses the appendix card consistently. The last axiom removes CSP only when the same term checks at both stages. For a constant 𝑐, MD-Const supplies both premises. For a variable declared only at 𝐴, the first premise fails. This side condition is why definitional equality is larger than the compatible closure of full reduction.
For an immediate calculation, let 𝑓:Π𝑥:𝖭𝖺𝗍.𝖭𝖺𝗍@𝐴 and 𝑛:𝖭𝖺𝗍@𝐴. Rule MD-Q-Beta gives (𝜆𝑥:𝖭𝖺𝗍.𝑓𝑥)𝑛≡𝑓𝑛:𝖭𝖺𝗍@𝐴. Rule MD-Q-Quote transports this equality to code at the preceding stage, and MD-Q-Splice contracts the matching escape–quotation pair. In contrast, MD-QT-CSP applied to ▹𝛼𝜌≡▹𝛼𝜏::∗@𝐴 yields an equality at 𝐴𝛽 while its bodies remain related at 𝐴𝛼, not 𝐴𝛽𝛼. This concrete stage-order mismatch is the counterexample that forces the inversion-stable delta recorded above.
For a type constant 𝖭𝖺𝗍::∗, the dependent identity has the full derivation Γ⊢𝖭𝖺𝗍::∗@𝐴𝑥:𝖭𝖺𝗍@𝐴∈Γ,𝑥:𝖭𝖺𝗍@𝐴Γ,𝑥:𝖭𝖺𝗍@𝐴⊢𝑥:𝖭𝖺𝗍@𝐴MD−VarΓ⊢𝜆𝑥:𝖭𝖺𝗍.𝑥:Π𝑥:𝖭𝖺𝗍.𝖭𝖺𝗍@𝐴MD−Abs. If 𝑓:Π𝑥:𝖭𝖺𝗍.𝖭𝖺𝗍@𝐴 is a variable, then 𝑓𝑐 is a well-typed neutral application. No full-reduction rule fires at its head.
For 𝑛:𝖭𝖺𝗍@𝜀, rule MD-CSP gives %𝛼𝑛:𝖭𝖺𝗍@𝛼. Hence a quoted vector constructor may have type ▹𝛼(𝖵𝖾𝖼𝐴(%𝛼𝑛)) at the empty stage. Omitting %𝛼 fails at MD-Var; placing it around a term already at 𝐴𝛼 fails the premise of MD-CSP.
Fix a type constant 𝐴::∗ and signature constants 𝗇𝗂𝗅:𝖵𝖾𝖼𝐴0,𝖼𝗈𝗇𝗌:Π𝑛:𝖭𝖺𝗍.𝐴→𝖵𝖾𝖼𝐴𝑛→𝖵𝖾𝖼𝐴(𝗌𝗎𝖼𝑛), and 𝑎0,𝑎1:𝐴. Repeated MD-CSP and MD-App at stage 𝛼 derive Γ⊢𝖼𝗈𝗇𝗌1(%𝛼𝑎1)(𝖼𝗈𝗇𝗌0(%𝛼𝑎0)𝗇𝗂𝗅):𝖵𝖾𝖼𝐴2@𝛼. Rule MD-Quote therefore gives code of 𝖵𝖾𝖼𝐴2 at the empty stage. Since MD-Const types 𝑎0,𝑎1 at every stage, their CSP markers are redundant for typing and removable by MD-Q-Percent; they nevertheless make the intended persistence operation explicit. A context variable declared only at 𝜀 still requires CSP, as the preceding 𝑛-example shows. The closed constants make this seminar generator a staged value under the grammar used below.
In the inversion-stable fragment, if Γ⊢▹𝛼𝜌≡𝜎::∗@𝐴 and Γ⊢𝜌::∗@𝐴𝛼, then 𝜎 is syntactically ▹𝛼𝜏 for some 𝜏, and Γ⊢𝜌≡𝜏::∗@𝐴𝛼. If instead Γ⊢𝜎≡▹𝛼𝜌::∗@𝐴 and Γ⊢𝜌::∗@𝐴𝛼, then 𝜎 is syntactically ▹𝛼𝜏 and Γ⊢𝜏≡𝜌::∗@𝐴𝛼 for some 𝜏.
Proof of Lemma 130.1 — Code-head inversion for type equivalence
Proof. First, induction on a type-equivalence derivation proves regularity: both endpoint types check at the displayed kind and stage. Constructor congruences rebuild their formation rules, reflexivity has formation as a premise, symmetry exchanges endpoints, and transitivity composes the two induction hypotheses. The corrected system has no MD-QT-CSP case.
Prove both orientations simultaneously by induction on the displayed type-equivalence derivation. In MD-QT-Code, the conclusion has the required head and its premise is the required body equality. In reflexivity, the additional body-formation hypothesis supplies body reflexivity at 𝐴𝛼. Symmetry exchanges the two induction statements.
For transitivity in the first orientation, the first induction hypothesis writes the middle type as ▹𝛼𝜏 and gives 𝜌≡𝜏 at 𝐴𝛼. Regularity of that equality supplies the formation premise needed by the second induction hypothesis. The second hypothesis writes the final type as ▹𝛼𝜐 and gives 𝜏≡𝜐; transitivity at 𝐴𝛼 completes the case. The reverse orientation exchanges the two induction statements. The Pi, application, and stage-quantifier congruences cannot have a code constructor on the displayed side. These are every type-equivalence rule in the corrected system.
The published proof’s simultaneous-inversion architecture motivates this induction , but its exact signature also has MD-QT-CSP. That missing case is not imported: at a code head it gives the noncommutative stage-order counterexample above. The explicit body-formation premise is necessary because published type-level CSP can form a code-headed type at a later word without furnishing code-formation inversion at that word. ◻
In the inversion-stable fragment, if Γ⊢⟨𝑀⟩𝛼:𝜎@𝐴, then 𝜎 is syntactically ▹𝛼𝜏 for some 𝜏, and Γ⊢𝑀:𝜏@𝐴𝛼. If Γ⊢∼𝛼𝑀:𝜏@𝐴𝛼, then there is a 𝜌 such that Γ⊢𝑀:▹𝛼𝜌@𝐴 and either 𝜌 is syntactically 𝜏, or Γ⊢𝜌≡𝜏::∗@𝐴𝛼.
Proof of Lemma 130.2 — Quotation and escape inversion
Proof. The source’s printed quotation-inversion premise uses @𝐴; the quotation conclusion and MD-Quote force @𝐴𝛼. We use that corrected stage annotation, which is also forced by the simultaneous inversion induction. Induct upward through trailing uses of MD-Conv. The first non-conversion rule is respectively MD-Quote or MD-Escape. In the quote case, regularity of the direct quote premise supplies the body-formation hypothesis of lemma 130.1; that lemma transports the body premise through every trailing type conversion and preserves the syntactic code head. In the escape case, retain the body type 𝜌 from MD-Escape. With no trailing conversion it is syntactically the conclusion type. Otherwise the trailing conversions compose to Γ⊢𝜌≡𝜏::∗@𝐴𝛼. These cases establish exactly the stated alternatives without assuming code-formation inversion for a type introduced only by published type-level CSP. ◻
Ordinary substitution [𝑁/𝑥] replaces terms and dependent occurrences in types. Stage substitution [𝐵/𝛼] replaces stage variables in stage words, quotation labels, escapes, CSP, and types; it alpha-renames a bound stage variable before crossing Λ. Representative defining equations are (𝜆𝑥:𝜏.𝑀)[𝐵/𝛼]=𝜆𝑥:𝜏[𝐵/𝛼].𝑀[𝐵/𝛼],(𝑀𝐶)[𝐵/𝛼]=𝑀[𝐵/𝛼]𝐶[𝐵/𝛼],⟨𝑀⟩𝛽[𝐵/𝛼]=⟨𝑀[𝐵/𝛼]⟩𝛽[𝐵/𝛼],(∼𝛽𝑀)[𝐵/𝛼]=∼𝛽[𝐵/𝛼]𝑀[𝐵/𝛼],(%𝛽𝑀)[𝐵/𝛼]=%𝛽[𝐵/𝛼]𝑀[𝐵/𝛼],(𝛽𝐶)[𝐵/𝛼]={𝛽(𝐶[𝐵/𝛼]),𝛽≠𝛼,𝐵(𝐶[𝐵/𝛼]),𝛽=𝛼. Primitive quotation, escape, and CSP nodes carry one stage variable. For a word 𝛼1⋯𝛼𝑛, the source’s derived notation denotes iteration in source order for quotation and in reverse order for escape and CSP. At the empty word all three operations are the identity. Consequently, stage substitution can expand one primitive occurrence into 𝑛 nodes when it replaces its label by a word of length 𝑛. It introduces no stage abstraction or stage-application node. These conventions determine the quote, escape, and CSP cases below; they are part of the syntax definition.
Let J range over the six judgment shapes 𝐾𝗄𝗂𝗇𝖽@𝐶,𝜏::𝐾@𝐶,𝑀:𝜏@𝐶,𝐾≡𝐽@𝐶,𝜏≡𝜎::𝐾@𝐶,𝑀≡𝐿:𝜏@𝐶. Substitution acts on every term, type, kind, stage annotation, and context entry displayed in a judgment.
Well-formed contexts and all six judgments admit weakening and exchange of independent entries. Moreover, capture-avoiding substitution satisfies both of the following schemas. Γ,𝑥:𝜉@𝐵,Γ′⊢J,Γ⊢𝑁:𝜉@𝐵⟹Γ,Γ′[𝑁/𝑥]⊢J[𝑁/𝑥],Γ⊢J⟹Γ[𝐷/𝛼]⊢J[𝐷/𝛼]. The same implications hold with the judgment conclusion replaced by context well-formedness. For every expression 𝐸, where 𝐸 may be a context, kind, type, or term, the two substitutions commute up to alpha-equivalence: 𝐸[𝑁/𝑥][𝐷/𝛼]≡𝛼𝐸[𝐷/𝛼][𝑁[𝐷/𝛼]/𝑥]. Choose term binders outside the free term names of 𝐸 and 𝑁, and choose stage binders outside the free stage names of 𝐸 and 𝐷. If a fixed deterministic convention selects among those names, the two representatives are syntactically equal.
Proof of Lemma 130.3 — Simultaneous structural and substitution package
Proof. Prove weakening, exchange, ordinary substitution, and stage substitution simultaneously for context well-formedness and the six judgment families. Context extension uses the type-kinding induction hypothesis for the declared type. In MD-Var, ordinary substitution uses the premise Γ⊢𝑁:𝜉@𝐵 when the selected variable is 𝑥, and otherwise rebuilds membership in the substituted context. The variable case of stage substitution changes both the declaration and its exact stage annotation.
For MD-Kind-Pi, MD-Pi, MD-Abs, and every dependent congruence, alpha-rename the term binder away from 𝑁, apply the induction hypotheses to the domain and binder-extended premise, and rebuild the rule. MD-TApp, MD-App, and MD-Q-App additionally use the structural composition law for dependent substitution in their result kind or type. The constructor rules for code, quotation, escape, and CSP apply the induction hypothesis at the premise stage and then rebuild the derived word-labelled rule determined by the substituted annotation.
For MD-TForall, MD-SAbs, MD-QT-Forall, and MD-Q-SAbs, alpha-rename the bound stage variable outside the free stage variables of the substituting word 𝐷 and the substituted expressions. The freshness premise is then preserved. Stage application substitutes in its result type as well as its term premise. Reflexivity, symmetry, and transitivity use the corresponding formation or equality induction hypotheses. The conversion rules MD-TConv and MD-Conv use, respectively, the simultaneously proved kind- and type-equivalence clauses; this is why a typing-only induction would be insufficient. Each computational equality axiom uses the typing clauses for its premises and the substitution composition law for its contractum. These cases exhaust context formation, kind formation, type kinding, term typing, and the three equivalence families.
Finally, prove the interaction equation by structural induction on 𝐸. Constructor cases commute componentwise. At a term or stage binder, rename the binder outside the free names of 𝑁, 𝑁[𝐷/𝛼], and 𝐷, then use the induction hypothesis for the body. The resulting representatives differ only by those bound-name choices, which proves alpha-equivalence and the stated deterministic-representative corollary. ◻
Full reduction and staged execution differ
Let 𝐶 range over arbitrary finite stage words. Full reduction ⟶ contracts terms only. Its one-hole full contexts are F::=[]∣𝜆𝑥:𝜏.F∣F𝑀∣𝑀F∣⟨F⟩𝛼∣∼𝛼F∣Λ𝛼.F∣F𝐵∣%𝛼F. In particular, no full context enters a binder annotation, a type, a kind, or a stage word. This makes precise the source’s phrase “least compatible relations on terms”: compatibility stays within the term syntactic category. The relation contains exactly three root contractions: (𝜆𝑥:𝜏.𝑀)𝑁⟶𝑀[𝑁/𝑥],∼𝛼⟨𝑀⟩𝛼⟶𝑀,(Λ𝛼.𝑀)𝐶⟶𝑀[𝐶/𝛼]. If 𝑅⟶𝑅′ is one of these root contractions, then F[𝑅]⟶F[𝑅′]. These are all full-reduction rules. There is no CSP contraction. Substituting the empty stage for 𝛼 erases %𝛼 syntactically; MD-Q-Percent is instead a typed equivalence axiom with two premises.
The term-only boundary exposes a failure in the source’s exact syntactic confluence claim.
Proof of Proposition 130.4 — Dependent annotations obstruct exact confluence
Proof. Take a signature containing 𝖭𝖺𝗍::∗,𝐹::Π𝑛:𝖭𝖺𝗍.∗,𝑐:𝖭𝖺𝗍, and put 𝐿=(𝜆𝑧:𝖭𝖺𝗍.𝑧)𝑐,𝑇=(𝜆𝑥:𝖭𝖺𝗍.𝜆𝑦:𝐹𝑥.𝑦)𝐿. Rules MD-TApp, MD-Abs, and MD-App derive 𝐿:𝖭𝖺𝗍@𝜀 and 𝑇:(Π𝑦:𝐹𝐿.𝐹𝐿)@𝜀. Contracting the outer redex gives 𝑇⟶𝑈=𝜆𝑦:𝐹𝐿.𝑦. Reducing the argument first and then contracting the outer redex gives 𝑇⟶(𝜆𝑥:𝖭𝖺𝗍.𝜆𝑦:𝐹𝑥.𝑦)𝑐⟶𝑉=𝜆𝑦:𝐹𝑐.𝑦. Rule MD-Q-Beta, followed by MD-QT-App and dependent-product congruence, gives Π𝑦:𝐹𝐿.𝐹𝐿≡Π𝑦:𝐹𝑐.𝐹𝑐::∗@𝜀, so conversion types both arms at the original result type. The only redex in 𝑈 occurs inside its binder annotation. No displayed full context reaches it; hence 𝑈 and 𝑉 are distinct full normal forms. They have no common reduct. ◻
Extending compatibility into annotations would make 𝑈⟶𝑉, but that is a different mutually sorted reduction. It would also invalidate the nonempty simple-erasure simulation below because (𝐹𝐿)♮=𝐹=(𝐹𝑐)♮. The corrected local card therefore retains term-only reduction, strong normalization for that relation, and the annotation-erased confluence theorem proved below. It does not repeat the published exact-confluence claim [KI19a].
Staged reduction ⟶𝑠 is deterministic, left-to-right, and indexed by stages. Constant-headed neutral spines ℎ𝐴 and values 𝑉𝐴 are defined mutually by ℎ𝜀::=𝑐∣ℎ𝜀𝑣𝜀∣ℎ𝜀𝐵,ℎ𝐴′::=𝑐∣𝑥∣ℎ𝐴′𝑣𝐴′∣ℎ𝐴′𝐵∣∼𝛼ℎ𝜀(𝐴′=𝛼),𝑣𝜀::=ℎ𝜀∣𝜆𝑥:𝜏.𝑀∣⟨𝑣𝛼⟩𝛼∣Λ𝛼.𝑣𝜀,𝑣𝐴′::=ℎ𝐴′∣𝜆𝑥:𝜏.𝑣𝐴′∣𝑣𝐴′𝑣𝐴′∣⟨𝑣𝐴′𝛼⟩𝛼∣Λ𝛼.𝑣𝐴′∣𝑣𝐴′𝐵∣∼𝛼𝑣𝐴″(𝐴′=𝐴″𝛼,𝐴″≠𝜀)∣%𝛼𝑣𝐴″(𝐴′=𝐴″𝛼). The source omits term constants from its value grammar although MD-Const types them at every stage. The displayed book-local delta closes constant heads under ordinary and stage application. At a nonempty stage it also classifies an escape whose empty-stage operand is a neutral constant spine; a quoted operand remains a splice redex. Thus 𝑐𝑣, 𝑐𝐵, and ∼𝛼(𝑐𝐵) are final forms, while ∼𝛼⟨𝑣⟩𝛼 is not. These productions enable no reduction and leave preservation, full normalization, and annotation-erased confluence unchanged. Let 𝐷 be either 𝜀 or one stage variable. The hole of 𝐸𝐴𝐷 is at stage 𝐷, while the whole context is at stage 𝐴: 𝐸𝜀𝐷::=[](𝐷=𝜀)∣𝐸𝜀𝐷𝑀∣𝑣𝜀𝐸𝜀𝐷∣⟨𝐸𝛼𝐷⟩𝛼∣Λ𝛼.𝐸𝜀𝐷∣𝐸𝜀𝐷𝐶,𝐸𝐴′𝐷::=[](𝐴′=𝐷)∣𝜆𝑥:𝜏.𝐸𝐴′𝐷∣𝐸𝐴′𝐷𝑀∣𝑣𝐴′𝐸𝐴′𝐷∣⟨𝐸𝐴′𝛼𝐷⟩𝛼∣∼𝛼𝐸𝐴𝐷(𝐴𝛼=𝐴′)∣Λ𝛼.𝐸𝐴′𝐷∣𝐸𝐴′𝐷𝐶∣%𝛼𝐸𝐴𝐷(𝐴𝛼=𝐴′). The redexes are 𝑅𝜀::=(𝜆𝑥:𝜏.𝑀)𝑣𝜀∣(Λ𝛼.𝑣𝜀)𝐶,𝑅𝛼::=∼𝛼⟨𝑣𝛼⟩𝛼. The staged relation consists of these three rule schemas: 𝐸𝐴𝜀[(𝜆𝑥:𝜏.𝑀)𝑣𝜀]⟶𝑠𝐸𝐴𝜀[𝑀[𝑣𝜀/𝑥]],𝐸𝐴𝜀[(Λ𝛼.𝑣𝜀)𝐶]⟶𝑠𝐸𝐴𝜀[𝑣𝜀[𝐶/𝛼]],𝐸𝐴𝛼[∼𝛼⟨𝑣𝛼⟩𝛼]⟶𝑠𝐸𝐴𝛼[𝑣𝛼]. The source prints 𝐶=𝜀 in one redex grammar but admits an arbitrary stage word in the contraction schema. The card uses the contraction schema: 𝐶 is unrestricted in the stage-beta redex, while 𝐷 records only the stage at which a redex is selected. Thus the grammar and decomposition theorem quantify over the same redex. In particular, (Λ𝛼.𝑐)(𝛽𝛾) is an empty-stage redex, not a stuck nonvalue, and the stage-beta rule gives the calculation (Λ𝛼.𝑐)(𝛽𝛾)⟶𝑠𝑐. The staged relation does not normalize arbitrary code bodies at the generation stage. Thus ⟨(𝜆𝑥:𝜏.𝑥)𝑐⟩𝛼 reduces under full reduction but is a code value for empty-stage execution.
Proof. Induct on the reduction derivation. For full beta, invert trailing MD-Conv rules, then invert MD-App and MD-Abs. Ordinary substitution from lemma 130.3 types the contractum at the dependent result type; reapply the inverted conversions. Quote–escape inversion uses lemma 130.2: escape inversion produces a body type 𝜌, while quote inversion types the contractum at 𝜌@𝐴𝛼. If 𝜌 is syntactically 𝜏, this is already the required judgment; otherwise escape inversion supplies Γ⊢𝜌≡𝜏::∗@𝐴𝛼, and MD-Conv gives it. Stage beta first inverts MD-SApp and MD-SAbs; stage substitution types 𝑀[𝐶/𝛼] at 𝜏[𝐶/𝛼]@𝐴, and alpha-renaming preserves the freshness premise.
For compatibility in the displayed full contexts beneath an ordinary abstraction, application, quotation, escape, stage abstraction, or stage application, apply the induction hypothesis to the selected premise and rebuild respectively MD-Abs, MD-App, MD-Quote, MD-Escape, MD-SAbs, or MD-SApp. The quotation case changes the premise stage to 𝐴𝛼; the escape case changes it back to 𝐴. A step beneath CSP is typed by the induction hypothesis at 𝐴 and rebuilt by MD-CSP at 𝐴𝛼. A trailing MD-Conv reuses its unchanged type-equivalence premise after applying the induction hypothesis to the term premise. These are every compatible term constructor and conversion. There is no compatibility case for a binder annotation or another type expression. Each staged evaluation context selects one of these cases, so the staged assertion follows from the same derivation. ◻
The erasure used for normalization is defined locally. On terms it is homomorphic for variables, constants, ordinary abstraction, and application, and it deletes staging constructors: ⟨𝑀⟩♮𝛼=(∼𝛼𝑀)♮=(Λ𝛼.𝑀)♮=(𝑀𝐵)♮=(%𝛼𝑀)♮=𝑀♮. On types, 𝑋♮=𝑋,(Π𝑥:𝜏.𝜎)♮=𝜏♮→𝜎♮,(𝜏𝑀)♮=𝜏♮,(▹𝛼𝜏)♮=𝜏♮,(∀𝛼.𝜏)♮=𝜏♮. Erase every kind to the one simple kind. Signature erasure retains each type constant as a simple type constant and changes each declaration 𝑐:𝜏 to 𝑐:𝜏♮. Context erasure keeps term declarations and drops their stages: ∅♮=∅,(Γ,𝑥:𝜏@𝐴)♮=Γ♮,𝑥:𝜏♮. The published translation prints an additional type-variable-context clause on physical page 30, but the published context grammar on physical page 6 has no such entry. The local translation therefore has no unreachable clause. These equations extend the source translation. The source omits clauses for constants and CSP and prints type application only at a variable argument; the local total translation adds 𝑐♮=𝑐, deletes CSP, and treats an arbitrary type-level term argument uniformly . The simulation statement below is proved for the corrected rule signature.
If Γ⊢𝑀:𝜏@𝐴 in 𝜆𝖬𝖣𝗂𝗌, then the simply typed judgment Γ♮⊢𝑀♮:𝜏♮ holds. Moreover, an ordinary-beta full step maps to a nonempty simply typed beta sequence, whereas a stage-beta or splice full step leaves erasure syntactically equal. The same classification holds under every displayed full context F.
Proof of Lemma 130.6 — Simple erasure and full-step simulation
Proof. Prove erasure of kinding, typing, and the three equivalence judgments simultaneously. Kind and type constants use their erased signature entries. Dependent product formation, ordinary abstraction, and ordinary application become the simple arrow rules. Erasure commutes with dependent result substitution: (𝜎[𝑁/𝑥])♮=𝜎♮. Code, quotation, escape, stage abstraction/application, and CSP erase to their premises. Conversion uses the simultaneous assertion 𝜏≡𝜎⟹𝜏♮=𝜎♮. Constructor congruences preserve that equality, and each computational equality has identical erasure or one simple beta equality. Reflexivity, symmetry, and transitivity preserve it. These cases cover every retained rule; the corrected system has no MD-QT-CSP case.
For reduction, ordinary beta uses (𝑀[𝑁/𝑥])♮=𝑀♮[𝑁♮/𝑥], proved by structural induction on 𝑀, and contracts the erased beta redex. Stage substitution changes only stage annotations and their derived staging nodes; erasure deletes both, so stage beta has equal erasures. Quote and escape are both erased, so splice also has equal erasures. An induction on the full-context derivation transports the corresponding beta sequence or syntactic equality through the erased context. These are all three root contractions and every term-only compatibility family. The qualification is essential: a hypothetical beta step inside a type annotation would erase to equality, as proposition 130.4 demonstrates. ◻
Proof of Theorem 130.7 — Strong normalization of full reduction
Proof. By lemma 130.6, 𝑀♮ is simply typed. An ordinary beta step gives a nonempty target beta reduction; splice and stage beta leave the translation equal. Let 𝑠(𝑀) count stage-abstraction and stage-application nodes, and let 𝑞(𝑀) count quotation and escape nodes. Order (𝑠(𝑀),𝑞(𝑀)) lexicographically. A stage-beta contraction strictly decreases the first component. It may expand derived word-labelled quotation, escape, or CSP notation, but it cannot change the first component; quote and escape expansion may increase the second. A splice preserves the first component and strictly decreases the second. Stage substitution introduces no stage abstraction or stage-application node. Ordinary beta may increase both components, but an infinite source reduction with infinitely many ordinary-beta steps would give an infinite simply typed beta reduction. If it had only finitely many, its tail would strictly decrease the displayed lexicographic pair at every step, also impossible. This lexicographic argument repairs the published proof’s insufficient raw-size sentence. Only strong normalization of the simply typed target is imported; the source-to-target simulation is the local lemma above. Classifying constant-headed spines as final forms does not add a full-reduction step. ◻
Exact confluence fails only because ordinary substitution changes dependent binder annotations that full reduction deliberately freezes. Remove those annotations while retaining every computational and staging constructor. The binder-annotation erasure has target grammar 𝑢,𝑣::=𝑐∣𝑥∣𝜆𝑥.𝑢∣𝑢𝑣∣⟨𝑢⟩𝛼∣∼𝛼𝑢∣Λ𝛼.𝑢∣𝑢𝐵∣%𝛼𝑢 and is defined by ⌊𝑐⌋a=𝑐,⌊𝑥⌋a=𝑥,⌊𝜆𝑥:𝜏.𝑀⌋a=𝜆𝑥.⌊𝑀⌋a,⌊𝑀𝑁⌋a=⌊𝑀⌋a⌊𝑁⌋a,⌊⟨𝑀⟩𝛼⌋a=⟨⌊𝑀⌋a⟩𝛼,⌊∼𝛼𝑀⌋a=∼𝛼⌊𝑀⌋a,⌊Λ𝛼.𝑀⌋a=Λ𝛼.⌊𝑀⌋a,⌊𝑀𝐵⌋a=⌊𝑀⌋a𝐵,⌊%𝛼𝑀⌋a=%𝛼⌊𝑀⌋a. Alpha-equivalent target terms are identified. This erasure differs from (−)♮: it deletes only ordinary binder types and retains quotation, escape, stage abstraction/application, and CSP.
Put the three root contractions and the term-compatible closure above on the annotation-free grammar, and write the resulting relation as ⟶a. A primitive splice can become a tower of splices after stage substitution, so ordinary one-layer parallel reduction is insufficient. For a word 𝐵=𝛽1⋯𝛽𝑛, define the derived shells 𝗊𝐵(𝑢)=⟨⋯⟨𝑢⟩𝛽𝑛⋯⟩𝛽1,𝖾𝐵(𝑢)=∼𝛽𝑛⋯∼𝛽1𝑢,𝗉𝐵(𝑢)=%𝛽𝑛⋯%𝛽1𝑢. All three shells are the identity at 𝐵=𝜀. These equations are the iteration convention of section 130.2; for example, (∼𝛼⟨𝑐⟩𝛼)[𝛽𝛾/𝛼]=∼𝛾(∼𝛽⟨⟨𝑐⟩𝛾⟩𝛽). Contracting only the inner 𝛽-splice exposes a 𝛾-splice, so this term does not reduce to 𝑐 in one ordinary parallel step.
Define word-parallel reduction⇒𝑤 by the rules
𝑢⇒𝑤𝑢
WP-Refl
𝑢1⇒𝑤𝑣1⋯𝑢𝑘⇒𝑤𝑣𝑘
𝐻(𝑢1,…,𝑢𝑘)⇒𝑤𝐻(𝑣1,…,𝑣𝑘)
WP-Cong
where 𝐻 ranges over the seven constructor schemas 𝜆𝑥.(−), (−)(−), ⟨−⟩𝛼, ∼𝛼(−), Λ𝛼.(−), −𝐶, and %𝛼(−). Constants and variables use reflexivity, and stage words are unchanged. Add ordinary beta, stage beta for every finite word 𝐶, and one word-splice rule for every nonempty finite word 𝐵:
𝑢⇒𝑤𝑢′𝑣⇒𝑤𝑣′
(𝜆𝑥.𝑢)𝑣⇒𝑤𝑢′[𝑣′/𝑥]
WP-Beta
𝑢⇒𝑤𝑢′𝐵≠𝜀
𝖾𝐵(𝗊𝐵(𝑢))⇒𝑤𝑢′
WP-Splice
𝑢⇒𝑤𝑢′
(Λ𝛼.𝑢)𝐶⇒𝑤𝑢′[𝐶/𝛼]
WP-StageBeta
Rule WP-Splice contracts the entire derived splice tower in one word-parallel step. At 𝐵=𝛼 it is the primitive splice rule. The other two root rules are WP-Beta and WP-StageBeta.
For annotation-free terms 𝑢,𝑢′,𝑣,𝑣′, a term variable 𝑥, a stage variable 𝛼, and an arbitrary finite stage word 𝐶, 𝑢⇒𝑤𝑢′,𝑣⇒𝑤𝑣′⟹𝑢[𝑣/𝑥]⇒𝑤𝑢′[𝑣′/𝑥],𝑢⇒𝑤𝑢′⟹𝑢[𝐶/𝛼]⇒𝑤𝑢′[𝐶/𝛼].
Proof of Lemma 130.8 — Substitution compatibility of word-parallel reduction
Proof. Prove the two assertions simultaneously by induction on the displayed word-parallel derivation. Alpha-rename term and stage binders outside the free names of the substituting expression or word before applying an induction hypothesis. At an ordinary-beta root, let 𝑦 be its term binder and let 𝑎,𝑎′ be its annotation-free argument endpoints. Ordinary beta uses the ordinary-substitution assertion twice and the substitution-composition equation. After alpha-renaming 𝑦≠𝑥 outside the free variables of 𝑣, the decisive equation is 𝑢′[𝑎′/𝑦][𝑣′/𝑥]≡𝛼𝑢′[𝑣′/𝑥][𝑎′[𝑣′/𝑥]/𝑦]. At a stage-beta root, let 𝐷 be its finite stage-word argument. Stage beta uses the stage-substitution assertion on its body. After renaming the bound stage variable 𝛿 outside 𝐶, its composition equation is 𝑢′[𝐷/𝛿][𝐶/𝛼]≡𝛼𝑢′[𝐶/𝛼][𝐷[𝐶/𝛼]/𝛿].
For a word-splice root with shell word 𝐵, ordinary substitution leaves the shell unchanged and the body induction hypothesis supplies the premise of the same root rule. Stage substitution changes its shell word to 𝐵[𝐶/𝛼]. If this word is nonempty, apply the word-splice rule to the body induction hypothesis. If it is empty, both shells erase by definition and that induction hypothesis is already the required conclusion. A primitive quotation, escape, or CSP congruence whose label is 𝛼 expands to a shell indexed by 𝐶; induction on the length of 𝐶 rebuilds the required single congruence derivation. The other constructor congruences rebuild directly. These cases exhaust the three root rules and the seven congruence schemas. ◻
Proof. Define the complete development 𝑢⋆ recursively. A term has at most one outer word-splice shell: reading its consecutive outer escape labels and then the immediately following quotation labels determines the nonempty word 𝐵. At that shell and at the other two root-redex shapes set ((𝜆𝑥.𝑢)𝑣)⋆=𝑢⋆[𝑣⋆/𝑥],(𝖾𝐵(𝗊𝐵(𝑢)))⋆=𝑢⋆(𝐵≠𝜀),((Λ𝛼.𝑢)𝐶)⋆=𝑢⋆[𝐶/𝛼], and otherwise rebuild the outer constructor from the complete developments of its term children.
First prove 𝑢⇒𝑤𝑢⋆ by structural induction. At a root redex, apply the corresponding word-parallel root rule to the induction hypotheses for its term children. Otherwise apply congruence. Next induct on 𝑢⇒𝑤𝑣. The root cases use lemma 130.8; the word-splice case uses the induction hypothesis for its body. A congruence derivation either rebuilds a nonredex constructor or retains one of the three root shapes. Ordinary beta and stage beta then use their root rules on the induction hypotheses for the children.
The remaining overlap is a congruence derivation from an outer shell 𝖾𝐵(𝗊𝐵(𝑢)). A congruence derivation cannot contract the outermost escape. Induction on |𝐵| therefore gives exactly two possibilities. Either every shell constructor remains, or an inner word-splice step removes a prefix of 𝐵. In both cases the reduct has the form 𝖾𝐶(𝗊𝐶(𝑣)),𝐶≠𝜀,𝑢⇒𝑤𝑣, where 𝐶 is respectively 𝐵 or the unique nonempty suffix left after the contracted prefix. For 𝐵=𝛽𝛾, contracting the inner 𝛽-shell leaves 𝖾𝛾(𝗊𝛾(𝑣)). The induction hypothesis gives 𝑣⇒𝑤𝑢⋆, and the word-splice root rule sends the retained 𝐶-shell to 𝑢⋆ in one step. This treats the congruence-versus-generalized-root overlap. Thus the induction proves the triangle property 𝑢⇒𝑤𝑣⟹𝑣⇒𝑤𝑢⋆. Both reducts in the statement therefore reduce to 𝑢⋆. ◻
Proof of Proposition 130.10 — Confluence of annotation-free reduction
Proof. Every ⟶a step is a word-parallel step. Conversely, induction on a word-parallel derivation expands it to ⟶a∗: congruence interleaves the finite child sequences; ordinary and stage beta contribute one root contraction after the child sequences; and a word-splice root indexed by 𝐵 contributes exactly |𝐵| primitive splice contractions after the body sequence. By lemma 130.9, the word-parallel relation has the diamond property. The two inclusions imply (⟶a)∗=(⇒𝑤)∗. Induction on the length of one word-parallel path, with an inner induction that moves its first step across the other path one diamond at a time, proves confluence of its reflexive-transitive closure. The displayed equality therefore gives confluence of ⟶a. ◻
In the inversion-stable fragment, suppose Γ⊢𝑀:𝜏@𝐴, 𝑀⟶∗𝑀′, and 𝑀⟶∗𝑀″. There are terms 𝑁′,𝑁″ and an annotation-free term 𝑢 such that 𝑀′⟶∗𝑁′,𝑀″⟶∗𝑁″,⌊𝑁′⌋a=𝑢=⌊𝑁″⌋a. No claim that 𝑁′=𝑁″ is made.
Proof of Theorem 130.11 — Confluence modulo binder annotations
Proof. Structural induction on terms and on the displayed full contexts gives both directions needed for lifting: 𝑃⟶𝑄⟹⌊𝑃⌋a⟶a⌊𝑄⌋a,⌊𝑃⌋a⟶a𝑢⟹∃𝑄.𝑃⟶𝑄∧⌊𝑄⌋a=𝑢. For ordinary beta these statements use ⌊𝑃[𝑄/𝑥]⌋a=⌊𝑃⌋a[⌊𝑄⌋a/𝑥]; for stage beta they use the exact equation ⌊𝑃[𝐵/𝛼]⌋a=⌊𝑃⌋a[𝐵/𝛼], where 𝐵 is the substituted stage word. Splice is homomorphic. No annotation case occurs because neither relation reduces there.
Project the two reductions from 𝑀 to the annotation-free relation. By proposition 130.10, their erasures have a common target 𝑢. Lift the two joining sequences back one step at a time. The lifted endpoints are the required 𝑁′ and 𝑁″. The counterpeak of proposition 130.4 shows why the conclusion cannot in general be strengthened to 𝑁′=𝑁″. ◻
If two full normal forms are reachable from one well-typed term in the inversion-stable fragment, their binder-annotation erasures are alpha-equivalent.
In the inversion-stable fragment, suppose Γ⊢𝜏≡𝜎::∗@𝐴. If either endpoint has outer constructor Π, ▹𝛼, or ∀, then the other endpoint has the same outer constructor. In the code case the stage label is the same 𝛼.
Proof of Lemma 130.13 — Type-constructor head separation
Proof. Prove both orientations simultaneously by induction on the type-equivalence derivation. Rules MD-QT-Pi, MD-QT-Code, and MD-QT-Forall preserve the displayed outer constructor, and MD-QT-Refl preserves it syntactically. Rule MD-QT-App has a type application at both endpoints, so none of the three hypotheses can hold in that case. Symmetry exchanges the two induction statements. In a transitivity derivation, the first induction hypothesis gives the same head for the middle type and the second gives that head for the final type. The inversion-stable fragment has no MD-QT-CSP case. These are all type-equivalence rules. ◻
Proof. Inspect the four productions of 𝑣𝜀. A neutral constant-headed spine gives the stated neutral alternative. In the other three productions, invert trailing uses of MD-Conv. The first non-conversion rule is respectively MD-Abs, MD-Quote, or MD-SAbs, so its result type is headed respectively by Π, ▹𝛽, or ∀. Every trailing conversion preserves that head by lemma 130.13; in the code case it also preserves 𝛽. Hence exactly the production named in each clause can remain besides the neutral alternative. The empty-stage context hypothesis excludes a variable head through the exact-stage premise of MD-Var. ◻
In the inversion-stable fragment, suppose Γ has no variable declared at stage 𝜀 and Γ⊢𝑀:𝜏@𝐴. Write 𝑉𝐴 for the grammar 𝑣𝐴 above. Either 𝑀∈𝑉𝐴, or there are a unique redex stage 𝐷∈{𝜀}∪{𝛼∣𝛼isastagevariable}, a unique context 𝐸𝐴𝐷, and a unique redex 𝑅𝐷 such that 𝑀=𝐸𝐴𝐷[𝑅𝐷]. The stage word 𝐶 in a stage-beta redex is unrestricted.
Proof of Theorem 130.15 — Unique staged decomposition
Proof. Induct on the final typing rule. The induction hypothesis includes uniqueness for each premise to which staged evaluation descends.
For MD-Const, the term belongs to ℎ𝐴. In MD-Var, the exact stage premise contradicts the context hypothesis when 𝐴=𝜀; at a nonempty stage the variable belongs to ℎ𝐴.
For MD-Abs, an abstraction at 𝜀 is a value because its body is not selected there. At a nonempty stage, apply the induction hypothesis to the body under Γ,𝑥:𝜏@𝐴. The added declaration is not at 𝜀. A body value gives the abstraction-value production; a body decomposition is lifted by the unique 𝜆𝑥:𝜏.𝐸𝐴𝐷 context production.
For MD-App, first apply the induction hypothesis to the function. Its decomposition lifts uniquely to 𝐸𝐴𝐷𝑁. If the function is a value, apply the induction hypothesis to the argument; its decomposition lifts uniquely to 𝑣𝐴𝐸𝐴𝐷. If both are values and 𝐴≠𝜀, the production 𝑣𝐴𝑣𝐴 makes the whole application a value. If 𝐴=𝜀, the function has dependent-product type, so clause 1 of lemma 130.14 leaves two cases. A lambda head gives the unique ordinary-beta redex; a head in ℎ𝜀 extends uniquely to the final spine ℎ𝜀𝑣𝜀. Quotation and stage- abstraction heads are excluded by the cited lemma.
For MD-Quote, apply the induction hypothesis to its premise at 𝐴𝛼. A body value gives ⟨𝑣𝐴𝛼⟩𝛼; a body decomposition lifts uniquely through ⟨𝐸𝐴𝛼𝐷⟩𝛼.
For MD-Escape, write the conclusion stage as 𝐴𝛼 and apply the induction hypothesis to the operand at 𝐴. An operand decomposition lifts through ∼𝛼𝐸𝐴𝐷. If the operand is a value and 𝐴≠𝜀, the production ∼𝛼𝑣𝐴∈𝑉𝐴𝛼 applies. If 𝐴=𝜀, the operand has code type. Clause 2 of lemma 130.14 says that it is either ⟨𝑣𝛼⟩𝛼, which exposes the unique splice redex at stage 𝛼, or ℎ𝜀, which gives the final neutral ∼𝛼ℎ𝜀∈ℎ𝛼. Ordinary and stage abstractions are excluded by the same clause.
For MD-SAbs, apply the induction hypothesis to the body at 𝐴. A body value gives Λ𝛼.𝑣𝐴; a body decomposition lifts through the unique Λ𝛼.𝐸𝐴𝐷 production. For MD-SApp, first decompose its function. A decomposition lifts through 𝐸𝐴𝐷𝐶. If the function is a value and 𝐴≠𝜀, the production 𝑣𝐴𝐶 gives a value. If 𝐴=𝜀, the function has stage-quantifier type, so clause 3 of lemma 130.14 leaves a Λ-head, which gives the unique stage-beta redex for the unrestricted word 𝐶, or a neutral head, which extends to ℎ𝜀𝐶. Lambda and quotation heads are excluded by the cited lemma.
For MD-CSP, decompose its premise at 𝐴. A value gives %𝛼𝑣𝐴∈𝑉𝐴𝛼; a decomposition lifts through the unique %𝛼𝐸𝐴𝐷 production. A trailing MD-Conv changes neither term nor stage and therefore reuses the induction result for its term premise. These cases cover constants, variables, and all seven term constructors, plus conversion.
At each binary constructor the context grammar first selects the left premise unless it is a value and then selects the right premise; the two choices are disjoint. The remaining context productions have distinct outer constructors. At an empty-stage root, lemma 130.14 makes the redex-head and neutral-head cases disjoint, and the three redex schemas have distinct outer shapes. Combining these syntactic facts with uniqueness in the induction hypotheses proves uniqueness of 𝐷, 𝐸𝐴𝐷, and 𝑅𝐷. ◻
Under the hypotheses of theorem 130.15, either 𝑀∈𝑉𝐴 or there exists 𝑁 with 𝑀⟶𝑠𝑁. Consequently a closed, well-typed staged evaluation never reaches a nonvalue with no staged step.
Proof of Corollary 130.16 — Staged progress and type safety
Proof. Apply theorem 130.15. In its second alternative, the displayed staged rule for the unique redex gives 𝑁. Preservation from theorem 130.5 retains the hypothesis after every step, so a finite evaluation cannot end at an untyped stuck term. ◻
★★☆ Prove the MD-SApp beta case of theorem 130.5, including the stage-word annotation and freshness renaming. Then show why omitting stage substitution from the result type makes the conclusion ill formed.
★★☆ In the inversion-stable fragment, let one full-reduction step contract an outer stage-beta redex and a second step contract a redex strictly inside its body. Draw the one-step peak. Use stage-substitution compatibility to construct a common reduct by zero or more steps, naming every copied or erased residual redex. Repeat for an outer splice and an inner ordinary-beta redex.
The published rules are source-bounded to Kawata–Igarashi’s pure 𝜆𝖬𝖣[KI19b]. The theorems in this chapter are instead local theorems about the corrected card introduced above. That card deletes published rule MD-QT-CSP, requires the body-formation premise in code-head inversion, and extends the published staged-value grammar by constant-headed spines. Its full reduction is explicitly term-compatible and freezes binder annotations; exact syntactic confluence is replaced by theorem 130.11 after the counterexample proposition 130.4. The published proofs supply named proof architectures and comparison points; none is cited as an exact-signature theorem for the corrected card. There is no general inference procedure, reference semantics, or compiler-correctness theorem attached to either card. Unrestricted CSP for references can preserve a dead cell; adding effects also invalidates the annotation-free reduction permutations used by theorem 130.11. MetaOCaml, multilevel contextual type theory, Mœbius, and Cocon have separate contexts and observations; a quotation glyph is not a translation. The boundaries are concrete on the open-code judgment 𝑥:𝜏@𝛼⊢⟨𝑥⟩𝛽.
MetaML.
A stage-indexed environment may admit CSP for selected values, but a persisted reference gives future code a cell whose allocation stage has ended; 𝜆𝖬𝖣𝗂𝗌 has neither stores nor that rule.
Multilevel contextual type theory.
Open code carries an explicit environment classifier or contextual type recording 𝑥; the 𝜆𝖬𝖣𝗂𝗌 card records availability by @𝐴 and supplies no contextual-code elimination.
Mœbius.
Type and term contexts are layered and code may abstract over context variables; no such context abstraction appears in 𝜆𝖬𝖣𝗂𝗌.
Cocon.
Contextual objects and LF substitutions make the open context an explicit index. That supports hereditary substitution judgments absent here and does not validate MD-CSP for effects.
These four cards vary the representation of the open context, so none supplies a translation theorem for the displayed example.
[4]
Suggested first pass.
None of these problems is a prerequisite for a later chapter. Begin with exercise 130.4, then complete exercise 130.6.
★★☆ Type a generator for a two-element vector whose result type contains the literal index two. Calculate staged evaluation to a code value and verify the body type at the extended stage.
★★★ Extend the empty-stage language with 𝖱𝖾𝖿𝖭𝖺𝗍, locations ℓ, allocation 𝗇𝖾𝗐𝑛, and dereference !ℓ. A store is a finite map from locations to naturals; allocation chooses the least unused location. A generation boundary evaluates its generator, returns the generated code, and then discards every location allocated during that generation. Add unrestricted CSP for locations. Generate code for dereferencing a freshly allocated cell, then give two later evaluations: before each, allocate a new cell initialized respectively to zero and one. Calculate both stores and results, and identify the store-independence premise in canonical forms or local confluence that the extension invalidates.
★★★Practical project.dependent-stage-checker Complete project dependent-stage-checker. Implement stage-depth checking for the one-name finite corpus, quotation, escape, CSP, and splice evaluation. Replay the stage-match mutant and connect its changed decision to the MD-Var case above. The named cases print vector-index: Vec(1), quote-dependent: Code(Vec(1)), and raw-crossing: rejected. The finite checker is independent evidence; it does not implement stage abstraction/application or mechanize confluence or strong normalization.