Documentation

DescriptiveComplexity.Problems.Knapsack.Defs

Binary-weighted instances, and Karp's Knapsack #

This file opens the binary encoding of DescriptiveComplexity.Numbers.BinRel, the one the last four problems of Karp's list need: numbers that must be exponential in the size of the instance, hence written in binary. Under the unary encoding of DescriptiveComplexity.Numbers.Unary these problems are solvable in polynomial time by dynamic programming, so they are simply not NP-hard there – the representation is not a detail of the encoding but part of the statement.

The vocabulary #

FirstOrder.Language.binWeights carries

Being a linear order is not automatic for a relation symbol, so it is folded into the yes-instances (DescriptiveComplexity.IsLinOrd), exactly as 3SAT folds its width bound in.

The decoding #

DescriptiveComplexity.bitRank is the rank of a position – how many positions lie strictly below it – and DescriptiveComplexity.binNum decodes a set of positions as ∑ 2 ^ rank. Both are defined for an arbitrary relation Le, with no well-formedness assumption, which keeps them total and makes isomorphism-invariance a plain transport statement; when Le is a linear order they agree with DescriptiveComplexity.binValue of the numbers layer.

The sum ranges over a set rather than a Finset, via finsum, so that no finiteness assumption is needed to state the value; on an infinite universe it is 0, which no yes-instance ever looks at since finiteness is part of the problem.

Relation symbols of binary-weighted instances.

Instances For
    Dependency graph
    Dependency graph
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      Dependency graph

      The relational language of binary-weighted instances: items and bit positions, the bits of each item's weight and of the target, and a linear order.

      Equations
      Instances For
        Dependency graph
        Dependency graph
        Dependency graph
        Dependency graph
        Dependency graph
        Dependency graph
        Dependency graph

        The shorthands of the vocabulary #

        Dependency graph
        Dependency graph
        Dependency graph
        Dependency graph
        Dependency graph
        Dependency graph
        Dependency graph

        The problem #

        A binary-weighted instance is a yes-instance of Knapsack when its order is a linear order and some set of items has weights summing exactly to the target. (Karp's KNAPSACK is this subset-sum question.)

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          Dependency graph
          Dependency graph

          KNAPSACK, as a problem on binary-weighted instances: is there a set of items whose weights sum exactly to the target? The weights are written in binary, which is what makes the problem NP-hard rather than polynomial-time.

          Equations
          Instances For
            Dependency graph