Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Annotated syntax and derivability for the selected intensional type theory

Definition
HofmannStreicher1994_Syntax

by kmehltretter82 · Oct 29, 2026 · Mathlib 0df444a (Lean v4.33.1)

category-theorygroupoidsidentity-typestype-theory

The object language has dependent products Π\PiΠ with judgemental β\betaβ and η\etaη, dependent sums Σ\SigmaΣ with their dependent eliminator and β\betaβ rule, identity types with reflexivity and JJJ, natural numbers with dependent recursion, and a universe UUU with decoding family El\mathrm{El}El. 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 UUU as a type and El(X)\mathrm{El}(X)El(X) as a type whenever X:UX:UX:U. It has no small-type code constructors or decoding computation rules, no U:UU:UU:U, and no universe induction. There is no equality reflection, KKK, identity-type η\etaη, or judgemental Σ\SigmaΣ-η\etaη. The ordinary Π\PiΠ, Σ\SigmaΣ, identity and natural-number constructors remain available, including large sums over UUU.

The closed expression A0=ΣX:U.El(X)A_0=\Sigma X:U.\mathrm{El}(X)A0​=ΣX:U.El(X) and the two UIP contexts and conclusions are defined explicitly. The diagonal context is x:A,p,q:IdA(x,x)x:A,p,q:\mathrm{Id}_A(x,x)x:A,p,q:IdA​(x,x) and its conclusion is IdIdA(x,x)(p,reflA(x))\mathrm{Id}_{\mathrm{Id}_A(x,x)}(p,\mathrm{refl}_A(x))IdIdA​(x,x)​(p,reflA​(x)), retaining the unused qqq. The standard context is x,y:A,p,q:IdA(x,y)x,y:A,p,q:\mathrm{Id}_A(x,y)x,y:A,p,q:IdA​(x,y) with conclusion IdIdA(x,y)(p,q)\mathrm{Id}_{\mathrm{Id}_A(x,y)}(p,q)IdIdA​(x,y)​(p,q).

Presentation convention. Expressions carry Church annotations. The application/η\etaη presentation of Π\PiΠ 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.

Definition code
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
Source
Hofmann and Streicher, A Groupoid Model Refutes Uniqueness of Identity Proofs, author manuscript dated 21 March 1994, https://www.dcs.ed.ac.uk/home/mxh/SH.dvi.gz; LICS 1994, https://doi.org/10.1109/LICS.1994.316071. Manuscript Sections 1–3, pp. 1–7; Pi presentation from the fuller account, Appendix A.4. The mission owner selected the restricted 1994 U/El interface on 29 October 2026.
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 vnv_nvn​ for each natural number nnn, including 000; two-argument expressions Π(A,B)\Pi(A,B)Π(A,B) and Σ(A,B)\Sigma(A,B)Σ(A,B); a three-argument expression Id⁡(A,a,b)\operatorname{Id}(A,a,b)Id(A,a,b); constants N\mathsf NN and U\mathsf UU; a one-argument expression El⁡(a)\operatorname{El}(a)El(a); a two-argument abstraction λ(A,b)\lambda(A,b)λ(A,b); four-argument application and pairing expressions App⁡(A,B,f,a)\operatorname{App}(A,B,f,a)App(A,B,f,a) and Pair⁡(A,B,a,b)\operatorname{Pair}(A,B,a,b)Pair(A,B,a,b); a five-argument expression SRec⁡(A,B,C,d,p)\operatorname{SRec}(A,B,C,d,p)SRec(A,B,C,d,p); a two-argument expression Refl⁡(A,a)\operatorname{Refl}(A,a)Refl(A,a); a six-argument expression J⁡(A,C,d,a,b,p)\operatorname{J}(A,C,d,a,b,p)J(A,C,d,a,b,p); a constant 0\mathsf 00; a one-argument expression Suc⁡(a)\operatorname{Suc}(a)Suc(a); and a four-argument expression NRec⁡(C,z,s,n)\operatorname{NRec}(C,z,s,n)NRec(C,z,s,n). Every argument other than a variable's natural-number index is another raw expression. In particular, the type annotations A,BA,BA,B 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 000 at the head; an entry's expression is stored relative to the older entries in its tail.

liftRenaming. For every total function ρ:N→N\rho:\mathbb N\to\mathbb Nρ:N→N, its lifted function ρ+:N→N\rho^+:\mathbb N\to\mathbb Nρ+:N→N is defined by ρ+(0)=0\rho^+(0)=0ρ+(0)=0 and ρ+(n+1)=ρ(n)+1\rho^+(n+1)=\rho(n)+1ρ+(n+1)=ρ(n)+1 for every n∈Nn\in\mathbb Nn∈N. Thus the newly bound index 000 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 ρ\rhoρ.

