Dynamic programming for CSPs on bounded treewidth #
For a constraint satisfaction problem F : CSP Rel V over a finite inhabited domain Fin q
(0 < q), and a valid nice tree decomposition covering every constraint scope of F (from
F.primalGraph or F.activePrimalGraph), this module implements executable pure dynamic
programming procedures for both exact model counting (cspCountNice, cspCountRooted) and
satisfiability (cspDecideNice, cspDecideRooted).
Using SimpleGraph.RootedTreeDecomposition.toNiceTreePruned, any supplied rooted tree
decomposition R of width w is converted to a nice tree decomposition of width at most w and
size at most (3 * w + 5) * (card V + 1). Machine-level running-time bounds over pre-serialized
nice tree decompositions and pre-materialized constraint truth tables (logarithmic-word decision
and single-word wide-word exact counting) live in
CslibFrontier.Algorithms.WordRAM.TreeDecomposition.CSP.
Main definitions #
Cslib.Algorithms.Lean.TreeDecomposition.bagList: canonical vertex list order at each nice-tree node.Cslib.Algorithms.Lean.TreeDecomposition.cspCountTree,Cslib.Algorithms.Lean.TreeDecomposition.cspDecideTree: bottom-up DP tables over aNiceTree.Cslib.Algorithms.Lean.TreeDecomposition.cspCountNice,Cslib.Algorithms.Lean.TreeDecomposition.cspDecideNice: root answers on nice decompositions ofF.primalGraph(andcspCountActiveNice,cspDecideActiveNiceonF.activePrimalGraph).Cslib.Algorithms.Lean.TreeDecomposition.cspCountRooted,Cslib.Algorithms.Lean.TreeDecomposition.cspDecideRooted: wrappers over arbitrary rooted tree decompositions viatoNiceTreePruned(and active counterparts).
Main results #
Cslib.Algorithms.Lean.TreeDecomposition.cspCountNice_eq_modelCount,Cslib.Algorithms.Lean.TreeDecomposition.cspDecideNice_eq_true_iff: exact agreement withCSP.modelCountandCSP.Satisfiable.Cslib.Algorithms.Lean.TreeDecomposition.cspCountRooted_eq_modelCount,Cslib.Algorithms.Lean.TreeDecomposition.cspDecideRooted_eq_true_iff(and active counterparts): exact agreement on rooted tree decompositions viatoNiceTreePruned.Cslib.Algorithms.Lean.TreeDecomposition.modelCount_semFin,Cslib.Algorithms.Lean.TreeDecomposition.satisfiable_semFin_iff: reduction from an arbitrary[Fintype D] [Inhabited D]domain toFin (Fintype.card D).
Canonical variable listing of each bag in a NiceTree.
Shared DP engine and correctness against specDPCount and specDPDecide #
Semiring-like operations used by dpTree for both counting and decision.
- zero : β
Additive identity (
0for counting,falsefor decision). - one : β
Multiplicative identity (
1for counting,truefor decision). - add : β → β → β
Aggregation across values of a forgotten variable.
- mul : β → β → β
Combination of two join-branch table entries.
Generic bottom-up DP engine over a NiceTree, parameterized by DPAlg.
DPAlg instance over ℕ for exact model counting.
Compute the bottom-up exact-count DP table on a nice tree decomposition over Fin q.
Compute the bottom-up satisfiability DP table on a nice tree decomposition over Fin q.
Top-level CSP solvers on nice and rooted tree decompositions #
Exact model count computed from a supplied nice tree T.
Satisfiability decision computed from a supplied nice tree T.
Exact model count on a nice tree decomposition of F.primalGraph.
Satisfiability decision on a nice tree decomposition of F.primalGraph.
Exact model count on a nice tree decomposition of F.activePrimalGraph.
Satisfiability decision on a nice tree decomposition of F.activePrimalGraph.
Exact model count on a rooted tree decomposition of F.primalGraph via toNiceTreePruned.
Satisfiability decision on a rooted tree decomposition of F.primalGraph via
toNiceTreePruned.
Exact model count on a rooted tree decomposition of F.activePrimalGraph via
toNiceTreePruned.
Satisfiability decision on a rooted tree decomposition of F.activePrimalGraph via
toNiceTreePruned.