Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Section 2.1: De Bruijn Syntax, Weakenings, Parallel Substitutions, and Weak-Head Normal Forms

Definition
Abel2018_Syntax

by kmehltretter82 · Nov 7, 2026 · Mathlib 0df444a (Lean v4.33.1)

conversion-checkingdependent-typeslogical-relationsnormalizationtype-theory

Formalizes the untyped de Bruijn syntax and syntactic operations of Section 2.1 (Definition/Untyped.agda): raw terms Term (U,ΠA B,N,var(x),λt,t u,0,suc(t),natrec(A,z,s,n)U, \Pi A\, B, \mathbb{N}, \mathsf{var}(x), \lambda t, t\, u, 0, \mathsf{suc}(t), \mathsf{natrec}(A, z, s, n)U,ΠAB,N,var(x),λt,tu,0,suc(t),natrec(A,z,s,n)), newest-first contexts Context, inductive weakenings Wk (id, step, lift) and term weakening wk, parallel substitutions Subst := Nat → Term and subst, single-variable substitution subst0 (t[a]t[a]t[a]) and lifted substitution substKeep (t[a]↑t[a]\uparrowt[a]↑), the recursor step motive type recStepType, canonical numerals suck (suck(0)\mathsf{suc}^k(0)suck(0)), neutral terms Neutral, weak-head normal forms Whnf, and WHNF shape views (NaturalView, SmallTypeView, FunctionView).

Definition code
/-
Copyright (c) 2016 Joakim Öhman, Andrea Vezzosi, Andreas Abel.
Lean translation prepared for the Feasible Univalence project, 2026.
Released under the MIT license; see the source artifact LICENSE.

Source: Andreas Abel, Joakim Öhman, and Andrea Vezzosi,
"Decidability of Conversion for Type Theory in Type Theory",
Proceedings of the ACM on Programming Languages 2(POPL), Article 23, 2018
(doi:10.1145/3158111), and Agda artifact mr-ohman/logrel-mltt v2.1
(commit eb2b15ab1c4b45923025834d3bb798943cb44b8e), Definition/Untyped.agda.
-/
import Init

namespace Abel2018

/-- Raw de Bruijn syntax for the source lambda-Pi-U-N calculus. -/
inductive Term where
  | univ : Term
  | pi : Term → Term → Term
  | nat : Term
  | var : Nat → Term
  | lam : Term → Term
  | app : Term → Term → Term
  | zero : Term
  | succ : Term → Term
  | natrec : Term → Term → Term → Term → Term
  deriving DecidableEq, Repr

/-- Newest-first representation of the source's snoc contexts: Γ ∙ A becomes A :: Γ. -/
abbrev Context := List Term

def liftRen (ρ : Nat → Nat) : Nat → Nat
  | 0 => 0
  | n + 1 => ρ n + 1

/-- Renaming lifts under precisely the Pi codomain, lambda body, and recursor motive. -/
def rename (ρ : Nat → Nat) : Term → Term
  | .univ => .univ
  | .pi A B => .pi (rename ρ A) (rename (liftRen ρ) B)
  | .nat => .nat
  | .var x => .var (ρ x)
  | .lam t => .lam (rename (liftRen ρ) t)
  | .app t u => .app (rename ρ t) (rename ρ u)
  | .zero => .zero
  | .succ t => .succ (rename ρ t)
  | .natrec A z s n =>
      .natrec (rename (liftRen ρ) A) (rename ρ z) (rename ρ s) (rename ρ n)

/-- Syntactic weakenings from the source, retaining its inductive presentation. -/
inductive Wk where
  | id : Wk
  | step : Wk → Wk
  | lift : Wk → Wk
  deriving DecidableEq, Repr

def wkVar : Wk → Nat → Nat
  | .id, n => n
  | .step ρ, n => wkVar ρ n + 1
  | .lift _, 0 => 0
  | .lift ρ, n + 1 => wkVar ρ n + 1

def wk (ρ : Wk) : Term → Term
  | .univ => .univ
  | .pi A B => .pi (wk ρ A) (wk (.lift ρ) B)
  | .nat => .nat
  | .var x => .var (wkVar ρ x)
  | .lam t => .lam (wk (.lift ρ) t)
  | .app t u => .app (wk ρ t) (wk ρ u)
  | .zero => .zero
  | .succ t => .succ (wk ρ t)
  | .natrec A z s n =>
      .natrec (wk (.lift ρ) A) (wk ρ z) (wk ρ s) (wk ρ n)

