Knapsack is NP-hard #
The reduction is Karp's, from EXACT COVER: give the set s the weight
∑_{e ∈ s} B ^ rank e, one digit block per ground element, and give the
target the digit 1 in every block. A subfamily then has the right weight
exactly when it covers every element once – provided that the digits never
carry, which is what choosing the base B above the number of sets buys.
The gadget, in the shape an interpretation can build #
The base is B = 2 ^ |A|, so a block is |A| bit positions, and the bit
positions are pairs: the position (e, x) is the x-th bit of the block of
the ground element e. The order on positions is lexicographic, so the block
of e is a contiguous range of |A| positions and the rank of its lowest
position is |A| * rank e (DescriptiveComplexity.KnapRed.bitRank_kLow) – place
value (2 ^ |A|) ^ rank e, as wanted.
Only the lowest position of a block ever carries a bit: the weight of s
has a 1 at (e, ⊥) for e ∈ s, and the target has a 1 at (e, ⊥) for
every e. The digit of the block of e in the sum over a subfamily G is
therefore the number of sets of G containing e, at most the number of
sets, hence at most |A| < 2 ^ |A| = B. Uniqueness of base-B expansions
(DescriptiveComplexity.digitNum_inj) turns the equation into “every digit is 1”,
which is exactly exactness of the cover.
The order is needed twice – to say “the lowest position of a block” and to
pin the padding of the items down to a single representative – so this is an
DescriptiveComplexity.OrderedFOReduction, and being one has the pleasant side effect
of supplying the finiteness that the counting needs.
Formula builders over the ordered expansion of set systems #
The ordered expansion of the language of set systems.
Equations
Instances For
Dependency graph
The ground-element symbol in the ordered expansion.
Instances For
Dependency graph
The family symbol in the ordered expansion.
Instances For
Dependency graph
The incidence symbol in the ordered expansion.
Instances For
Dependency graph
x is a ground element, as a formula.
Equations
Instances For
Dependency graph
f is a set of the family, as a formula.
Equations
Instances For
Dependency graph
x belongs to f, as a formula.
Equations
Instances For
Dependency graph
x ≤ y, as a formula.
Equations
Instances For
Dependency graph
x = y, as a formula.
Equations
Instances For
Dependency graph
x < y, as a formula.
Equations
Instances For
Dependency graph
x holds a minimum of the order, as a formula.
Instances For
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Lexicographic order on pairs #
The lexicographic order on pairs of elements, as the interpretation sees
them: coordinates of a 2-tuple.
Instances For
Dependency graph
Two 2-tuples with the same coordinates are equal.
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
The interpretation #
Tags of the reduction: the items (one per set of the family) and the bit positions (one per pair “ground element, index inside its block”).
Instances For
Dependency graph
Dependency graph
Equations
- One or more equations did not get rendered due to their size.
Dependency graph
Dependency graph
Defining formula for the items: the sets of the family, padded canonically.
Equations
Instances For
Dependency graph
Defining formula for the bit positions: the pairs whose first coordinate is a ground element.
Equations
Instances For
Dependency graph
Defining formula for the bits of the weights: the weight of the set s
has a 1 at the lowest position of the block of e exactly when e ∈ s.
Equations
- One or more equations did not get rendered due to their size.
- DescriptiveComplexity.KnapRed.bitF x✝¹ x✝ = ⊥
Instances For
Dependency graph
Defining formula for the bits of the target: a 1 at the lowest position
of every block.
Equations
Instances For
Dependency graph
The lexicographic comparison of the two argument tuples, as a formula.
Equations
Instances For
Dependency graph
Defining formula for the order: items first, positions next, each group ordered lexicographically.
Equations
- DescriptiveComplexity.KnapRed.leKF DescriptiveComplexity.KnapRed.KTag.itm DescriptiveComplexity.KnapRed.KTag.itm = DescriptiveComplexity.KnapRed.lexF
- DescriptiveComplexity.KnapRed.leKF DescriptiveComplexity.KnapRed.KTag.itm DescriptiveComplexity.KnapRed.KTag.pos = ⊤
- DescriptiveComplexity.KnapRed.leKF DescriptiveComplexity.KnapRed.KTag.pos DescriptiveComplexity.KnapRed.KTag.itm = ⊥
- DescriptiveComplexity.KnapRed.leKF DescriptiveComplexity.KnapRed.KTag.pos DescriptiveComplexity.KnapRed.KTag.pos = DescriptiveComplexity.KnapRed.lexF
Instances For
Dependency graph
The interpretation of a binary-weighted instance in a set system: one item per set, one bit position per pair “ground element, index”.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The points of the interpreted structure #
The point of tag t over the pair w.
Equations
Instances For
Dependency graph
Dependency graph
Dependency graph
Dependency graph
The item of the set s, padded with the minimum a₀.
Equations
Instances For
Dependency graph
The bit position (e, x): the x-th position of the block of e.
Equations
Instances For
Dependency graph
The lowest position of the block of e.
Equations
Instances For
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Being the lowest position of a block, coordinate by coordinate.
Dependency graph
Characterization of the interpreted relations #
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Comparison with the lowest position of a block.
Dependency graph
Dependency graph
The interpreted order is a linear order: the two tags in order, each carrying the lexicographic order on pairs.
Dependency graph
The place values #
An item is the padded item of the set it carries.
Dependency graph
The block structure: the rank of the lowest position of the block of
e is |A| times the rank of e, so its place value is (2 ^ |A|) ^ rank e
– one digit of base 2 ^ |A| per ground element.
Dependency graph
Weights and target, as base-2 ^ |A| numbers #
The base: one digit per ground element, |A| bits wide, which is above
the number of sets, so digits never carry into the next block.
Equations
Instances For
Dependency graph
Dependency graph
Dependency graph
A binary number whose bits sit on the lowest positions of the blocks
selected by sub is the base-2 ^ |A| number with digit 1 there.
Dependency graph
The target is the number with digit 1 in every block.
Dependency graph
The weight of an item is the number with digit 1 in the blocks of the
elements of its set.
Dependency graph
The counting step #
The sum of the selected weights, read digit by digit: the digit of the
block of e is the number of selected items whose set contains e.
Dependency graph
Only items are selected, and there are at most |A| of them, so the
digits of the sum stay below the base.
Dependency graph
Correctness #
Correctness of the reduction: the set system has an exact cover iff the interpreted binary-weighted instance has a set of items summing to the target.
Dependency graph
Exact Cover FO-reduces to Knapsack, over any linear order on the input:
one item per set, one digit block of |A| bits per ground element, weights
carrying a 1 in the block of each of their elements and the target a 1 in
every block.
Equations
- One or more equations did not get rendered due to their size.