Node-descriptor layout, telescoping table-entry sum, and initNodesProg #
This module defines the memory-layout invariant NodeLayout for all numNodes + 1 bag descriptors
and DP tables, the telescoping prefix-maximum potential prefixMaxSum that prevents 2 ^ numNodes
table-entry growth, and the Word-RAM parser/allocator initNodesProg. It has no dependency on any
bag-scan or DP-pass submodule (IndepScan, MaskOps, WeightScan, ChildPass, ParentPass,
RootPass).
Main definitions #
Cslib.Algorithms.WordRAM.TreeDecomposition.NodeLayout: memory-layout invariant over weights, adjacency matrix, parent pointers, 4-word node descriptors, and pairwise-disjoint DP tables.Cslib.Algorithms.WordRAM.TreeDecomposition.prefixMaxSum: sum of per-table maximum entries across nodes0 .. m.Cslib.Algorithms.WordRAM.TreeDecomposition.InitNodesArgs,Cslib.Algorithms.WordRAM.TreeDecomposition.initNodesProg: register arguments and Word-RAM routine parsing length-prefixed bags and zero-allocating alln + 1DP tables.
Main results #
Cslib.Algorithms.WordRAM.TreeDecomposition.NodeLayout.mono_frontier,Cslib.Algorithms.WordRAM.TreeDecomposition.NodeLayout.update_table: framing under frontier allocations and single-table in-place updates.Cslib.Algorithms.WordRAM.TreeDecomposition.prefixMaxSum_update_le: telescoping potential step when childk + 1accumulates into strictly smaller parentp < k + 1.Cslib.Algorithms.WordRAM.TreeDecomposition.initNodesProg_spec,Cslib.Algorithms.WordRAM.TreeDecomposition.initNodesProg_realizes: initialNodeLayoutestablishment, cost bound, and exact-basis realization certificate.
Memory layout invariant (NodeLayout) #
Memory-layout invariant over inst's input slices, 4-word node descriptors at descBase, and
disjoint materialized DP tables tblList i of length 2 ^ |bagAt i|.
- wt_holds : WordRAM.Realization.HoldsIn 3 inst.weights s
Weights array at word address
3. Row-major adjacency matrix at
3 + numVerts.- par_holds : WordRAM.Realization.HoldsIn (3 + inst.numVerts + inst.numVerts * inst.numVerts) inst.parents s
Parent array at
3 + numVerts + numVerts * numVerts. Descriptor block starts after the input prefix.
All
4 * (numNodes + 1)descriptor words lie withins.frontier.- bags_holds (i : Fin (inst.numNodes + 1)) : s.mem (descBase + 4 * ↑i + 1) = (inst.bagAt i).length ∧ s.mem (descBase + 4 * ↑i + 3) = 2 ^ (inst.bagAt i).length ∧ s.mem (descBase + 4 * ↑i) + (inst.bagAt i).length ≤ descBase ∧ WordRAM.Realization.HoldsIn (s.mem (descBase + 4 * ↑i)) (inst.bagAt i) s
Each node
idescriptor stores(bagPtr, bagLen, tblPtr, 2 ^ bagLen)withbagAt ibelowdescBase. - tbl_holds (i : Fin (inst.numNodes + 1)) : (tblList i).length = 2 ^ (inst.bagAt i).length ∧ descBase + 4 * (inst.numNodes + 1) ≤ s.mem (descBase + 4 * ↑i + 2) ∧ WordRAM.Realization.HoldsIn (s.mem (descBase + 4 * ↑i + 2)) (tblList i) s
Each node
iDP table lies at or abovedescBase + 4 * (numNodes + 1)and holdstblList i. - tbl_disj (i j : Fin (inst.numNodes + 1)) : ↑i < ↑j → s.mem (descBase + 4 * ↑i + 2) + 2 ^ (inst.bagAt i).length ≤ s.mem (descBase + 4 * ↑j + 2)
Distinct node DP tables occupy strictly ordered, non-overlapping address ranges.
NodeLayout is preserved by allocations or writes at or above s.frontier.
NodeLayout updates cleanly when node p's DP table is overwritten in-place.
Telescoping prefix-sum potential (prefixMaxSum) #
All-zero tables have prefixMaxSum = 0.
Splitting prefixMaxSum tblList (k + 1) off node k + 1 when k + 1 ≤ n.
Telescoping step: folding node k + 1's table into strictly earlier parent p < k + 1
increases the remaining prefix sum 0 .. k by at most B relative to 0 .. k + 1.
Node descriptor initialization (initNodesProg) #
Register arguments (rawBagsPtr, count) for initNodesProg.
- rawBagsPtr : ℕ
Base memory address of
inst.bags.flatMap encodeBag. - count : ℕ
Number of tree-decomposition nodes
numNodes + 1.
Instances For
Tuple equivalence encoding InitNodesArgs into Word-RAM registers.
Allocate 4 * args.count descriptor words, parse each length-prefixed bag, zero-allocate its
2 ^ bagLen-word DP table, and return descBase.
initNodesProg establishes NodeLayout with zero-initialized tables in
≤ 1 + (numNodes + 1) * (2 ^ maxBagLen + maxBagLen + 6) memory operations.
Exact-basis Word-RAM realization certificate for initNodesProg.