Serialized finite-domain CSP model and DP specification over nice tree decompositions #
This module defines the pure data structures, post-order serialization, explicit ℕ-table DP
(dpInstTree), tight active-variable entry bounds (activeForgetCount), and step/word envelopes
shared by the Word-RAM nice-tree CSP modules.
Main definitions #
Cslib.Algorithms.WordRAM.TreeDecomposition.ConstraintTable: materialized truth table for a constraint overℕvariable indices;ConstraintTable.ofConstraintdeduplicates repeated variables inc.scopeso each table hasq ^ |c.scope.toFinset|entries (at mostq ^ (k + 1)for a width-kdecomposition ofF.primalGraph).Cslib.Algorithms.WordRAM.TreeDecomposition.encodeNiceTree: post-order 4-word-per-node serialization ofNiceTree ℕ.Cslib.Algorithms.WordRAM.TreeDecomposition.dpInstTree: explicitℕ-table DP overConstraintTablelists mirroringcspCountTree/cspDecideTree.Cslib.Algorithms.WordRAM.TreeDecomposition.activeForgetCount: number offorgetnodes in aNiceTree ℕwhose variable belongs tovars; bounds counting-mode DP entries byq ^ activeForgetCount vars T(= q ^ F.numVarson valid nice decompositions ofF.primalGraph, independent of redundant tree nodes).Cslib.Algorithms.WordRAM.TreeDecomposition.TreeCSPInstance: serialized extensional CSP + nice tree decomposition instance supporting both decision (counting = false) and single-word wide-word exact model counting (counting = true), with constructorsofNiceTree,ofNice, and the external-preprocessing helperofToNiceTreePruned.Cslib.Algorithms.WordRAM.TreeDecomposition.cspNiceStepBound: explicit FPT step-count polynomial for nice-tree DP.Cslib.Algorithms.WordRAM.TreeDecomposition.cspPrunedNiceStepBound: post-normalization step-count bound after computingR.toNiceTreePrunedexternally (does not depend on or chargen; #9170).
Main results #
Cslib.Algorithms.WordRAM.TreeDecomposition.activeForgetCount_eq_card_forgotten,Cslib.Algorithms.WordRAM.TreeDecomposition.TreeCSPInstance.maxEntryBound_ofNice_eq: exact identification of the counting-mode entry bound withq ^ F.numVarson valid nice decompositions.Cslib.Algorithms.WordRAM.TreeDecomposition.TreeCSPInstance.result_ofNice_count,Cslib.Algorithms.WordRAM.TreeDecomposition.TreeCSPInstance.result_ofNice_decide: agreement ofTreeCSPInstance.resultwith exact model counting and satisfiability on nice decompositions.Cslib.Algorithms.WordRAM.TreeDecomposition.TreeCSPInstance.stepBound_ofNice_le,Cslib.Algorithms.WordRAM.TreeDecomposition.TreeCSPInstance.wordBound_ofNice_le: explicit step-count and word-width upper bounds forofNice(andofToNiceTreePrunedpost-normalization counterparts).
Materialized constraint tables #
Materialized truth table of a single constraint over ℕ variable indices and domain Fin q.
Flat word encoding of a ConstraintTable: [|scope|, |table|] ++ scope ++ table.
Evaluate a ConstraintTable on a natural-valued assignment α : ℕ → ℕ.
Compile a Constraint Rel V into a materialized ConstraintTable q via e : V ≃ Fin m,
deduplicating repeated variables in c.scope so table.length = q ^ |c.scope.toFinset|.
This materialization is performed externally before Word-RAM execution.
Post-order serialization of NiceTree ℕ and pure ℕ-table DP #
Post-order 4-word-per-node serialization of S starting at node index offset:
Post-order 4-word-per-node serialization of T : NiceTree ℕ rooted at T.size - 1.
Largest vertex label occurring anywhere in T.
Every vertex in bagList T is bounded by maxTreeVert T.
Every word emitted by encodeNiceTreeAux offset T is bounded by
max 3 (max (maxTreeVert T) (offset + T.size)).
Unified natural-valued DP table over ConstraintTable q matching both cspDecideTree
(counting = false, {0, 1} entries) and cspCountTree (counting = true, ℕ entries).
dpInstTree emits q ^ (bagList T).length entries.
Number of forget nodes in T whose forgotten variable belongs to vars.
Bounds the exponent of q in counting-mode DP entries (mem_dpInstTree_le), and equals
((T.subtreeVerts \ T.bag) ∩ vars.toFinset).card whenever T.LocalValid holds.
On any locally valid nice tree T, activeForgetCount vars T equals the number of distinct
active variables already forgotten below the root bag of T.
On any locally valid nice tree T, activeForgetCount vars T ≤ vars.toFinset.card.
Entry magnitude bound for dpInstTree: ≤ 1 in decision mode and
≤ q ^ activeForgetCount vars T in counting mode.
Agreement of dpInstTree with cspCountTree and cspDecideTree #
TreeCSPInstance and FPT step bounds #
Worst-case table exponent across T: bounds (bagList S).length at all nodes and
((bagList child).erase v).length + 1 at forget nodes, while staying ≤ T.width + 1 whenever
T.LocalValid holds.
The bag length at T is bounded by maxTableExp T.
FPT memoryCost bound for extensional CSP decision or single-word wide-word model counting on a
pre-serialized nice tree decomposition of size numNodes and width ≤ k, domain size q,
numCons = |F|, and varsLen = |F.vars| (total arity across all constraints):
O(numNodes · q ^ (k + 1) · ((k + 1) ^ 2 + |F| + |F.vars| · (k + 1)) + numNodes · |F.vars|).
Post-normalization FPT memoryCost bound for the nice-tree DP phase on a nice tree of size
≤ (3 * k + 5) * (cardV + 1) produced externally by R.toNiceTreePruned.
This bound covers only the nice-tree DP pass after external conversion and has no dependence on the
input rooted decomposition's node count n; Word-RAM rooted-to-nice normalization remains open
(#9170).
Serialized finite-domain extensional CSP instance with a pre-serialized nice tree decomposition for Word-RAM execution.
- counting : Bool
falsefor satisfiability ({0, 1}output),truefor single-word exact model counting. - domainSize : ℕ
Domain size
q > 0. - domainSize_pos : 0 < self.domainSize
Positivity of
domainSize. Active variable indices (
F.vars).Materialized constraint truth tables.
- tree : SimpleGraph.NiceTree ℕ
Nice tree decomposition over
ℕvertex indices.
Flat word encoding loaded into State.init:
[mode, q, |vars|, |constraints|, tree.size] ++ vars ++ encodeNiceTree tree ++ constraints.
Total arity across all materialized constraints.
Maximum variable index occurring in vars, tree, or any constraint scope.
Maximum DP entry value: 1 in decision mode, q ^ activeForgetCount vars tree in counting
mode (which equals q ^ F.numVars on valid nice tree decompositions of F.primalGraph,
independent of redundant tree nodes).
Sufficient word bound covering all memory frontiers, node/bag/table indices, variable names, and DP entry values.
Step-count bound (memoryCost) for inst.
Compile a CSP Rel V and NiceTree V into a TreeCSPInstance via e : V ≃ Fin m,
materializing deduplicated constraint truth tables externally.
Compile a CSP Rel V and NiceTreeDecomposition of F.primalGraph.
External-preprocessing convenience wrapper compiling a CSP Rel V and
RootedTreeDecomposition of F.primalGraph by running R.toNiceTreePruned and
ConstraintTable.ofConstraint outside the Word-RAM before serialization.
This is not a Word-RAM encoding of R (the machine never sees R or its node count n; #9170).
On any valid nice tree decomposition of F.primalGraph, the counting-mode entry bound
maxEntryBound equals q ^ F.numVars (independent of redundant tree nodes).
Closed-form upper bound on (ofNice counting q hq e sem F N).wordBound.
In decision mode (counting = false), the entry term is 1, so logarithmic word width
w = O(log(m + N.size + |F.vars| + |F| + q ^ (k + 1))) suffices even with repeated variables in
constraint scopes. In counting mode (counting = true), the entry term is q ^ F.numVars
(independent of redundant tree nodes), requiring single-word width w > F.numVars · log₂ q.
Closed-form upper bound on (ofToNiceTreePruned counting q hq e sem F R).wordBound via
R.toNiceTreePruned_size_le and R.toNiceTreePruned_width_le.
Post-normalization step bound for ofToNiceTreePruned (≤ cspPrunedNiceStepBound,
independent of the rooted decomposition's node count n; #9170).
Monotonicity of maxTreeVert across introduce.
Monotonicity of maxTreeVert across forget.
Monotonicity of maxTreeVert into the left child of join.
Monotonicity of maxTreeVert into the right child of join.
Monotonicity of maxTableExp across introduce.
Monotonicity of maxTableExp across forget.
Monotonicity of maxTableExp into the left child of join.
Monotonicity of maxTableExp into the right child of join.
Monotonicity of activeForgetCount across introduce.
Monotonicity of activeForgetCount across forget.
Monotonicity of activeForgetCount into the left child of join.
Monotonicity of activeForgetCount into the right child of join.