Polynomial Evaluation of Type `0 → 0` Subterms on Nonzero Numerals
OpenSchwichtenberg1976.subterm_polynomial_lemmaFor 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.
import Definitions.Def_Schwichtenberg1976_Lambda
namespace Schwichtenberg1976
/-- 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 Schwichtenberg1976Read-back
What the Lean code literally says, in plain math · Gemini 3.1 Pro (Independent Blind Auditor)
Mathematical Read-Back: Thm_Schwichtenberg1976_subterm_polynomial_lemma.lean
All declarations below reside in the namespace Schwichtenberg1976 and depend on Definitions.Def_Schwichtenberg1976_Lambda.
1. Definition and Theorem Read-Backs
numeralSubst (Definition)
For an arity , an indexed family of typed variables , and an input tuple , the substitution list is defined by mapping each index (List.finRange k) to the pair :
where (churchNumeral (v i)) is the closed Church numeral .
subterm_polynomial_on_positive_inputs (Theorem)
Let be a natural number, let be a -tuple of typed variables, let be a typed variable, and let be a -term. Assume the following four hypotheses:
- Types of (
hFs_ty): For every index , . - Injectivity of (
hFs_inj): The map is injective, i.e., for all . - Type of (
hα_ty): The variable has type (Ty.endo). - Grammar membership of (
hs): The term belongs to the inductive grammarIsType00Subterm (List.ofFn Fs) α sgenerated by Clauses (1)–(3) over the variable list and .
Then at least one of the following two alternatives holds:
- First case: is the variable term ().
- Second case: There exist a -ary function and a typed variable such that:
- is a multivariate polynomial over (
IsPolynomial P, built from natural-number constants and coordinate projections by pointwise addition and multiplication), - has ground type (
Ty.zero), and - for every strictly positive input tuple satisfying for all , there exists a typed variable of ground type such that:
- either (so is bound by the outer ) or (so is a free variable of ), and
- the sequentially substituted term
- is a multivariate polynomial over (
reduces via $\triangleright$ (`ReducesTo`) to
2. Audit Notes: Edge Cases, Degenerate Cases, and Potential Issues
- Why the positivity condition is essential: When a subterm reduces to a constant function of the form with (so does not occur in the body ), applying a Church numeral to iterates times on a bound argument . For every , iterating the constant function times yields (preserving both the target variable and the exponent , independent of the value of ). In contrast, for , reduces to the identity , which changes both the exponent (to ) and the target variable (from to the bound variable ). Thus a single polynomial and a single variable uniform across all inputs only exist when restricted to a fixed zero/nonzero pattern—here, the all-nonzero pattern .
- Quantifier order of and :
In the second disjunct, and are existentially quantified outside the universal quantifier , whereas is existentially quantified inside . When , the condition forces for every positive input , meaning the reduced term is . Because , , so any with is -equivalent (via
AlphaEq.lam_renameand henceReducesTo.refl_alpha) to for a fixed of type . - Sequential substitution vs. simultaneous substitution: Because each Church numeral is closed (), sequential substitution coincides with simultaneous substitution of for the distinct variables , and never triggers bound-variable renaming inside .
- Arity edge case:
When , the positivity hypothesis is vacuously true for the unique empty tuple , , and
IsPolynomial Pmeans is a constant function.