Exact-multiplicity CSP and CNF compilation of circuits via the frontier compiler #
Compiles a circuit c : Circuit σ n m over an arbitrary Boolean signature σ into a Boolean
constraint satisfaction instance Compiler.toCSP c : CSP (CircuitRel σ m) ℕ on its reachable wires
(Compiler.Signal c), and from there via Cslib.Logic.PL.CSP.toCNF into a CNF formula
Compiler.toCNF c I acc accompanied by an explicit unread-input / unconstrained-wire shift
Compiler.freeShift c I acc, such that:
- Bounded scope and clause width: when
c.FanInAtMost k, every constraint oftoCSP c(and therefore every clause oftoCNF c I acc) has width at mostk + 1. - Gate-size variable bound:
(toCNF c I acc).numVars ≤ k * c.size + m(independent of the ambient input countn), bounded throughCompiler.card_signal_leonCompiler.Signal c. - Exact multiplicity (
acceptCount_eq_two_pow_freeShift_mul_modelCount):c.acceptCount I acc = 2 ^ freeShift c I acc * (toCNF c I acc).modelCount, proved through the frontier constraint networkCompiler.network c I _, its exactness and trace-uniqueness theorems (Compiler.satisfies_iff,Compiler.eq_trace,Compiler.accepted_network), and read-dependence (Network.dependsOn_read).
Source relation and library extensions #
Appendix C.1 of [OAI26c] (p. 51) introduces one variable per gate (n + s variables total)
for single-output De Morgan (AND/OR/NOT) circuits to preserve satisfiability in 3-CNF.
Generalizing to arbitrary signatures σ and multi-output acceptance predicates acc, pruning to
reachable wires (Signal c) so the variable bound k * c.size + m depends on gate count rather
than ambient input count n, and tracking exact multiplicity via 2 ^ freeShift for #Circuit-SAT
are original extensions built on Cslib.Circuits.Frontier.Compiler and Cslib.Logic.PL.CSP.ToCNF.
Main definitions #
Cslib.Circuits.Frontier.Compiler.satisfiedPairsEquiv: bijection between input/edge-assignment pairs satisfyingCompiler.networkandNetwork.accepted.Cslib.Circuits.Frontier.Compiler.CircuitRel,Cslib.Circuits.Frontier.Compiler.circuitSem: relation alphabetσ.Op ⊕ Fin mand Boolean semantics for gate evaluation and output acceptance.Cslib.Circuits.Frontier.Compiler.toCSP,Cslib.Circuits.Frontier.Compiler.toCNF,Cslib.Circuits.Frontier.Compiler.freeShift,Cslib.Circuits.Frontier.Compiler.toSatCNF,Cslib.Circuits.Frontier.Compiler.satFreeShift: reachable-wire CSP and exact-multiplicity CNF compilation.
Main results #
Cslib.Circuits.Frontier.Compiler.length_scope_le_of_mem_toCSP,Cslib.Circuits.Frontier.Compiler.length_le_of_mem_toCNF: constraint scopes and clauses have length at mostk + 1whenc.FanInAtMost k.Cslib.Circuits.Frontier.Compiler.numVars_toCNF_le:(toCNF c I acc).numVars ≤ k * c.size + m.Cslib.Circuits.Frontier.Compiler.acceptCount_eq_two_pow_freeShift_mul_modelCount,Cslib.Circuits.Frontier.Compiler.satCount_eq_two_pow_satFreeShift_mul_modelCount: exact counting identities reducing#Circuit-SATto bounded-width#SAT.Cslib.Circuits.Frontier.Compiler.satisfiable_toSatCNF_iff: satisfiability equivalence.
References #
Uniqueness bijection on Compiler.network #
By Compiler.satisfies_iff and Compiler.eq_trace, pairs (x, α) satisfying
Compiler.network c I Acc correspond bijectively to accepted inputs
x ∈ (network c I Acc).accepted with zero multiplicity inflation.
Instances For
Constructive CSP and CNF compilation along reachable wires #
Relation alphabet for frontier CSP compilation of an m-output circuit over σ:
.inl op: a gate-evaluation relation onoutWire :: argWires;.inr o: the unary acceptance predicate at outputo : Fin m.
Instances For
Boolean relation semantics for CircuitRel σ m:
.inl opacceptsoutBit :: inBitsiffinBits.length = σ.Arity opandoutBit = I op (fun a => inBits.getD a.val false);.inr oaccepts[b]iffacc o b = true.
Instances For
Serialized circuit-to-CSP compiler emitting one gate constraint (Sum.inl g.1, (n + j) :: g.2)
for each reachable gate (g, j) followed by one unary output constraint
(Sum.inr o, [code.2.getD o.val 0]) for each o : Fin m.
Instances For
Reachable-wire Boolean CSP compiled from c : Circuit σ n m.
Instances For
Exact binary-exponent shift accounting for unread inputs and reachable wires that do not appear
syntactically in toCNFCode (e.g. unconstrained outputs).
Instances For
Exact-multiplicity CNF formula compiled from c : Circuit σ n m along its reachable wires.
Instances For
Specialization of toCNF to 1-output #Circuit-SAT (accepting true at output 0).
Instances For
Specialization of freeShift to 1-output #Circuit-SAT.
Instances For
Local constraint semantics #
Equivalence of reachWiresCode and Compiler.Reach #
Every constraint in toCSP c has scope length at most k + 1 when c.FanInAtMost k.
Every clause of toCNF c I acc has length at most k + 1 when c.FanInAtMost k.
Every variable occurring in toCNF c I acc belongs to (reachWiresCode n c.code).toFinset.
When c.FanInAtMost k, toCNF c I acc uses at most k * c.size + m distinct variables.
toCNF c I acc uses at most n + c.size distinct variables (all wire numbers lie below
n + c.size).
Exact counting through Compiler.network #
Exact counting via Compiler.network. For every circuit c : Circuit σ n m,
interpretation I, and output predicate acc, the number of accepted inputs equals
2 ^ freeShift c I acc * (toCNF c I acc).modelCount.
Single-output #Circuit-SAT specialization of
acceptCount_eq_two_pow_freeShift_mul_modelCount.
toCNF c I acc is satisfiable iff c has an input accepted by acc.
toSatCNF c I is satisfiable iff ⟨n, c⟩ ∈ SignatureCircuitSAT I.