Circuit value problem
AbbreviationEncoded circuit gates#✓fully proved
An encoded gate of a flat Boolean circuit is a pair \((k, r)\) of a natural number \(k\), the kind of the gate, and a list \(r\) of natural numbers, its references.
Such a pair is read as a gate by the shared (kind, references) decoding of flat circuit gates.
abbrev CVGate := ℕ × List ℕ
DefinitionEvaluation of an encoded Boolean circuit#✓fully proved
Let \(n\) be a number of inputs, let \(C\) be a list of gates, each encoded as a (kind, references) pair, and let \(a = (a_0, a_1, \dots)\) be a list of booleans. The evaluation of \(C\) on \(a\) is the list of values of all gates, in order, of the flat Boolean circuit on \(n\) inputs obtained by decoding each pair of \(C\), under the assignment that sends each input \(i < n\) to \(a_i\), or to false when \(i\) is at least the length of \(a\).
def cvCircuitEval {n : ℕ} (C : List CVGate) (assign : List Bool) : List Bool :=
circuitEval (C.map (acGateOfPair (n := n))) (fun i => assign.getD i.val false)
abbrev CVGate := ℕ × List ℕ
WantedExt/Complexity/KeyTheorems/CircuitValuePCompleteWanted.lean:48
def circuitEval {n : ℕ} (C : List (ACGate n)) (assign : Fin n → Bool) : List Bool :=
C.foldl (fun vs g => vs ++ [gateValue vs assign g]) []
CSLibExt/Computability/Complexity/Classes.lean:447
def acGateOfPair {n : ℕ} : ℕ × List ℕ → ACGate n
| (0, [i]) => if h : i < n then .var ⟨i, h⟩ else .const false
| (1, [b]) => .const (b = 1)
| (2, [a]) => .notGate a
| (3, l) => .andGate l
| (4, l) => .orGate l
| _ => .const false
CSLibExt/Computability/Complexity/Classes.lean:469
Uses 4 · Used by 1
DefinitionWell-formed encoded circuits#✓fully proved
A list \(C\) of encoded gates, each a (kind, references) pair, is well formed as a circuit on \(n\) inputs when the flat Boolean circuit on \(n\) inputs obtained by decoding each pair of \(C\) is well formed: every decoded gate references only strictly earlier gates.
def CVWellFormed {n : ℕ} (C : List CVGate) : Prop :=
WellFormedCircuit (C.map (acGateOfPair (n := n)))
abbrev CVGate := ℕ × List ℕ
WantedExt/Complexity/KeyTheorems/CircuitValuePCompleteWanted.lean:48
def WellFormedCircuit {n : ℕ} (C : List (ACGate n)) : Prop :=
∀ j (h : j < C.length), ∀ a ∈ gateInputs (C[j]'h), a < j
CSLibExt/Computability/Complexity/Classes.lean:432
def acGateOfPair {n : ℕ} : ℕ × List ℕ → ACGate n
| (0, [i]) => if h : i < n then .var ⟨i, h⟩ else .const false
| (1, [b]) => .const (b = 1)
| (2, [a]) => .notGate a
| (3, l) => .andGate l
| (4, l) => .orGate l
| _ => .const false
CSLibExt/Computability/Complexity/Classes.lean:469
Uses 4 · Used by 1
DefinitionThe Circuit Value Problem#✓fully proved
The Circuit Value Problem is the decision problem that accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding of such triples, to a triple \((n, C, a)\) of a natural number \(n\), a list \(C\) of encoded gates and a list \(a\) of booleans such that the flat Boolean circuit on \(n\) inputs obtained by decoding the gates of \(C\) is well formed, \(a\) has length \(n\), and the evaluation of \(C\) on \(a\) is a nonempty list whose last entry is true. It rejects every bitstring that does not decode.
noncomputable def cvpDec : MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := ℕ × List CVGate × List Bool) x with
| some i => decide (CVWellFormed (n := i.1) i.2.1 ∧ i.2.2.length = i.1 ∧
(cvCircuitEval (n := i.1) i.2.1 i.2.2).getLast? = some true)
| none => false
abbrev DecisionProblem := List Bool → Bool
MathlibExt/Computability/Complexity.lean:170
def bitDecode [BitstringEncoding α] (l : List Bool) : Option α := toEncoding.decode l
MathlibExt/Computability/Complexity.lean:58
abbrev CVGate := ℕ × List ℕ
WantedExt/Complexity/KeyTheorems/CircuitValuePCompleteWanted.lean:48
def CVWellFormed {n : ℕ} (C : List CVGate) : Prop :=
WellFormedCircuit (C.map (acGateOfPair (n := n)))
WantedExt/Complexity/KeyTheorems/CircuitValuePCompleteWanted.lean:57
def cvCircuitEval {n : ℕ} (C : List CVGate) (assign : List Bool) : List Bool :=
circuitEval (C.map (acGateOfPair (n := n))) (fun i => assign.getD i.val false)
WantedExt/Complexity/KeyTheorems/CircuitValuePCompleteWanted.lean:53
Uses 12 · Used by 1
TheoremThe Circuit Value Problem is P-complete#●ready to prove
The Circuit Value Problem is in P, and every decision problem in P is log-space many-one reducible to the Circuit Value Problem.
public theorem_wanted cvp_p_complete :
cvpDec ∈ MetaMathlibExt.ComplexityTheory.P ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.P → LogSpaceRed L cvpDec
noncomputable def cvpDec : MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := ℕ × List CVGate × List Bool) x with
| some i => decide (CVWellFormed (n := i.1) i.2.1 ∧ i.2.2.length = i.1 ∧
(cvCircuitEval (n := i.1) i.2.1 i.2.2).getLast? = some true)
| none => false
WantedExt/Complexity/KeyTheorems/CircuitValuePCompleteWanted.lean:63
def P : DecisionComplexityClass :=
{ L | IsPolyTime L }
MathlibExt/Computability/Complexity.lean:194
abbrev DecisionProblem := List Bool → Bool
MathlibExt/Computability/Complexity.lean:170
def LogSpaceRed (L₁ L₂ : DecisionProblem) : Prop :=
∃ f, LogSpaceComputable f ∧ ∀ x, L₁ x ↔ L₂ (f x)
CSLibExt/Computability/Complexity/Classes.lean:146
Sources
- R. E. Ladner, "The circuit value problem is log space complete for P", SIGACT News 7 (1975), 18-20; S. A. Cook, "A hierarchy for nondeterministic time complexity", Journal of Computer and System Sciences 7 (1973), 343-353.
Uses 5
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.