Documentation

CslibFrontier.Computability.Complexity.Problems.SharpDNF

Counting satisfying assignments of a DNF formula: #DNF #

SharpDNF φ is the number of satisfying assignments of a formula φ in disjunctive normal form over variables numbered by ℕ: the assignments of the variables occurring in φ that satisfy it (Cslib.Logic.PL.DNF.modelCount). Deciding whether a formula in disjunctive normal form is satisfiable is easy, but counting its satisfying assignments exactly is #P-complete Valiant. It nevertheless has a fully polynomial randomized approximation scheme, the estimator of Karp, Luby and Madras Karp, Luby and Madras, Mitzenmacher and Upfal, Section 11.2 (Cslib.Complexity.SharpDNF.mem_FPRAS).

Main definitions #

Main results #

References #

#DNF: the number of satisfying assignments of a formula in disjunctive normal form over variables numbered by ℕ, counting assignments of the variables occurring in the formula.

The Karp–Luby–Madras estimator is an FPRAS for #DNF Karp, Luby and Madras: on a formula with m terms, it runs dyadicSize m * 3 (t + 1) p ^ 2 trials and its estimate is within relative error 1 / p of the number of models with probability at least 1 - (1 / 2) ^ t.

theorem Cslib.Complexity.KarpLubyMadras.approx_estimate (φ : Logic.PL.DNF ℕ) {ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) :
1 - δ ≤ ((estimate φ ⌈ε⁻¹⌉₊ (Nat.clog 2 ⌈δ⁻¹⌉₊)).eval.toOuterMeasure {out : ℕ × ℕ | 0 < out.2 ∧ |↑out.1 / ↑out.2 - ↑φ.modelCount| ≤ ε * ↑φ.modelCount}).toReal

The guarantee for real parameters: run with p = ⌈1 / ε⌉ and t = ⌈log₂ ⌈1 / δ⌉⌉, the Karp–Luby–Madras estimator is within relative error ε of the number of models with probability at least 1 - δ.

#DNF has a fully polynomial randomized approximation scheme Karp, Luby and Madras.