Polynomial-time computable functions #
PolyTimeFun α β bundles a function with a closed program of the ambient model
(Cost.Basic) computing it on encodings (Cost.Encoding), together with an
explicit polynomial time bound. Every "there is a polynomial-time Turing
machine …" of the blueprint (thm:introspection, thm:oracularization,
thm:answer-reduction, thm:parallel-repetition, thm:compression, and the
hypothesis and conclusion of lem:recursive-compression) is a PolyTimeFun.
The time bound is data, not an existential: the recursion of [JNVWY, §12] closes by choosing the parameter λ above the concrete overhead polynomials of the toolkit, and that arithmetic needs the polynomials in hand.
The closure library — the combinator toolkit through which all concrete deciders
and transformations will be proven polynomial-time (projections, list/string
operations, recursion on notation, arithmetic on binary numbers, 𝔽₂-linear
algebra, …) — is the main infrastructure investment of this layer
(planning/compression-track.md, K2). Only id and comp are stated here to fix the
interface; the library grows with the sections that consume it.
Evaluation of a polynomial with natural coefficients is monotone in the argument.
A polynomial-time computable function α → β: a closed program computing it on
encodings, with an explicit polynomial bound on the cost in terms of esize of the
input.
- toFun : α → β
The function computed.
- code : Prog
A program computing
toFunon encodings; its input is variable0. - closed : Prog.WellScoped 1 self.code
The program is closed (well-scoped in the one-entry environment).
- timeBound : Polynomial ℕ
The (explicit) polynomial time bound.
Instances For
Equations
Polynomial-time output-size bound: a run of cost t produces a result of size at most
t (Eval.size_le). This is what makes comp below well-bounded.
The identity, in polynomial time: var 0 reads the input at cost esize a + 1.
(noncomputable refers only to the bundled Polynomial ℕ, which is noncomputable data
in Mathlib.)
Equations
- MIPRE.Cost.PolyTimeFun.id α = { toFun := id, code := MIPRE.Cost.Prog.var 0, closed := Nat.zero_lt_one, timeBound := Polynomial.X + 1, computes := ⋯ }
Instances For
Composition: bind the value of F and run G on it.
Equations
Instances For
Further combinators for the closure library (deferred to K2; the list is indicative):
const : β → PolyTimeFun α β(viaCost.Toolkit.constProg);pair : PolyTimeFun α β → PolyTimeFun α γ → PolyTimeFun α (β × γ),fst,snd;- case analysis on a bit, iteration over a list (
loop) with a size-bounded body — the Cobham-style recursion principle: if the step function is polynomial-time and the iterate provably shrinks or preserves size, the recursion is polynomial-time; - binary arithmetic on
ℕ,𝔽₂- and𝔽_{2^k}-algebra as needed by samplers, deciders, and the answer-reduction verifier.