Corollary 4.11: Polynomial-Time Program Extraction from N-HA^ω
OpenABHS2004.corollary_4_11Every numerical function f : ℕ^k → ℕ proven total (!∀x₁ ∈ N ... !∀xₖ ∈ N ∃y ∈ N. A(x⃗, y)) in N-HA^ω is represented by an extracted closed term t of the !-free affine λ-calculus and is therefore computable in polynomial time.
import Definitions.Def_ABHS2004_Realizability
namespace ABHS2004
theorem corollary_4_11 {Δ Γ : ProofContext} {M : ProofTerm}
{xs : List Var} {y : Var} {A : Formula}
(hdata_xs : ∀ x ∈ xs, IsDataType x.ty ∧ cleanTy x.ty = x.ty ∧ x.ty ≠ .unit)
(hdata_y : IsDataType y.ty ∧ cleanTy y.ty = y.ty ∧ y.ty ≠ .unit)
(hnodup : (xs ++ [y]).Nodup)
(hA : IsExistAndDisjFree A)
(hac : IsAlmostClosedDerivation Δ Γ)
(hd : Derives Δ Γ M
(Formula.allRel xs (.ex y (.tensor (.existPred y.ty (.var y)) A))))
(hfresh : FreshRealizerVars Δ Γ M
(Formula.allRel xs (.ex y (.tensor (.existPred y.ty (.var y)) A)))) :
∃ (B : Nat → Nat) (k : Nat),
BoundedByPolyOfDegree B (Nat.max (iterNesting (extractCleaned M)) 1) ∧
∀ ws : List Term,
ValidDataInputs (extractCleaned M) (xs.map Var.ty) ws →
∃ (steps : Nat) (w : Term),
RedSteps steps (Term.appMany (extractCleaned M) ws) w ∧
IsDataObject y.ty w ∧
steps ≤ B (totalTermLength ws) ∧
termLength w ≤ totalTermLength ws + k ∧
freeVarCount w ≤ totalFreeVarCount ws + k ∧
Provable (mrContext (Δ ++ Γ)) []
(substFormula (substFormulaMany A (xs.zip ws)) y w) := by sorry
end ABHS2004Read-back
What the Lean code literally says, in plain math · Gemini 3.1 Pro (Independent Blind Auditor)
Blind Read-back: Thm_ABHS2004_corollary_4_11.lean
Declaration corollary_4_11.
For any passive proof context , any active proof context , any raw proof term , any finite list of input term variables (including ), any output term variable , and any formula , suppose that:
- for every variable , its type is a data type (, meaning is built from using , , and ), cleaning leaves unchanged (), and ;
- the output variable's type is a data type (), cleaning leaves unchanged (), and ;
- the combined list of variables has no duplicates ();
- contains neither existence predicates nor disjunctions ();
- the contexts form an almost closed derivation (, meaning every variable in and has type , i.e., every assumption in has cleaned realizer type or );
- (), where
(); and 7. holds, meaning that across , any two assumption variables with are identical (), and for every , its realizer variable does not occur free in or in for any .
Then there exist a bounding function and an additive constant such that:
- is bounded by a polynomial of degree at most (, meaning , where ); and
- for every list of input terms satisfying (meaning , each is an almost closed normal linearly well-typed term of type , and the free variables of are pairwise disjoint), there exist a step count and an output term such that:
- the iterated application () reduces to in steps ();
- is a data object of type ();
- , , and ; and
- the substituted formula
($\mathrm{substFormula}(\mathrm{substFormulaMany}(A, xs.\mathrm{zip}(ws)), y, w)$) is provable in passive context $\mathrm{mrContext}(\Delta \mathbin{+\!+} \Gamma)$ and empty active context $[]$ ($\mathrm{Provable}(\mathrm{mrContext}(\Delta \mathbin{+\!+} \Gamma), [], \dots)$).