rename. For any total function ρ:N→N\rho:\mathbb N\to\mathbb Nρ:N→N, renaming is a total recursively defined map RρR_\rhoRρ​ on raw expressions. Write ρ+(0)=0\rho^+(0)=0ρ+(0)=0, ρ+(n+1)=ρ(n)+1\rho^+(n+1)=\rho(n)+1ρ+(n+1)=ρ(n)+1, and ρ+k\rho^{+k}ρ+k for kkk successive such lifts. It sends vnv_nvn​ to vρ(n)v_{\rho(n)}vρ(n)​, fixes N,U,0\mathsf N,\mathsf U,\mathsf 0N,U,0, and otherwise preserves the outer constructor while renaming its arguments as follows: in Π(A,B)\Pi(A,B)Π(A,B) and Σ(A,B)\Sigma(A,B)Σ(A,B) it uses ρ\rhoρ on AAA and ρ+\rho^+ρ+ on BBB; in Id⁡(A,a,b)\operatorname{Id}(A,a,b)Id(A,a,b) it uses ρ\rhoρ on all three arguments; in El⁡(a)\operatorname{El}(a)El(a) it uses ρ\rhoρ on aaa; in λ(A,b)\lambda(A,b)λ(A,b) it uses ρ\rhoρ on AAA and ρ+\rho^+ρ+ on bbb; in App⁡(A,B,f,a)\operatorname{App}(A,B,f,a)App(A,B,f,a) and Pair⁡(A,B,a,b)\operatorname{Pair}(A,B,a,b)Pair(A,B,a,b) it uses ρ+\rho^+ρ+ only on BBB and ρ\rhoρ on the other arguments; in SRec⁡(A,B,C,d,p)\operatorname{SRec}(A,B,C,d,p)SRec(A,B,C,d,p) it uses respectively ρ,ρ+,ρ+,ρ+2,ρ\rho,\rho^+,\rho^+,\rho^{+2},\rhoρ,ρ+,ρ+,ρ+2,ρ; in Refl⁡(A,a)\operatorname{Refl}(A,a)Refl(A,a) it uses ρ\rhoρ on both arguments; in J⁡(A,C,d,a,b,p)\operatorname{J}(A,C,d,a,b,p)J(A,C,d,a,b,p) it uses respectively ρ,ρ+3,ρ+,ρ,ρ,ρ\rho,\rho^{+3},\rho^+,\rho,\rho,\rhoρ,ρ+3,ρ+,ρ,ρ,ρ; in Suc⁡(a)\operatorname{Suc}(a)Suc(a) it uses ρ\rhoρ on aaa; and in NRec⁡(C,z,s,n)\operatorname{NRec}(C,z,s,n)NRec(C,z,s,n) it uses respectively ρ+,ρ,ρ+2,ρ\rho^+,\rho,\rho^{+2},\rhoρ+,ρ,ρ+2,ρ. Thus the motive of J⁡\operatorname{J}J 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 eee, weakening is the expression obtained by the renaming n↦n+1n\mapsto n+1n↦n+1. 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 Π,Σ,λ\Pi,\Sigma,\lambdaΠ,Σ,λ, 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 σ:N→Expr⁡\sigma:\mathbb N\to\operatorname{Expr}σ:N→Expr, its lifted assignment σ+\sigma^+σ+ is defined by σ+(0)=v0\sigma^+(0)=v_0σ+(0)=v0​ and σ+(n+1)=weaken⁡(σ(n))\sigma^+(n+1)=\operatorname{weaken}(\sigma(n))σ+(n+1)=weaken(σ(n)) for every natural number nnn. Here weakening renames free indices by k↦k+1k\mapsto k+1k↦k+1, 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 σ:N→Expr⁡\sigma:\mathbb N\to\operatorname{Expr}σ:N→Expr, simultaneous substitution is a total recursive map SσS_\sigmaSσ​ on raw expressions. Define its lift by σ+(0)=v0\sigma^+(0)=v_0σ+(0)=v0​ and σ+(n+1)=Rk↦k+1(σ(n))\sigma^+(n+1)=R_{k\mapsto k+1}(\sigma(n))σ+(n+1)=Rk↦k+1​(σ(n)), where renaming preserves constructor-local binders, and write σ+k\sigma^{+k}σ+k for kkk repeated lifts. The operation sends vnv_nvn​ to σ(n)\sigma(n)σ(n), fixes N,U,0\mathsf N,\mathsf U,\mathsf 0N,U,0, and preserves each other outer constructor with these assignments on its arguments: σ,σ+\sigma,\sigma^+σ,σ+ in Π(A,B)\Pi(A,B)Π(A,B) and Σ(A,B)\Sigma(A,B)Σ(A,B); σ\sigmaσ on all arguments of Id⁡(A,a,b)\operatorname{Id}(A,a,b)Id(A,a,b); σ\sigmaσ in El⁡(a)\operatorname{El}(a)El(a); σ,σ+\sigma,\sigma^+σ,σ+ in λ(A,b)\lambda(A,b)λ(A,b); σ,σ+,σ,σ\sigma,\sigma^+,\sigma,\sigmaσ,σ+,σ,σ in both application App⁡(A,B,f,a)\operatorname{App}(A,B,f,a)App(A,B,f,a) and pairing Pair⁡(A,B,a,b)\operatorname{Pair}(A,B,a,b)Pair(A,B,a,b); σ,σ+,σ+,σ+2,σ\sigma,\sigma^+,\sigma^+,\sigma^{+2},\sigmaσ,σ+,σ+,σ+2,σ in SRec⁡(A,B,C,d,p)\operatorname{SRec}(A,B,C,d,p)SRec(A,B,C,d,p); σ,σ\sigma,\sigmaσ,σ in Refl⁡(A,a)\operatorname{Refl}(A,a)Refl(A,a); σ,σ+3,σ+,σ,σ,σ\sigma,\sigma^{+3},\sigma^+,\sigma,\sigma,\sigmaσ,σ+3,σ+,σ,σ,σ in J⁡(A,C,d,a,b,p)\operatorname{J}(A,C,d,a,b,p)J(A,C,d,a,b,p); σ\sigmaσ in Suc⁡(a)\operatorname{Suc}(a)Suc(a); and σ+,σ,σ+2,σ\sigma^+,\sigma,\sigma^{+2},\sigmaσ+,σ,σ+2,σ in NRec⁡(C,z,s,n)\operatorname{NRec}(C,z,s,n)NRec(C,z,s,n). 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 BBB and aaa, the result is the simultaneous, binder-preserving substitution into BBB whose assignment sends index 000 to aaa and every index n+1n+1n+1 to vnv_nvn​, for all natural numbers nnn. Equivalently, at the outer level it replaces the newest free variable by aaa 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 aaa itself. The definition applies even if BBB does not mention index 000, if aaa has free variables, or if either expression is ill scoped or ill typed.

instantiate₂. For arbitrary raw expressions C,a,bC,a,bC,a,b, the result is the simultaneous, binder-preserving substitution into CCC assigning 0↦b0\mapsto b0↦b, 1↦a1\mapsto a1↦a, and n+2↦vnn+2\mapsto v_nn+2↦vn​ for every natural number nnn. Thus the most recent of the two removed free-variable slots is filled by bbb, and the next by aaa; older free indices are lowered by two. The inserted a,ba,ba,b 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 C,a,b,pC,a,b,pC,a,b,p, the result is the simultaneous, binder-preserving substitution into CCC assigning 0↦p0\mapsto p0↦p, 1↦b1\mapsto b1↦b, 2↦a2\mapsto a2↦a, and n+3↦vnn+3\mapsto v_nn+3↦vn​ for every natural number nnn. Thus three newest free-variable slots are removed, in the order p,b,ap,b,ap,b,a 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 Γ\GammaΓ and every raw expression AAA, the result is the list Id⁡(W(W(A)),v1,v0)::W(A)::A::Γ\operatorname{Id}(W(W(A)),v_1,v_0)::W(A)::A::\GammaId(W(W(A)),v1​,v0​)::W(A)::A::Γ, where WWW renames each free index nnn to n+1n+1n+1 while preserving locally bound variables, and the head is the newest entry. Thus the three new entries, in order of extension from Γ\GammaΓ, are AAA, its one-step weakening, and an identity expression whose carrier is the twice-weakened AAA and whose endpoints are respectively the older and newer of those two variables. In the final context those three added variables have indices 2,1,02,1,02,1,0, respectively, with the identity witness newest. The definition does not assume that Γ\GammaΓ or AAA is well formed and does not assert well-formedness of the resulting context.

reflexivityMotive. For arbitrary raw expressions A,CA,CA,C, this definition substitutes into CCC with the simultaneous assignment 0↦Refl⁡(W(A),v0)0\mapsto\operatorname{Refl}(W(A),v_0)0↦Refl(W(A),v0​), 1↦v01\mapsto v_01↦v0​, 2↦v02\mapsto v_02↦v0​, and n+3↦vn+1n+3\mapsto v_{n+1}n+3↦vn+1​ for every natural number nnn, where WWW 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 W(A)W(A)W(A). There is no premise relating AAA to CCC, no requirement that CCC is a type over an identity context, and no typing conclusion in this declaration.