def wk1 : Term → Term := wk (.step .id)

def compWk : Wk → Wk → Wk
  | .id, ρ' => ρ'
  | .step ρ, ρ' => .step (compWk ρ ρ')
  | .lift ρ, .id => .lift ρ
  | .lift ρ, .step ρ' => .step (compWk ρ ρ')
  | .lift ρ, .lift ρ' => .lift (compWk ρ ρ')

abbrev Subst := Nat → Term

def liftSubst (σ : Subst) : Subst
  | 0 => .var 0
  | n + 1 => wk1 (σ n)

def subst (σ : Subst) : Term → Term
  | .univ => .univ
  | .pi A B => .pi (subst σ A) (subst (liftSubst σ) B)
  | .nat => .nat
  | .var x => σ x
  | .lam t => .lam (subst (liftSubst σ) t)
  | .app t u => .app (subst σ t) (subst σ u)
  | .zero => .zero
  | .succ t => .succ (subst σ t)
  | .natrec A z s n =>
      .natrec (subst (liftSubst σ) A) (subst σ z) (subst σ s) (subst σ n)

def consSubst (σ : Subst) (a : Term) : Subst
  | 0 => a
  | n + 1 => σ n

def idSubst : Subst := Term.var

def sgSubst (a : Term) : Subst := consSubst idSubst a

def toSubst (ρ : Wk) : Subst := fun x ↦ .var (wkVar ρ x)

def headSubst (σ : Subst) : Term := σ 0

def tailSubst (σ : Subst) : Subst := fun n ↦ σ (n + 1)

def wk1Subst (σ : Subst) : Subst := fun n ↦ wk1 (σ n)

def compSubst (σ τ : Subst) : Subst := fun n ↦ subst σ (τ n)

def wkSubst (ρ : Wk) (σ : Subst) : Subst := fun n ↦ wk ρ (σ n)

def substWk (σ : Subst) (ρ : Wk) : Subst := fun n ↦ σ (wkVar ρ n)

/-- Replace index zero and remove its binder, corresponding to source t [ a ]. -/
def subst0 (t a : Term) : Term := subst (consSubst idSubst a) t

/-- Replace index zero while retaining the context, corresponding to source t [ a ]↑. -/
def substKeep (t a : Term) : Term := subst (consSubst (wk1Subst idSubst) a) t

/-- Nondependent arrow: source A ▹▹ B. -/
def arr (A B : Term) : Term := .pi A (wk1 B)

/-- Type of the step argument of natrec, in the context outside its motive binder. -/
def recStepType (F : Term) : Term :=
  .pi .nat (arr F (substKeep F (.succ (.var 0))))

/-- Numeral representation `sucᵏ k` of a natural number `k` (`sucᵏ`). -/
def suck : Nat → Term
  | 0 => .zero
  | n + 1 => .succ (suck n)

inductive Neutral : Term → Prop where
  | var (n : Nat) : Neutral (.var n)
  | app {k u} : Neutral k → Neutral (.app k u)
  | natrec {C z s k} : Neutral k → Neutral (.natrec C z s k)

inductive Whnf : Term → Prop where
  | univ : Whnf .univ
  | pi {A B} : Whnf (.pi A B)
  | nat : Whnf .nat
  | lam {t} : Whnf (.lam t)
  | zero : Whnf .zero
  | succ {t} : Whnf (.succ t)
  | neutral {n} : Neutral n → Whnf n

/-- Source view Natural: the weak-head forms of natural-number terms. -/
inductive NaturalView : Term → Prop where
  | zero : NaturalView .zero
  | succ {t} : NaturalView (.succ t)
  | neutral {n} : Neutral n → NaturalView n

/-- Source view Type: small types in weak-head form; the universe is excluded. -/
inductive SmallTypeView : Term → Prop where
  | pi {A B} : SmallTypeView (.pi A B)
  | nat : SmallTypeView .nat
  | neutral {n} : Neutral n → SmallTypeView n

/-- Source view Function: weak-head forms of function terms. -/
inductive FunctionView : Term → Prop where
  | lam {t} : FunctionView (.lam t)
  | neutral {n} : Neutral n → FunctionView n

