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.Realizable— whether a function is computed by some circuit over a basisCircuit.sizeComplexityWithTop— generic minimum size, with⊤for unrealizable functionsCircuit.sizeComplexity— natural-valued minimum size over a complete basis
Main results #
Circuit.sizeComplexity_pos— for complete bases, size complexity is positive
A BitString of length n.
Equations
- Complexity.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
- Complexity.BoolFunFamily = ((N : ℕ) → Complexity.BitString N → Bool)
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Complexity.instReprArity.repr Complexity.Arity.unbounded prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Complexity.Arity.unbounded")).group prec✝
Instances For
Equations
- Complexity.instReprArity = { reprPrec := Complexity.instReprArity.repr }
Equations
- Complexity.instDecidableEqArity.decEq Complexity.Arity.unbounded Complexity.Arity.unbounded = isTrue ⋯
- Complexity.instDecidableEqArity.decEq Complexity.Arity.unbounded (Complexity.Arity.exactly k) = isFalse ⋯
- Complexity.instDecidableEqArity.decEq Complexity.Arity.unbounded (Complexity.Arity.upto k) = isFalse ⋯
- Complexity.instDecidableEqArity.decEq (Complexity.Arity.exactly k) Complexity.Arity.unbounded = isFalse ⋯
- Complexity.instDecidableEqArity.decEq (Complexity.Arity.exactly a) (Complexity.Arity.exactly b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Complexity.instDecidableEqArity.decEq (Complexity.Arity.exactly k) (Complexity.Arity.upto k_1) = isFalse ⋯
- Complexity.instDecidableEqArity.decEq (Complexity.Arity.upto k) Complexity.Arity.unbounded = isFalse ⋯
- Complexity.instDecidableEqArity.decEq (Complexity.Arity.upto k) (Complexity.Arity.exactly k_1) = isFalse ⋯
- Complexity.instDecidableEqArity.decEq (Complexity.Arity.upto a) (Complexity.Arity.upto b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
Instances For
Whether n satisfies an arity constraint.
Equations
- Complexity.Arity.unbounded.satisfiedBy x✝ = True
- (Complexity.Arity.exactly k).satisfiedBy x✝ = (x✝ = k)
- (Complexity.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 basis operation this gate computes.
- fanIn : ℕ
The number of inputs this gate reads.
- arityOk : (B.arity self.op).satisfiedBy self.fanIn
The wire each of the gate's
fanIninputs is connected to.Per-input negation flag. Negations are free under this library's size convention.
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 internal gates; gate
idrives wireN + i.The output gates; output bit
jis the value of gateoutputs j.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
The library's circuit size: internal gates plus output gates.
Primary input vertices are not counted, and the negation flags on gate inputs have zero cost. Some texts instead count input vertices and explicit NOT gates; those conventions agree only up to additive/linear overhead, not on exact size bounds.
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.
A Boolean function is realizable over B when some single-output circuit
over B computes it.
Equations
- Complexity.Circuit.Realizable B f = ∃ (G : ℕ) (c : Complexity.Circuit B N 1 G), (fun (x : Complexity.BitString N) => c.eval x 0) = f
Instances For
Sizes of all single-output circuits over B that realize f.
Equations
- Complexity.Circuit.realizationSizes B f = {s : ℕ | ∃ (G : ℕ) (c : Complexity.Circuit B N 1 G), c.size = s ∧ (fun (x : Complexity.BitString N) => c.eval x 0) = f}
Instances For
The minimum circuit size over an arbitrary basis, as an extended natural.
A single-output circuit Circuit B N 1 G has size G + 1. The value is ⊤
exactly when no circuit over B computes f; thus an unrealizable function
cannot be confused with a zero-size function.
Equations
- Complexity.Circuit.sizeComplexityWithTop B f = sInf ((fun (s : ℕ) => ↑s) '' Complexity.Circuit.realizationSizes B f)
Instances For
The minimum circuit size over a complete basis B computing f.
This natural-valued interface requires completeness so that the set of
realizing circuits is nonempty. Use sizeComplexityWithTop when the basis may
be incomplete.
Equations
Instances For
Whenever the generic size complexity is finite, a circuit realizes its minimum value.
Over a complete basis, the generic extended measure agrees with the natural-valued minimum.
For a complete basis, circuit size complexity is always positive.
Any circuit computing f has size at least sizeComplexity B f.
For a complete basis, sizeComplexity is realized by some circuit.