pairingMotive. For arbitrary raw expressions A,B,CA,B,CA,B,C, let A↑2A^{\uparrow2}A↑2 be AAA renamed by n↦n+2n\mapsto n+2n↦n+2, and let B⋆B^\starB⋆ be BBB renamed by the function fixing 000 and sending n+1n+1n+1 to n+3n+3n+3. The definition substitutes into CCC with the simultaneous assignment 0↦Pair⁡(A↑2,B⋆,v1,v0)0\mapsto\operatorname{Pair}(A^{\uparrow2},B^\star,v_1,v_0)0↦Pair(A↑2,B⋆,v1​,v0​) and n+1↦vn+2n+1\mapsto v_{n+2}n+1↦vn+2​ for every natural number nnn, lifting the assignment beneath all local binders. Thus the newest free-variable slot of CCC is replaced by an explicitly annotated pair using variables 111 and 000, 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 000 preserved by its renaming. The definition requires no context, typing, or well-formedness evidence.

successorMotive. For every raw expression CCC, the result is its simultaneous substitution by the assignment 0↦Suc⁡(v1)0\mapsto\operatorname{Suc}(v_1)0↦Suc(v1​) and n+1↦vn+2n+1\mapsto v_{n+2}n+1↦vn+2​ for every natural number nnn, lifted beneath the local binders of CCC. Thus the newest free-variable slot is replaced by the successor of variable 111, and older free-variable slots move past two retained slots. The replacement explicitly uses index 111, not index 000; index 000 is not used in any of the expressions supplied by this assignment. No type or context condition is imposed on CCC.

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 Γ\GammaΓ and raw expression AAA, declare A::ΓA::\GammaA::Γ well formed when Γ\GammaΓ is well formed and the type-formation judgement Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type holds. The head AAA is checked in the tail Γ\GammaΓ, before the new variable is added; arbitrary expression lists are not admitted without such a finite derivation.

TypeWf. For every finite expression-list context Γ\GammaΓ and raw expression AAA, the proposition written Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type is generated mutually with the other judgement relations by exactly these rules, universally quantified over the contexts, expressions, and assignments appearing in them: from Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type and A::Γ⊢B typeA::\Gamma\vdash B\ \mathrm{type}A::Γ⊢B type, infer both Γ⊢Π(A,B) type\Gamma\vdash\Pi(A,B)\ \mathrm{type}Γ⊢Π(A,B) type and Γ⊢Σ(A,B) type\Gamma\vdash\Sigma(A,B)\ \mathrm{type}Γ⊢Σ(A,B) type; from Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type and the term judgements Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A, Γ⊢b:A\Gamma\vdash b:AΓ⊢b:A, infer Γ⊢Id⁡(A,a,b) type\Gamma\vdash\operatorname{Id}(A,a,b)\ \mathrm{type}Γ⊢Id(A,a,b) type; if Γ\GammaΓ is a well-formed context, infer Γ⊢N type\Gamma\vdash\mathsf N\ \mathrm{type}Γ⊢N type and Γ⊢U type\Gamma\vdash\mathsf U\ \mathrm{type}Γ⊢U type; from Γ⊢a:U\Gamma\vdash a:\mathsf UΓ⊢a:U, infer Γ⊢El⁡(a) type\Gamma\vdash\operatorname{El}(a)\ \mathrm{type}Γ⊢El(a) type; from Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type and a well-formed substitution σ\sigmaσ from Γ\GammaΓ to a context Δ\DeltaΔ, infer Δ⊢Sσ(A) type\Delta\vdash S_\sigma(A)\ \mathrm{type}Δ⊢Sσ​(A) type; and from Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type and the generated context equality Γ≃Δ\Gamma\simeq\DeltaΓ≃Δ, infer Δ⊢A type\Delta\vdash A\ \mathrm{type}Δ⊢A type with the same raw expression AAA. Here SσS_\sigmaSσ​ is simultaneous substitution, replacing vnv_nvn​ by the arbitrary total assignment σ(n)\sigma(n)σ(n) and lifting it under the syntax's binders; well-formedness of this substitution requires well-formed Γ,Δ\Gamma,\DeltaΓ,Δ and, for every index nnn with stored entry D=Γ[n]D=\Gamma[n]D=Γ[n], the judgement Δ⊢σ(n):Sσ(Rk↦k+n+1(D))\Delta\vdash\sigma(n):S_\sigma(R_{k\mapsto k+n+1}(D))Δ⊢σ(n):Sσ​(Rk↦k+n+1​(D)). Context equality is generated from equality of two empty lists and the rule extending Γ≃Δ\Gamma\simeq\DeltaΓ≃Δ to D::Γ≃E::ΔD::\Gamma\simeq E::\DeltaD::Γ≃E::Δ when the type-equality judgement Γ⊢D≡E type\Gamma\vdash D\equiv E\ \mathrm{type}Γ⊢D≡E type 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 N\mathsf NN, Π\PiΠ, Σ\SigmaΣ, or identity expressions into terms of U\mathsf UU.