end Abel2018
Source
Andreas Abel, Joakim Öhman, and Andrea Vezzosi, 'Decidability of Conversion for Type Theory in Type Theory', Proceedings of the ACM on Programming Languages 2(POPL), Article 23, 2018, pp. 23:1-23:29 (doi:10.1145/3158111); Agda artifact mr-ohman/logrel-mltt v2.1 (commit eb2b15ab1c4b45923025834d3bb798943cb44b8e). Section 2.1, pp. 23:5-23:6; Definition/Untyped.agda.
Read-back

What the Lean code literally says, in plain math · Gemini 4 Argon (Independent Blind Auditor)

All definitions reside in the Abel2018 namespace (Def_Abel2018_Syntax.lean).

Raw Terms and Contexts

  • Term: An inductive type (deriving DecidableEq and Repr) with 9 constructors:
    1. univ:Term\mathsf{univ} : \mathsf{Term}univ:Term (universe U\mathcal{U}U),
    2. pi(A,B):Term→Term→Term\mathsf{pi}(A, B) : \mathsf{Term} \to \mathsf{Term} \to \mathsf{Term}pi(A,B):Term→Term→Term (dependent function type ΠA. B\Pi A.\,BΠA.B),
    3. nat:Term\mathsf{nat} : \mathsf{Term}nat:Term (natural number type N\mathbb{N}N),
    4. var(x):N→Term\mathsf{var}(x) : \mathbb{N} \to \mathsf{Term}var(x):N→Term (de Bruijn index xxx),
    5. lam(t):Term→Term\mathsf{lam}(t) : \mathsf{Term} \to \mathsf{Term}lam(t):Term→Term (lambda abstraction λt\lambda tλt),
    6. app(t,u):Term→Term→Term\mathsf{app}(t, u) : \mathsf{Term} \to \mathsf{Term} \to \mathsf{Term}app(t,u):Term→Term→Term (application t  ut\;utu),
    7. zero:Term\mathsf{zero} : \mathsf{Term}zero:Term (zero constructor 000),
    8. succ(t):Term→Term\mathsf{succ}(t) : \mathsf{Term} \to \mathsf{Term}succ(t):Term→Term (successor succ(t)\mathsf{succ}(t)succ(t)),
    9. natrec(A,z,s,n):Term→Term→Term→Term→Term\mathsf{natrec}(A, z, s, n) : \mathsf{Term} \to \mathsf{Term} \to \mathsf{Term} \to \mathsf{Term} \to \mathsf{Term}natrec(A,z,s,n):Term→Term→Term→Term→Term (recursor with motive AAA, base case zzz, step case sss, and target nnn).
  • Context: Abbreviated as List  Term\mathsf{List}\;\mathsf{Term}ListTerm (newest-first list representation where A::ΓA :: \GammaA::Γ extends Γ\GammaΓ by AAA).

Renamings and Syntactic Weakenings

  • liftRen: Given ρ:N→N\rho : \mathbb{N} \to \mathbb{N}ρ:N→N, defines liftRen(ρ):N→N\mathsf{liftRen}(\rho) : \mathbb{N} \to \mathbb{N}liftRen(ρ):N→N by:
liftRen(ρ)(0)=0,liftRen(ρ)(n+1)=ρ(n)+1.\mathsf{liftRen}(\rho)(0) = 0, \qquad \mathsf{liftRen}(\rho)(n + 1) = \rho(n) + 1.liftRen(ρ)(0)=0,liftRen(ρ)(n+1)=ρ(n)+1.
  • rename: Given ρ:N→N\rho : \mathbb{N} \to \mathbb{N}ρ:N→N, defines rename(ρ):Term→Term\mathsf{rename}(\rho) : \mathsf{Term} \to \mathsf{Term}rename(ρ):Term→Term by structural recursion:
