Subsets of a bag as bit masks #
Executable dynamic programs over a tree decomposition index the subsets of a bag by bit masks.
Given an ordering L : List V of a bag, ofMask L m is the subset whose i-th entry is selected
by bit i of m, and toMask L S is the mask of S. When L has no repetitions these are
inverse bijections between Finset.range (2 ^ L.length) and the subsets of L.toFinset.
The library has other mask encodings: Cslib.Algorithms.Lean.Yates.maskSet and
Cslib.Algorithms.MatrixMultiplication.Schonhage.MaskTable.maskSet for subsets of Fin n,
Cslib.Complexity.maskSelect for a list of Boolean selectors, and Mathlib's Nat.bitIndices.
None of them maps numeric masks to subsets of an arbitrary list of vertices by the recursion on
its head that the scan helpers below follow, so the encoding is defined here.
The module also provides the pure scan helpers that executable programs run on masks: membership
by a linear scan of a bag, the parent-bag mask of a child subset, its restriction, the weight of
the entries that are forgotten, and an independence test. Their values are specified against
ofMask/toMask, while machine-level running-time bounds live in
CslibFrontier.Algorithms.WordRAM.TreeDecomposition.IndependentSet.
SimpleGraph.RootedTreeDecomposition stores its bags as Finsets, which have no executable
order. IsBagOrder R L states that L i lists the vertices of R.bag i without repetition, and
sortedBags R is such an ordering for a linearly ordered vertex type.
Main definitions #
Cslib.Algorithms.Lean.TreeDecomposition.ofMask: the subset of a bag list selected by a mask.Cslib.Algorithms.Lean.TreeDecomposition.toMask: the mask of a subset.Cslib.Algorithms.Lean.TreeDecomposition.memBag,selMemMask,keyMask,restrictMask,forgetWeight,noAdjMask,indepMask: executable scan helpers on masks.Cslib.Algorithms.Lean.TreeDecomposition.IsBagOrder: an ordering of the bags of a rooted decomposition.Cslib.Algorithms.Lean.TreeDecomposition.sortedBags: the sorted ordering of the bags.
Main results #
Cslib.Algorithms.Lean.TreeDecomposition.ofMask_toMask,Cslib.Algorithms.Lean.TreeDecomposition.toMask_ofMask,Cslib.Algorithms.Lean.TreeDecomposition.powerset_toFinset_eq_image: the bijection between masks and subsets.Cslib.Algorithms.Lean.TreeDecomposition.keyMask_eq_toMask,restrictMask_eq_toMask,forgetWeight_eq_sum,indepMask_eq_true_iff: specifications of the mask helpers.Cslib.Algorithms.Lean.TreeDecomposition.isBagOrder_sortedBags:sortedBagsis an ordering of the bags.
Subsets of a bag as bit masks #
The subset of the list L selected by the bit mask m: bit i of m selects L[i].
The bit mask of the elements of L that lie in S: bit i is set when L[i] ∈ S.
Scan helpers on masks #
Membership test by a linear scan of L.
Membership in the subset of L selected by the mask m, by a linear scan of L.
The parent-bag mask of the child subset selected by t: for each entry u of the parent bag
LP, test whether u is selected in the child bag LB.
The parent-bag mask of S ∩ B, where S is the parent subset selected by s and B is the
set of entries of the child bag LB.
The total weight of the entries selected by t from the child bag LB that are not in the
parent bag LP.
Whether x has no neighbour in the subset of L selected by m.
Whether the subset of L selected by m is independent.
Orderings of the bags #
L lists the bags of R: each L i lists the vertices of R.bag i without repetition.
Instances For
The bags of R sorted in increasing order.