Documentation

DescriptiveComplexity.Problems.Knapsack.Counting

#Knapsack: counting the solutions of a subset-sum instance #

The counting version of DescriptiveComplexity.Knapsack: the number of sets of items whose binary weights sum exactly to the target (DescriptiveComplexity.KnapsackSol).

Membership in #P (DescriptiveComplexity.sharpKnapsack_mem_sharpP) is where a counting definition differs from a Σ₁ one. The certificate of DescriptiveComplexity.knapsack_sigmaSODefinable carries, besides the chosen items, the running totals and the carries of an addition walk, and a count of certificates is a count of solutions only if a solution has one: the totals and carries are forced where the walk reads them (DescriptiveComplexity.isChain_agree), and the counting kernel (DescriptiveComplexity.sharpKnapsackKernel) forbids them anywhere else. The certificates are then the solutions, bijectively (DescriptiveComplexity.knapsackEquiv).

The set S of items is a solution: the instance is finite, its order is linear, and the weights of S sum exactly to the target.

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

    The certificate built on a walk: the chosen items, and the totals and carries of the walk kept only where a walk reads them.

    Equations
    Instances For
      Dependency graph
      theorem DescriptiveComplexity.exists_knapsackCert {A : Type} [FirstOrder.Language.binWeights.Structure A] [Finite A] {S : A → Prop} (h : KnapsackSol A S) :
      ∃ (PS : A → A → Prop) (Cy : A → A → Prop), IsChain BWLe BWItem BWLe BWPosn S BWBit PS Cy ∧ KnapsackCert A (certOfWalk S PS Cy)

      A solution has a certificate.

      Dependency graph

      The chosen items of a certificate are a solution.

      Dependency graph

      The solutions of a subset-sum instance are the witnesses of the counting kernel, bijectively: a solution has exactly one certificate.

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

        #Knapsack: the number of sets of items whose weights sum exactly to the target.

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

          #Knapsack is in #P: a solution has exactly one certificate of the counting kernel.

          Dependency graph