Annotated syntax and derivability for the selected intensional type theory
DefinitionHofmannStreicher1994_SyntaxThe object language has dependent products with judgemental and , dependent sums with their dependent eliminator and rule, identity types with reflexivity and , natural numbers with dependent recursion, and a universe with decoding family . Its contexts, types, terms, judgemental equalities, substitutions and equal substitutions are specified by mutually inductive relations on annotated de Bruijn expressions. Substitution and context conversion are explicit closure rules.
The selected 1994 universe interface has as a type and as a type whenever . It has no small-type code constructors or decoding computation rules, no , and no universe induction. There is no equality reflection, , identity-type , or judgemental -. The ordinary , , identity and natural-number constructors remain available, including large sums over .
The closed expression and the two UIP contexts and conclusions are defined explicitly. The diagonal context is and its conclusion is , retaining the unused . The standard context is with conclusion .
Presentation convention. Expressions carry Church annotations. The application/ presentation of is selected from the fuller Hofmann–Streicher account, Appendix A.4. This is an explicitly fixed rule system for the chosen fragment; it does not assert an annotation comparison with every other presentation of Martin-Löf type theory. These are syntax definitions, with no assumed interpretation or soundness.
import Std
/-!
# Object syntax for the Hofmann--Streicher independence theorem
Source: Hofmann--Streicher, March 21, 1994 author manuscript, §§1--3.
The paper specifies J and refers to Nordström--Petersson--Smith for the remaining
rules. Here the application/eta presentation of Pi is fixed explicitly as in
Hofmann--Streicher, *The groupoid interpretation of type theory*, Appendix A.4.
Sigma has its dependent eliminator and beta rule, with no judgmental eta rule.
The first-universe interface consists exactly of U as a type and El as its
generic family, as established in §2.3 of the 1994 manuscript. There are no
small-type code constructors, decoding computation rules, code for U itself,
or universe induction principle. Ordinary Pi, Sigma, Id/J and N remain full
object-theory constructors, including large Pi/Sigma over U. In particular,
Sigma X:U, El(X) remains a closed type. This source-approved scope retains the
literal 1994 discrete universe and does not import closure operations from the
later isomorphism-valued-universe construction. Binary sums and other additional
type formers are outside the explicitly selected fragment.
All object expressions, including object identity proofs, are data in `Type`.
The judgment `TermEq` denotes the object's judgmental equality; it is not an
object identity type and it has no equality-reflection constructor.
Contexts list the most recent binder first. A stored binder type is expressed
in the context preceding that binder. The definitions below are syntax only;
there is no semantic-soundness premise in object derivability.
Application, pairing and Sigma elimination explicitly carry their domain A and
family B. Reflexivity explicitly carries its type A. These Church annotations
make the typing data available to an interpretation defined recursively on raw
syntax; the annotations are also renamed, substituted and compared by congruence.
In each occurrence, B binds one variable over the current context. In Sigma
elimination C binds the pair variable, while d binds its two components.
-/
namespace HofmannStreicher1994
/-- Raw de Bruijn syntax. Bodies of Pi, Sigma and lambda bind one variable;
the Sigma eliminator's branch binds two; the J motive binds three and its branch
binds one; the natural-number step binds a number and its induction hypothesis. -/
inductive Expr where
| var : Nat → Expr
| pi : Expr → Expr → Expr
| sigma : Expr → Expr → Expr
| identity : Expr → Expr → Expr → Expr
| nat : Expr
| universe : Expr
| el : Expr → Expr
| lam : Expr → Expr → Expr
| app : Expr → Expr → Expr → Expr → Expr
| pair : Expr → Expr → Expr → Expr → Expr
| sigmaRec : Expr → Expr → Expr → Expr → Expr → Expr
| refl : Expr → Expr → Expr
| idRec : Expr → Expr → Expr → Expr → Expr → Expr → Expr
| zero : Expr
| succ : Expr → Expr
| natRec : Expr → Expr → Expr → Expr → Expr
deriving DecidableEq, Repr
abbrev Context := List Expr
/-- Extend a renaming underneath one binder. -/
def liftRenaming (ρ : Nat → Nat) : Nat → Nat
| 0 => 0
| n + 1 => ρ n + 1
/-- Capture-avoiding simultaneous renaming. -/
def rename (ρ : Nat → Nat) : Expr → Expr
| .var n => .var (ρ n)
| .pi A B => .pi (rename ρ A) (rename (liftRenaming ρ) B)
| .sigma A B => .sigma (rename ρ A) (rename (liftRenaming ρ) B)
| .identity A a b => .identity (rename ρ A) (rename ρ a) (rename ρ b)
| .nat => .nat
| .universe => .universe
| .el a => .el (rename ρ a)
| .lam A b => .lam (rename ρ A) (rename (liftRenaming ρ) b)
| .app A B f a => .app (rename ρ A) (rename (liftRenaming ρ) B)
(rename ρ f) (rename ρ a)
| .pair A B a b => .pair (rename ρ A) (rename (liftRenaming ρ) B)
(rename ρ a) (rename ρ b)
| .sigmaRec A B C d p => .sigmaRec (rename ρ A) (rename (liftRenaming ρ) B)
(rename (liftRenaming ρ) C)
(rename (liftRenaming (liftRenaming ρ)) d) (rename ρ p)
| .refl A a => .refl (rename ρ A) (rename ρ a)
| .idRec A C d a b p => .idRec (rename ρ A)
(rename (liftRenaming (liftRenaming (liftRenaming ρ))) C)
(rename (liftRenaming ρ) d) (rename ρ a) (rename ρ b) (rename ρ p)
| .zero => .zero
| .succ a => .succ (rename ρ a)
| .natRec C z s n => .natRec (rename (liftRenaming ρ) C) (rename ρ z)
(rename (liftRenaming (liftRenaming ρ)) s) (rename ρ n)
/-- Weaken an expression by inserting one new most-recent variable. -/
def weaken (e : Expr) : Expr := rename Nat.succ e
/-- Extend a simultaneous substitution underneath a binder. -/
def liftSubstitution (σ : Nat → Expr) : Nat → Expr
| 0 => .var 0
| n + 1 => weaken (σ n)
/-- Capture-avoiding simultaneous substitution. -/
def substitute (σ : Nat → Expr) : Expr → Expr
| .var n => σ n
| .pi A B => .pi (substitute σ A) (substitute (liftSubstitution σ) B)
| .sigma A B => .sigma (substitute σ A) (substitute (liftSubstitution σ) B)
| .identity A a b => .identity (substitute σ A) (substitute σ a) (substitute σ b)
| .nat => .nat
| .universe => .universe
| .el a => .el (substitute σ a)
| .lam A b => .lam (substitute σ A) (substitute (liftSubstitution σ) b)
| .app A B f a => .app (substitute σ A) (substitute (liftSubstitution σ) B)
(substitute σ f) (substitute σ a)
| .pair A B a b => .pair (substitute σ A) (substitute (liftSubstitution σ) B)
(substitute σ a) (substitute σ b)
| .sigmaRec A B C d p => .sigmaRec (substitute σ A) (substitute (liftSubstitution σ) B)
(substitute (liftSubstitution σ) C)
(substitute (liftSubstitution (liftSubstitution σ)) d) (substitute σ p)
| .refl A a => .refl (substitute σ A) (substitute σ a)
| .idRec A C d a b p => .idRec (substitute σ A)
(substitute (liftSubstitution (liftSubstitution (liftSubstitution σ))) C)
(substitute (liftSubstitution σ) d) (substitute σ a) (substitute σ b) (substitute σ p)
| .zero => .zero
| .succ a => .succ (substitute σ a)
| .natRec C z s n => .natRec (substitute (liftSubstitution σ) C) (substitute σ z)
(substitute (liftSubstitution (liftSubstitution σ)) s) (substitute σ n)
/-- Instantiate the most recent variable, discharging its binder. -/
def instantiate (B a : Expr) : Expr :=
substitute (fun | 0 => a | n + 1 => .var n) B
/-- Instantiate the two most recent variables: index zero receives `b`. -/
def instantiate₂ (C a b : Expr) : Expr :=
substitute (fun | 0 => b | 1 => a | n + 2 => .var n) C
/-- Instantiate three most recent variables: index zero receives `p`. -/
def instantiate₃ (C a b p : Expr) : Expr :=
substitute (fun | 0 => p | 1 => b | 2 => a | n + 3 => .var n) C
/-- The context Γ,x:A,y:A,p:Id_A(x,y), with the appropriate weakenings. -/
def identityContext (Γ : Context) (A : Expr) : Context :=
.identity (weaken (weaken A)) (.var 1) (.var 0) :: weaken A :: A :: Γ
/-- The restriction of a J motive to (x,x,refl x), in context Γ,x:A. -/
def reflexivityMotive (A C : Expr) : Expr :=
substitute (fun | 0 => .refl (weaken A) (.var 0) | 1 => .var 0 | 2 => .var 0
| n + 3 => .var (n + 1)) C
/-- The restriction of a Sigma motive to pair(x,y), in context Γ,x:A,y:B. -/
def pairingMotive (A B C : Expr) : Expr :=
substitute (fun
| 0 => .pair (rename (fun n => n + 2) A)
(rename (liftRenaming (fun n => n + 2)) B) (.var 1) (.var 0)
| n + 1 => .var (n + 2)) C
/-- The natural-recursion successor motive, in context Γ,n:N,h:C(n). -/
def successorMotive (C : Expr) : Expr :=
substitute (fun | 0 => .succ (.var 1) | n + 1 => .var (n + 2)) C
/-! The five judgments and simultaneous substitution are the least relations
closed under the displayed rules. Structural substitution is included explicitly
so that judgmental equality is stable under substitution of equal terms. -/
mutual
/-- Well-formed object contexts. -/
inductive ContextWf : Context → Prop where
| nil : ContextWf []
| cons {Γ A} : ContextWf Γ → TypeWf Γ A → ContextWf (A :: Γ)
/-- Formation of object types (including the large first universe). -/
inductive TypeWf : Context → Expr → Prop where
| pi {Γ A B} : TypeWf Γ A → TypeWf (A :: Γ) B → TypeWf Γ (.pi A B)
| sigma {Γ A B} : TypeWf Γ A → TypeWf (A :: Γ) B → TypeWf Γ (.sigma A B)
| identity {Γ A a b} : TypeWf Γ A → TermWf Γ a A → TermWf Γ b A →
TypeWf Γ (.identity A a b)
| nat {Γ} : ContextWf Γ → TypeWf Γ .nat
| universe {Γ} : ContextWf Γ → TypeWf Γ .universe
| el {Γ a} : TermWf Γ a .universe → TypeWf Γ (.el a)
| subst {Γ Δ A σ} : TypeWf Γ A → SubstitutionWf Γ Δ σ →
TypeWf Δ (substitute σ A)
| context {Γ Δ A} : TypeWf Γ A → ContextEq Γ Δ → TypeWf Δ A
/-- Object term formation. -/
inductive TermWf : Context → Expr → Expr → Prop where
| var {Γ n A} : ContextWf Γ → Γ[n]? = some A →
TermWf Γ (.var n) (rename (fun k => k + n + 1) A)
| lam {Γ A B b} : TypeWf Γ A → TypeWf (A :: Γ) B → TermWf (A :: Γ) b B →
TermWf Γ (.lam A b) (.pi A B)
| app {Γ A B f a} : TypeWf Γ A → TypeWf (A :: Γ) B →
TermWf Γ f (.pi A B) → TermWf Γ a A → TermWf Γ (.app A B f a) (instantiate B a)
| pair {Γ A B a b} : TypeWf Γ A → TypeWf (A :: Γ) B →
TermWf Γ a A → TermWf Γ b (instantiate B a) →
TermWf Γ (.pair A B a b) (.sigma A B)
| sigmaRec {Γ A B C d p} : TypeWf Γ A → TypeWf (A :: Γ) B →
TypeWf (.sigma A B :: Γ) C → TermWf (B :: A :: Γ) d (pairingMotive A B C) →
TermWf Γ p (.sigma A B) → TermWf Γ (.sigmaRec A B C d p) (instantiate C p)
| refl {Γ A a} : TypeWf Γ A → TermWf Γ a A →
TermWf Γ (.refl A a) (.identity A a a)
| idRec {Γ A C d a b p} : TypeWf Γ A → TypeWf (identityContext Γ A) C →
TermWf (A :: Γ) d (reflexivityMotive A C) → TermWf Γ a A → TermWf Γ b A →
TermWf Γ p (.identity A a b) →
TermWf Γ (.idRec A C d a b p) (instantiate₃ C a b p)
| zero {Γ} : ContextWf Γ → TermWf Γ .zero .nat
| succ {Γ n} : TermWf Γ n .nat → TermWf Γ (.succ n) .nat
| natRec {Γ C z s n} : TypeWf (.nat :: Γ) C →
TermWf Γ z (instantiate C .zero) → TermWf (C :: .nat :: Γ) s (successorMotive C) →
TermWf Γ n .nat → TermWf Γ (.natRec C z s n) (instantiate C n)
| conv {Γ a A B} : TermWf Γ a A → TypeEq Γ A B → TermWf Γ a B
| subst {Γ Δ a A σ} : TermWf Γ a A → SubstitutionWf Γ Δ σ →
TermWf Δ (substitute σ a) (substitute σ A)
| context {Γ Δ a A} : TermWf Γ a A → ContextEq Γ Δ → TermWf Δ a A
/-- Judgmental equality of object types. -/
inductive TypeEq : Context → Expr → Expr → Prop where
| refl {Γ A} : TypeWf Γ A → TypeEq Γ A A
| symm {Γ A B} : TypeEq Γ A B → TypeEq Γ B A
| trans {Γ A B C} : TypeEq Γ A B → TypeEq Γ B C → TypeEq Γ A C
| pi {Γ A A' B B'} : TypeEq Γ A A' → TypeEq (A :: Γ) B B' →
TypeEq Γ (.pi A B) (.pi A' B')
| sigma {Γ A A' B B'} : TypeEq Γ A A' → TypeEq (A :: Γ) B B' →
TypeEq Γ (.sigma A B) (.sigma A' B')
| identity {Γ A A' a a' b b'} : TypeEq Γ A A' → TermEq Γ a a' A →
TermEq Γ b b' A → TypeEq Γ (.identity A a b) (.identity A' a' b')
| el {Γ a b} : TermEq Γ a b .universe → TypeEq Γ (.el a) (.el b)
| subst {Γ Δ A B σ} : TypeEq Γ A B → SubstitutionWf Γ Δ σ →
TypeEq Δ (substitute σ A) (substitute σ B)
| substEq {Γ Δ A σ τ} : TypeWf Γ A → SubstitutionEq Γ Δ σ τ →
TypeEq Δ (substitute σ A) (substitute τ A)
| context {Γ Δ A B} : TypeEq Γ A B → ContextEq Γ Δ → TypeEq Δ A B
/-- Judgmental equality of object terms, generated by congruence and beta/eta
rules. There is no reflection of object identity proofs into this judgment. -/
inductive TermEq : Context → Expr → Expr → Expr → Prop where
| refl {Γ a A} : TermWf Γ a A → TermEq Γ a a A
| symm {Γ a b A} : TermEq Γ a b A → TermEq Γ b a A
| trans {Γ a b c A} : TermEq Γ a b A → TermEq Γ b c A → TermEq Γ a c A
| conv {Γ a b A B} : TermEq Γ a b A → TypeEq Γ A B → TermEq Γ a b B
| lam {Γ A A' B b b'} : TypeEq Γ A A' → TypeWf (A :: Γ) B →
TermEq (A :: Γ) b b' B → TermEq Γ (.lam A b) (.lam A' b') (.pi A B)
| app {Γ A A' B B' f f' a a'} : TypeEq Γ A A' → TypeEq (A :: Γ) B B' →
TermEq Γ f f' (.pi A B) → TermEq Γ a a' A →
TermEq Γ (.app A B f a) (.app A' B' f' a') (instantiate B a)
| pair {Γ A A' B B' a a' b b'} : TypeEq Γ A A' → TypeEq (A :: Γ) B B' →
TermEq Γ a a' A → TermEq Γ b b' (instantiate B a) →
TermEq Γ (.pair A B a b) (.pair A' B' a' b') (.sigma A B)
| sigmaRec {Γ A A' B B' C C' d d' p p'} : TypeEq Γ A A' → TypeEq (A :: Γ) B B' →
TypeEq (.sigma A B :: Γ) C C' →
TermEq (B :: A :: Γ) d d' (pairingMotive A B C) →
TermEq Γ p p' (.sigma A B) →
TermEq Γ (.sigmaRec A B C d p) (.sigmaRec A' B' C' d' p') (instantiate C p)
| reflCongr {Γ A A' a a'} : TypeEq Γ A A' → TermEq Γ a a' A →
TermEq Γ (.refl A a) (.refl A' a') (.identity A a a)
| idRec {Γ A A' C C' d d' a a' b b' p p'} : TypeEq Γ A A' →
TypeEq (identityContext Γ A) C C' →
TermEq (A :: Γ) d d' (reflexivityMotive A C) → TermEq Γ a a' A →
TermEq Γ b b' A → TermEq Γ p p' (.identity A a b) →
TermEq Γ (.idRec A C d a b p) (.idRec A' C' d' a' b' p') (instantiate₃ C a b p)
| succ {Γ n n'} : TermEq Γ n n' .nat → TermEq Γ (.succ n) (.succ n') .nat
| natRec {Γ C C' z z' s s' n n'} : TypeEq (.nat :: Γ) C C' →
TermEq Γ z z' (instantiate C .zero) →
TermEq (C :: .nat :: Γ) s s' (successorMotive C) → TermEq Γ n n' .nat →
TermEq Γ (.natRec C z s n) (.natRec C' z' s' n') (instantiate C n)
| betaPi {Γ A B b a} : TypeWf Γ A → TypeWf (A :: Γ) B →
TermWf (A :: Γ) b B → TermWf Γ a A →
TermEq Γ (.app A B (.lam A b) a) (instantiate b a) (instantiate B a)
| etaPi {Γ A B f} : TypeWf Γ A → TypeWf (A :: Γ) B → TermWf Γ f (.pi A B) →
TermEq Γ (.lam A (.app (weaken A) (rename (liftRenaming Nat.succ) B) (weaken f) (.var 0))) f (.pi A B)
| betaSigma {Γ A B C d a b} : TypeWf Γ A → TypeWf (A :: Γ) B →
TypeWf (.sigma A B :: Γ) C → TermWf (B :: A :: Γ) d (pairingMotive A B C) →
TermWf Γ a A → TermWf Γ b (instantiate B a) →
TermEq Γ (.sigmaRec A B C d (.pair A B a b)) (instantiate₂ d a b)
(instantiate C (.pair A B a b))
| betaId {Γ A C d a} : TypeWf Γ A → TypeWf (identityContext Γ A) C →
TermWf (A :: Γ) d (reflexivityMotive A C) → TermWf Γ a A →
TermEq Γ (.idRec A C d a a (.refl A a)) (instantiate d a)
(instantiate₃ C a a (.refl A a))
| betaNatZero {Γ C z s} : TypeWf (.nat :: Γ) C →
TermWf Γ z (instantiate C .zero) → TermWf (C :: .nat :: Γ) s (successorMotive C) →
TermEq Γ (.natRec C z s .zero) z (instantiate C .zero)
| betaNatSucc {Γ C z s n} : TypeWf (.nat :: Γ) C →
TermWf Γ z (instantiate C .zero) → TermWf (C :: .nat :: Γ) s (successorMotive C) →
TermWf Γ n .nat →
TermEq Γ (.natRec C z s (.succ n)) (instantiate₂ s n (.natRec C z s n))
(instantiate C (.succ n))
| subst {Γ Δ a b A σ} : TermEq Γ a b A → SubstitutionWf Γ Δ σ →
TermEq Δ (substitute σ a) (substitute σ b) (substitute σ A)
| substEq {Γ Δ a A σ τ} : TermWf Γ a A → SubstitutionEq Γ Δ σ τ →
TermEq Δ (substitute σ a) (substitute τ a) (substitute σ A)
| context {Γ Δ a b A} : TermEq Γ a b A → ContextEq Γ Δ → TermEq Δ a b A
/-- Pointwise well-typed simultaneous substitutions, from Γ into Δ. -/
inductive SubstitutionWf : Context → Context → (Nat → Expr) → Prop where
| mk {Γ Δ σ} : ContextWf Γ → ContextWf Δ →
(∀ n A, Γ[n]? = some A →
TermWf Δ (σ n) (substitute σ (rename (fun k => k + n + 1) A))) →
SubstitutionWf Γ Δ σ
/-- Pointwise equal simultaneous substitutions. -/
inductive SubstitutionEq : Context → Context → (Nat → Expr) → (Nat → Expr) → Prop where
| mk {Γ Δ σ τ} : SubstitutionWf Γ Δ σ → SubstitutionWf Γ Δ τ →
(∀ n A, Γ[n]? = some A →
TermEq Δ (σ n) (τ n) (substitute σ (rename (fun k => k + n + 1) A))) →
SubstitutionEq Γ Δ σ τ
/-- Context conversion by judgmentally equal binder types. -/
inductive ContextEq : Context → Context → Prop where
| nil : ContextEq [] []
| cons {Γ Δ A B} : ContextEq Γ Δ → TypeEq Γ A B → ContextEq (A :: Γ) (B :: Δ)
end
/-- The closed type used in the 1994 proof: Σ X:U, El X. -/
def counterexampleType : Expr := .sigma .universe (.el (.var 0))
/-- The exact printed context x:A,p:Id_A(x,x),q:Id_A(x,x); q is intentionally
retained even though it is unused in the printed conclusion. -/
def diagonalContext (A : Expr) : Context :=
.identity (weaken (weaken A)) (.var 1) (.var 1) ::
.identity (weaken A) (.var 0) (.var 0) :: A :: []
/-- The exact printed conclusion Id_{Id_A(x,x)}(p,refl_A(x)), in the context
with x at index 2, p at index 1 and q at index 0. -/
def diagonalConclusion (A : Expr) : Expr :=
.identity (.identity (rename (fun n => n + 3) A) (.var 2) (.var 2))
(.var 1) (.refl (rename (fun n => n + 3) A) (.var 2))
/-- The standard UIP context x:A,y:A,p:Id_A(x,y),q:Id_A(x,y). -/
def uipContext (A : Expr) : Context :=
.identity (rename (fun n => n + 3) A) (.var 2) (.var 1) ::
.identity (weaken (weaken A)) (.var 1) (.var 0) :: weaken A :: A :: []
/-- The standard UIP conclusion Id_{Id_A(x,y)}(p,q). -/
def uipConclusion (A : Expr) : Expr :=
.identity (.identity (rename (fun n => n + 4) A) (.var 3) (.var 2)) (.var 1) (.var 0)
end HofmannStreicher1994
Read-back
What the Lean code literally says, in plain math · GPT-6 (Codex independent blind auditor)
Expr. The raw expressions form a freely generated inductive set with the following sixteen constructors: a variable for each natural number , including ; two-argument expressions and ; a three-argument expression ; constants and ; a one-argument expression ; a two-argument abstraction ; four-argument application and pairing expressions and ; a five-argument expression ; a two-argument expression ; a six-argument expression ; a constant ; a one-argument expression ; and a four-argument expression . Every argument other than a variable's natural-number index is another raw expression. In particular, the type annotations in application and pairing, and the annotations and motives in the recursors, are actual fields of the syntax. Types and terms share this one set; the constructors themselves impose no scope, typing, closedness, or context requirement and identify no distinct expression trees. Binder behavior is specified by the separate renaming and substitution operations, rather than by the constructor arities alone. Structural equality is decidable, and a textual representation operation is generated.
Context. A context is a finite list of raw expressions, with no well-formedness condition built into this abbreviation. The empty list is included. The other definitions use the head of the list as its newest entry, and context lookup numbers positions from at the head; an entry's expression is stored relative to the older entries in its tail.
liftRenaming. For every total function , its lifted function is defined by and for every . Thus the newly bound index is fixed and the old indices are renamed after removing, then restoring, their one-index offset. No injectivity, surjectivity, monotonicity, finite-support, or context condition is imposed on .
rename. For any total function , renaming is a total recursively defined map on raw expressions. Write , , and for successive such lifts. It sends to , fixes , and otherwise preserves the outer constructor while renaming its arguments as follows: in and it uses on and on ; in it uses on all three arguments; in it uses on ; in it uses on and on ; in and it uses only on and on the other arguments; in it uses respectively ; in it uses on both arguments; in it uses respectively ; in it uses on ; and in it uses respectively . Thus the motive of is treated as lying under three binders, its branch under one, the sum branch under two, and the natural-number step under two. These equations apply to every raw expression, including expressions that have out-of-range variable indices or cannot be assigned any type.
weaken. For every raw expression , weakening is the expression obtained by the renaming . It increases every free de Bruijn index by one, while renaming under each of the constructor-specific binders uses lifted maps fixing the locally bound indices: one binder in the second arguments of , in the family annotation of application and pairing, in the sum motive, in the identity branch, and in the natural-number motive; two in the sum branch and natural-number step; and three in the identity motive. This is a total operation on raw expressions and does not require or supply a context or a typing proof.
liftSubstitution. For every total assignment , its lifted assignment is defined by and for every natural number . Here weakening renames free indices by , preserving locally bound indices according to the expression constructors. Thus the fresh bound variable is retained, and every expression inserted for an older variable is shifted once. The assignment may have arbitrary values at all indices; it need not be a well-formed substitution between contexts.
substitute. For every total assignment , simultaneous substitution is a total recursive map on raw expressions. Define its lift by and , where renaming preserves constructor-local binders, and write for repeated lifts. The operation sends to , fixes , and preserves each other outer constructor with these assignments on its arguments: in and ; on all arguments of ; in ; in ; in both application and pairing ; in ; in ; in ; in ; and in . Expressions inserted at variables are returned as assigned, rather than recursively subjected again to the same assignment. No scope or typing conditions are part of this operation.
instantiate. For arbitrary raw expressions and , the result is the simultaneous, binder-preserving substitution into whose assignment sends index to and every index to , for all natural numbers . Equivalently, at the outer level it replaces the newest free variable by and removes its slot from all older indices; under local binders the substitution is lifted, keeping their bound variables and shifting inserted expressions. The substitution is simultaneous, so it does not further instantiate itself. The definition applies even if does not mention index , if has free variables, or if either expression is ill scoped or ill typed.
instantiate₂. For arbitrary raw expressions , the result is the simultaneous, binder-preserving substitution into assigning , , and for every natural number . Thus the most recent of the two removed free-variable slots is filled by , and the next by ; older free indices are lowered by two. The inserted are not substituted into one another. Lifting under local binders preserves their variables and shifts the inserted expressions, and no typing, scope, or occurrence assumptions are imposed.
instantiate₃. For arbitrary raw expressions , the result is the simultaneous, binder-preserving substitution into assigning , , , and for every natural number . Thus three newest free-variable slots are removed, in the order from newest to oldest, and older free indices are lowered by three. The inserted expressions are not recursively substituted into one another. Local binders use lifted substitutions, and the operation has no scope, well-formedness, or typing prerequisites.
identityContext. For every finite expression-list context and every raw expression , the result is the list , where renames each free index to while preserving locally bound variables, and the head is the newest entry. Thus the three new entries, in order of extension from , are , its one-step weakening, and an identity expression whose carrier is the twice-weakened and whose endpoints are respectively the older and newer of those two variables. In the final context those three added variables have indices , respectively, with the identity witness newest. The definition does not assume that or is well formed and does not assert well-formedness of the resulting context.
reflexivityMotive. For arbitrary raw expressions , this definition substitutes into with the simultaneous assignment , , , and for every natural number , where raises free indices by one and preserves locally bound variables. Substitution is lifted beneath local binders. It therefore replaces the newest three free-variable slots by a reflexivity expression and two occurrences of one variable, retains one new free-variable slot, and moves each older slot accordingly; the reflexivity constructor contains the explicit carrier annotation . There is no premise relating to , no requirement that is a type over an identity context, and no typing conclusion in this declaration.
pairingMotive. For arbitrary raw expressions , let be renamed by , and let be renamed by the function fixing and sending to . The definition substitutes into with the simultaneous assignment and for every natural number , lifting the assignment beneath all local binders. Thus the newest free-variable slot of is replaced by an explicitly annotated pair using variables and , and each older free-variable slot is relocated past these two variables. Both the carrier and family annotations of the pair are transformed, with the family's index preserved by its renaming. The definition requires no context, typing, or well-formedness evidence.
successorMotive. For every raw expression , the result is its simultaneous substitution by the assignment and for every natural number , lifted beneath the local binders of . Thus the newest free-variable slot is replaced by the successor of variable , and older free-variable slots move past two retained slots. The replacement explicitly uses index , not index ; index is not used in any of the expressions supplied by this assignment. No type or context condition is imposed on .
ContextWf. This is a proposition on finite lists of raw expressions, generated mutually with the seven other judgement relations in the bundle. Its only generating rules declare the empty context well formed, and, for every context and raw expression , declare well formed when is well formed and the type-formation judgement holds. The head is checked in the tail , before the new variable is added; arbitrary expression lists are not admitted without such a finite derivation.
TypeWf. For every finite expression-list context and raw expression , the proposition written is generated mutually with the other judgement relations by exactly these rules, universally quantified over the contexts, expressions, and assignments appearing in them: from and , infer both and ; from and the term judgements , , infer ; if is a well-formed context, infer and ; from , infer ; from and a well-formed substitution from to a context , infer ; and from and the generated context equality , infer with the same raw expression . Here is simultaneous substitution, replacing by the arbitrary total assignment and lifting it under the syntax's binders; well-formedness of this substitution requires well-formed and, for every index with stored entry , the judgement . Context equality is generated from equality of two empty lists and the rule extending to when the type-equality judgement holds in the left tail. These are derivability relations, not identifications of raw expression trees. There is no additional primitive type-formation rule for a bare variable, or rule here making , , , or identity expressions into terms of .
TermWf. For contexts that are finite lists of raw expressions and arbitrary raw expressions in every expression position below, write for this mutually generated term-formation proposition, for type formation, and for generated type equality. To specify its rules, let be the raw variable of index , let be the renaming of free indices by , preserving bound variables, and let denote simultaneous substitution and denote , always lifted under local binders. Define the displayed auxiliary expressions explicitly by ; with , , , and ; with , , and ; and with and . All numerical indices range over , and all these substitutions preserve local binders. The generating rules are: (i) if is well formed and its index- lookup succeeds with stored expression , then ; (ii) if , , and , then ; (iii) under and , from and infer ; (iv) under the same two type-formation premises, from and infer ; (v) from , , , , and , infer ; (vi) from and , infer ; (vii) from , , , , , and , infer ; (viii) if is well formed, then ; (ix) from , infer ; (x) from , , , and , infer , where in the step context the induction-result slot is and the natural-number slot is ; (xi) from and , infer ; (xii) from and a total substitution well formed from to , infer , where well-formedness means both contexts are well formed and for each successful lookup ; and (xiii) from and generated context equality , infer . That context equality starts with two empty lists and extends equal tails using type equality of their new entries in the left tail. The variable rule excludes every out-of-range index because lookup must succeed; in particular it supplies no variable in the empty context. No direct introduction rule here supplies a universe code.
TypeEq. For finite expression-list contexts and arbitrary raw expressions in all displayed expression positions, write for this generated proposition, distinct from literal equality of expression trees; write for type formation, for term formation, and for generated term equality. Its universally quantified generating rules are: implies ; an equality can be reversed; equalities and in the same compose to there; from and one obtains respectively and ; from , , and one obtains ; from one obtains ; a type equality in can be simultaneously substituted by any well-formed total assignment from to , producing ; from and equal substitutions from to , one obtains ; and any transfers unchanged to given generated context equality . Here substitution is simultaneous and lifted under local binders. For a stored source entry , put ; a substitution is well formed when both contexts are well formed and for each successful lookup, and two substitutions are equal when each is well formed and at every such entry. Context equality starts with the empty lists and extends equal tails by entries when . In the product and sum congruence rules both family expressions are compared in the context extended by the unprimed ; in identity congruence both endpoint comparisons use the unprimed carrier . There are no further primitive type-equality rules in this declaration.
TermEq. For contexts that are finite expression lists and arbitrary raw expressions wherever they occur below, this mutually generated relation is written ; , , and denote the other term-formation, type-formation, and type-equality relations. Define the notation used here explicitly: renames free indices by while preserving bound indices; , , and are simultaneous, binder-preserving substitutions with assignments respectively , , and ; ; substitutes into the assignment , , where and ; substitutes , , , and into ; and substitutes and into . Every substitution just specified is lifted under local binders, and every numerical index is a natural number. The full generating rules, with all displayed arguments universally quantified, are these: (i) gives ; (ii) gives ; (iii) and give ; (iv) and give ; (v) , , and give ; (vi) , , , and give ; (vii) , , , and give ; (viii) , , , , and give ; (ix) and give ; (x) , , , , , and give ; (xi) gives ; (xii) , , , and give ; (xiii) if , , , and , then ; (xiv) if , , and , then , where and ; (xv) if , , , , , and , then ; (xvi) if , , , and , then ; (xvii) if , , and , then ; (xviii) under those same three premises and the additional premise , one has ; (xix) from and a well-formed total substitution from to , infer ; (xx) from and equal total substitutions from to , infer ; and (xxi) from and generated context equality , infer . In (xix) and (xx), substitution is simultaneous and lifted under binders; for each stored entry , its full source-context type is , substitution well-formedness requires well-formed contexts and , and substitution equality requires both assignments well formed and at each such index. Context equality is the relation generated by equal empty lists and extension of equal tails by entries equal as types in the left tail. All congruence rules above compare components in the contexts and types formed from the unprimed annotations; their result types are likewise the displayed unprimed ones, including in (xx). These are precisely generating rules for a proposition: the declaration supplies no additional primitive sum or natural-number eta rule, identity-proof uniqueness rule, or rule reflecting an inhabitant of an identity expression into this equality judgement.
SubstitutionWf. For arbitrary finite expression-list contexts and a total function , this proposition holds exactly when and are well-formed contexts and, for every natural number and every raw expression , successful zero-based lookup of at position in implies the term-formation judgement . Here the renaming raises the free indices of the stored entry by to place its type in the full source context, and simultaneous substitution replaces free variables according to , lifting under each local binder. The first context is the source whose variables are assigned expressions in the second context. The function is still defined on every natural number, but no component condition is imposed where source lookup fails; in particular, for an empty source the component condition is vacuous, so every total assignment is admitted whenever the target is well formed. There is no requirement that the source and target have the same length.
SubstitutionEq. For arbitrary finite expression-list contexts and total functions , this proposition holds exactly when both assignments are well-formed substitutions from to and, for every natural number and every raw expression occurring at source position , the judgement holds. Explicitly, well-formedness requires well-formed and, at every such source entry, term formation of at and of at ; the component equality itself is stated at the type obtained with . Renaming shifts the stored entry into the full source context, and substitution is simultaneous and lifted under local binders. Equality here is the generated term-equality judgement, rather than literal equality of the two expressions or equality of the total functions. Values at indices beyond the source list are unconstrained and need not agree; for empty source, any two total assignments are equal in this sense whenever the target context is well formed.
ContextEq. For finite lists of raw expressions, this proposition is generated by equality of the empty context with itself and the following universally quantified extension rule: for contexts and raw expressions , if and the type-equality judgement holds, then . Thus the new entries are compared in the left tail , even though the right entry is placed over the right tail . No separate well-formedness premise or comparison in is included in this constructor. Only lists of equal length can be generated as related, and the declaration has no additional primitive symmetry, transitivity, or arbitrary-list reflexivity constructor.
counterexampleType. This is the single raw expression , where is the universe-expression constructor, is the one-argument decoding constructor, and index in the second argument of denotes the variable bound by that sum constructor's family position. It is a dependent-sum expression whose family is the decoding expression applied to that variable. This definition has no parameters or hypotheses and asserts neither that the expression is a well-formed type nor that it has an inhabitant or any counterexample property.
diagonalContext. For every raw expression , the result is the three-entry context , written newest entry first, where raises every free index by while preserving local binders. Starting with the empty tail, the entries add a variable of stored type , then an identity expression from that variable to itself, then another identity expression from that same older variable to itself. In the complete context the original variable has index , the first identity-witness slot index , and the second identity-witness slot index ; each stored identity expression is written relative to its own tail. There is no requirement that be closed or well formed, and the definition supplies no proof that the resulting list is a well-formed context.
diagonalConclusion. For every raw expression , the result is , where renames free indices by while preserving locally bound indices, is the three-argument identity-expression constructor, and carries the displayed carrier annotation. Thus its outer carrier is the identity expression from variable to itself, and its outer endpoints are variable and the reflexivity expression at variable . There is no free reference to the surrounding context's slot ; locally bound occurrences of index may remain inside the shifted copies of . No context argument, closedness premise on , type-formation assertion, or inhabitant is part of this definition.
uipContext. For every raw expression , the result is the four-entry context , newest entry first, where raises free de Bruijn indices by and preserves local binders. In extension order from the empty context it adds a variable with stored type , a second variable with stored type , an identity-witness slot from the older of these variables to the newer, and a second identity-witness slot with the same two endpoints. In the final list the two original variables have indices and , and the first and second identity-witness slots have indices and . The expression defining each entry is written in its own tail context. The parameter may have arbitrary free variables; no closedness or well-formedness requirement, and no proof of context well-formedness, is supplied.
uipConclusion. For every raw expression , the result is , where raises free indices by four while preserving locally bound indices, and is the raw identity-expression constructor. Its carrier is the identity expression from variable to variable , and its endpoints are variables and . The declaration takes no context or well-formedness evidence and imposes no closedness assumption on ; it merely constructs this raw expression and does not assert that it is well formed, inhabited, or derivable as a judgement.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.