rename(ρ,univ)=univ,rename(ρ,pi(A,B))=pi(rename(ρ,A),rename(liftRen(ρ),B)),rename(ρ,nat)=nat,rename(ρ,var(x))=var(ρ(x)),rename(ρ,lam(t))=lam(rename(liftRen(ρ),t)),rename(ρ,app(t,u))=app(rename(ρ,t),rename(ρ,u)),rename(ρ,zero)=zero,rename(ρ,succ(t))=succ(rename(ρ,t)),rename(ρ,natrec(A,z,s,n))=natrec(rename(liftRen(ρ),A),rename(ρ,z),rename(ρ,s),rename(ρ,n)).\begin{aligned} \mathsf{rename}(\rho, \mathsf{univ}) &= \mathsf{univ}, \\ \mathsf{rename}(\rho, \mathsf{pi}(A, B)) &= \mathsf{pi}(\mathsf{rename}(\rho, A), \mathsf{rename}(\mathsf{liftRen}(\rho), B)), \\ \mathsf{rename}(\rho, \mathsf{nat}) &= \mathsf{nat}, \\ \mathsf{rename}(\rho, \mathsf{var}(x)) &= \mathsf{var}(\rho(x)), \\ \mathsf{rename}(\rho, \mathsf{lam}(t)) &= \mathsf{lam}(\mathsf{rename}(\mathsf{liftRen}(\rho), t)), \\ \mathsf{rename}(\rho, \mathsf{app}(t, u)) &= \mathsf{app}(\mathsf{rename}(\rho, t), \mathsf{rename}(\rho, u)), \\ \mathsf{rename}(\rho, \mathsf{zero}) &= \mathsf{zero}, \\ \mathsf{rename}(\rho, \mathsf{succ}(t)) &= \mathsf{succ}(\mathsf{rename}(\rho, t)), \\ \mathsf{rename}(\rho, \mathsf{natrec}(A, z, s, n)) &= \mathsf{natrec}(\mathsf{rename}(\mathsf{liftRen}(\rho), A), \mathsf{rename}(\rho, z), \mathsf{rename}(\rho, s), \mathsf{rename}(\rho, n)). \end{aligned}rename(ρ,univ)rename(ρ,pi(A,B))rename(ρ,nat)rename(ρ,var(x))rename(ρ,lam(t))rename(ρ,app(t,u))rename(ρ,zero)rename(ρ,succ(t))rename(ρ,natrec(A,z,s,n))​=univ,=pi(rename(ρ,A),rename(liftRen(ρ),B)),=nat,=var(ρ(x)),=lam(rename(liftRen(ρ),t)),=app(rename(ρ,t),rename(ρ,u)),=zero,=succ(rename(ρ,t)),=natrec(rename(liftRen(ρ),A),rename(ρ,z),rename(ρ,s),rename(ρ,n)).​
  • Wk: An inductive type (deriving DecidableEq and Repr) of syntactic weakenings with 3 constructors:
id:Wk,step:Wk→Wk,lift:Wk→Wk.\mathsf{id} : \mathsf{Wk}, \qquad \mathsf{step} : \mathsf{Wk} \to \mathsf{Wk}, \qquad \mathsf{lift} : \mathsf{Wk} \to \mathsf{Wk}.id:Wk,step:Wk→Wk,lift:Wk→Wk.
  • wkVar: Action of a weakening on de Bruijn indices wkVar:Wk→N→N\mathsf{wkVar} : \mathsf{Wk} \to \mathbb{N} \to \mathbb{N}wkVar:Wk→N→N:
wkVar(id,n)=n,wkVar(step(ρ),n)=wkVar(ρ,n)+1,wkVar(lift(ρ),0)=0,wkVar(lift(ρ),n+1)=wkVar(ρ,n)+1.\begin{aligned} \mathsf{wkVar}(\mathsf{id}, n) &= n, \\ \mathsf{wkVar}(\mathsf{step}(\rho), n) &= \mathsf{wkVar}(\rho, n) + 1, \\ \mathsf{wkVar}(\mathsf{lift}(\rho), 0) &= 0, \\ \mathsf{wkVar}(\mathsf{lift}(\rho), n + 1) &= \mathsf{wkVar}(\rho, n) + 1. \end{aligned}wkVar(id,n)wkVar(step(ρ),n)wkVar(lift(ρ),0)wkVar(lift(ρ),n+1)​=n,=wkVar(ρ,n)+1,=0,=wkVar(ρ,n)+1.​
  • wk: Action of ρ:Wk\rho : \mathsf{Wk}ρ:Wk on terms wk(ρ):Term→Term\mathsf{wk}(\rho) : \mathsf{Term} \to \mathsf{Term}wk(ρ):Term→Term:
