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
Dependency graph
The symbol of the chosen-items relation variable.
Instances For
Dependency graph
The symbol of the partial-sum relation variable.
Instances For
Dependency graph
The symbol of the carry relation variable.
Instances For
Dependency graph
The vocabulary of the kernel.
Equations
Instances For
Dependency graph
The item symbol in the kernel's vocabulary.
Instances For
Dependency graph
The position symbol in the kernel's vocabulary.
Instances For
Dependency graph
The bit symbol in the kernel's vocabulary.
Instances For
Dependency graph
The target symbol in the kernel's vocabulary.
Instances For
Dependency graph
The order symbol in the kernel's vocabulary.
Instances For
Dependency graph
The chosen-items symbol in the kernel's vocabulary.
Instances For
Dependency graph
The partial-sum symbol in the kernel's vocabulary.
Instances For
Dependency graph
The carry symbol in the kernel's vocabulary.
Instances For
Dependency graph
Formula builders #
x is an item, as a formula.
Equations
Instances For
Dependency graph
x is a bit position, as a formula.
Equations
Instances For
Dependency graph
The weight of i has bit 1 at p, as a formula.
Equations
Instances For
Dependency graph
The target has bit 1 at p, as a formula.
Equations
Instances For
Dependency graph
x ≤ y, as a formula.
Equations
Instances For
Dependency graph
x is chosen, as a formula.
Equations
Instances For
Dependency graph
Bit p of the running total at i, as a formula.
Equations
Instances For
Dependency graph
The carry at p of the step appending i, as a formula.
Equations
Instances For
Dependency graph
x = y, as a formula.
Equations
Instances For
Dependency graph
The bit that the item i contributes at p: its weight's bit, if it is
chosen.
Equations
Instances For
Dependency graph
The exclusive or of three formulas, as x ↔ (y ↔ z).
Equations
- DescriptiveComplexity.kXor3F x y z = x.iff (y.iff z)
Instances For
Dependency graph
The majority of three formulas.
Equations
- DescriptiveComplexity.kMaj3F x y z = x ⊓ y ⊔ (x ⊓ z ⊔ y ⊓ z)
Instances For
Dependency graph
i is the first item, as a formula.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
i is the last item, as a formula.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
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
Dependency graph
p is the lowest position, as a formula.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
p is the highest position, as a formula.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
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
Dependency graph
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
Dependency graph
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.