Selecting list entries by a mask #
Cslib.Complexity.maskSelect l w keeps the entries of l at the positions where the bit string
w is true. Masks describe exactly the sublists of l, and therefore, up to order, exactly the
sub-multisets of l; this makes them polynomially long certificates for problems that ask for a
sub-multiset of the input numbers, such as subset sum, partition and knapsack. Unlike
Cslib.Complexity.selectDistinct, which selects each distinct entry at most once and so selects
sets, a repeated entry may be selected repeatedly.
Main definitions #
Main results #
Cslib.Complexity.maskSelect_sublist,Cslib.Complexity.exists_maskSelect_eq: masks select exactly the sublists.Cslib.Complexity.exists_le_coe_iff_exists_sublist: sub-multisets are sublists up to order.Cslib.Complexity.exists_le_iff_exists_maskSelect: a property of sub-multisets holds for one of them exactly when it holds for the selection of some mask of any length at least the length of the list.Cslib.Complexity.maskSelect_eq_map_filter_range: the selection as the entries at the selected indices.Cslib.Complexity.sum_maskSelect: the sum of the selected numbers is the scalar product with the mask.
The entries of l at the positions where w is true; positions beyond the end of w are
not selected. Repeated entries may be selected repeatedly, so masks select sub-multisets; for sets,
Cslib.Complexity.selectDistinct selects each entry at most once.
Instances For
A mask selects a sublist.
The selection of a mask is the list of entries at the selected indices.