Documentation

CslibFrontier.Computability.WordRAM.Invariance

Polynomial time on the word RAM and on multi-tape Turing machines #

A function with binary output is computable in polynomial time by a multi-tape Turing machine (Turing.MultiTapeTM.ComputableInPolyTime) exactly when one fixed word-RAM program computes it on the bits of its input within polynomially many instructions, at every word size above a polynomial threshold. The two directions are the simulation of Turing machines by the word RAM (Cslib.WordRAM.OfTuring) and the simulation of the word RAM by Turing machines (Cslib.WordRAM.Program.ComputesInTime.turingComputableInPolyTime_of_width) Cook and Reckhow.

Conventions #

Main results #

References #

The bits of an instance, as words framed as a list of binary naturals, are computable in polynomial time from the instance.

theorem Cslib.WordRAM.turingComputableInPolyTime_iff_exists_computesInTime {B : Basis} {α : Type} {encIn : α ↪ List Bool} (φ : Basis.additive.Hom B) (hop : ∀ (op : B.Op), Turing.MultiTapeTM.ComputableInPolyTime (B.genericModel.checkedOp op) encWidthOperands (Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encNat)) {f : α → ℕ} :
Turing.MultiTapeTM.ComputableInPolyTime f encIn Turing.MultiTapeTM.encNat ↔ ∃ (r : ℕ) (p : Program B r) (T : ℕ → ℕ) (W : ℕ → ℕ), PolynomiallyBounded T ∧ PolynomiallyBounded W ∧ p.ComputesInTime (fun (x : ℕ) (a : α) => List.map Bool.toNat (encIn a)) (fun (a : α) (x : ℕ) => T (encIn a).length) (fun (a : α) (w : ℕ) => W (encIn a).length ≤ w) f

Turing-machine polynomial time is word-RAM polynomial time. Over any basis B containing Basis.additive whose checked operations are polynomial-time, a function f with binary output is computable in polynomial time by a multi-tape Turing machine exactly when one fixed word-RAM program over B computes it on the bits (encIn a).map Bool.toNat of its input, within T |encIn a| instructions at every word size of at least W |encIn a|, for polynomially bounded T and W.

Logarithmic word sizes #

theorem Cslib.WordRAM.UniformComputableInPolyTime.polyBounded {B : Basis} {α : Type} {encIn : α ↪ List Bool} {f : α → ℕ} (h : UniformComputableInPolyTime B f (fun (x : ℕ) (a : α) => List.map Bool.toNat (encIn a)) fun (a : α) => (encIn a).length) :
Turing.MultiTapeTM.PolyBounded (fun (a : α) => (encIn a).length) f

A uniform polynomial-time word-RAM function has polynomially bounded values. At the smallest admitted word size, logWidth k |encIn a|, the output f a is one word, so f a < 2 ^ logWidth k |encIn a| ≤ 2 ^ k (|encIn a| + 1) ^ k.

Turing-machine polynomial time is uniform polynomial word-RAM time at logarithmic word sizes, for functions with polynomially bounded values. Over any basis B containing Basis.additive whose checked operations are polynomial-time, let f a be polynomially bounded in |encIn a|. Then f is computable in polynomial time by a multi-tape Turing machine exactly when one fixed word-RAM program over B computes it on the bits (encIn a).map Bool.toNat, within polynomially many instructions in |encIn a|, at every word size above a logarithmic threshold (Cslib.WordRAM.UniformComputableInPolyTime). The value bound is necessary for the word-RAM side (Cslib.WordRAM.UniformComputableInPolyTime.polyBounded); without it, see Cslib.WordRAM.turingComputableInPolyTime_iff_exists_computesInTime.