Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Register-Machine Evaluation and Linear Step/Register Bounds for R-Free RS-Terms (Theorem 4.3 & Corollary 4.4)

Open
BNS2000.theorem_4_3_and_4_4

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

implicit-computational-complexitypolynomial-timeproof-theoryramified-recursiontype-theory

Theorem 4.3 and Corollary 4.4 (pp. 23-24): Every R-free RS-term t of ground type evaluated on numeral environment n⃗ via NFEval computes its numeral normal form nf(t[n⃗/x⃗]) in at most 2|t| steps using at most |t| registers of length at most |t| + max |n_i|.

Preamble
import Definitions.Def_BNS2000_Terms
Formal statement
namespace BNS2000

/-- **Theorem 4.3 and Corollary 4.4 (Base Normalisation)** (Section 4, p. 24):
1. (**Theorem 4.3**): For every `R`-free `RS`-term `t` of ground type and numeral environment
   `n⃗; x⃗` (`IsNumeralEnv env`) such that `FV(t) ⊆ x⃗`:
   (i) the register-machine algorithm `nf(t; n⃗; x⃗)` (`NFEval`) computes the numeral normal form
       `out = nf(t[n⃗/x⃗])` in at most `2 |t|` steps,
   (ii) the number of used registers is `≤ |t| + #n⃗`, and
   (iii) the maximum length `maxLen` of any term occurring in the computation satisfies
         `maxLen ≤ |t| + max |nᵢ|`.
2. (**Corollary 4.4, Base Normalisation**): For every closed `R`-free `RS`-term `t` of ground
   type, the numeral `nf(t)` is computed in at most `2 |t|` steps using `≤ |t|` registers,
   with every term occurring in the computation having length `≤ |t|`. -/
theorem theorem_4_3_and_4_4 :
    (∀ (t : Term) (τ : Ty) (env : List (Var × Term)),
      IsRSTerm t →
      isRFree t = true →
      HasType t τ →
      τ.isGround = true →
      IsNumeralEnv env →
      (∀ v ∈ freeVars t, v ∈ env.map Prod.fst) →
      ∃ (out : Term) (steps regs maxLen : Nat),
        NFEval t env out steps regs maxLen ∧
        IsNormalFormOf (substEnv t env) out ∧
        isNumeral out = true ∧
        steps ≤ 2 * termLength t ∧
        regs ≤ termLength t + env.length ∧
        maxLen ≤ termLength t + maxEnvTermLength env) ∧
    (∀ (t : Term) (τ : Ty),
      IsRSTerm t →
      isRFree t = true →
      IsClosed t →
      HasType t τ →
      τ.isGround = true →
      ∃ (out : Term) (steps regs maxLen : Nat),
        NFEval t [] out steps regs maxLen ∧
        IsNormalFormOf t out ∧
        isNumeral out = true ∧
        steps ≤ 2 * termLength t ∧
        regs ≤ termLength t ∧
        maxLen ≤ termLength t) := by
  sorry

end BNS2000
Source
Stephen Bellantoni, Karl-Heinz Niggl, and Helmut Schwichtenberg, 'Higher type recursion, ramification and polynomial time', Annals of Pure and Applied Logic 104, 2000, pp. 17-30 (doi:10.1016/S0168-0072(00)00006-3). Section 4, Theorem 4.3 and Corollary 4.4, pp. 23-24.
Read-back

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

Read-back: Thm_BNS2000_theorem_4_3_and_4_4.lean

theorem_4_3_and_4_4

