Documentation

CslibFrontier.Computability.Complexity.Classes.P.WordRAM

P is uniform polynomial time on the word RAM #

A problem decided by a fixed word-RAM program in polynomially many instructions is in P, through the simulation of the word RAM by multi-tape Turing machines (Cslib.WordRAM.Program.ComputesInTime.turingComputableInPolyTime_of_width). The instance is the bit string encIn a; its word list must be computable from it in polynomial time, and the size measure must be polynomially bounded in its length. The conventions are those of the simulation: unit-cost instructions on w-bit words, the input placed as in State.init, and a word size computed by the simulating machine.

Conversely, every problem in P is decided by one fixed word-RAM program over Basis.additive, in polynomially many instructions, at every word size above a logarithmic threshold, through the simulation of multi-tape Turing machines by the word RAM (Cslib.WordRAM.OfTuring). The instance is given as its bits, (encIn a).map Bool.toNat, and its size is |encIn a|. So P is Cslib.WordRAM.UniformPolynomialTime for these conventions, over Basis.additive, Basis.arithmetic and Basis.standard alike: the class does not depend on the machine model.

Main results #

theorem Cslib.WordRAM.Program.DecidesInTime.mem_P_of_width {B : Basis} {r : ℕ} {α : Type} {encIn : α ↪ List Bool} (hop : ∀ (op : B.Op), Turing.MultiTapeTM.ComputableInPolyTime (B.genericModel.checkedOp op) encWidthOperands (Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encNat)) {p : Program B r} {encode : ℕ → α → List ℕ} {A : Set α} {time : α → ℕ → ℕ} {allowed : α → ℕ → Prop} (h : p.DecidesInTime encode A time allowed) {width : α → ℕ} (hwidth : Turing.MultiTapeTM.ComputableInPolyTime width encIn Turing.MultiTapeTM.encUnary) (hallowed : ∀ (a : α), allowed a (width a)) (hfits : ∀ (a : α), InputFits (width a) (encode (width a) a)) (hencode : Turing.MultiTapeTM.ComputableInPolyTime (fun (a : α) => encode (width a) a) encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat)) (htime : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (encIn a).length) fun (a : α) => time a (width a)) :

A word-RAM decider at a polynomial-time width schedule places its problem in P. The width width a must be computable in unary in polynomial time and admitted, the input must fit it, its word list must be computable in polynomial time, and the time bound at that width must be polynomial in |encIn a|.

theorem Cslib.WordRAM.Program.DecidesInTime.mem_P {B : Basis} {r : ℕ} {α : Type} {encIn : α ↪ List Bool} (hop : ∀ (op : B.Op), Turing.MultiTapeTM.ComputableInPolyTime (B.genericModel.checkedOp op) encWidthOperands (Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encNat)) {p : Program B r} {encode : α → List ℕ} {A : Set α} {size : α → ℕ} {T : ℕ → ℕ} {k : ℕ} (hT : PolynomiallyBounded T) (hsize : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (encIn a).length) size) (hencode : Turing.MultiTapeTM.ComputableInPolyTime encode encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat)) (h : p.DecidesInTime (fun (x : ℕ) => encode) A (fun (a : α) (x : ℕ) => T (size a)) fun (a : α) (w : ℕ) => logWidth k (size a) ≤ w) :

A polynomial-time word-RAM decider places its problem in P. The program decides A within T (size a) instructions at every fitting word size above logWidth k (size a), the word list encode a is computable in polynomial time from encIn a, and size a is polynomially bounded in |encIn a|.

theorem Cslib.WordRAM.UniformPolynomialTime.mem_P {B : Basis} {α : Type} {encIn : α ↪ List Bool} (hop : ∀ (op : B.Op), Turing.MultiTapeTM.ComputableInPolyTime (B.genericModel.checkedOp op) encWidthOperands (Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encNat)) {encode : α → List ℕ} {A : Set α} {size : α → ℕ} (h : UniformPolynomialTime B A (fun (x : ℕ) => encode) size) (hsize : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (encIn a).length) size) (hencode : Turing.MultiTapeTM.ComputableInPolyTime encode encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat)) :

Uniform polynomial word-RAM time is in P, for a width-independent word encoding computable in polynomial time and a size measure polynomially bounded in the encoded input length.

P on the word RAM #

theorem Cslib.WordRAM.uniformPolynomialTime_of_mem_P {α : Type} {encIn : α ↪ List Bool} {A : Set α} (h : A ∈ Complexity.P encIn) :
UniformPolynomialTime Basis.additive A (fun (x : ℕ) (a : α) => List.map Bool.toNat (encIn a)) fun (a : α) => (encIn a).length

A problem in P is decided in uniform polynomial time on the word RAM. The decider is the simulator (Cslib.WordRAM.OfTuring.simProgram) of a polynomial-time machine deciding the problem, over Basis.additive, run on the bits (encIn a).map Bool.toNat of the instance. It answers within simTime of the machine's time bound, a polynomial in |encIn a|, at every word size above logWidth K |encIn a| for a constant K: the words then hold the addresses of the simulated tapes and the one-bit output.

P is uniform polynomial time on the word RAM, over any basis B containing Basis.additive whose checked operations are polynomial-time: a problem is in P exactly when one fixed word-RAM program over B decides it on the bits of its instances, within polynomially many instructions in |encIn a|, at every word size above a logarithmic threshold.

theorem Cslib.WordRAM.mem_P_iff_uniformPolynomialTime_additive {α : Type} {encIn : α ↪ List Bool} {A : Set α} :
A ∈ Complexity.P encIn ↔ UniformPolynomialTime Basis.additive A (fun (x : ℕ) (a : α) => List.map Bool.toNat (encIn a)) fun (a : α) => (encIn a).length

P is uniform polynomial time over Basis.additive.

theorem Cslib.WordRAM.mem_P_iff_uniformPolynomialTime_arithmetic {α : Type} {encIn : α ↪ List Bool} {A : Set α} :
A ∈ Complexity.P encIn ↔ UniformPolynomialTime Basis.arithmetic A (fun (x : ℕ) (a : α) => List.map Bool.toNat (encIn a)) fun (a : α) => (encIn a).length

P is uniform polynomial time over Basis.arithmetic.

theorem Cslib.WordRAM.mem_P_iff_uniformPolynomialTime_standard {α : Type} {encIn : α ↪ List Bool} {A : Set α} :
A ∈ Complexity.P encIn ↔ UniformPolynomialTime Basis.standard A (fun (x : ℕ) (a : α) => List.map Bool.toNat (encIn a)) fun (a : α) => (encIn a).length

P is uniform polynomial time over Basis.standard.