Knapsack is in NP #
The Σ₁ definition of DescriptiveComplexity.Knapsack. Verifying that a set of
binary weights sums to the target is the one place in the catalog where the
certificate has to carry arithmetic: the guess is
sel, the chosen items;psum i p, the bits of the running total over the chosen items up toi;carry i p, the carries of the addition that appendsito that total,
and the kernel checks, first-order, that each step is a ripple-carry addition
– every bit the exclusive or of the three inputs, every carry their majority –
with no carry into the lowest position and none out of the highest. That the
chain really computes the sum is DescriptiveComplexity.binNum_ripple, and that a
chain exists whenever the sum fits is DescriptiveComplexity.exists_ripple
(DescriptiveComplexity.Numbers.BinRel).
Walking the items in order is what makes a single relation psum enough, and
it is why the vocabulary orders the items and not only the bit positions.
The single existential block of the Σ₁ definition of Knapsack: the
chosen items (unary), the running partial sums and the carries (binary, an
item and a bit position).
Equations
Instances For
The symbol of the chosen-items relation variable.
Instances For
The symbol of the partial-sum relation variable.
Instances For
The symbol of the carry relation variable.
Instances For
The vocabulary of the kernel.
Equations
Instances For
The item symbol in the kernel's vocabulary.
Instances For
The position symbol in the kernel's vocabulary.
Instances For
The bit symbol in the kernel's vocabulary.
Instances For
The target symbol in the kernel's vocabulary.
Instances For
The order symbol in the kernel's vocabulary.
Instances For
The chosen-items symbol in the kernel's vocabulary.
Instances For
The partial-sum symbol in the kernel's vocabulary.
Instances For
The carry symbol in the kernel's vocabulary.
Instances For
Formula builders #
x is an item, as a formula.
Equations
Instances For
x is a bit position, as a formula.
Equations
Instances For
The weight of i has bit 1 at p, as a formula.
Equations
Instances For
The target has bit 1 at p, as a formula.
Equations
Instances For
x ≤ y, as a formula.
Equations
Instances For
x is chosen, as a formula.
Equations
Instances For
Bit p of the running total at i, as a formula.
Equations
Instances For
The carry at p of the step appending i, as a formula.
Equations
Instances For
x = y, as a formula.
Equations
Instances For
The bit that the item i contributes at p: its weight's bit, if it is
chosen.
Equations
Instances For
The majority of three formulas.
Equations
- DescriptiveComplexity.kMaj3F x y z = x ⊓ y ⊔ (x ⊓ z ⊔ y ⊓ z)
Instances For
i is the first item, as a formula.
Equations
- One or more equations did not get rendered due to their size.
Instances For
i is the last item, as a formula.
Equations
- One or more equations did not get rendered due to their size.
Instances For
j is the item right after i, as a formula.
Equations
- One or more equations did not get rendered due to their size.
Instances For
p is the lowest position, as a formula.
Equations
- One or more equations did not get rendered due to their size.
Instances For
p is the highest position, as a formula.
Equations
- One or more equations did not get rendered due to their size.
Instances For
q is the position right above p, as a formula.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The clauses #
The first-order kernel of the Σ₁ definition of Knapsack.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Realization #
Membership #
Knapsack is Σ₁-definable: guess the chosen items, the running totals
and the carries, and check first-order that each step is a ripple-carry
addition whose last total is the target. Since NP is defined as
Σ₁-definability, this is the membership half of the NP-completeness of
Knapsack.