CNF counting encodings for independent sets, vertex colourings, and set splitting #
Executable CNF encodings with explicit assignment bijections (Equiv), exact model counts, and
clause/variable parameter bounds for three combinatorial counting problems:
- Independent sets (
indepSetCNF, parametern = |V|, width2): one variable per declared vertex, a width-2 tautology per vertex so every declared vertex occurs, and¬x_u ∨ ¬x_vper edge. Bijects satisfying assignments with independent vertex sets (indepSetCNFEquiv). - Proper
q-colourings (coloringCNF, parametern = q * |V|, width≤ max q 2): one-hot colour indicatorsCNF.exactlyOneper vertex and pairwise conflict clauses¬x_{u,c} ∨ ¬x_{v,c}per edge and colourc < q. Bijects satisfying assignments withSimpleGraph.Coloring (Fin q)(coloringCNFEquiv). - Ordered
k-set splitting (setSplittingCNF, parametern = |U|, width≤ k): positive and negative clauses per subset (CNF.evalNAE). Bijects satisfying assignments with ordered splitting bipartitions(A, B)(setSplittingCNFEquiv).
Main definitions #
Cslib.Logic.PL.CNF.indepSetCNF,Cslib.Logic.PL.CNF.indepSetCNFEquiv.Cslib.Logic.PL.CNF.coloringCNF,Cslib.Logic.PL.CNF.coloringCNFEquiv.Cslib.Logic.PL.CNF.setSplittingCNF,Cslib.Logic.PL.CNF.setSplittingCNFEquiv.
References #
Graph adjacency helper from vertex and edge lists #
Edges between distinct declared vertices of vs.
1. Independent sets (n = |V|, width 2) #
CNF encoding of independent sets: one variable per vertex v ∈ vs, tautology
[(v, true), (v, false)] so all declared vertices occur, and [(e.1, false), (e.2, false)] for
every declared edge e ∈ es. Every clause has width 2.
Every clause of indepSetCNF vs es has length 2.
The occurring variables of indepSetCNF vs es are precisely the vertices in vs.
indepSetCNF vs es has at most vs.toFinset.card variables (equality holds always).
Evaluation of indepSetCNF vs es under σ: no declared edge has both endpoints true.
Assignment bijection for indepSetCNF: given a simple graph G on vertex subtype
{v // v ∈ vs} whose adjacency matches es, satisfying assignments on vs.toFinset biject with
independent sets of G.
indepSetCNF preserves the exact count of independent sets.
2. Proper q-colourings (n = q * |V|, width ≤ max q 2) #
CNF encoding of proper q-colourings: one-hot variables (v, c) (c < q) per vertex
v ∈ vs, CNF.exactlyOne constraints for every vertex, and edge exclusions
[((e.1, c), false), ((e.2, c), false)] for every declared edge e and colour c < q.
Every clause of coloringCNF q vs es has width at most max q 2.
The occurring variables of coloringCNF q vs es are {v ∈ vs} × {c < q}.
coloringCNF q vs es has q * |vs.toFinset| occurring variables.
Evaluation of coloringCNF q vs es under σ: every v ∈ vs has a unique true colour < q,
and adjacent vertices never share a colour.
Assignment bijection for coloringCNF: satisfying assignments on the one-hot variables
vs.toFinset ×ˢ Finset.range q biject with proper Fin q-colourings of G.
coloringCNF preserves the exact count of proper q-colourings.
3. Ordered k-set splitting (n = |U|, width ≤ k) #
Every clause of setSplittingCNF sets has length at most k when every set has size ≤ k.
All variables of setSplittingCNF sets belong to sets.flatten.
Evaluation of setSplittingCNF sets matches CNF.evalNAE on the positive clauses:
every set contains at least one true and one false element.
Bridge to CNF.evalNAE: setSplittingCNF evaluates identically to evalNAE on the
positive hyperedge clauses.
Assignment bijection for setSplittingCNF: on any declared universe U : Finset V
covering sets, satisfying assignments on U biject with ordered bipartitions (A, B) of U
such that every s ∈ sets meets both A and B.
setSplittingCNF preserves the exact count of ordered splitting bipartitions.