Counting complexity
#P and PP: #P-completeness (counting SAT, permanent), PP-completeness, Toda's theorem, threshold languages, and approximate counting algorithms and schemes (Stockmeyer, Karp–Luby, Jerrum–Sinclair–Vigoda).
- Complexity of the permanent
- Counting satisfiability (#SAT)
- Karp–Luby algorithm for DNF counting
- Threshold languages of #P functions
- Unbounded-error probabilistic time (PP)
TheoremStockmeyer: approximate counting of #P functions in BPP^NP#●ready to prove
For every function \(f\) in \(\#P\) there are a decision problem \(O\) in NP, polynomials \(p_r\), \(p\) and \(q\) with natural-number coefficients, and polynomial-time computable functions \(\mathrm{nextQ}\) and \(\mathrm{final}\), each taking a bitstring and a list of query/answer pairs (bitstring, boolean), with \(\mathrm{nextQ}\) returning a bitstring and \(\mathrm{final}\) returning a natural number, such that the following holds. Let \(x\) and \(w\) be bitstrings with \(n = |w| \ge 1\), where \(|\cdot|\) denotes length, and put \(m = |x| + n\). For a bitstring \(r\) of length \(p_r(m)\), let \(E(r)\) be the output of the oracle computation that chooses queries with \(\mathrm{nextQ}\) and decides with \(\mathrm{final}\), run with oracle \(O\), query-length cap \(q(m)\) and \(p(m)\) adaptive queries on the bitstring encoding of the pair \((x, (r, w))\) from the empty history. Then \(f(x)/(1 + 1/n) \le E(r) \le f(x) \cdot (1 + 1/n)\), computed in the rationals, for at least two thirds of the \(2^{p_r(m)}\) bitstrings \(r\) of length \(p_r(m)\).
The bitstring \(w\) gives the precision \(n\) in unary; the number of random bits, the number of queries and the query-length cap are all polynomial in \(|x| + n\).
MetaMathlibExt.Complexity.KeyTheorems.Stockmeyer.stockmeyer_approximate_counting · 16 lines
public theorem_wanted stockmeyer_approximate_counting :
∀ f : List Bool → ℕ, f ∈ SharpP →
∃ O : MetaMathlibExt.ComplexityTheory.DecisionProblem,
O ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∃ pRand p q : Polynomial ℕ,
∃ nextQ : List Bool × List (List Bool × Bool) → List Bool,
∃ final : List Bool × List (List Bool × Bool) → ℕ,
IsPolyTime nextQ ∧ IsPolyTime final ∧
∀ (x : List Bool) (prec : List Bool), 1 ≤ prec.length →
3 * Set.ncard {r : Fin (pRand.eval (x.length + prec.length)) → Bool |
let E := evalOracle (q.eval (x.length + prec.length)) nextQ final O
(MetaMathlibExt.BitstringEncoding.bitEncode (x, List.ofFn r, prec))
(p.eval (x.length + prec.length)) []
(f x : ℚ) / (1 + 1 / (prec.length : ℚ)) ≤ (E : ℚ) ∧
(E : ℚ) ≤ (f x : ℚ) * (1 + 1 / (prec.length : ℚ))} ≥
2 * 2 ^ (pRand.eval (x.length + prec.length))
def SharpP : Set (List Bool → ℕ) :=
{f | ∃ p : Polynomial ℕ, ∃ R : List Bool × List Bool → Bool, IsPolyTime R ∧
∀ x, f x = Set.ncard
{w : Fin (p.eval x.length) → Bool | R (x, List.ofFn w) = true}}
CSLibExt/Computability/Complexity/Classes.lean:229
abbrev DecisionProblem := List Bool → Bool
MathlibExt/Computability/Complexity.lean:170
def NP : DecisionComplexityClass :=
{ L | ∃ (p : Polynomial ℕ), ∃ R : (List Bool × List Bool) → Bool,
IsPolyTime R ∧
∀ x, L x ↔ ∃ w : List Bool, w.length ≤ p.eval x.length ∧ R (x, w) }
MathlibExt/Computability/Complexity.lean:200
def IsPolyTime {α β : Type} [BitstringEncoding α] [BitstringEncoding β]
(f : α → β) : Prop :=
IsPolyTimeWithEncoding (BitstringEncoding.toEncoding (α := α))
(BitstringEncoding.toEncoding (α := β)) f
MathlibExt/Computability/Complexity.lean:186
def evalOracle {α β : Type} (cap : ℕ)
(nextQ : List Bool × List (List Bool × α) → List Bool)
(final : List Bool × List (List Bool × α) → β)
(oracle : List Bool → α) (x : List Bool) (fuel : ℕ)
(hist : List (List Bool × α)) : β :=
match fuel with
| 0 => final (x, hist)
| fuel + 1 =>
let q := nextQ (x, hist)
if q.length ≤ cap then
evalOracle cap nextQ final oracle x fuel
(hist ++ [(q, oracle q)])
⋯
CSLibExt/Computability/Complexity/Classes.lean:244
def bitEncode [BitstringEncoding α] (a : α) : List Bool := toEncoding.encode a
MathlibExt/Computability/Complexity.lean:55
Sources
- L. J. Stockmeyer, "The complexity of approximate counting", Proceedings of the Fifteenth Annual ACM Symposium on Theory of Computing (STOC 1983), 118-126 (journal version in Information and Computation 1985).
Uses 14
TheoremToda's theorem: PH is contained in \(\mathsf{P}^{\#\mathsf{P}}\)#●ready to prove
Every decision problem in the polynomial hierarchy PH lies in \(\mathsf{P}^{\#\mathsf{P}}\), the class of decision problems decidable in polynomial time with a \(\#\mathsf{P}\) oracle.
public theorem_wanted toda :
PH ⊆ PWithSharpP
def PH : DecisionComplexityClass := ⋃ k, SigmaK k
CSLibExt/Computability/Complexity/Classes.lean:323
def PWithSharpP : DecisionComplexityClass :=
{L | ∃ f ∈ SharpP, ∃ p q : Polynomial ℕ,
∃ nextQ : List Bool × List (List Bool × ℕ) → List Bool,
∃ final : List Bool × List (List Bool × ℕ) → Bool,
IsPolyTime nextQ ∧ IsPolyTime final ∧
∀ x, L x ↔
evalOracle (q.eval x.length) nextQ final f x (p.eval x.length) [] = true}
CSLibExt/Computability/Complexity/Classes.lean:279
Sources
- S. Toda, "PP is as hard as the polynomial-time hierarchy", SIAM Journal on Computing 20 (1991), 865-877 (FOCS 1989).
Uses 4
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.