Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Inclusion Theorem — Embedding Bellantoni-Cook Safe Recursion into RA and RS (Theorem 5.2)

Open
BNS2000.theorem_5_2

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

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

Theorem 5.2 (pp. 26-29): Every function f(x⃗; y⃗) in the Bellantoni-Cook algebra BC is represented by a closed RA-term (and RS-term) t_f of type ι₁ → ⋯ → ι_m → ι₀ → ⋯ → ι₀ → ι₀ using higher-type safe recursion at type ι₀ → ι₀.

Preamble
import Definitions.Def_BNS2000_Terms
Formal statement
namespace BNS2000

/-- **Theorem 5.2** (Section 5, p. 27):
Every function `f(x⃗; y⃗)` in the Bellantoni–Cook safe recursion function algebra `B`
(`f : BCFunc m n`, which characterizes the polynomial-time computable functions) is
denoted by a closed `RA`-term `t_f` of type `!ι → ⋯ → !ι → ι → ⋯ → ι → ι`
(`RADenotesTwoSorted t_f (evalBC f)`). -/
theorem theorem_5_2
    {m n : Nat} (f : BCFunc m n) :
    ∃ t_f : Term, RADenotesTwoSorted t_f (evalBC f) := 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 5, Theorem 5.2, pp. 26-29.
Read-back

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

Read-back: Thm_BNS2000_theorem_5_2.lean

theorem_5_2

For all natural numbers m,n∈Nm, n \in \mathbb{N}m,n∈N and every function syntax tree f∈BCFunc(m,n)f \in \mathsf{BCFunc}(m, n)f∈BCFunc(m,n) in the Bellantoni–Cook safe recursion algebra with mmm normal inputs and nnn safe inputs, there exists a term tf∈Termt_f \in \mathsf{Term}tf​∈Term such that RADenotesTwoSorted(tf,evalBC(f))\mathsf{RADenotesTwoSorted}(t_f, \mathsf{evalBC}(f))RADenotesTwoSorted(tf​,evalBC(f)) holds — that is:

  1. tft_ftf​ is an RA\mathsf{RA}RA-term (IsRATerm(tf)\mathsf{IsRATerm}(t_f)IsRATerm(tf​): tft_ftf​ is well-typed, every complete subterm of tft_ftf​ has only complete free variables, and for every subterm λx. s\lambda x.\, sλx.s of tft_ftf​ with xxx of incomplete type, xxx is affinable in some reduct s′s's′ of sss);
  2. tft_ftf​ is closed (IsClosed(tf)\mathsf{IsClosed}(t_f)IsClosed(tf​), i.e., freeVars(tf)=[]\mathsf{freeVars}(t_f) = []freeVars(tf​)=[]);
  3. tft_ftf​ has the type
!ι→⋯→!ι⏟m→ι→⋯→ι⏟n→ι\underbrace{!\iota \to \cdots \to !\iota}_{m} \to \underbrace{\iota \to \cdots \to \iota}_{n} \to \iotam!ι→⋯→!ι​​→nι→⋯→ι​​→ι

(HasType(tf,Ty.arrMany(List.replicate(m,!ι)+ ⁣+List.replicate(n,ι),ι))\mathsf{HasType}(t_f, \mathsf{Ty.arrMany}(\mathsf{List.replicate}(m, !\iota) \mathbin{+\!+} \mathsf{List.replicate}(n, \iota), \iota))HasType(tf​,Ty.arrMany(List.replicate(m,!ι)++List.replicate(n,ι),ι))); and 4. for every tuple of normal arguments x⃗:Fin(m)→N\vec{x} : \mathsf{Fin}(m) \to \mathbb{N}x:Fin(m)→N and every tuple of safe arguments y⃗:Fin(n)→N\vec{y} : \mathsf{Fin}(n) \to \mathbb{N}y​:Fin(n)→N, writing k‾=binaryNumeralOfNat(k)\overline{k} = \mathsf{binaryNumeralOfNat}(k)k=binaryNumeralOfNat(k) for the canonical binary numeral of k∈Nk \in \mathbb{N}k∈N, the canonical binary numeral evalBC(f,x⃗,y⃗)‾\overline{\mathsf{evalBC}(f, \vec{x}, \vec{y})}evalBC(f,x,y​)​ is a normal form of the left-associated application

tf (!x0‾)⋯(!xm−1‾) y0‾⋯yn−1‾t_f\, (!\overline{x_0}) \cdots (!\overline{x_{m-1}})\, \overline{y_0} \cdots \overline{y_{n-1}}tf​(!x0​​)⋯(!xm−1​​)y0​​⋯yn−1​​

(IsNormalFormOf(Term.appMany(tf,[!x0‾,…,!xm−1‾,y0‾,…,yn−1‾]),evalBC(f,x⃗,y⃗)‾)\mathsf{IsNormalFormOf}(\mathsf{Term.appMany}(t_f, [!\overline{x_0}, \dots, !\overline{x_{m-1}}, \overline{y_0}, \dots, \overline{y_{n-1}}]), \overline{\mathsf{evalBC}(f, \vec{x}, \vec{y})})IsNormalFormOf(Term.appMany(tf​,[!x0​​,…,!xm−1​​,y0​​,…,yn−1​​]),evalBC(f,x,y​)​)).

Edge-Case and Faithfulness Notes

  • The theorem covers all arities m,n≥0m, n \ge 0m,n≥0, including m=0m = 0m=0 (no normal inputs) and n=0n = 0n=0 (no safe inputs).
  • Both input numerals and the output numeral use the canonical binary representation binaryNumeralOfNat:N→Term\mathsf{binaryNumeralOfNat} : \mathbb{N} \to \mathsf{Term}binaryNumeralOfNat:N→Term (0↦00 \mapsto 00↦0, 1↦s1 01 \mapsto s_1\, 01↦s1​0, 2↦s0(s1 0)2 \mapsto s_0(s_1\, 0)2↦s0​(s1​0), 3↦s1(s1 0)3 \mapsto s_1(s_1\, 0)3↦s1​(s1​0), etc.), with normal arguments wrapped in a single !!! constructor (!xi‾!\overline{x_i}!xi​​ of type !ι!\iota!ι) and safe arguments passed unwrapped (yj‾\overline{y_j}yj​​ of type ι\iotaι).
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