Documentation

Complexitylib.Classes.SharpP

The counting class #P #

#P (sharp-P) is the class of functions that count the accepting leaves of a polynomial-time nondeterministic computation tree (roadmap track L5).

This is deliberately distinct from NTM.acceptCount, which counts fixed-length choice strings for probabilistic semantics. If a machine halts early, all extensions of that random string must retain their multiplicity when computing a probability, but the halted computation is only one leaf of a nondeterministic tree. NTM.acceptLeafCount implements the latter convention and is invariant under extending any clock by which every path has halted.

Main definitions and results #

def Complexity.NTM.acceptLeafCountFrom {n : } (tm : NTM n) :
Cfg n tm.Q

Count accepting leaves in the nondeterministic computation tree rooted at c, truncated after at most T transitions. A halted configuration contributes one leaf, rather than one copy for every unused suffix of the choice string.

Equations
Instances For
    def Complexity.NTM.acceptLeafCount {n : } (tm : NTM n) (x : List Bool) (T : ) :

    Number of accepting leaves reached from the initial configuration within T transitions. Unlike acceptCount, this counts an early-halting path once.

    Equations
    Instances For
      theorem Complexity.NTM.acceptLeafCountFrom_le {n : } (tm : NTM n) (c : Cfg n tm.Q) (T : ) :

      An accepting computation tree of height at most T has at most 2 ^ T leaves.

      theorem Complexity.NTM.acceptLeafCount_le {n : } (tm : NTM n) (x : List Bool) (T : ) :
      tm.acceptLeafCount x T 2 ^ T

      A machine has at most 2 ^ T accepting leaves within T transitions.

      theorem Complexity.NTM.acceptLeafCount_eq_of_le_of_allChoicesHalt {n : } (tm : NTM n) (x : List Bool) {T T' : } (hle : T T') (hhalt : ∀ (choices : Fin TBool), tm.halted (tm.trace T choices (tm.initCfg x))) :

      Once every path has halted by T, extending the observation clock to any T' ≥ T leaves the accepting-leaf count unchanged.

      theorem Complexity.NTM.acceptLeafCount_eq_of_le_of_allPathsHaltIn {n : } {T T' : } (tm : NTM n) (hle : ∀ (m : ), T m T' m) (hhalt : tm.AllPathsHaltIn T) (x : List Bool) :

      A pointwise-larger sufficient clock gives the same accepting-leaf count.

      theorem Complexity.NTM.acceptCount_le {n : } (N : NTM n) (x : List Bool) (T : ) :
      N.acceptCount x T 2 ^ T

      The number of accepting choice sequences is at most the total number of choice sequences, 2 ^ T: it is the cardinality of a subset of the 2 ^ T length-T random strings.

      #P (sharp-P): the class of functions f : List Bool → ℕ counting the accepting leaves of a polynomial-time nondeterministic machine. f ∈ SharpP when some NTM halts on every path within a polynomial time bound T and f x equals its accepting-leaf count. Unlike fixed-clock PTM probability, unused choice bits after an early halt do not duplicate a computation leaf.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        theorem Complexity.SharpP.le_two_pow {f : List Bool} (hf : f SharpP) :
        ∃ (T : ), (∃ (k : ), BigO T fun (x : ) => x ^ k) ∀ (x : List Bool), f x 2 ^ T x.length

        Every #P function is bounded by 2 ^ T(|x|) for its polynomial clock T: a witness that #P functions have at-most-exponential values.

        GapP: the class of integer-valued functions expressible as the difference of two #P functions (equivalently, accepting minus rejecting paths of a polynomial-time nondeterministic machine).

        Equations
        Instances For
          theorem Complexity.GapP.neg_mem {h : List Bool} (hh : h GapP) :
          (fun (x : List Bool) => -h x) GapP

          GapP is closed under negation: swap the two #P functions.