The theorem is a conjunction of two universally quantified statements:

  1. Part 1 (Theorem 4.3 — Register-Machine Normalization in a Numeral Environment): For every term t∈Termt \in \mathsf{Term}t∈Term, type τ∈Ty\tau \in \mathsf{Ty}τ∈Ty, and environment list env=[(x1,n1),…,(xk,nk)]∈List(Var×Term)\mathsf{env} = [(x_1, n_1), \dots, (x_k, n_k)] \in \mathsf{List}(\mathsf{Var} \times \mathsf{Term})env=[(x1​,n1​),…,(xk​,nk​)]∈List(Var×Term), if:
    • ttt is an RS\mathsf{RS}RS-term (IsRSTerm(t)\mathsf{IsRSTerm}(t)IsRSTerm(t), meaning ttt is a well-typed RA\mathsf{RA}RA-term in which every free or bound variable has safe or ground type, every free higher-type variable vvv satisfies FO(v,t)≤1\mathsf{FO}(v, t) \le 1FO(v,t)≤1, and every subterm λx. s\lambda x.\, sλx.s with l(x.ty)≥1l(x.\mathsf{ty}) \ge 1l(x.ty)≥1 satisfies FO(x,s)≤1\mathsf{FO}(x, s) \le 1FO(x,s)≤1),
    • ttt contains no recursor constant RσR_\sigmaRσ​ (isRFree(t)=true\mathsf{isRFree}(t) = \mathsf{true}isRFree(t)=true),
    • ttt has type τ\tauτ (HasType(t,τ)\mathsf{HasType}(t, \tau)HasType(t,τ)),
    • τ\tauτ is a ground type (isGround(τ)=true\mathsf{isGround}(\tau) = \mathsf{true}isGround(τ)=true, i.e., l(τ)=0l(\tau) = 0l(τ)=0),
    • env\mathsf{env}env is a numeral environment (IsNumeralEnv(env)\mathsf{IsNumeralEnv}(\mathsf{env})IsNumeralEnv(env), meaning the variables x1,…,xkx_1, \dots, x_kx1​,…,xk​ are pairwise distinct and each nin_ini​ satisfies HasType(ni,xi.ty)\mathsf{HasType}(n_i, x_i.\mathsf{ty})HasType(ni​,xi​.ty) and isNumeral(ni)=true\mathsf{isNumeral}(n_i) = \mathsf{true}isNumeral(ni​)=true, so ni=!mibin_i = !^{m_i} b_ini​=!mi​bi​ for a binary numeral bib_ibi​), and
    • every free variable v∈freeVars(t)v \in \mathsf{freeVars}(t)v∈freeVars(t) is among {x1,…,xk}\{x_1, \dots, x_k\}{x1​,…,xk​} (∀v∈freeVars(t),  v∈env.map(Prod.fst)\forall v \in \mathsf{freeVars}(t),\; v \in \mathsf{env.map}(\mathsf{Prod.fst})∀v∈freeVars(t),v∈env.map(Prod.fst)), then there exist an output term out∈Term\mathsf{out} \in \mathsf{Term}out∈Term and natural numbers steps,regs,maxLen∈N\mathsf{steps}, \mathsf{regs}, \mathsf{maxLen} \in \mathbb{N}steps,regs,maxLen∈N such that:
    • NFEval(t,env,out,steps,regs,maxLen)\mathsf{NFEval}(t, \mathsf{env}, \mathsf{out}, \mathsf{steps}, \mathsf{regs}, \mathsf{maxLen})NFEval(t,env,out,steps,regs,maxLen) holds (the inductive register-machine evaluation relation produces out\mathsf{out}out from ttt and env\mathsf{env}env with cost parameters steps\mathsf{steps}steps, regs\mathsf{regs}regs, and maxLen\mathsf{maxLen}maxLen),
    • out\mathsf{out}out is a normal form of the substituted term substEnv(t,env)=t[n1/x1]⋯[nk/xk]\mathsf{substEnv}(t, \mathsf{env}) = t[n_1/x_1]\cdots[n_k/x_k]substEnv(t,env)=t[n1​/x1​]⋯[nk​/xk​] (IsNormalFormOf(substEnv(t,env),out)\mathsf{IsNormalFormOf}(\mathsf{substEnv}(t, \mathsf{env}), \mathsf{out})IsNormalFormOf(substEnv(t,env),out)),
    • out\mathsf{out}out is a numeral (isNumeral(out)=true\mathsf{isNumeral}(\mathsf{out}) = \mathsf{true}isNumeral(out)=true), and
    • the resource bounds hold:
