The Karp–Luby–Madras estimator for #DNF #
Let φ = t₀ ∨ … ∨ t_{m-1} be a formula in disjunctive normal form with n variables, and let
S_i be the set of assignments satisfying term t_i, so that #φ = |S_0 ∪ … ∪ S_{m-1}|. A
consistent term of width w (the number of distinct variables it mentions) has
|S_i| = 2 ^ (n - w), and an inconsistent term has S_i = ∅. Karp, Luby and Madras
Karp, Luby and Madras, Mitzenmacher and Upfal, Section
11.2 sample a pair (i, a) with a ∈ S_i uniformly, by choosing i with
probability |S_i| / Σ |S_j| and then a ∈ S_i uniformly, and accept when t_i is the first term
that a satisfies. Each model is accepted for exactly one i, so the acceptance probability is
#φ / Σ |S_j| ≥ 1 / m, and O(m ε⁻² log (1 / δ)) trials estimate #φ within relative error ε
with probability at least 1 - δ.
The weights |S_i| / Σ |S_j| need not be dyadic (for |S_0| = 1 and |S_1| = 2 the first is
1 / 3), so a fair-coin program cannot sample them exactly with a bounded number of coins. The
trial here (Cslib.Complexity.KarpLubyMadras.trial) has the same conditional law. Let L be
the minimum width of a consistent term (Cslib.Complexity.KarpLubyMadras.minWidth). Choose
i uniformly below D = dyadicSize m, a power of two above m. Reject if i ≥ m. Otherwise flip
padding φ i = w_i - L fair coins and reject unless all are false. Then draw a uniform
assignment, force the literals of t_i (Cslib.Logic.PL.Term.force), and accept when t_i is
the first term satisfied. The pair (i, a) is then produced with probability
2 ^ (L - w_i) / D · 1 / 2 ^ (n - w_i) = 1 / (D · 2 ^ (n - L)), the same for every pair. Forcing an
inconsistent term never satisfies it, so contradictory terms are rejected with no special case.
The exact law (Cslib.Complexity.KarpLubyMadras.eval_trial_true_toReal) is
Pr[trial accepts] = #φ / (D · 2 ^ (n - L)).
A satisfiable formula has a consistent term of width L (or L = n), so #φ ≥ 2 ^ (n - L)
(Cslib.Complexity.KarpLubyMadras.two_pow_sub_minWidth_le_modelCount), and the acceptance
probability is at least 1 / D ≥ 1 / (2 m + 2).
The estimator (Cslib.Complexity.KarpLubyMadras.estimate) with relative error 1 / p and
failure probability 2 ^ (-t) runs T = D · K trials, K = 3 (t + 1) p ^ 2, counts the
acceptances S, and returns the rational number S · 2 ^ (n - L) / K, whose mean is #φ. The
mean of S is μ = K · #φ / 2 ^ (n - L) ≥ K. The multiplicative Chernoff bound with deviation
1 / p gives failure probability at most 2 exp (-μ / (3 p ^ 2)) ≤ 2 exp (-(t + 1)) ≤ 2 ^ (-t)
(Cslib.Complexity.KarpLubyMadras.approxWithin_estimate). A formula without models is counted
exactly: every trial rejects and the estimate is 0 with probability one
(Cslib.Complexity.KarpLubyMadras.estimate_fst_eq_zero).
Main definitions #
Cslib.Complexity.KarpLubyMadras.minWidth: the minimum width of a consistent term, capped at the number of variables.Cslib.Complexity.KarpLubyMadras.trial: one Karp–Luby–Madras trial.Cslib.Complexity.KarpLubyMadras.estimate: the estimator.
Main results #
Cslib.Complexity.KarpLubyMadras.two_pow_sub_minWidth_le_modelCount: the smallest subcube of a satisfiable formula is not too small.Cslib.Complexity.KarpLubyMadras.sum_firstCount: the first satisfied terms partition the models.Cslib.Complexity.KarpLubyMadras.eval_trial_true_toReal: the exact law of one trial.Cslib.Complexity.KarpLubyMadras.approxWithin_estimate: the estimate is within relative error1 / pwith probability at least1 - 2 ^ (-t).Cslib.Complexity.KarpLubyMadras.estimate_fst_eq_zero: a formula without models is counted exactly with probability one.
References #
The minimum width of a consistent term #
The minimum width of a consistent term of φ, capped at the number of variables: the
number of k < CNF.numVars φ below the width of every consistent term.
The minimum width is at most the number of variables.
The minimum width is at most the width of every consistent term.
Below the number of variables, the minimum width is attained by a consistent term.
The smallest subcube is not too small: a satisfiable formula has at least
2 ^ (CNF.numVars φ - minWidth φ) satisfying assignments.
One trial #
The number of extra fair coins that term i spends so that it is chosen with probability
proportional to 2 ^ (CNF.numVars φ - width).
The assignment read from the word w on the distinct variables of φ, with the literals
of term i forced.
Term i is the first term of φ satisfied by the forced assignment read from w.
A trial for term i accepts the word w when its first padding φ i bits are false and
term i is the first term satisfied by the forced assignment read from the remaining bits.
One Karp–Luby–Madras trial. Choose an index below the dyadic size of the number of
terms; if it names a term, flip its padding coins and draw an assignment of the variables, forced
on the term, and accept when the padding coins are all false and the term is the first one
satisfied.
The exact law of one trial #
The number of assignments of the variables of φ, as words, whose first satisfied term is
term i.
The first satisfied terms partition the models.
Forcing term i multiplies the count of words whose first satisfied term is i by
2 ^ width.
The exact law of one trial: it accepts with probability
#φ / (dyadicSize m * 2 ^ (n - L)), where m is the number of terms, n the number of
variables and L the minimum width of a consistent term.
The estimator #
The number of trials: dyadicSize m * 3 (t + 1) p ^ 2.
The Karp–Luby–Madras estimator with relative error 1 / p and failure probability
2 ^ (-t): count the accepting trials S among trialBudget φ p t, and return the rational
estimate S * 2 ^ (n - L) / (3 (t + 1) p ^ 2).
A trial on a formula without models never accepts.
Zero counts are exact: on a formula without models the estimate is 0 with probability
one, for every p and t.
Accuracy of the Karp–Luby–Madras estimator: for p > 0, its estimate is within relative
error 1 / p of the number of models with probability at least 1 - (1 / 2) ^ t. A formula
without models is counted exactly.