Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Polynomial Evaluation of Type `0 → 0` Subterms on Nonzero Numerals

Proved
Schwichtenberg1976V2.subterm_polynomial_lemma

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

church-numeralsdefinabilitylambda-calculuspolynomialstype-theory

For every subterm s generated by clauses (1)-(3) (IsType00Subterm), either s = α or there exist a multivariate polynomial P with natural number coefficients and a variable z : 0 such that substituting Fᵢ ↦ n̄ᵢ with n₁, ..., nₖ ≠ 0 reduces s to λy. α^{P(n₁, ..., nₖ)} z.

Preamble
import Definitions.Def_Schwichtenberg1976V2_Lambda
Formal statement
namespace Schwichtenberg1976V2

/-- Inductive lemma on clauses (1)–(3) (p. 114, lines 14–22):
For every `s` satisfying `IsType00Subterm (List.ofFn Fs) α s`, either `s = .var α`, or
there exist a multivariate polynomial `P : (Fin k → Nat) → Nat` (`IsPolynomial P`) and
a variable `z` of type `0` (either bound by the outer `λy` or free in `s`) such that for
all positive inputs `v : Fin k → Nat` (`∀ i, v i ≠ 0`), substituting `Fᵢ ↦ v(i)̄` into `s`
reduces to `λy. α^{P(v)} z` (which is `α^{P(v)}` when `z = y`). -/
theorem subterm_polynomial_lemma
    (k : Nat) (Fs : Fin k → Var) (α : Var)
    (hFs_ty : ∀ i : Fin k, (Fs i).ty = Ty.nu)
    (hFs_inj : Function.Injective Fs)
    (hα_ty : α.ty = Ty.endo)
    (s : Term)
    (hs : IsType00Subterm (List.ofFn Fs) α s) :
    s = .var α ∨
    ∃ (P : (Fin k → Nat) → Nat) (z : Var),
      IsPolynomial P ∧
      z.ty = .zero ∧
      ∀ v : Fin k → Nat,
        (∀ i : Fin k, v i ≠ 0) →
        ∃ y : Var,
          y.ty = .zero ∧
          (z = y ∨ z ∈ freeVars s) ∧
          ReducesTo
            (substMany s ((List.finRange k).map (fun i => (Fs i, churchNumeral (v i)))))
            (.lam y (iterApp (.var α) (.var z) (P v))) := by
  sorry

end Schwichtenberg1976V2
Source
Helmut Schwichtenberg, 'Definierbare Funktionen im λ-Kalkül mit Typen', Archiv für mathematische Logik und Grundlagenforschung 17, 1975/1976, pp. 113-114 (doi:10.1007/BF02011242). p. 114, lines 14-22.
Read-back

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

