Polynomial-time counting CNF reductions for graph problems #
Executable polynomial-time CNF encodings for three classical graph counting problems on
Cslib.Complexity.Graph, preserving exact solution counts with explicit assignment bijections:
- Independent sets (
Graph.toIndepSetCNF):n = |V|variables, clause width2, preservingNat.card {S // G.induced.IsIndepSet S}. - Proper
q-colourings (Graph.toColoringCNF q):n = q * |V|variables, clause width≤ max q 2, preservingNat.card (G.induced.Coloring (Fin q)). - Perfect matchings (
Graph.toPerfectMatchingCNF):n ≤ 1 + 4 |V| + 7 |E| = O(|V| + |E|)variables, exact clause width3, compiled via sequential linear-size exact-one De Morgan circuits (Cslib.Circuits.Boolean.seqExactlyOneAll) andtseitinSatCNF, preservingNat.card {M : G.induced.Subgraph // M.IsPerfectMatching}(Tseitin 1983, Cygan et al.).
Main definitions #
Cslib.Complexity.Graph.toIndepSetCNF,Cslib.Complexity.Graph.indepSetCNFEquiv.Cslib.Complexity.Graph.coloringVar,Cslib.Complexity.Graph.toColoringCNF,Cslib.Complexity.Graph.coloringCNFEquiv.Cslib.Complexity.Graph.perfectMatchingWires,Cslib.Complexity.Graph.perfectMatchingCircuit,Cslib.Complexity.Graph.toPerfectMatchingCNF,Cslib.Complexity.Graph.perfectMatchingCNFEquiv.
Main results #
Cslib.Complexity.Graph.modelCount_toIndepSetCNF,Cslib.Complexity.Graph.computableInPolyTime_toIndepSetCNF: exact count, width2,numVars = |V|, and polynomial-time compilation for independent sets.Cslib.Complexity.Graph.modelCount_toColoringCNF,Cslib.Complexity.Graph.computableInPolyTime_toColoringCNF: exact count, width≤ max q 2,numVars = q * |V|, and polynomial-time compilation forq-colourings.Cslib.Complexity.Graph.modelCountOn_toPerfectMatchingCNF,Cslib.Complexity.Graph.numVars_toPerfectMatchingCNF_le,Cslib.Complexity.Graph.computableInPolyTime_toPerfectMatchingCNF: exact count, width3, linearO(|V| + |E|)variables and clauses, and polynomial-time compilation for perfect matchings.
References #
1. Independent sets (n = |V|, width 2) #
Executable width-2 CNF encoding of the independent sets of G.induced on |V| variables.
Every clause of G.toIndepSetCNF has exact length 2.
G.toIndepSetCNF has exactly G.1.toFinset.card occurring variables.
Occurring variables of G.toIndepSetCNF are bounded by (encGraph G).length.
Explicit bijection between satisfying assignments of G.toIndepSetCNF on G.1.toFinset
and independent sets of G.induced.
Exact model count of G.toIndepSetCNF: number of independent sets of G.induced.
Constructing G.toIndepSetCNF from encGraph is polynomial-time.
2. Proper q-colourings (n = q * |V|, width ≤ max q 2) #
Executable CNF encoding of proper q-colourings of G.induced over dense natural variables
0, …, q * |V| - 1, with clause width at most max q 2.
Every clause of G.toColoringCNF q has width at most max q 2.
The occurring variables of G.toColoringCNF q are precisely Finset.range (q * |V|).
G.toColoringCNF q uses exactly q * G.1.toFinset.card variables.
Explicit bijection between satisfying assignments of G.toColoringCNF q on
Finset.range (q * |V|) and proper q-colourings of G.induced.
Exact model count of G.toColoringCNF q: number of proper q-colourings of G.induced.
Constructing G.toColoringCNF q from encGraph is polynomial-time for every fixed q.
3. Perfect matchings (n = O(|V| + |E|), width 3) #
Linear-size sequential exact-one De Morgan gate list and output wire for G.
Width-3 CNF encoding of perfect matchings via sequential exact-one De Morgan circuits
and Tseitin compilation: exact clause width 3 and O(|V| + |E|) variables and clauses.
Every clause of G.toPerfectMatchingCNF has exact width 3.
Total length of all vertex-incidence lists is at most 2 * G.edgeList.length, since each
edge contributes to at most two vertex constraints.
Number of clauses of G.toPerfectMatchingCNF is linear: ≤ 4 + 12 |V| + 18 |E|.
Variable count of G.toPerfectMatchingCNF in terms of (encGraph G).length.
Explicit bijection between declared-range models of G.toPerfectMatchingCNF and perfect
matchings of G.induced.
Exact model count of G.toPerfectMatchingCNF on Finset.range (|E| + gates):
equals the number of perfect matchings of G.induced.
Exact model count of G.toPerfectMatchingCNF (modelCount), preserving the number of
perfect matchings up to unused free wires (and exact equality when every wire occurs).
Polynomial-time certificate for Graph.toPerfectMatchingCNF #
Constructing G.toPerfectMatchingCNF from encGraph is polynomial-time.