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
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
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
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
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
The counting step #
Correctness #
Stated for an explicit cover and an explicit set of items, so that the same
lemmas give the equivalence of the two decision problems and the bijection
between their solutions (DescriptiveComplexity.Problems.Knapsack.CountingHardness).
The items of a subfamily: the padded items of its sets.
Equations
- DescriptiveComplexity.KnapRed.itemsOf a₀ G i = ∃ (s : A), G s ∧ i = DescriptiveComplexity.KnapRed.kItem a₀ s
Instances For
Dependency graph
The subfamily of a set of items: the sets whose padded item is chosen.
Equations
Instances For
Dependency graph
The items of an exact cover sum to the target.
Dependency graph
A set of items summing to the target is an exact cover.
Dependency graph
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.