wk(ρ,univ)=univ,wk(ρ,pi(A,B))=pi(wk(ρ,A),wk(lift(ρ),B)),wk(ρ,nat)=nat,wk(ρ,var(x))=var(wkVar(ρ,x)),wk(ρ,lam(t))=lam(wk(lift(ρ),t)),wk(ρ,app(t,u))=app(wk(ρ,t),wk(ρ,u)),wk(ρ,zero)=zero,wk(ρ,succ(t))=succ(wk(ρ,t)),wk(ρ,natrec(A,z,s,n))=natrec(wk(lift(ρ),A),wk(ρ,z),wk(ρ,s),wk(ρ,n)).\begin{aligned} \mathsf{wk}(\rho, \mathsf{univ}) &= \mathsf{univ}, \\ \mathsf{wk}(\rho, \mathsf{pi}(A, B)) &= \mathsf{pi}(\mathsf{wk}(\rho, A), \mathsf{wk}(\mathsf{lift}(\rho), B)), \\ \mathsf{wk}(\rho, \mathsf{nat}) &= \mathsf{nat}, \\ \mathsf{wk}(\rho, \mathsf{var}(x)) &= \mathsf{var}(\mathsf{wkVar}(\rho, x)), \\ \mathsf{wk}(\rho, \mathsf{lam}(t)) &= \mathsf{lam}(\mathsf{wk}(\mathsf{lift}(\rho), t)), \\ \mathsf{wk}(\rho, \mathsf{app}(t, u)) &= \mathsf{app}(\mathsf{wk}(\rho, t), \mathsf{wk}(\rho, u)), \\ \mathsf{wk}(\rho, \mathsf{zero}) &= \mathsf{zero}, \\ \mathsf{wk}(\rho, \mathsf{succ}(t)) &= \mathsf{succ}(\mathsf{wk}(\rho, t)), \\ \mathsf{wk}(\rho, \mathsf{natrec}(A, z, s, n)) &= \mathsf{natrec}(\mathsf{wk}(\mathsf{lift}(\rho), A), \mathsf{wk}(\rho, z), \mathsf{wk}(\rho, s), \mathsf{wk}(\rho, n)). \end{aligned}wk(ρ,univ)wk(ρ,pi(A,B))wk(ρ,nat)wk(ρ,var(x))wk(ρ,lam(t))wk(ρ,app(t,u))wk(ρ,zero)wk(ρ,succ(t))wk(ρ,natrec(A,z,s,n))​=univ,=pi(wk(ρ,A),wk(lift(ρ),B)),=nat,=var(wkVar(ρ,x)),=lam(wk(lift(ρ),t)),=app(wk(ρ,t),wk(ρ,u)),=zero,=succ(wk(ρ,t)),=natrec(wk(lift(ρ),A),wk(ρ,z),wk(ρ,s),wk(ρ,n)).​
  • wk1: Single-variable weakening wk1:Term→Term\mathsf{wk1} : \mathsf{Term} \to \mathsf{Term}wk1:Term→Term defined as wk(step(id))\mathsf{wk}(\mathsf{step}(\mathsf{id}))wk(step(id)).
  • compWk: Composition of weakenings compWk:Wk→Wk→Wk\mathsf{compWk} : \mathsf{Wk} \to \mathsf{Wk} \to \mathsf{Wk}compWk:Wk→Wk→Wk:
compWk(id,ρ′)=ρ′,compWk(step(ρ),ρ′)=step(compWk(ρ,ρ′)),compWk(lift(ρ),id)=lift(ρ),compWk(lift(ρ),step(ρ′))=step(compWk(ρ,ρ′)),compWk(lift(ρ),lift(ρ′))=lift(compWk(ρ,ρ′)).\begin{aligned} \mathsf{compWk}(\mathsf{id}, \rho') &= \rho', \\ \mathsf{compWk}(\mathsf{step}(\rho), \rho') &= \mathsf{step}(\mathsf{compWk}(\rho, \rho')), \\ \mathsf{compWk}(\mathsf{lift}(\rho), \mathsf{id}) &= \mathsf{lift}(\rho), \\ \mathsf{compWk}(\mathsf{lift}(\rho), \mathsf{step}(\rho')) &= \mathsf{step}(\mathsf{compWk}(\rho, \rho')), \\ \mathsf{compWk}(\mathsf{lift}(\rho), \mathsf{lift}(\rho')) &= \mathsf{lift}(\mathsf{compWk}(\rho, \rho')). \end{aligned}compWk(id,ρ′)compWk(step(ρ),ρ′)compWk(lift(ρ),id)compWk(lift(ρ),step(ρ′))compWk(lift(ρ),lift(ρ′))​=ρ′,=step(compWk(ρ,ρ′)),=lift(ρ),=step(compWk(ρ,ρ′)),=lift(compWk(ρ,ρ′)).​

