Boolean Circuit Complexity #
This file defines Boolean circuits parameterized by a basis of operations and establishes the circuit size complexity measure for Boolean functions.
Main definitions #
BitString— a string of bits of a specific lengthBoolFunFamily— a family of Boolean functions indexed by input lengthBasis— a basis of Boolean operations with arity constraintsCircuit— an acyclic Boolean circuit (well-formedness by construction)CompleteBasis— typeclass for functionally complete basesCircuit.wireDepth— depth of a wire in the circuit DAGCircuit.outputDepth— depth of a single output gateCircuit.depth— depth of a (possibly multi-output) circuitCircuit.sizeComplexity— minimum circuit size computing a given function
Main results #
Circuit.size_complexity_pos— for complete bases, size complexity is positive
A BitString of length n.
Equations
- CircuitComplexity.BitString n = (Fin n → Bool)
Instances For
A family of Boolean functions indexed by input length N.
Each member maps N-bit strings to a single output bit.
Equations
- CircuitComplexity.BoolFunFamily = ((N : ℕ) → CircuitComplexity.BitString N → Bool)
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- CircuitComplexity.instDecidableEqArity.decEq CircuitComplexity.Arity.unbounded CircuitComplexity.Arity.unbounded = isTrue ⋯
- CircuitComplexity.instDecidableEqArity.decEq CircuitComplexity.Arity.unbounded (CircuitComplexity.Arity.exactly k) = isFalse ⋯
- CircuitComplexity.instDecidableEqArity.decEq CircuitComplexity.Arity.unbounded (CircuitComplexity.Arity.upto k) = isFalse ⋯
- CircuitComplexity.instDecidableEqArity.decEq (CircuitComplexity.Arity.exactly k) CircuitComplexity.Arity.unbounded = isFalse ⋯
- CircuitComplexity.instDecidableEqArity.decEq (CircuitComplexity.Arity.exactly a) (CircuitComplexity.Arity.exactly b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- CircuitComplexity.instDecidableEqArity.decEq (CircuitComplexity.Arity.exactly k) (CircuitComplexity.Arity.upto k_1) = isFalse ⋯
- CircuitComplexity.instDecidableEqArity.decEq (CircuitComplexity.Arity.upto k) CircuitComplexity.Arity.unbounded = isFalse ⋯
- CircuitComplexity.instDecidableEqArity.decEq (CircuitComplexity.Arity.upto k) (CircuitComplexity.Arity.exactly k_1) = isFalse ⋯
- CircuitComplexity.instDecidableEqArity.decEq (CircuitComplexity.Arity.upto a) (CircuitComplexity.Arity.upto b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
Instances For
Whether n satisfies an arity constraint.
Equations
- CircuitComplexity.Arity.unbounded.satisfiedBy x✝ = True
- (CircuitComplexity.Arity.exactly k).satisfiedBy x✝ = (x✝ = k)
- (CircuitComplexity.Arity.upto k).satisfiedBy x✝ = (x✝ ≤ k)
Instances For
Equations
- One or more equations did not get rendered due to their size.
A basis of Boolean operations.
Each operation has an arity constraint and an evaluation function that computes the output bit from any valid number of input bits.
- Op : Type
The type of operations (e.g., AND, OR, NOT).
The arity constraint for each operation.
Evaluate an operation on
ninput bits, given thatnsatisfies the arity.
Instances For
A gate in a circuit over basis B with W wires available as inputs.
The gate's fan-in must satisfy the arity constraint of its operation, and each
input is wired to one of the W available wires.
- op : B.Op
The operation computed by this gate.
- fanIn : ℕ
The number of inputs (fan-in) of this gate.
- arityOk : (B.arity self.op).satisfiedBy self.fanIn
Proof that the fan-in satisfies the operation's arity constraint.
Wiring: each gate input is connected to one of the
Wavailable wires.Per-input negation flag. Negations are free in circuit complexity.
Instances For
A Boolean circuit over basis B with N inputs, M outputs, and G
internal gates.
All gates reference wires from Fin (N + G). The acyclic field ensures
that internal gate i only reads wires 0, …, N + i − 1, preventing cycles.
The
Ginternal gates of the circuit.The
Moutput gates of the circuit.Acyclicity: internal gate
ionly reads wires0, …, N + i − 1.
Instances For
Value of wire w when the circuit is fed input.
The first N wires carry the primary inputs. Wire N + i carries the
output of internal gate i.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Depth of wire w in the circuit DAG.
Primary inputs have depth 0. Wire N + i (internal gate i) has depth
1 + max over input wires.
Equations
- One or more equations did not get rendered due to their size.
Instances For
If every circuit over B₁ can be simulated by a circuit over B₂
(possibly with a different number of internal gates), then completeness
of B₁ implies completeness of B₂.
This is the generic tool for proving new bases complete: show you can compile each gate of a known-complete basis into a subcircuit of the new basis.
The minimum circuit size over basis B computing a Boolean function f.
A single-output circuit Circuit B N 1 G computes f when
(fun x => (c.eval x) 0) = f. The size is G + 1 (internal gates +
output gate). Returns 0 if no circuit over B computes f.
Equations
- One or more equations did not get rendered due to their size.
Instances For
For a complete basis, circuit size complexity is always positive.
For a complete basis, sizeComplexity is realized by some circuit.