The theorem subterm_polynomial_lemma is universally quantified over an arity k∈Nk \in \mathbb{N}k∈N, a variable-indexing function Fs:Fin k→Var\mathrm{Fs} : \mathrm{Fin}\, k \to \mathrm{Var}Fs:Fink→Var, a variable α:Var\alpha : \mathrm{Var}α:Var, and a term s:Terms : \mathrm{Term}s:Term in the simply typed Church-style λ\lambdaλ-calculus (with base type 0:=Ty.zero0 := \mathrm{Ty.zero}0:=Ty.zero, arrow σ→τ\sigma \to \tauσ→τ, endo:=0→0\mathrm{endo} := 0 \to 0endo:=0→0, and ν:=(0→0)→(0→0)\nu := (0 \to 0) \to (0 \to 0)ν:=(0→0)→(0→0)). It assumes the following four hypotheses:

  • hFs_ty: For every i∈Fin ki \in \mathrm{Fin}\, ki∈Fink, (Fs(i)).ty=ν=(0→0)→(0→0)(\mathrm{Fs}(i)).\mathrm{ty} = \nu = (0 \to 0) \to (0 \to 0)(Fs(i)).ty=ν=(0→0)→(0→0).
  • hFs_inj: The map Fs:Fin k→Var\mathrm{Fs} : \mathrm{Fin}\, k \to \mathrm{Var}Fs:Fink→Var is injective (Fs(i)=Fs(j)  ⟹  i=j\mathrm{Fs}(i) = \mathrm{Fs}(j) \implies i = jFs(i)=Fs(j)⟹i=j).
  • hα_ty: α.ty=endo=0→0\alpha.\mathrm{ty} = \mathrm{endo} = 0 \to 0α.ty=endo=0→0. (Note: there is no explicit hypothesis stating α∉range(Fs)\alpha \notin \mathrm{range}(\mathrm{Fs})α∈/range(Fs), because (Fs(i)).ty=ν≠endo=α.ty(\mathrm{Fs}(i)).\mathrm{ty} = \nu \neq \mathrm{endo} = \alpha.\mathrm{ty}(Fs(i)).ty=ν=endo=α.ty already forces α≠Fs(i)\alpha \neq \mathrm{Fs}(i)α=Fs(i) for all iii.)
  • hs: IsType00Subterm(List.ofFn Fs,α,s)\mathrm{IsType00Subterm}(\mathrm{List.ofFn}\, \mathrm{Fs}, \alpha, s)IsType00Subterm(List.ofFnFs,α,s) holds, where List.ofFn Fs=[Fs(0),…,Fs(k−1)]\mathrm{List.ofFn}\, \mathrm{Fs} = [\mathrm{Fs}(0), \dots, \mathrm{Fs}(k-1)]List.ofFnFs=[Fs(0),…,Fs(k−1)] and the mutually inductive predicates IsBasicType00\mathrm{IsBasicType00}IsBasicType00, IsBasicType00Chain\mathrm{IsBasicType00Chain}IsBasicType00Chain, and IsType00Subterm\mathrm{IsType00Subterm}IsType00Subterm for a list L=List.ofFn FsL = \mathrm{List.ofFn}\, \mathrm{Fs}L=List.ofFnFs and α\alphaα mean:
    • IsBasicType00(L,α,u)\mathrm{IsBasicType00}(L, \alpha, u)IsBasicType00(L,α,u) holds iff u=.var αu = \mathrm{.var}\, \alphau=.varα or u=(Fs(i) s′)u = (\mathrm{Fs}(i)\, s')u=(Fs(i)s′) for some i∈Fin ki \in \mathrm{Fin}\, ki∈Fink and some term s′s's′ satisfying IsType00Subterm(L,α,s′)\mathrm{IsType00Subterm}(L, \alpha, s')IsType00Subterm(L,α,s′);
    • IsBasicType00Chain(L,α,z,body)\mathrm{IsBasicType00Chain}(L, \alpha, z, \mathrm{body})IsBasicType00Chain(L,α,z,body) holds iff z.ty=0z.\mathrm{ty} = 0z.ty=0 and body=(s1 (s2 ⋯(sm z)⋯ ))\mathrm{body} = (s_1\, (s_2\, \cdots (s_m\, z)\cdots))body=(s1​(s2​⋯(sm​z)⋯)) for some m≥0m \ge 0m≥0 with each sjs_jsj​ satisfying IsBasicType00(L,α,sj)\mathrm{IsBasicType00}(L, \alpha, s_j)IsBasicType00(L,α,sj​);
    • IsType00Subterm(L,α,s)\mathrm{IsType00Subterm}(L, \alpha, s)IsType00Subterm(L,α,s) holds iff either IsBasicType00(L,α,s)\mathrm{IsBasicType00}(L, \alpha, s)IsBasicType00(L,α,s) holds, or s=(λy. body)s = (\lambda y.\, \mathrm{body})s=(λy.body) for some variables y,zy, zy,z with y.ty=0y.\mathrm{ty} = 0y.ty=0, z.ty=0z.\mathrm{ty} = 0z.ty=0, and IsBasicType00Chain(L,α,z,body)\mathrm{IsBasicType00Chain}(L, \alpha, z, \mathrm{body})IsBasicType00Chain(L,α,z,body).

Under these hypotheses, the theorem concludes that either sss is literally the variable term α\alphaα (s=.var αs = \mathrm{.var}\, \alphas=.varα), or there exist a function P:(Fin k→N)→NP : (\mathrm{Fin}\, k \to \mathbb{N}) \to \mathbb{N}P:(Fink→N)→N and a variable z:Varz : \mathrm{Var}z:Var such that all three of the following hold:

  1. IsPolynomial(P)\mathrm{IsPolynomial}(P)IsPolynomial(P) holds, where IsPolynomial is the smallest class of functions (Fin k→N)→N(\mathrm{Fin}\, k \to \mathbb{N}) \to \mathbb{N}(Fink→N)→N containing all constants v↦cv \mapsto cv↦c (c∈Nc \in \mathbb{N}c∈N) and projections v↦v(i)v \mapsto v(i)v↦v(i) (i∈Fin ki \in \mathrm{Fin}\, ki∈Fink), and closed under pointwise addition v↦P1(v)+P2(v)v \mapsto P_1(v) + P_2(v)v↦P1​(v)+P2​(v) and pointwise multiplication v↦P1(v)⋅P2(v)v \mapsto P_1(v) \cdot P_2(v)v↦P1​(v)⋅P2​(v).
  2. z.ty=0z.\mathrm{ty} = 0z.ty=0.
  3. For every tuple v:Fin k→Nv : \mathrm{Fin}\, k \to \mathbb{N}v:Fink→N satisfying v(i)≠0v(i) \neq 0v(i)=0 for all i∈Fin ki \in \mathrm{Fin}\, ki∈Fink, there exists a variable y:Vary : \mathrm{Var}y:Var (which may depend on vvv) such that:
    • y.ty=0y.\mathrm{ty} = 0y.ty=0;
    • either z=yz = yz=y or z∈freeVars(s)z \in \mathrm{freeVars}(s)z∈freeVars(s) (where freeVars(s)\mathrm{freeVars}(s)freeVars(s) is the deduplicated list of free variable occurrences of sss); and
    • the sequential substitution
substMany(s,[(Fs(0),v(0)‾),…,(Fs(k−1),v(k−1)‾)])\mathrm{substMany}\big(s, [(\mathrm{Fs}(0), \overline{v(0)}), \dots, (\mathrm{Fs}(k-1), \overline{v(k-1)})]\big)substMany(s,[(Fs(0),v(0)​),…,(Fs(k−1),v(k−1)​)])
 reduces via $\twoheadrightarrow_{\beta\alpha}$ (`ReducesTo`) to
 
λy. iterApp(.var α,.var z,P(v))=λy. (α (α ⋯(α⏟P(v) times z)⋯ )).\lambda y.\, \mathrm{iterApp}(\mathrm{.var}\, \alpha, \mathrm{.var}\, z, P(v)) = \lambda y.\, \underbrace{(\alpha\, (\alpha\, \cdots (\alpha}_{P(v)\text{ times}}\, z)\cdots)).λy.iterApp(.varα,.varz,P(v))=λy.P(v) times(α(α⋯(α​​z)⋯)).

Here n‾:=churchNumeral(n):=λα1. λx0. iterApp(α1,x0,n)\overline{n} := \mathrm{churchNumeral}(n) := \lambda \alpha_1.\, \lambda x_0.\, \mathrm{iterApp}(\alpha_1, x_0, n)n:=churchNumeral(n):=λα1​.λx0​.iterApp(α1​,x0​,n) with α1=(1,endo)\alpha_1 = (1, \mathrm{endo})α1​=(1,endo) and x0=(0,0)x_0 = (0, 0)x0​=(0,0); substMany(t,[(x1,u1),…,(xk,uk)])\mathrm{substMany}(t, [(x_1, u_1), \dots, (x_k, u_k)])substMany(t,[(x1​,u1​),…,(xk​,uk​)]) applies capture-avoiding single-variable substitution substTerm\mathrm{substTerm}substTerm sequentially from left to right; and ↠βα\twoheadrightarrow_{\beta\alpha}↠βα​ is the transitive closure of α\alphaα-equivalence (AlphaEq, including reflexivity) and single-step capture-avoiding β\betaβ-reduction closed under application and λ\lambdaλ-abstraction.

Note on edge cases:

  • The reduction guarantee is restricted strictly to inputs vvv where v(i)≠0v(i) \neq 0v(i)=0 for every i∈Fin ki \in \mathrm{Fin}\, ki∈Fink; nothing is asserted by the second disjunct when v(i)=0v(i) = 0v(i)=0 for at least one iii.
  • When k=0k = 0k=0, List.ofFn Fs=[]\mathrm{List.ofFn}\, \mathrm{Fs} = []List.ofFnFs=[], the hypothesis ∀i∈Fin 0, v(i)≠0\forall i \in \mathrm{Fin}\, 0,\, v(i) \neq 0∀i∈Fin0,v(i)=0 is vacuously true for the unique v:Fin 0→Nv : \mathrm{Fin}\, 0 \to \mathbb{N}v:Fin0→N, and substMany(s,[])=s\mathrm{substMany}(s, []) = ssubstMany(s,[])=s.
  • Notice that PPP and zzz are chosen uniformly for sss before quantifying over vvv, whereas the outer λ\lambdaλ-binder yyy is existentially quantified inside the ∀v\forall v∀v quantifier.
Human review
  • Endorsed by Shuze Chen · Nov 20, 2026

    Confirmed by the moderator at approval.

  • 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