Substitutions and Derived Syntactic Operations

  • Subst: Abbreviated as N→Term\mathbb{N} \to \mathsf{Term}N→Term.
  • liftSubst: Given σ:Subst\sigma : \mathsf{Subst}σ:Subst, defines liftSubst(σ):Subst\mathsf{liftSubst}(\sigma) : \mathsf{Subst}liftSubst(σ):Subst by:
liftSubst(σ)(0)=var(0),liftSubst(σ)(n+1)=wk1(σ(n)).\mathsf{liftSubst}(\sigma)(0) = \mathsf{var}(0), \qquad \mathsf{liftSubst}(\sigma)(n + 1) = \mathsf{wk1}(\sigma(n)).liftSubst(σ)(0)=var(0),liftSubst(σ)(n+1)=wk1(σ(n)).
  • subst: Given σ:Subst\sigma : \mathsf{Subst}σ:Subst, defines subst(σ):Term→Term\mathsf{subst}(\sigma) : \mathsf{Term} \to \mathsf{Term}subst(σ):Term→Term by:
subst(σ,univ)=univ,subst(σ,pi(A,B))=pi(subst(σ,A),subst(liftSubst(σ),B)),subst(σ,nat)=nat,subst(σ,var(x))=σ(x),subst(σ,lam(t))=lam(subst(liftSubst(σ),t)),subst(σ,app(t,u))=app(subst(σ,t),subst(σ,u)),subst(σ,zero)=zero,subst(σ,succ(t))=succ(subst(σ,t)),subst(σ,natrec(A,z,s,n))=natrec(subst(liftSubst(σ),A),subst(σ,z),subst(σ,s),subst(σ,n)).\begin{aligned} \mathsf{subst}(\sigma, \mathsf{univ}) &= \mathsf{univ}, \\ \mathsf{subst}(\sigma, \mathsf{pi}(A, B)) &= \mathsf{pi}(\mathsf{subst}(\sigma, A), \mathsf{subst}(\mathsf{liftSubst}(\sigma), B)), \\ \mathsf{subst}(\sigma, \mathsf{nat}) &= \mathsf{nat}, \\ \mathsf{subst}(\sigma, \mathsf{var}(x)) &= \sigma(x), \\ \mathsf{subst}(\sigma, \mathsf{lam}(t)) &= \mathsf{lam}(\mathsf{subst}(\mathsf{liftSubst}(\sigma), t)), \\ \mathsf{subst}(\sigma, \mathsf{app}(t, u)) &= \mathsf{app}(\mathsf{subst}(\sigma, t), \mathsf{subst}(\sigma, u)), \\ \mathsf{subst}(\sigma, \mathsf{zero}) &= \mathsf{zero}, \\ \mathsf{subst}(\sigma, \mathsf{succ}(t)) &= \mathsf{succ}(\mathsf{subst}(\sigma, t)), \\ \mathsf{subst}(\sigma, \mathsf{natrec}(A, z, s, n)) &= \mathsf{natrec}(\mathsf{subst}(\mathsf{liftSubst}(\sigma), A), \mathsf{subst}(\sigma, z), \mathsf{subst}(\sigma, s), \mathsf{subst}(\sigma, n)). \end{aligned}subst(σ,univ)subst(σ,pi(A,B))subst(σ,nat)subst(σ,var(x))subst(σ,lam(t))subst(σ,app(t,u))subst(σ,zero)subst(σ,succ(t))subst(σ,natrec(A,z,s,n))​=univ,=pi(subst(σ,A),subst(liftSubst(σ),B)),=nat,=σ(x),=lam(subst(liftSubst(σ),t)),=app(subst(σ,t),subst(σ,u)),=zero,=succ(subst(σ,t)),=natrec(subst(liftSubst(σ),A),subst(σ,z),subst(σ,s),subst(σ,n)).​
  • consSubst: Given σ:Subst\sigma : \mathsf{Subst}σ:Subst and a:Terma : \mathsf{Term}a:Term, defines consSubst(σ,a)(0)=a\mathsf{consSubst}(\sigma, a)(0) = aconsSubst(σ,a)(0)=a and consSubst(σ,a)(n+1)=σ(n)\mathsf{consSubst}(\sigma, a)(n + 1) = \sigma(n)consSubst(σ,a)(n+1)=σ(n).
  • idSubst: idSubst(n)=var(n)\mathsf{idSubst}(n) = \mathsf{var}(n)idSubst(n)=var(n).
  • sgSubst: Given a:Terma : \mathsf{Term}a:Term, sgSubst(a)=consSubst(idSubst,a)\mathsf{sgSubst}(a) = \mathsf{consSubst}(\mathsf{idSubst}, a)sgSubst(a)=consSubst(idSubst,a).
  • toSubst: Given ρ:Wk\rho : \mathsf{Wk}ρ:Wk, toSubst(ρ)(x)=var(wkVar(ρ,x))\mathsf{toSubst}(\rho)(x) = \mathsf{var}(\mathsf{wkVar}(\rho, x))toSubst(ρ)(x)=var(wkVar(ρ,x)).
  • headSubst: headSubst(σ)=σ(0)\mathsf{headSubst}(\sigma) = \sigma(0)headSubst(σ)=σ(0).
  • tailSubst: tailSubst(σ)(n)=σ(n+1)\mathsf{tailSubst}(\sigma)(n) = \sigma(n + 1)tailSubst(σ)(n)=σ(n+1).
  • wk1Subst: wk1Subst(σ)(n)=wk1(σ(n))\mathsf{wk1Subst}(\sigma)(n) = \mathsf{wk1}(\sigma(n))wk1Subst(σ)(n)=wk1(σ(n)).
  • compSubst: compSubst(σ,τ)(n)=subst(σ,τ(n))\mathsf{compSubst}(\sigma, \tau)(n) = \mathsf{subst}(\sigma, \tau(n))compSubst(σ,τ)(n)=subst(σ,τ(n)).
  • wkSubst: wkSubst(ρ,σ)(n)=wk(ρ,σ(n))\mathsf{wkSubst}(\rho, \sigma)(n) = \mathsf{wk}(\rho, \sigma(n))wkSubst(ρ,σ)(n)=wk(ρ,σ(n)).
  • substWk: substWk(σ,ρ)(n)=σ(wkVar(ρ,n))\mathsf{substWk}(\sigma, \rho)(n) = \sigma(\mathsf{wkVar}(\rho, n))substWk(σ,ρ)(n)=σ(wkVar(ρ,n)).
  • subst0: Single substitution removing binder 000: subst0(t,a)=subst(consSubst(idSubst,a),t)\mathsf{subst0}(t, a) = \mathsf{subst}(\mathsf{consSubst}(\mathsf{idSubst}, a), t)subst0(t,a)=subst(consSubst(idSubst,a),t).
  • substKeep: Single substitution retaining the context: substKeep(t,a)=subst(consSubst(wk1Subst(idSubst),a),t)\mathsf{substKeep}(t, a) = \mathsf{subst}(\mathsf{consSubst}(\mathsf{wk1Subst}(\mathsf{idSubst}), a), t)substKeep(t,a)=subst(consSubst(wk1Subst(idSubst),a),t).
  • arr: Non-dependent function type arr(A,B)=pi(A,wk1(B))\mathsf{arr}(A, B) = \mathsf{pi}(A, \mathsf{wk1}(B))arr(A,B)=pi(A,wk1(B)).
  • recStepType: Step-case type for natrec\mathsf{natrec}natrec with motive FFF:
