Johnson's algorithm for MAX-SAT #
Johnson's algorithm [Joh74] sets the variables of a CNF formula one at a time; this file
formalizes it in the form obtained by derandomizing a uniformly random assignment with the method
of conditional expectations Williamson and Shmoys, Sections 5.1–5.2. A
clause with j distinct literals, none of them yet set, is falsified by a uniformly
random assignment with probability 2 ^ -j, so the weight Σ_c 2 ^ (L - |c|)
(Cslib.Logic.PL.CNF.johnsonWeight) is 2 ^ L times the expected number of falsified clauses
when no clause contains a complementary pair. Setting a variable v to b drops the clauses
satisfied by the literal (v, b) and deletes (v, !b) from the others; this is the restriction
Cslib.Logic.PL.CNF.restrict used for resolution. The weights after setting v to true and
to false sum to at most twice the current weight
(Cslib.Logic.PL.CNF.johnsonWeight_restrict_add_le), with equality when no clause contains both
(v, true) and (v, false). Setting each variable to the value of smaller weight is therefore
the method of conditional expectations with the weight as a pessimistic estimator
(Cslib.PessimisticEstimator.greedy_spec_of_add_le).
The algorithm (Cslib.Logic.PL.johnson) first removes repeated literals from each clause, then
sets the variables in order of first occurrence. When no variable is left, every remaining clause
is empty and contributes 2 ^ L to the weight, so 2 ^ L times the number of clauses falsified by
the output is at most the initial weight
(Cslib.Logic.PL.two_pow_mul_countUnsat_johnsonAssignment_le). If every clause has at least k
distinct literals, the output falsifies at most 2 ^ -k of the clauses
(Cslib.Logic.PL.two_pow_mul_countUnsat_johnsonAssignment_le_length). This gives the 7 / 8
guarantee for clauses with three distinct variables
(Cslib.Logic.PL.CNF.IsExactThreeDistinct.eight_mul_countUnsat_johnsonAssignment_le), a
constructive form of Cslib.Logic.PL.CNF.IsExactThreeDistinct.exists_countUnsat_le_div_eight,
and the 1 / 2 guarantee for formulas without empty clauses
(Cslib.Logic.PL.two_mul_countUnsat_johnsonAssignment_le).
The polynomial running time is proved in CslibFrontier.Logics.Propositional.CNF.Johnson.PolyTime.
Main definitions #
Cslib.Logic.PL.Clause.eraseDupLits,Cslib.Logic.PL.CNF.eraseDupLits: remove repeated literals.Cslib.Logic.PL.CNF.johnsonWeight: Johnson's weight.Cslib.Logic.PL.johnson,Cslib.Logic.PL.johnsonAssignment: Johnson's algorithm, as the list of variables it sets totrueand as an assignment.
Main results #
Cslib.Logic.PL.CNF.countUnsat_restrict: setting a variable as the assignment does keeps the number of falsified clauses.Cslib.Logic.PL.CNF.johnsonWeight_restrict_add_le: the averaging step.Cslib.Logic.PL.two_pow_mul_countUnsat_johnsonAssignment_le: correctness against the initial weight.Cslib.Logic.PL.countUnsat_johnsonAssignment_le_sum: the output falsifies at mostΣ_c 2 ^ -|c|clauses, counting distinct literals.Cslib.Logic.PL.two_pow_mul_countUnsat_johnsonAssignment_le_length: the1 - 2 ^ -kguarantee.Cslib.Logic.PL.CNF.IsExactThreeDistinct.eight_mul_countUnsat_johnsonAssignment_le: the7 / 8guarantee for MAX-E3SAT.Cslib.Logic.PL.two_mul_countUnsat_johnsonAssignment_le: the1 / 2guarantee for MAX-SAT.Cslib.Logic.PL.one_sub_inv_two_pow_mul_le_johnsonAssignment,Cslib.Logic.PL.CNF.IsExactThreeDistinct.seven_div_eight_mul_le_johnsonAssignment,Cslib.Logic.PL.one_div_two_mul_le_johnsonAssignment: the same guarantees as approximation ratios against1 - unsatVal.
References #
Repeated literals #
Remove repeated literals from a clause, keeping first occurrences.
Remove repeated literals from every clause of a formula.
Removing repeated literals leaves no repeated literals.
Removing repeated literals keeps every literal.
Removing repeated literals does not lengthen a clause.
After removing repeated literals, the length of a clause is its number of distinct literals.
Removing repeated literals does not change the value of a clause.
Removing repeated literals does not change the number of falsified clauses.
Setting a variable #
Setting a variable with CNF.restrict, one clause at a time.
Under an assignment that sets v to b, setting v to b in the formula does not change
the number of falsified clauses.
Johnson's weight #
Johnson's weight Σ_c 2 ^ (L - |c|). For clauses of length at most L without repeated
literals and without complementary pairs, this is 2 ^ L times the expected number of clauses
falsified by a uniformly random assignment.
The empty formula has weight 0.
The weight of a formula, one clause at a time.
Averaging: on clauses without repeated literals and of length at most L, setting a
variable to true and to false gives weights summing to at most twice the weight.
Johnson's algorithm #
The final state of Johnson's algorithm: the variables of φ are fixed in order of first
occurrence, each to the value giving the smaller weight.
Johnson's algorithm: the variables set to true.
The assignment computed by Johnson's algorithm.
Correctness of Johnson's algorithm: with L the number of variable occurrences, 2 ^ L
times the number of clauses that the output falsifies is at most the initial weight.
Corollaries #
After removing repeated literals, the weight counts the distinct literals of each clause.
Johnson's bound: the output of Johnson's algorithm falsifies at most Σ_c 2 ^ -|c|
clauses, where |c| is the number of distinct literals of c. This is the expected number of
clauses falsified by a uniformly random assignment when no clause contains a complementary pair,
and an upper bound for it otherwise.
Johnson's bound: if every clause has at least k distinct literals, Johnson's algorithm
falsifies at most 2 ^ -k of the clauses.
The 7 / 8 guarantee: on an exact 3-CNF formula with three distinct variables per
clause, Johnson's algorithm falsifies at most 1 / 8 of the clauses.
The 1 / 2 guarantee: on a formula without empty clauses, Johnson's algorithm falsifies at
most half of the clauses.
Approximation ratios #
Approximation ratio: if every clause has at least k distinct literals, the proportion of
the clauses that Johnson's algorithm satisfies is at least 1 - 2 ^ -k times the largest
proportion that an assignment satisfies, 1 - φ.unsatVal.
The 7 / 8 approximation ratio for MAX-E3SAT with three distinct variables per clause.
The 1 / 2 approximation ratio for MAX-SAT on formulas without empty clauses.