Documentation

CslibFrontier.Logics.Propositional.CNF.ParitySearch

Searching a three-wise independent sample space for MAX-SAT #

Number the variables of a list vs by their positions j < n = |vs|, and let d = ⌈log₂ n⌉. A seed t ∈ {0,1}^(d+1) gives the variable at position j the value t ⬝ (1, bin_d(j)) over GF(2), where bin_d(j) are the d low binary digits of j (Cslib.Logic.PL.paritySample_ofFn). Over a uniformly random seed these values are three-wise independent and uniform: the family x ↦ t ⬝ (1, x) on {0,1}^d is the one-row Boolean affine hash family (Cslib.BitString.LinearHash.isKWiseIndependentHash_dotProduct_cons_true), and the variables have distinct binary numbers. This is the case k = 3 of the small sample spaces of k-wise independent bits of Alon, Babai and Itai [ABI86]; it has 2 ^ (d + 1) < 4 n points (Cslib.Logic.PL.length_parityCandidates_lt).

By Cslib.Logic.PL.exists_two_pow_mul_countUnsat_le, if every clause of φ has at least k ≤ 3 distinct literals and vs lists the variables of φ, one of the seeds falsifies at most 2 ^ -k of the clauses (Cslib.Logic.PL.exists_mem_parityCandidates_two_pow_mul_countUnsat_le). The candidate assignments, as the lists Cslib.Logic.PL.parityCandidates vs of variables set to true, depend only on vs and not on the clauses: the same < 4 n assignments serve every formula on these variables. The deterministic algorithm Cslib.Logic.PL.paritySearch tries them all on the distinct variables of φ and keeps one falsifying the fewest clauses; it satisfies at least 7 / 8 of the clauses of every formula with three distinct variables per clause (Cslib.Logic.PL.CNF.IsExactThreeDistinct.eight_mul_countUnsat_paritySearchAssignment_le). This is the guarantee of Johnson's algorithm (Cslib.Logic.PL.johnson), obtained by exhaustive search of a small sample space instead of the method of conditional expectations Alon and Spencer, Section 16.2.

The polynomial running time is proved in CslibFrontier.Logics.Propositional.CNF.ParitySearch.PolyTime.

Main definitions #

Main results #

References #

The sample space #

def Cslib.Logic.PL.paritySample {V : Type u_1} [DecidableEq V] (vs : List V) (seed : List Bool) (v : V) :

The value that the seed t ∈ {0,1}^(d+1) gives the variable at position j of vs: the parity of the bits of t selected by 1 followed by the d low binary digits of j.

The points of the sample space for the variables vs: for each seed of ⌈log₂ |vs|⌉ + 1 bits, the variables of vs that it sets to true.

def Cslib.Logic.PL.betterCandidate {V : Type u_1} [DecidableEq V] (φ : CNF V) (best T : List V) :

Of the current choice best and a candidate T, both lists of variables set to true, the one falsifying fewer clauses of φ, keeping best on ties.

def Cslib.Logic.PL.paritySearch {V : Type u_1} [DecidableEq V] (φ : CNF V) :

Exhaustive search of the three-wise independent sample space: the point of the sample space for the distinct variables of φ that falsifies the fewest clauses, as the list of variables set to true. The search starts from the all-false assignment, which is itself the point of the zero seed.

def Cslib.Logic.PL.paritySearchAssignment {V : Type u_1} [DecidableEq V] (φ : CNF V) (v : V) :

The assignment computed by Cslib.Logic.PL.paritySearch.

@[simp]

The sample space has one point per seed.

The sample space is small: fewer than 4 n points for n ≥ 1 variables.

Binary positions #

theorem Cslib.Logic.PL.paritySample_ofFn {V : Type u_1} [DecidableEq V] {d : ℕ} (vs : List V) (t : BitString (d + 1)) (v : V) :
paritySample vs (List.ofFn t) v = t ⬝ᵥ Fin.cons true fun (i : Fin d) => (List.idxOf v vs).testBit ↑i

On a seed of d + 1 bits, Cslib.Logic.PL.paritySample is the dot product of the seed with 1 followed by the d low binary digits of the position.

Correctness #

theorem Cslib.Logic.PL.exists_mem_parityCandidates_two_pow_mul_countUnsat_le {V : Type u_1} [DecidableEq V] {k : ℕ} (hk3 : k ≤ 3) {φ : CNF V} {vs : List V} (hvs : ∀ v ∈ φ.vars, v ∈ vs) (hk : ∀ c ∈ φ, k ≤ (List.toFinset c).card) :
∃ T ∈ parityCandidates vs, 2 ^ k * CNF.countUnsat (fun (v : V) => decide (v ∈ T)) φ ≤ List.length φ

A good point of the sample space: if vs contains the variables of φ and every clause has at least k ≤ 3 distinct literals, some point of the sample space for vs falsifies at most 2 ^ -k of the clauses.

theorem Cslib.Logic.PL.countUnsat_foldl_betterCandidate_le {V : Type u_1} [DecidableEq V] (φ : CNF V) (cands : List (List V)) (init : List V) :
CNF.countUnsat (fun (v : V) => decide (v ∈ List.foldl (betterCandidate φ) init cands)) φ ≤ CNF.countUnsat (fun (v : V) => decide (v ∈ init)) φ ∧ ∀ T ∈ cands, CNF.countUnsat (fun (v : V) => decide (v ∈ List.foldl (betterCandidate φ) init cands)) φ ≤ CNF.countUnsat (fun (v : V) => decide (v ∈ T)) φ

Folding Cslib.Logic.PL.betterCandidate finds a list falsifying no more clauses than the starting list and than every candidate.

theorem Cslib.Logic.PL.two_pow_mul_countUnsat_paritySearchAssignment_le {V : Type u_1} [DecidableEq V] {k : ℕ} (hk3 : k ≤ 3) {φ : CNF V} (hk : ∀ c ∈ φ, k ≤ (List.toFinset c).card) :

Correctness of the search: if every clause of φ has at least k ≤ 3 distinct literals, Cslib.Logic.PL.paritySearch falsifies at most 2 ^ -k of the clauses.

The 7 / 8 guarantee: on a formula with three distinct variables per clause, Cslib.Logic.PL.paritySearch falsifies at most 1 / 8 of the clauses.

The 1 / 2 guarantee: on a formula without empty clauses, Cslib.Logic.PL.paritySearch falsifies at most half of the clauses.

The 7 / 8 approximation ratio for MAX-E3SAT with three distinct variables per clause: Cslib.Logic.PL.paritySearch satisfies at least 7 / 8 times the largest proportion of the clauses that an assignment satisfies.