recStepType(F)=pi(nat,arr(F,substKeep(F,succ(var(0))))).\mathsf{recStepType}(F) = \mathsf{pi}(\mathsf{nat}, \mathsf{arr}(F, \mathsf{substKeep}(F, \mathsf{succ}(\mathsf{var}(0))))).recStepType(F)=pi(nat,arr(F,substKeep(F,succ(var(0))))).
  • suck: Numeral representation suck:N→Term\mathsf{suck} : \mathbb{N} \to \mathsf{Term}suck:N→Term defined by suck(0)=zero\mathsf{suck}(0) = \mathsf{zero}suck(0)=zero and suck(n+1)=succ(suck(n))\mathsf{suck}(n + 1) = \mathsf{succ}(\mathsf{suck}(n))suck(n+1)=succ(suck(n)).

Syntactic Views and Normal Form Predicates

  • Neutral: Inductive predicate Neutral:Term→Prop\mathsf{Neutral} : \mathsf{Term} \to \mathsf{Prop}Neutral:Term→Prop with 3 constructors:
    1. var(n):Neutral(var(n))\mathsf{var}(n) : \mathsf{Neutral}(\mathsf{var}(n))var(n):Neutral(var(n)) for n:Nn : \mathbb{N}n:N,
    2. app:Neutral(k)→Neutral(app(k,u))\mathsf{app} : \mathsf{Neutral}(k) \to \mathsf{Neutral}(\mathsf{app}(k, u))app:Neutral(k)→Neutral(app(k,u)),
    3. natrec:Neutral(k)→Neutral(natrec(C,z,s,k))\mathsf{natrec} : \mathsf{Neutral}(k) \to \mathsf{Neutral}(\mathsf{natrec}(C, z, s, k))natrec:Neutral(k)→Neutral(natrec(C,z,s,k)).
  • Whnf: Inductive predicate Whnf:Term→Prop\mathsf{Whnf} : \mathsf{Term} \to \mathsf{Prop}Whnf:Term→Prop with 7 constructors:
