Documentation

CslibFrontier.Computability.Complexity.Problems.CircuitValue.Completeness

The circuit value problem is P-complete #

Ladner proved [Lad75b] that the circuit value problem is P-complete under logarithmic-space many-one reductions Arora and Barak, Section 6.7, Papadimitriou, Theorem 8.1.

A problem A ∈ P enc is decided by a machine tm within C (n + 1) ^ d steps on encoded instances of length n. The reduction maps an instance a to the tableau circuit of tm for C (n + 1) ^ d + n + 1 steps on inputs of length n = |enc a| (Cslib.Circuits.Boolean.Tableau.circuit), together with the input enc a. The circuit outputs whether tm, started on enc a, has written exactly [true] after that many steps (Cslib.Circuits.Boolean.Tableau.eval_circuit); since tm has halted by then with the answer on its output, this is whether a ∈ A. The circuit reads the bits of enc a as its inputs; it does not hardwire them as constants. The reduction is computable in logarithmic space: a read machine (Turing.ReadMachine) on the framed input counts its length n, then writes the gates one by one, keeping only the number of the current gate, since each gate is computed from its number within work space linear in the binary lengths of n, the time bound and the number (Cslib.Circuits.Boolean.Tableau.gateCode_inSpace), and finally copies the input.

Main definitions #

Main results #

References #

The writer #

The number of steps of the tableau for inputs of length n: C (n + 1) ^ d + n + 1.

noncomputable def Cslib.Complexity.CircuitValue.tableauInstance {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (C d : ℕ) (w : List Bool) :

The instance of the circuit value problem for the input w: the tableau circuit of tm for timeBound C d |w| steps on inputs of length |w|, with the input w.

noncomputable def Cslib.Complexity.CircuitValue.gateChunk {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (C d n i : ℕ) :

Gate i of the tableau, as the writer emits it.

noncomputable def Cslib.Complexity.CircuitValue.trailer (k : ℕ) (State : Type) [Fintype State] (C d n : ℕ) :

What the writer emits after the gates: the end of the gate list and the output wire.

The encoded instance: the length in unary, the gates and the output wire, framed twice, and the input.

noncomputable def Cslib.Complexity.CircuitValue.tableauSpec {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (C d : ℕ) :

The uniform writer specification for tableau circuit instances.

noncomputable def Cslib.Complexity.CircuitValue.writer {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (C d : ℕ) :

The writer of encoded tableau instances, on framed inputs.

def Cslib.Complexity.CircuitValue.writerRounds {k : ℕ} {State : Type} [Fintype State] (C d n : ℕ) :

The number of steps of the writer on an input of length n.

theorem Cslib.Complexity.CircuitValue.run_writer {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (C d : ℕ) (w : List Bool) :
(writer tm C d).run (Turing.MultiTapeTM.frame w) (writerRounds C d w.length) = { state := (3, w.length, 0), out := encCircuitValue (tableauInstance tm C d w) }

The writer halts with the encoded tableau instance.

The writer in logarithmic space #

Evaluating the fixed polynomial tableau time bound preserves a space budget.

Computing the tableau gate count preserves a space budget.

The end of a gate list, a framed wire number and a fixed suffix preserve a space budget: the shape of the trailer emitted by the tableau writers after their gates.

The number of gates of the tableau for timeBound C d n steps is polynomial in n.

Constructing circuit codes #

noncomputable def Cslib.Complexity.CircuitValue.tableauCode {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (C d n : ℕ) :

The tableau code for inputs of length n. The input wires remain free; the constructor receives only the length, in unary, rather than any assignment to those wires.

Writing the tableau code takes polynomial time in the unary input length. This reuses the certified logarithmic-space writer and discards its dummy input assignment.

theorem Cslib.Complexity.CircuitValue.eval_tableau_of_computesFun {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (C d : ℕ) {α : Type} {enc : α ↪ List Bool} {f : α → Bool} {t s : ℕ → ℕ} (htm : tm.ComputesFunInTimeAndSpace enc Turing.MultiTapeTM.encBool f (fun (a : α) => t (enc a).length) fun (a : α) => s (enc a).length) (ht : ∀ (n : ℕ), t n ≤ C * (n + 1) ^ d) (a : α) :
(Circuits.Boolean.Tableau.circuit tm (enc a).length (timeBound C d (enc a).length)).eval Circuits.Boolean.interpretation (fun (i : Fin (enc a).length) => (enc a)[i]) 0 = f a

Correctness of the tableau. If tm decides f within time t ≤ C (n + 1) ^ d on inputs of length n, the tableau circuit for timeBound C d |enc a| steps evaluates to f a on the encoding of a.

Every polynomial-time Boolean function has circuits whose codes are constructed in polynomial time from the unary encoded input length. Correctness is required on the encoding's image; no decoder or efficient membership test for that image is assumed.

P-completeness #

Every problem in P reduces to the circuit value problem in logarithmic space: an instance is mapped to the tableau circuit of a polynomial-time decider on inputs of the length of the encoded instance, with the encoded instance as its input.

The circuit value problem is P-hard under logarithmic-space reductions [Lad75b].

The circuit value problem is P-complete under logarithmic-space reductions [Lad75b], Arora and Barak, Section 6.7.

The circuit value problem is in L exactly when P = L, for every encoding of instances Arora and Barak, Section 6.7.