Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Characterization of the Polynomial-Time Functions by RA and RS

Open
BNS2000.ptime_characterization

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

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

Main Result (Sections 4-5, pp. 21-29): The numerical functions definable by closed level-1 terms of RA, the numerical functions definable by closed level-1 terms of RS, and the polynomial-time computable functions (BCFunc k 0) coincide.

Preamble
import Definitions.Def_BNS2000_Terms
Formal statement
namespace BNS2000

/-- **Characterization of Polynomial-Time Computability by Higher-Type Ramified Affinable Recursion**
(Sections 1 & 5, pp. 18, 26–27):
A numerical function `F : (Fin k → Nat) → Nat` is denoted by a closed `RA`-term `t` of type
`!ι → ⋯ → !ι → ι` if and only if `F` is computable in polynomial time (characterized via the
Bellantoni–Cook safe recursion function algebra `BCFunc k 0` together with a polynomial bound
`p_t` on the normalization complexity of `t (!n₁) ... (!nₖ)`). -/
theorem ptime_characterization
    (k : Nat) (F : (Fin k → Nat) → Nat) :
    (∃ t : Term, RADenotesTwoSorted (m := k) (n := 0) t (fun xs _ => F xs)) ↔
    (∃ f : BCFunc k 0, ∀ xs : Fin k → Nat, F xs = evalBC f xs Fin.elim0) := 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). Sections 4-5, Theorems 5.1 and 5.2, pp. 21-29.
Read-back

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

Read-back: Thm_BNS2000_ptime_characterization.lean

ptime_characterization

For every natural number k∈Nk \in \mathbb{N}k∈N and every kkk-ary numerical function F:(Fin(k)→N)→NF : (\mathsf{Fin}(k) \to \mathbb{N}) \to \mathbb{N}F:(Fin(k)→N)→N, the following two statements are logically equivalent:

  1. Representability by a closed RA\mathsf{RA}RA-term of type !ι→⋯→!ι→ι!\iota \to \cdots \to !\iota \to \iota!ι→⋯→!ι→ι: There exists a term t∈Termt \in \mathsf{Term}t∈Term such that RADenotesTwoSortedk,0(t,(x⃗,_)↦F(x⃗))\mathsf{RADenotesTwoSorted}_{k, 0}(t, (\vec{x}, \_) \mapsto F(\vec{x}))RADenotesTwoSortedk,0​(t,(x,_)↦F(x)) holds — that is:
    • ttt is a well-typed term satisfying properties (R) and (A) (IsRATerm(t)\mathsf{IsRATerm}(t)IsRATerm(t)),
    • ttt is closed (freeVars(t)=[]\mathsf{freeVars}(t) = []freeVars(t)=[]),
    • ttt has type !ι→⋯→!ι⏟k→ι\underbrace{!\iota \to \cdots \to !\iota}_{k} \to \iotak!ι→⋯→!ι​​→ι, and
    • for every x⃗:Fin(k)→N\vec{x} : \mathsf{Fin}(k) \to \mathbb{N}x:Fin(k)→N, writing n‾=binaryNumeralOfNat(n)\overline{n} = \mathsf{binaryNumeralOfNat}(n)n=binaryNumeralOfNat(n), the canonical binary numeral F(x⃗)‾\overline{F(\vec{x})}F(x)​ is a normal form of the left-associated application
t (!x0‾)⋯(!xk−1‾).t\, (!\overline{x_0}) \cdots (!\overline{x_{k-1}}).t(!x0​​)⋯(!xk−1​​).
  1. Representability in the Bellantoni–Cook safe recursion function algebra BCFunc(k,0)\mathsf{BCFunc}(k, 0)BCFunc(k,0): There exists a Bellantoni–Cook function syntax tree f∈BCFunc(k,0)f \in \mathsf{BCFunc}(k, 0)f∈BCFunc(k,0) with kkk normal arguments and 000 safe arguments such that for every x⃗:Fin(k)→N\vec{x} : \mathsf{Fin}(k) \to \mathbb{N}x:Fin(k)→N,
F(x⃗)=evalBC(f,x⃗,Fin.elim0).F(\vec{x}) = \mathsf{evalBC}(f, \vec{x}, \mathsf{Fin.elim0}).F(x)=evalBC(f,x,Fin.elim0).

Edge-Case and Faithfulness Notes

  • In this theorem statement, "polynomial-time computability" of F:(Fin(k)→N)→NF : (\mathsf{Fin}(k) \to \mathbb{N}) \to \mathbb{N}F:(Fin(k)→N)→N is formalized via representability in the Bellantoni–Cook safe recursion algebra BCFunc(k,0)\mathsf{BCFunc}(k, 0)BCFunc(k,0) rather than via a direct Turing-machine time-complexity definition.
  • The polynomial bound ptp_tpt​ on register-machine normalization steps and register lengths mentioned in the docstring is proved separately in theorem_5_1 for any closed RA\mathsf{RA}RA-term ttt of ground-arrow type σ0→⋯→σk−1→τ\sigma_0 \to \cdots \to \sigma_{k-1} \to \tauσ0​→⋯→σk−1​→τ, and is not part of the equivalence in ptime_characterization itself.
  • The right-to-left implication (⇐\Leftarrow⇐) is the m=k,n=0m = k, n = 0m=k,n=0 case of theorem_5_2, while the left-to-right implication (⇒\Rightarrow⇒) states that every kkk-ary function on N\mathbb{N}N denoted by a closed RA\mathsf{RA}RA-term of type !ι→⋯→!ι→ι!\iota \to \cdots \to !\iota \to \iota!ι→⋯→!ι→ι is computable by a Bellantoni–Cook term in BCFunc(k,0)\mathsf{BCFunc}(k, 0)BCFunc(k,0).
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