Documentation

CslibFrontier.Computability.Complexity.Problems.CountingSAT

Complete problems for the counting classes #

Since the Cook–Levin reduction is parsimonious (CookLevin.SharpSAT_sharpPHard), each counting class defined by a condition on a function in #P has a complete problem defined by the same condition on the number of satisfying assignments of a formula (SharpSAT), under polynomial-time many-one reductions Valiant. The classes are the verifier-based ones of this library, following Fortnow, Section 4.

The first four follow one pattern (polyTimeComplete_sharpSAT): a problem in the class is {a | Q (f a)} for some f ∈ #P, and the parsimonious reduction r for f reduces it to {φ | Q (SharpSAT φ)}. For PP, the characterization of PP through #P (mem_PP_iff_exists_SharpP) gives a ∈ A ↔ 2 ^ q(n) < 2 f(a); the reduction to SharpSATAtLeast maps a to the formula for 2 f with the threshold 2 ^ q(n) + 1, and the reduction to MAJSAT pads that formula (padMajority) with q(n) even-numbered dummy variables and a selector variable 0 so that the padded formula has 1 + q(n) + k occurring variables and 2 f(a) + 2 ^ (q(n) + k) - 2 ^ q(n) satisfying assignments. For C=P, a problem in the class is {a | f₁ a = f₂ a} for f₁, f₂ ∈ #P, with f₂ ≤ 2 ^ p(n) and 2 ^ p(n) - f₂ ∈ #P (SharpP.exists_two_pow_sub_mem); the reduction maps a to the formula for f₁ + (2 ^ p(n) - f₂) with the count 2 ^ p(n). In the pair problems the number m is computed in polynomial time in binary.

Main definitions #

Main results #

References #

The problems #

⊕SAT: the formulas with an odd number of satisfying assignments.

Mod_k SAT: the formulas whose number of satisfying assignments is not divisible by k.

MAJSAT: the formulas satisfied by strictly more than half of the truth assignments to their occurring variables (2 ^ φ.vars.toFinset.card < 2 * SharpSAT φ) Gill, Simon.

An instance of a counting threshold or exact-count problem: a Boolean formula in conjunctive normal form paired with a target count of satisfying assignments.

  • formula : Logic.PL.CNF ℕ

    The formula in conjunctive normal form.

  • target : ℕ

    The target number of satisfying assignments.

Instances For
    theorem Cslib.Complexity.encSharpSATTarget_target_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → SharpSATTarget} :

    Pairs of a formula and a target count, encoded as encCNF paired with binary encNat.

    @[reducible, inline]

    The tuple of the fields of encSharpSATTarget.

    theorem Cslib.Complexity.encSharpSATTarget_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → Logic.PL.CNF ℕ} {x1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn encCNF budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encNat budget) :
    Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { formula := x0 x, target := x1 x }) encIn encSharpSATTarget budget
    theorem Cslib.Complexity.encSharpSATTarget_formula_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → SharpSATTarget} :
    Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ encSharpSATTarget S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).formula) encIn✝ encCNF S✝
    theorem Cslib.Complexity.encSharpSATTarget_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Logic.PL.CNF ℕ} {T0 S0 x1 T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn encCNF T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encNat T1 S1) :
    Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { formula := x0 x, target := x1 x }) encIn encSharpSATTarget (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x

    Instances x : SharpSATTarget such that x.formula has at least x.target satisfying assignments (encSharpSATTarget).

    Instances x : SharpSATTarget such that x.formula has exactly x.target satisfying assignments (encSharpSATTarget).

    Modulo two, a nonzero residue is oddness.

    Modulo zero, a nonzero residue is a positive count: ModSAT 0 is satisfiability.

    Completeness through the parsimonious reduction #

    theorem Cslib.Complexity.polyTimeComplete_sharpSAT {C : {α : Type} → (α ↪ List Bool) → Set (Set α)} (Q : ℕ → Prop) (hC : ∀ {α : Type} (enc : α ↪ List Bool) (A : Set α), A ∈ C enc ↔ ∃ f ∈ SharpP enc, ∀ (a : α), a ∈ A ↔ Q (f a)) :

    Complete problems from conditions on counts. If the problems of a class C are, for every encoding, the sets {a | Q (f a)} for functions f in #P, then {φ | Q (SharpSAT φ)} is C-complete.

    USAT is US-complete: unique satisfiability is complete for the class of problems defined by a function in #P equal to one.

    Mod_k SAT is ModP k-complete, for every modulus k.

    The complement of Mod_k SAT is coModP k-complete, for every modulus k.

    Thresholds and exact counts #

    Counting threshold is PP-complete: whether a formula has at least target satisfying assignments, for target given in binary.

    Exact counting is C=P-complete: whether a formula has exactly target satisfying assignments, for target given in binary.

    The complement of exact counting is coC=P-complete.

    Majority satisfiability #

    Relabel the variables of φ to the odd numbers 2 v + 1.

    Clauses forcing the Q positive even dummy variables 2, 4, …, 2 Q to false when the selector variable 0 is false.

    Pad φ with Q even dummy variables 2, 4, …, 2 Q and a selector variable 0 so that the resulting formula has 1 + Q + φ.vars.toFinset.card occurring variables and SharpSAT φ + (2 ^ (Q + φ.vars.toFinset.card) - 2 ^ Q) satisfying assignments.

    Padding a formula to a majority instance is computable in polynomial time, with Q in unary.

    Variable count of padMajority: the padded formula has 1 + Q + φ.vars.toFinset.card distinct occurring variables.

    Model count of padMajority: the padded formula has SharpSAT φ + (2 ^ (Q + φ.vars.toFinset.card) - 2 ^ Q) satisfying assignments.

    Threshold equivalence of padMajority: the padded formula belongs to MAJSAT if and only if φ has strictly more than 2 ^ Q satisfying assignments.