Whnf(univ),Whnf(pi(A,B)),Whnf(nat),Whnf(lam(t)),Whnf(zero),Whnf(succ(t)),Neutral(n)→Whnf(n).\mathsf{Whnf}(\mathsf{univ}), \quad \mathsf{Whnf}(\mathsf{pi}(A, B)), \quad \mathsf{Whnf}(\mathsf{nat}), \quad \mathsf{Whnf}(\mathsf{lam}(t)), \quad \mathsf{Whnf}(\mathsf{zero}), \quad \mathsf{Whnf}(\mathsf{succ}(t)), \quad \mathsf{Neutral}(n) \to \mathsf{Whnf}(n).Whnf(univ),Whnf(pi(A,B)),Whnf(nat),Whnf(lam(t)),Whnf(zero),Whnf(succ(t)),Neutral(n)→Whnf(n).
  • NaturalView: Inductive predicate NaturalView:Term→Prop\mathsf{NaturalView} : \mathsf{Term} \to \mathsf{Prop}NaturalView:Term→Prop with 3 constructors:
NaturalView(zero),NaturalView(succ(t)),Neutral(n)→NaturalView(n).\mathsf{NaturalView}(\mathsf{zero}), \qquad \mathsf{NaturalView}(\mathsf{succ}(t)), \qquad \mathsf{Neutral}(n) \to \mathsf{NaturalView}(n).NaturalView(zero),NaturalView(succ(t)),Neutral(n)→NaturalView(n).
  • SmallTypeView: Inductive predicate SmallTypeView:Term→Prop\mathsf{SmallTypeView} : \mathsf{Term} \to \mathsf{Prop}SmallTypeView:Term→Prop with 3 constructors (excluding univ\mathsf{univ}univ):
SmallTypeView(pi(A,B)),SmallTypeView(nat),Neutral(n)→SmallTypeView(n).\mathsf{SmallTypeView}(\mathsf{pi}(A, B)), \qquad \mathsf{SmallTypeView}(\mathsf{nat}), \qquad \mathsf{Neutral}(n) \to \mathsf{SmallTypeView}(n).SmallTypeView(pi(A,B)),SmallTypeView(nat),Neutral(n)→SmallTypeView(n).
  • FunctionView: Inductive predicate FunctionView:Term→Prop\mathsf{FunctionView} : \mathsf{Term} \to \mathsf{Prop}FunctionView:Term→Prop with 2 constructors:
FunctionView(lam(t)),Neutral(n)→FunctionView(n).\mathsf{FunctionView}(\mathsf{lam}(t)), \qquad \mathsf{Neutral}(n) \to \mathsf{FunctionView}(n).FunctionView(lam(t)),Neutral(n)→FunctionView(n).
Human review
  • Endorsed by Shuze Chen · Nov 7, 2026

    Confirmed by the moderator at approval.

  • Endorsed by kmehltretter82 · Nov 7, 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