steps≤2 ∣t∣,regs≤∣t∣+∣env∣,maxLen≤∣t∣+max⁡1≤i≤k∣ni∣.\mathsf{steps} \le 2\,|t|, \qquad \mathsf{regs} \le |t| + |\mathsf{env}|, \qquad \mathsf{maxLen} \le |t| + \max_{1 \le i \le k} |n_i|.steps≤2∣t∣,regs≤∣t∣+∣env∣,maxLen≤∣t∣+1≤i≤kmax​∣ni​∣.
  1. Part 2 (Corollary 4.4 — Base Normalization of Closed Ground RRR-Free RS\mathsf{RS}RS-Terms): For every term t∈Termt \in \mathsf{Term}t∈Term and type τ∈Ty\tau \in \mathsf{Ty}τ∈Ty, if:
    • ttt is an RS\mathsf{RS}RS-term (IsRSTerm(t)\mathsf{IsRSTerm}(t)IsRSTerm(t)),
    • ttt contains no recursor constant RσR_\sigmaRσ​ (isRFree(t)=true\mathsf{isRFree}(t) = \mathsf{true}isRFree(t)=true),
    • ttt is closed (IsClosed(t)\mathsf{IsClosed}(t)IsClosed(t), i.e., freeVars(t)=[]\mathsf{freeVars}(t) = []freeVars(t)=[]),
    • ttt has type τ\tauτ (HasType(t,τ)\mathsf{HasType}(t, \tau)HasType(t,τ)), and
    • τ\tauτ is a ground type (isGround(τ)=true\mathsf{isGround}(\tau) = \mathsf{true}isGround(τ)=true), then there exist an output term out∈Term\mathsf{out} \in \mathsf{Term}out∈Term and natural numbers steps,regs,maxLen∈N\mathsf{steps}, \mathsf{regs}, \mathsf{maxLen} \in \mathbb{N}steps,regs,maxLen∈N such that:
    • NFEval(t,[],out,steps,regs,maxLen)\mathsf{NFEval}(t, [], \mathsf{out}, \mathsf{steps}, \mathsf{regs}, \mathsf{maxLen})NFEval(t,[],out,steps,regs,maxLen) holds in the empty environment [][][],
    • out\mathsf{out}out is a normal form of ttt (IsNormalFormOf(t,out)\mathsf{IsNormalFormOf}(t, \mathsf{out})IsNormalFormOf(t,out)),
    • out\mathsf{out}out is a numeral (isNumeral(out)=true\mathsf{isNumeral}(\mathsf{out}) = \mathsf{true}isNumeral(out)=true), and
    • the resource bounds hold:
steps≤2 ∣t∣,regs≤∣t∣,maxLen≤∣t∣.\mathsf{steps} \le 2\,|t|, \qquad \mathsf{regs} \le |t|, \qquad \mathsf{maxLen} \le |t|.steps≤2∣t∣,regs≤∣t∣,maxLen≤∣t∣.

Edge-Case and Faithfulness Notes

  • In Part 1, because every numeral nin_ini​ in env\mathsf{env}env is closed (contains no variables) and the bound variables x1,…,xkx_1, \dots, x_kx1​,…,xk​ are pairwise distinct, the sequential substitution substEnv(t,env)\mathsf{substEnv}(t, \mathsf{env})substEnv(t,env) is identical to simultaneous substitution t[n⃗/x⃗]t[\vec{n}/\vec{x}]t[n/x].
  • When env=[]\mathsf{env} = []env=[], maxEnvTermLength([])=0\mathsf{maxEnvTermLength}([]) = 0maxEnvTermLength([])=0 and env.length=0\mathsf{env.length} = 0env.length=0, so Part 2 is the exact specialization of Part 1 to env=[]\mathsf{env} = []env=[].
Human review
  • Endorsed by Shuze Chen · Nov 20, 2026

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