TermWf. For contexts Γ,Δ\Gamma,\DeltaΓ,Δ that are finite lists of raw expressions and arbitrary raw expressions in every expression position below, write Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A for this mutually generated term-formation proposition, Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type for type formation, and Γ⊢A≡B type\Gamma\vdash A\equiv B\ \mathrm{type}Γ⊢A≡B type for generated type equality. To specify its rules, let vkv_kvk​ be the raw variable of index kkk, let E↑r=Rk↦k+r(E)E^{\uparrow r}=R_{k\mapsto k+r}(E)E↑r=Rk↦k+r​(E) be the renaming of free indices by rrr, preserving bound variables, and let E[t]E[t]E[t] denote simultaneous substitution 0↦t, k+1↦vk0\mapsto t,\ k+1\mapsto v_k0↦t, k+1↦vk​ and E[a,b,p]E[a,b,p]E[a,b,p] denote 0↦p, 1↦b, 2↦a, k+3↦vk0\mapsto p,\ 1\mapsto b,\ 2\mapsto a,\ k+3\mapsto v_k0↦p, 1↦b, 2↦a, k+3↦vk​, always lifted under local binders. Define the displayed auxiliary expressions explicitly by I(Γ,A)=Id⁡(A↑2,v1,v0)::A↑1::A::ΓI(\Gamma,A)=\operatorname{Id}(A^{\uparrow2},v_1,v_0)::A^{\uparrow1}::A::\GammaI(Γ,A)=Id(A↑2,v1​,v0​)::A↑1::A::Γ; P(A,B,C)=Sα(C)P(A,B,C)=S_\alpha(C)P(A,B,C)=Sα​(C) with α(0)=Pair⁡(A↑2,Rℓ(B),v1,v0)\alpha(0)=\operatorname{Pair}(A^{\uparrow2},R_\ell(B),v_1,v_0)α(0)=Pair(A↑2,Rℓ​(B),v1​,v0​), ℓ(0)=0\ell(0)=0ℓ(0)=0, ℓ(k+1)=k+3\ell(k+1)=k+3ℓ(k+1)=k+3, and α(k+1)=vk+2\alpha(k+1)=v_{k+2}α(k+1)=vk+2​; R(A,C)=Sβ(C)R(A,C)=S_\beta(C)R(A,C)=Sβ​(C) with β(0)=Refl⁡(A↑1,v0)\beta(0)=\operatorname{Refl}(A^{\uparrow1},v_0)β(0)=Refl(A↑1,v0​), β(1)=β(2)=v0\beta(1)=\beta(2)=v_0β(1)=β(2)=v0​, and β(k+3)=vk+1\beta(k+3)=v_{k+1}β(k+3)=vk+1​; and T(C)=Sγ(C)T(C)=S_\gamma(C)T(C)=Sγ​(C) with γ(0)=Suc⁡(v1)\gamma(0)=\operatorname{Suc}(v_1)γ(0)=Suc(v1​) and γ(k+1)=vk+2\gamma(k+1)=v_{k+2}γ(k+1)=vk+2​. All numerical indices kkk range over N\mathbb NN, and all these substitutions preserve local binders. The generating rules are: (i) if Γ\GammaΓ is well formed and its index-nnn lookup succeeds with stored expression AAA, then Γ⊢vn:A↑(n+1)\Gamma\vdash v_n:A^{\uparrow(n+1)}Γ⊢vn​:A↑(n+1); (ii) if Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type, A::Γ⊢B typeA::\Gamma\vdash B\ \mathrm{type}A::Γ⊢B type, and A::Γ⊢b:BA::\Gamma\vdash b:BA::Γ⊢b:B, then Γ⊢λ(A,b):Π(A,B)\Gamma\vdash\lambda(A,b):\Pi(A,B)Γ⊢λ(A,b):Π(A,B); (iii) under Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type and A::Γ⊢B typeA::\Gamma\vdash B\ \mathrm{type}A::Γ⊢B type, from Γ⊢f:Π(A,B)\Gamma\vdash f:\Pi(A,B)Γ⊢f:Π(A,B) and Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A infer Γ⊢App⁡(A,B,f,a):B[a]\Gamma\vdash\operatorname{App}(A,B,f,a):B[a]Γ⊢App(A,B,f,a):B[a]; (iv) under the same two type-formation premises, from Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A and Γ⊢b:B[a]\Gamma\vdash b:B[a]Γ⊢b:B[a] infer Γ⊢Pair⁡(A,B,a,b):Σ(A,B)\Gamma\vdash\operatorname{Pair}(A,B,a,b):\Sigma(A,B)Γ⊢Pair(A,B,a,b):Σ(A,B); (v) from Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type, A::Γ⊢B typeA::\Gamma\vdash B\ \mathrm{type}A::Γ⊢B type, Σ(A,B)::Γ⊢C type\Sigma(A,B)::\Gamma\vdash C\ \mathrm{type}Σ(A,B)::Γ⊢C type, B::A::Γ⊢d:P(A,B,C)B::A::\Gamma\vdash d:P(A,B,C)B::A::Γ⊢d:P(A,B,C), and Γ⊢p:Σ(A,B)\Gamma\vdash p:\Sigma(A,B)Γ⊢p:Σ(A,B), infer Γ⊢SRec⁡(A,B,C,d,p):C[p]\Gamma\vdash\operatorname{SRec}(A,B,C,d,p):C[p]Γ⊢SRec(A,B,C,d,p):C[p]; (vi) from Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type and Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A, infer Γ⊢Refl⁡(A,a):Id⁡(A,a,a)\Gamma\vdash\operatorname{Refl}(A,a):\operatorname{Id}(A,a,a)Γ⊢Refl(A,a):Id(A,a,a); (vii) from Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type, I(Γ,A)⊢C typeI(\Gamma,A)\vdash C\ \mathrm{type}I(Γ,A)⊢C type, A::Γ⊢d:R(A,C)A::\Gamma\vdash d:R(A,C)A::Γ⊢d:R(A,C), Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A, Γ⊢b:A\Gamma\vdash b:AΓ⊢b:A, and Γ⊢p:Id⁡(A,a,b)\Gamma\vdash p:\operatorname{Id}(A,a,b)Γ⊢p:Id(A,a,b), infer Γ⊢J⁡(A,C,d,a,b,p):C[a,b,p]\Gamma\vdash\operatorname{J}(A,C,d,a,b,p):C[a,b,p]Γ⊢J(A,C,d,a,b,p):C[a,b,p]; (viii) if Γ\GammaΓ is well formed, then Γ⊢0:N\Gamma\vdash\mathsf0:\mathsf NΓ⊢0:N; (ix) from Γ⊢n:N\Gamma\vdash n:\mathsf NΓ⊢n:N, infer Γ⊢Suc⁡(n):N\Gamma\vdash\operatorname{Suc}(n):\mathsf NΓ⊢Suc(n):N; (x) from N::Γ⊢C type\mathsf N::\Gamma\vdash C\ \mathrm{type}N::Γ⊢C type, Γ⊢z:C[0]\Gamma\vdash z:C[\mathsf0]Γ⊢z:C[0], C::N::Γ⊢s:T(C)C::\mathsf N::\Gamma\vdash s:T(C)C::N::Γ⊢s:T(C), and Γ⊢n:N\Gamma\vdash n:\mathsf NΓ⊢n:N, infer Γ⊢NRec⁡(C,z,s,n):C[n]\Gamma\vdash\operatorname{NRec}(C,z,s,n):C[n]Γ⊢NRec(C,z,s,n):C[n], where in the step context the induction-result slot is 000 and the natural-number slot is 111; (xi) from Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A and Γ⊢A≡B type\Gamma\vdash A\equiv B\ \mathrm{type}Γ⊢A≡B type, infer Γ⊢a:B\Gamma\vdash a:BΓ⊢a:B; (xii) from Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A and a total substitution σ\sigmaσ well formed from Γ\GammaΓ to Δ\DeltaΔ, infer Δ⊢Sσ(a):Sσ(A)\Delta\vdash S_\sigma(a):S_\sigma(A)Δ⊢Sσ​(a):Sσ​(A), where well-formedness means both contexts are well formed and Δ⊢σ(k):Sσ(D↑(k+1))\Delta\vdash\sigma(k):S_\sigma(D^{\uparrow(k+1)})Δ⊢σ(k):Sσ​(D↑(k+1)) for each successful lookup Γ[k]=D\Gamma[k]=DΓ[k]=D; and (xiii) from Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A and generated context equality Γ≃Δ\Gamma\simeq\DeltaΓ≃Δ, infer Δ⊢a:A\Delta\vdash a:AΔ⊢a:A. 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 Γ,Δ\Gamma,\DeltaΓ,Δ and arbitrary raw expressions in all displayed expression positions, write Γ⊢A≡B type\Gamma\vdash A\equiv B\ \mathrm{type}Γ⊢A≡B type for this generated proposition, distinct from literal equality of expression trees; write Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type for type formation, Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A for term formation, and Γ⊢a≡b:A\Gamma\vdash a\equiv b:AΓ⊢a≡b:A for generated term equality. Its universally quantified generating rules are: Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type implies Γ⊢A≡A type\Gamma\vdash A\equiv A\ \mathrm{type}Γ⊢A≡A type; an equality can be reversed; equalities A≡BA\equiv BA≡B and B≡CB\equiv CB≡C in the same Γ\GammaΓ compose to A≡CA\equiv CA≡C there; from Γ⊢A≡A′ type\Gamma\vdash A\equiv A'\ \mathrm{type}Γ⊢A≡A′ type and A::Γ⊢B≡B′ typeA::\Gamma\vdash B\equiv B'\ \mathrm{type}A::Γ⊢B≡B′ type one obtains respectively Γ⊢Π(A,B)≡Π(A′,B′) type\Gamma\vdash\Pi(A,B)\equiv\Pi(A',B')\ \mathrm{type}Γ⊢Π(A,B)≡Π(A′,B′) type and Γ⊢Σ(A,B)≡Σ(A′,B′) type\Gamma\vdash\Sigma(A,B)\equiv\Sigma(A',B')\ \mathrm{type}Γ⊢Σ(A,B)≡Σ(A′,B′) type; from Γ⊢A≡A′ type\Gamma\vdash A\equiv A'\ \mathrm{type}Γ⊢A≡A′ type, Γ⊢a≡a′:A\Gamma\vdash a\equiv a':AΓ⊢a≡a′:A, and Γ⊢b≡b′:A\Gamma\vdash b\equiv b':AΓ⊢b≡b′:A one obtains Γ⊢Id⁡(A,a,b)≡Id⁡(A′,a′,b′) type\Gamma\vdash\operatorname{Id}(A,a,b)\equiv\operatorname{Id}(A',a',b')\ \mathrm{type}Γ⊢Id(A,a,b)≡Id(A′,a′,b′) type; from Γ⊢a≡b:U\Gamma\vdash a\equiv b:\mathsf UΓ⊢a≡b:U one obtains Γ⊢El⁡(a)≡El⁡(b) type\Gamma\vdash\operatorname{El}(a)\equiv\operatorname{El}(b)\ \mathrm{type}Γ⊢El(a)≡El(b) type; a type equality in Γ\GammaΓ can be simultaneously substituted by any well-formed total assignment σ:N→Expr⁡\sigma:\mathbb N\to\operatorname{Expr}σ:N→Expr from Γ\GammaΓ to Δ\DeltaΔ, producing Δ⊢Sσ(A)≡Sσ(B) type\Delta\vdash S_\sigma(A)\equiv S_\sigma(B)\ \mathrm{type}Δ⊢Sσ​(A)≡Sσ​(B) type; from Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type and equal substitutions σ,τ\sigma,\tauσ,τ from Γ\GammaΓ to Δ\DeltaΔ, one obtains Δ⊢Sσ(A)≡Sτ(A) type\Delta\vdash S_\sigma(A)\equiv S_\tau(A)\ \mathrm{type}Δ⊢Sσ​(A)≡Sτ​(A) type; and any Γ⊢A≡B type\Gamma\vdash A\equiv B\ \mathrm{type}Γ⊢A≡B type transfers unchanged to Δ\DeltaΔ given generated context equality Γ≃Δ\Gamma\simeq\DeltaΓ≃Δ. Here substitution is simultaneous and lifted under local binders. For a stored source entry D=Γ[k]D=\Gamma[k]D=Γ[k], put Dk=Rj↦j+k+1(D)D_k=R_{j\mapsto j+k+1}(D)Dk​=Rj↦j+k+1​(D); a substitution is well formed when both contexts are well formed and Δ⊢σ(k):Sσ(Dk)\Delta\vdash\sigma(k):S_\sigma(D_k)Δ⊢σ(k):Sσ​(Dk​) for each successful lookup, and two substitutions are equal when each is well formed and Δ⊢σ(k)≡τ(k):Sσ(Dk)\Delta\vdash\sigma(k)\equiv\tau(k):S_\sigma(D_k)Δ⊢σ(k)≡τ(k):Sσ​(Dk​) at every such entry. Context equality starts with the empty lists and extends equal tails Γ0,Δ0\Gamma_0,\Delta_0Γ0​,Δ0​ by entries D,ED,ED,E when Γ0⊢D≡E type\Gamma_0\vdash D\equiv E\ \mathrm{type}Γ0​⊢D≡E type. In the product and sum congruence rules both family expressions are compared in the context extended by the unprimed AAA; in identity congruence both endpoint comparisons use the unprimed carrier AAA. There are no further primitive type-equality rules in this declaration.

