Documentation

DescriptiveComplexity.Problems.Knapsack.Membership

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

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.

@[reducible, inline]

The tgt symbol over the sum.

Equations
Instances For
    Dependency graph

    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
    • One or more equations did not get rendered due to their size.
    Instances For
      Dependency graph
      Dependency graph
      Dependency graph

      The relation variables of the block.

      Instances For
        Dependency graph
        @[reducible, inline]

        The bit symbol over the sum.

        Equations
        Instances For
          Dependency graph
          @[reducible, inline]

          The sel symbol over the sum.

          Equations
          Instances For
            Dependency graph
            @[reducible, inline]

            The posn symbol over the sum.

            Equations
            Instances For
              Dependency graph
              @[reducible, inline]

              The pS symbol over the sum.

              Equations
              Instances For
                Dependency graph
                Dependency graph
                @[reducible, inline]

                The item symbol over the sum.

                Equations
                Instances For
                  Dependency graph
                  Dependency graph
                  @[reducible, inline]

                  The le symbol over the sum.

                  Equations
                  Instances For
                    Dependency graph
                    Dependency graph
                    @[instance_reducible]
                    Equations
                    • One or more equations did not get rendered due to their size.
                    Dependency graph
                    @[reducible, inline]

                    The vocabulary of the kernel: the instance expanded by the block.

                    Equations
                    Instances For
                      Dependency graph

                      Formula builders #

                      Dependency graph
                      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
                          Dependency graph
                          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
                                  Instances For
                                    Dependency graph

                                    The majority of three formulas.

                                    Equations
                                    Instances For
                                      Dependency graph
                                      noncomputable def DescriptiveComplexity.kMinItemF {α : Type} (i : α) :

                                      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
                                        noncomputable def DescriptiveComplexity.kMaxItemF {α : Type} (i : α) :

                                        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
                                          noncomputable def DescriptiveComplexity.kSuccItemF {α : Type} (i j : α) :

                                          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
                                            noncomputable def DescriptiveComplexity.kMinPosnF {α : Type} (p : α) :

                                            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
                                              noncomputable def DescriptiveComplexity.kMaxPosnF {α : Type} (p : α) :

                                              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
                                                noncomputable def DescriptiveComplexity.kSuccPosnF {α : Type} (p q : α) :

                                                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.

                                                    Dependency graph