Lemma 2.2: Frame-Preserving Compilation of BC Programs and Polynomial-Time Soundness (BC <= FP)
ProvedBC1992.lemma_2_2_polytime_soundnesscomplexity-theoryimplicit-computational-complexitypolynomial-timesafe-recursionturing-machines
Establishes Lemma 2.2 of Bellantoni and Cook (1992):
- For every program , frame base , normal arguments (), and safe arguments () with all word lengths bounded by and empty scratch stacks , evaluates into stack within steps while preserving all argument stacks and clearing all workspace stacks above the frame.
- For every closed unary program and input , the compiled multi-tape Turing machine halts on within transitions with output .
- Consequently, every -definable unary word function belongs to ().
Preamble
import Definitions.Def_BC1992_Syntax import Definitions.Def_BC1992_Machines
Formal statement
namespace BC1992
/-- **Lemma 2.2 (Bellantoni & Cook 1992 — Polynomial-Time Soundness, `BCDefinable f → FP f`)**:
1. (`exec_compileBC`) For every `f : Fn n m`, frame base `base`, stack state `σ`,
normal arguments `xs` (`xs.length = n`), and safe arguments `ys` (`ys.length = m`)
with all word lengths bounded by `K` and `∀ r ≥ base, σ r = []`, `compileBC base f`
executes from `setFrame σ (base + 1) (xs ++ ys)` to
`(setFrame σ (base + 1) (xs ++ ys)).set base (f.eval xs ys)` in `c ≤ f.timePoly.eval K` steps.
2. (`topCompileBC_haltsWithin`) For every closed unary program `prog : Fn 1 0` and input `x : Word`,
`stmtToTM (topCompileBC prog)` halts on `x` within `(topTimePoly prog).eval x.length` steps
with output `prog.eval [x] []`.
3. (`bc_soundness`) Every BC-definable word function `f : Word → Word` is in `FP`. -/
theorem lemma_2_2_polytime_soundness :
(∀ {n m : Nat} (f : Fn n m) (base : Nat) (σ : Stacks)
(xs ys : List Word) (K : Nat),
xs.length = n →
ys.length = m →
(∀ r : Nat, base ≤ r → σ r = []) →
(∀ x ∈ xs, x.length ≤ K) →
(∀ y ∈ ys, y.length ≤ K) →
∃ c : Nat,
c ≤ f.timePoly.eval K ∧
Exec (compileBC base f)
(setFrame σ (base + 1) (xs ++ ys))
c
((setFrame σ (base + 1) (xs ++ ys)).set base (f.eval xs ys))) ∧
(∀ (prog : Fn 1 0) (x : Word),
(stmtToTM (topCompileBC prog)).HaltsWithin x
((topTimePoly prog).eval x.length)
(prog.eval [x] [])) ∧
(∀ (f : Word → Word), BCDefinable f → FP f) := by
sorry
end BC1992Source
Stephen Bellantoni and Stephen Cook, 'A new recursion-theoretic characterization of the polytime functions', Computational Complexity 2 (1992), pp. 97-110 (doi:10.1007/BF01201998). Section 2, Lemma 2.2, pp. 101-102.
Read-back
What the Lean code literally says, in plain math · Gemini 4 Argon (Independent Blind Auditor)
Overview
Thm_BC1992_lemma_2_2_polytime_soundness.lean states Lemma 2.2 of Bellantoni & Cook (1992): every function definable in the Bellantoni–Cook algebra is computable in polynomial time by a deterministic multi-tape Turing machine ().
Detailed Read-Back of Theorem Conjuncts
theorem lemma_2_2_polytime_soundness is a 3-way conjunction:
- Compiler Correctness and Polynomial Time Bound for
compileBC(exec_compileBC): For all , every BC program , stack frame base , initial stack state , normal argument list with , safe argument list with , and word-length bound :- If all stacks at or above are initially empty (),
- every normal input has length at most (), and
- every safe input has length at most (), then there exists a step count such that:
and
That is, compileBC base f terminates in stack steps, writing into stack , preserving all argument stacks as well as all caller stacks below , and restoring all scratch stacks above to [].
- End-to-End Turing Machine Soundness for Unary Programs (
topCompileBC_haltsWithin): For every closed unary BC program and input word :
- Polynomial-Time Soundness of BC (
bc_soundness):
Human review
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.