TermEq. For contexts Γ,Δ\Gamma,\DeltaΓ,Δ that are finite expression lists and arbitrary raw expressions A,A′,B,B′,C,C′,a,a′,b,b′,c,d,d′,f,f′,p,p′,z,z′,s,s′,n,n′A,A',B,B',C,C',a,a',b,b',c,d,d',f,f',p,p',z,z',s,s',n,n'A,A′,B,B′,C,C′,a,a′,b,b′,c,d,d′,f,f′,p,p′,z,z′,s,s′,n,n′ wherever they occur below, this mutually generated relation is written Γ⊢a≡b:A\Gamma\vdash a\equiv b:AΓ⊢a≡b:A; Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A, Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type, and Γ⊢A≡B type\Gamma\vdash A\equiv B\ \mathrm{type}Γ⊢A≡B type denote the other term-formation, type-formation, and type-equality relations. Define the notation used here explicitly: E↑rE^{\uparrow r}E↑r renames free indices by k↦k+rk\mapsto k+rk↦k+r while preserving bound indices; E[t]E[t]E[t], E[a,b]E[a,b]E[a,b], and E[a,b,p]E[a,b,p]E[a,b,p] are simultaneous, binder-preserving substitutions with assignments respectively (0↦t, k+1↦vk)(0\mapsto t,\ k+1\mapsto v_k)(0↦t, k+1↦vk​), (0↦b, 1↦a, k+2↦vk)(0\mapsto b,\ 1\mapsto a,\ k+2\mapsto v_k)(0↦b, 1↦a, k+2↦vk​), and (0↦p, 1↦b, 2↦a, k+3↦vk)(0\mapsto p,\ 1\mapsto b,\ 2\mapsto a,\ k+3\mapsto v_k)(0↦p, 1↦b, 2↦a, k+3↦vk​); I(Γ,A)=Id⁡(A↑2,v1,v0)::A↑1::A::ΓI(\Gamma,A)=\operatorname{Id}(A^{\uparrow2},v_1,v_0)::A^{\uparrow1}::A::\GammaI(Γ,A)=Id(A↑2,v1​,v0​)::A↑1::A::Γ; P(A,B,C)P(A,B,C)P(A,B,C) substitutes into CCC the assignment 0↦Pair⁡(A↑2,Rℓ(B),v1,v0)0\mapsto\operatorname{Pair}(A^{\uparrow2},R_\ell(B),v_1,v_0)0↦Pair(A↑2,Rℓ​(B),v1​,v0​), k+1↦vk+2k+1\mapsto v_{k+2}k+1↦vk+2​, where ℓ(0)=0\ell(0)=0ℓ(0)=0 and ℓ(k+1)=k+3\ell(k+1)=k+3ℓ(k+1)=k+3; R(A,C)R(A,C)R(A,C) substitutes 0↦Refl⁡(A↑1,v0)0\mapsto\operatorname{Refl}(A^{\uparrow1},v_0)0↦Refl(A↑1,v0​), 1↦v01\mapsto v_01↦v0​, 2↦v02\mapsto v_02↦v0​, and k+3↦vk+1k+3\mapsto v_{k+1}k+3↦vk+1​ into CCC; and T(C)T(C)T(C) substitutes 0↦Suc⁡(v1)0\mapsto\operatorname{Suc}(v_1)0↦Suc(v1​) and k+1↦vk+2k+1\mapsto v_{k+2}k+1↦vk+2​ into CCC. Every substitution just specified is lifted under local binders, and every numerical index kkk is a natural number. The full generating rules, with all displayed arguments universally quantified, are these: (i) Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A gives Γ⊢a≡a:A\Gamma\vdash a\equiv a:AΓ⊢a≡a:A; (ii) Γ⊢a≡b:A\Gamma\vdash a\equiv b:AΓ⊢a≡b:A gives Γ⊢b≡a:A\Gamma\vdash b\equiv a:AΓ⊢b≡a:A; (iii) Γ⊢a≡b:A\Gamma\vdash a\equiv b:AΓ⊢a≡b:A and Γ⊢b≡c:A\Gamma\vdash b\equiv c:AΓ⊢b≡c:A give Γ⊢a≡c:A\Gamma\vdash a\equiv c:AΓ⊢a≡c:A; (iv) Γ⊢a≡b:A\Gamma\vdash a\equiv b:AΓ⊢a≡b:A and Γ⊢A≡B type\Gamma\vdash A\equiv B\ \mathrm{type}Γ⊢A≡B type give Γ⊢a≡b:B\Gamma\vdash a\equiv b:BΓ⊢a≡b:B; (v) Γ⊢A≡A′ type\Gamma\vdash A\equiv A'\ \mathrm{type}Γ⊢A≡A′ type, A::Γ⊢B typeA::\Gamma\vdash B\ \mathrm{type}A::Γ⊢B type, and A::Γ⊢b≡b′:BA::\Gamma\vdash b\equiv b':BA::Γ⊢b≡b′:B give Γ⊢λ(A,b)≡λ(A′,b′):Π(A,B)\Gamma\vdash\lambda(A,b)\equiv\lambda(A',b'):\Pi(A,B)Γ⊢λ(A,b)≡λ(A′,b′):Π(A,B); (vi) Γ⊢A≡A′ type\Gamma\vdash A\equiv A'\ \mathrm{type}Γ⊢A≡A′ type, A::Γ⊢B≡B′ typeA::\Gamma\vdash B\equiv B'\ \mathrm{type}A::Γ⊢B≡B′ type, Γ⊢f≡f′:Π(A,B)\Gamma\vdash f\equiv f':\Pi(A,B)Γ⊢f≡f′:Π(A,B), and Γ⊢a≡a′:A\Gamma\vdash a\equiv a':AΓ⊢a≡a′:A give Γ⊢App⁡(A,B,f,a)≡App⁡(A′,B′,f′,a′):B[a]\Gamma\vdash\operatorname{App}(A,B,f,a)\equiv\operatorname{App}(A',B',f',a'):B[a]Γ⊢App(A,B,f,a)≡App(A′,B′,f′,a′):B[a]; (vii) Γ⊢A≡A′ type\Gamma\vdash A\equiv A'\ \mathrm{type}Γ⊢A≡A′ type, A::Γ⊢B≡B′ typeA::\Gamma\vdash B\equiv B'\ \mathrm{type}A::Γ⊢B≡B′ type, Γ⊢a≡a′:A\Gamma\vdash a\equiv a':AΓ⊢a≡a′:A, and Γ⊢b≡b′:B[a]\Gamma\vdash b\equiv b':B[a]Γ⊢b≡b′:B[a] give Γ⊢Pair⁡(A,B,a,b)≡Pair⁡(A′,B′,a′,b′):Σ(A,B)\Gamma\vdash\operatorname{Pair}(A,B,a,b)\equiv\operatorname{Pair}(A',B',a',b'):\Sigma(A,B)Γ⊢Pair(A,B,a,b)≡Pair(A′,B′,a′,b′):Σ(A,B); (viii) Γ⊢A≡A′ type\Gamma\vdash A\equiv A'\ \mathrm{type}Γ⊢A≡A′ type, A::Γ⊢B≡B′ typeA::\Gamma\vdash B\equiv B'\ \mathrm{type}A::Γ⊢B≡B′ type, Σ(A,B)::Γ⊢C≡C′ type\Sigma(A,B)::\Gamma\vdash C\equiv C'\ \mathrm{type}Σ(A,B)::Γ⊢C≡C′ type, B::A::Γ⊢d≡d′:P(A,B,C)B::A::\Gamma\vdash d\equiv d':P(A,B,C)B::A::Γ⊢d≡d′:P(A,B,C), and Γ⊢p≡p′:Σ(A,B)\Gamma\vdash p\equiv p':\Sigma(A,B)Γ⊢p≡p′:Σ(A,B) give Γ⊢SRec⁡(A,B,C,d,p)≡SRec⁡(A′,B′,C′,d′,p′):C[p]\Gamma\vdash\operatorname{SRec}(A,B,C,d,p)\equiv\operatorname{SRec}(A',B',C',d',p'):C[p]Γ⊢SRec(A,B,C,d,p)≡SRec(A′,B′,C′,d′,p′):C[p]; (ix) Γ⊢A≡A′ type\Gamma\vdash A\equiv A'\ \mathrm{type}Γ⊢A≡A′ type and Γ⊢a≡a′:A\Gamma\vdash a\equiv a':AΓ⊢a≡a′:A give Γ⊢Refl⁡(A,a)≡Refl⁡(A′,a′):Id⁡(A,a,a)\Gamma\vdash\operatorname{Refl}(A,a)\equiv\operatorname{Refl}(A',a'):\operatorname{Id}(A,a,a)Γ⊢Refl(A,a)≡Refl(A′,a′):Id(A,a,a); (x) Γ⊢A≡A′ type\Gamma\vdash A\equiv A'\ \mathrm{type}Γ⊢A≡A′ type, I(Γ,A)⊢C≡C′ typeI(\Gamma,A)\vdash C\equiv C'\ \mathrm{type}I(Γ,A)⊢C≡C′ type, A::Γ⊢d≡d′:R(A,C)A::\Gamma\vdash d\equiv d':R(A,C)A::Γ⊢d≡d′:R(A,C), Γ⊢a≡a′:A\Gamma\vdash a\equiv a':AΓ⊢a≡a′:A, Γ⊢b≡b′:A\Gamma\vdash b\equiv b':AΓ⊢b≡b′:A, and Γ⊢p≡p′:Id⁡(A,a,b)\Gamma\vdash p\equiv p':\operatorname{Id}(A,a,b)Γ⊢p≡p′:Id(A,a,b) give Γ⊢J⁡(A,C,d,a,b,p)≡J⁡(A′,C′,d′,a′,b′,p′):C[a,b,p]\Gamma\vdash\operatorname{J}(A,C,d,a,b,p)\equiv\operatorname{J}(A',C',d',a',b',p'):C[a,b,p]Γ⊢J(A,C,d,a,b,p)≡J(A′,C′,d′,a′,b′,p′):C[a,b,p]; (xi) Γ⊢n≡n′:N\Gamma\vdash n\equiv n':\mathsf NΓ⊢n≡n′:N gives Γ⊢Suc⁡(n)≡Suc⁡(n′):N\Gamma\vdash\operatorname{Suc}(n)\equiv\operatorname{Suc}(n'):\mathsf NΓ⊢Suc(n)≡Suc(n′):N; (xii) N::Γ⊢C≡C′ type\mathsf N::\Gamma\vdash C\equiv C'\ \mathrm{type}N::Γ⊢C≡C′ type, Γ⊢z≡z′:C[0]\Gamma\vdash z\equiv z':C[\mathsf0]Γ⊢z≡z′:C[0], C::N::Γ⊢s≡s′:T(C)C::\mathsf N::\Gamma\vdash s\equiv s':T(C)C::N::Γ⊢s≡s′:T(C), and Γ⊢n≡n′:N\Gamma\vdash n\equiv n':\mathsf NΓ⊢n≡n′:N give Γ⊢NRec⁡(C,z,s,n)≡NRec⁡(C′,z′,s′,n′):C[n]\Gamma\vdash\operatorname{NRec}(C,z,s,n)\equiv\operatorname{NRec}(C',z',s',n'):C[n]Γ⊢NRec(C,z,s,n)≡NRec(C′,z′,s′,n′):C[n]; (xiii) if Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type, A::Γ⊢B typeA::\Gamma\vdash B\ \mathrm{type}A::Γ⊢B type, A::Γ⊢b:BA::\Gamma\vdash b:BA::Γ⊢b:B, and Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A, then Γ⊢App⁡(A,B,λ(A,b),a)≡b[a]:B[a]\Gamma\vdash\operatorname{App}(A,B,\lambda(A,b),a)\equiv b[a]:B[a]Γ⊢App(A,B,λ(A,b),a)≡b[a]:B[a]; (xiv) if Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type, A::Γ⊢B typeA::\Gamma\vdash B\ \mathrm{type}A::Γ⊢B type, and Γ⊢f:Π(A,B)\Gamma\vdash f:\Pi(A,B)Γ⊢f:Π(A,B), then Γ⊢λ(A,App⁡(A↑1,Rh(B),f↑1,v0))≡f:Π(A,B)\Gamma\vdash\lambda(A,\operatorname{App}(A^{\uparrow1},R_h(B),f^{\uparrow1},v_0))\equiv f:\Pi(A,B)Γ⊢λ(A,App(A↑1,Rh​(B),f↑1,v0​))≡f:Π(A,B), where h(0)=0h(0)=0h(0)=0 and h(k+1)=k+2h(k+1)=k+2h(k+1)=k+2; (xv) if Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type, A::Γ⊢B typeA::\Gamma\vdash B\ \mathrm{type}A::Γ⊢B type, Σ(A,B)::Γ⊢C type\Sigma(A,B)::\Gamma\vdash C\ \mathrm{type}Σ(A,B)::Γ⊢C type, B::A::Γ⊢d:P(A,B,C)B::A::\Gamma\vdash d:P(A,B,C)B::A::Γ⊢d:P(A,B,C), Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A, and Γ⊢b:B[a]\Gamma\vdash b:B[a]Γ⊢b:B[a], then Γ⊢SRec⁡(A,B,C,d,Pair⁡(A,B,a,b))≡d[a,b]:C[Pair⁡(A,B,a,b)]\Gamma\vdash\operatorname{SRec}(A,B,C,d,\operatorname{Pair}(A,B,a,b))\equiv d[a,b]:C[\operatorname{Pair}(A,B,a,b)]Γ⊢SRec(A,B,C,d,Pair(A,B,a,b))≡d[a,b]:C[Pair(A,B,a,b)]; (xvi) if Γ⊢A type\Gamma\vdash A\ \mathrm{type}Γ⊢A type, I(Γ,A)⊢C typeI(\Gamma,A)\vdash C\ \mathrm{type}I(Γ,A)⊢C type, A::Γ⊢d:R(A,C)A::\Gamma\vdash d:R(A,C)A::Γ⊢d:R(A,C), and Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A, then Γ⊢J⁡(A,C,d,a,a,Refl⁡(A,a))≡d[a]:C[a,a,Refl⁡(A,a)]\Gamma\vdash\operatorname{J}(A,C,d,a,a,\operatorname{Refl}(A,a))\equiv d[a]:C[a,a,\operatorname{Refl}(A,a)]Γ⊢J(A,C,d,a,a,Refl(A,a))≡d[a]:C[a,a,Refl(A,a)]; (xvii) if N::Γ⊢C type\mathsf N::\Gamma\vdash C\ \mathrm{type}N::Γ⊢C type, Γ⊢z:C[0]\Gamma\vdash z:C[\mathsf0]Γ⊢z:C[0], and C::N::Γ⊢s:T(C)C::\mathsf N::\Gamma\vdash s:T(C)C::N::Γ⊢s:T(C), then Γ⊢NRec⁡(C,z,s,0)≡z:C[0]\Gamma\vdash\operatorname{NRec}(C,z,s,\mathsf0)\equiv z:C[\mathsf0]Γ⊢NRec(C,z,s,0)≡z:C[0]; (xviii) under those same three premises and the additional premise Γ⊢n:N\Gamma\vdash n:\mathsf NΓ⊢n:N, one has Γ⊢NRec⁡(C,z,s,Suc⁡(n))≡s[n,NRec⁡(C,z,s,n)]:C[Suc⁡(n)]\Gamma\vdash\operatorname{NRec}(C,z,s,\operatorname{Suc}(n))\equiv s[n,\operatorname{NRec}(C,z,s,n)]:C[\operatorname{Suc}(n)]Γ⊢NRec(C,z,s,Suc(n))≡s[n,NRec(C,z,s,n)]:C[Suc(n)]; (xix) from Γ⊢a≡b:A\Gamma\vdash a\equiv b:AΓ⊢a≡b:A and a well-formed total substitution σ\sigmaσ from Γ\GammaΓ to Δ\DeltaΔ, infer Δ⊢Sσ(a)≡Sσ(b):Sσ(A)\Delta\vdash S_\sigma(a)\equiv S_\sigma(b):S_\sigma(A)Δ⊢Sσ​(a)≡Sσ​(b):Sσ​(A); (xx) from Γ⊢a:A\Gamma\vdash a:AΓ⊢a:A and equal total substitutions σ,τ\sigma,\tauσ,τ from Γ\GammaΓ to Δ\DeltaΔ, infer Δ⊢Sσ(a)≡Sτ(a):Sσ(A)\Delta\vdash S_\sigma(a)\equiv S_\tau(a):S_\sigma(A)Δ⊢Sσ​(a)≡Sτ​(a):Sσ​(A); and (xxi) from Γ⊢a≡b:A\Gamma\vdash a\equiv b:AΓ⊢a≡b:A and generated context equality Γ≃Δ\Gamma\simeq\DeltaΓ≃Δ, infer Δ⊢a≡b:A\Delta\vdash a\equiv b:AΔ⊢a≡b:A. In (xix) and (xx), substitution is simultaneous and lifted under binders; for each stored entry D=Γ[k]D=\Gamma[k]D=Γ[k], its full source-context type is D↑(k+1)D^{\uparrow(k+1)}D↑(k+1), substitution well-formedness requires well-formed contexts and Δ⊢σ(k):Sσ(D↑(k+1))\Delta\vdash\sigma(k):S_\sigma(D^{\uparrow(k+1)})Δ⊢σ(k):Sσ​(D↑(k+1)), and substitution equality requires both assignments well formed and Δ⊢σ(k)≡τ(k):Sσ(D↑(k+1))\Delta\vdash\sigma(k)\equiv\tau(k):S_\sigma(D^{\uparrow(k+1)})Δ⊢σ(k)≡τ(k):Sσ​(D↑(k+1)) 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 Sσ(A)S_\sigma(A)Sσ​(A) 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 Γ,Δ\Gamma,\DeltaΓ,Δ and a total function σ:N→Expr⁡\sigma:\mathbb N\to\operatorname{Expr}σ:N→Expr, this proposition holds exactly when Γ\GammaΓ and Δ\DeltaΔ are well-formed contexts and, for every natural number nnn and every raw expression AAA, successful zero-based lookup of AAA at position nnn in Γ\GammaΓ implies the term-formation judgement Δ⊢σ(n):Sσ(Rk↦k+n+1(A))\Delta\vdash\sigma(n):S_\sigma(R_{k\mapsto k+n+1}(A))Δ⊢σ(n):Sσ​(Rk↦k+n+1​(A)). Here the renaming raises the free indices of the stored entry by n+1n+1n+1 to place its type in the full source context, and simultaneous substitution replaces free variables according to σ\sigmaσ, 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 Γ,Δ\Gamma,\DeltaΓ,Δ and total functions σ,τ:N→Expr⁡\sigma,\tau:\mathbb N\to\operatorname{Expr}σ,τ:N→Expr, this proposition holds exactly when both assignments are well-formed substitutions from Γ\GammaΓ to Δ\DeltaΔ and, for every natural number nnn and every raw expression AAA occurring at source position nnn, the judgement Δ⊢σ(n)≡τ(n):Sσ(Rk↦k+n+1(A))\Delta\vdash\sigma(n)\equiv\tau(n):S_\sigma(R_{k\mapsto k+n+1}(A))Δ⊢σ(n)≡τ(n):Sσ​(Rk↦k+n+1​(A)) holds. Explicitly, well-formedness requires well-formed Γ,Δ\Gamma,\DeltaΓ,Δ and, at every such source entry, term formation of σ(n)\sigma(n)σ(n) at Sσ(Rk↦k+n+1(A))S_\sigma(R_{k\mapsto k+n+1}(A))Sσ​(Rk↦k+n+1​(A)) and of τ(n)\tau(n)τ(n) at Sτ(Rk↦k+n+1(A))S_\tau(R_{k\mapsto k+n+1}(A))Sτ​(Rk↦k+n+1​(A)); the component equality itself is stated at the type obtained with σ\sigmaσ. 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 Γ,Δ\Gamma,\DeltaΓ,Δ and raw expressions A,BA,BA,B, if Γ≃Δ\Gamma\simeq\DeltaΓ≃Δ and the type-equality judgement Γ⊢A≡B type\Gamma\vdash A\equiv B\ \mathrm{type}Γ⊢A≡B type holds, then A::Γ≃B::ΔA::\Gamma\simeq B::\DeltaA::Γ≃B::Δ. Thus the new entries are compared in the left tail Γ\GammaΓ, even though the right entry is placed over the right tail Δ\DeltaΔ. No separate well-formedness premise or comparison in Δ\DeltaΔ 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 Σ(U,El⁡(v0))\Sigma(\mathsf U,\operatorname{El}(v_0))Σ(U,El(v0​)), where U\mathsf UU is the universe-expression constructor, El⁡\operatorname{El}El is the one-argument decoding constructor, and index 000 in the second argument of Σ\SigmaΣ 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 AAA, the result is the three-entry context [Id⁡(A↑2,v1,v1),Id⁡(A↑1,v0,v0),A]\bigl[\operatorname{Id}(A^{\uparrow2},v_1,v_1),\operatorname{Id}(A^{\uparrow1},v_0,v_0),A\bigr][Id(A↑2,v1​,v1​),Id(A↑1,v0​,v0​),A], written newest entry first, where A↑rA^{\uparrow r}A↑r raises every free index by rrr while preserving local binders. Starting with the empty tail, the entries add a variable of stored type AAA, 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 222, the first identity-witness slot index 111, and the second identity-witness slot index 000; each stored identity expression is written relative to its own tail. There is no requirement that AAA 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 AAA, the result is Id⁡(Id⁡(A↑3,v2,v2),v1,Refl⁡(A↑3,v2))\operatorname{Id}\bigl(\operatorname{Id}(A^{\uparrow3},v_2,v_2),v_1,\operatorname{Refl}(A^{\uparrow3},v_2)\bigr)Id(Id(A↑3,v2​,v2​),v1​,Refl(A↑3,v2​)), where A↑3A^{\uparrow3}A↑3 renames free indices by n↦n+3n\mapsto n+3n↦n+3 while preserving locally bound indices, Id⁡\operatorname{Id}Id is the three-argument identity-expression constructor, and Refl⁡\operatorname{Refl}Refl carries the displayed carrier annotation. Thus its outer carrier is the identity expression from variable 222 to itself, and its outer endpoints are variable 111 and the reflexivity expression at variable 222. There is no free reference to the surrounding context's slot 000; locally bound occurrences of index 000 may remain inside the shifted copies of AAA. No context argument, closedness premise on AAA, type-formation assertion, or inhabitant is part of this definition.

uipContext. For every raw expression AAA, the result is the four-entry context [Id⁡(A↑3,v2,v1),Id⁡(A↑2,v1,v0),A↑1,A]\bigl[\operatorname{Id}(A^{\uparrow3},v_2,v_1),\operatorname{Id}(A^{\uparrow2},v_1,v_0),A^{\uparrow1},A\bigr][Id(A↑3,v2​,v1​),Id(A↑2,v1​,v0​),A↑1,A], newest entry first, where A↑rA^{\uparrow r}A↑r raises free de Bruijn indices by rrr and preserves local binders. In extension order from the empty context it adds a variable with stored type AAA, a second variable with stored type A↑1A^{\uparrow1}A↑1, 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 333 and 222, and the first and second identity-witness slots have indices 111 and 000. The expression defining each entry is written in its own tail context. The parameter AAA 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 AAA, the result is Id⁡(Id⁡(A↑4,v3,v2),v1,v0)\operatorname{Id}\bigl(\operatorname{Id}(A^{\uparrow4},v_3,v_2),v_1,v_0\bigr)Id(Id(A↑4,v3​,v2​),v1​,v0​), where A↑4A^{\uparrow4}A↑4 raises free indices by four while preserving locally bound indices, and Id⁡\operatorname{Id}Id is the raw identity-expression constructor. Its carrier is the identity expression from variable 333 to variable 222, and its endpoints are variables 111 and 000. The declaration takes no context or well-formedness evidence and imposes no closedness assumption on AAA; it merely constructs this raw expression and does not assert that it is well formed, inhabited, or derivable as a judgement.

Human review
  • Endorsed by Shuze Chen · Oct 29, 2026

    Confirmed by the moderator at approval.

  • Endorsed by kmehltretter82 · Oct 29, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me