Documentation

CslibFrontier.Algorithms.WordRAM.Schoening.TrialCount

The trial count of Schöning's algorithm #

Schöning's algorithm with confidence c runs schoeningTrials k n c = ⌈(3 n + 1) (2 (k - 1) / k) ^ n (k / (k - 1)) ^ (k - 3)⌉ c trials on n variables and clauses of at most k literals Schöning. For k = 3 this is ⌈(3 n + 1) (4 / 3) ^ n⌉ c, a number of about 0.415 n bits.

The amplified algorithm computes this number on the word RAM with the multiword counter of Cslib.Algorithms.WordRAM.Schoening.mulAdd and Cslib.Algorithms.WordRAM.Schoening.divFloor: it forms the numerator (3 n + 1) (2 (k - 1)) ^ n k ^ (k - 3) by multiplications, divides it by k n times and by k - 1 k - 3 times, rounding up each time, and multiplies by c. Cslib.Algorithms.WordRAM.Schoening.counterDigits is the resulting digit list, and Cslib.Algorithms.WordRAM.Schoening.ofDigits_counterDigits proves that its value is schoeningTrials k n c: rounding up in stages is rounding up once, and the real expression is this quotient of natural numbers.

Main definitions #

Main results #

References #

The number of trials for confidence c: ⌈(3 n + 1) (2 (k - 1) / k) ^ n (k / (k - 1)) ^ (k - 3)⌉ c, the inverse of Schöning's bound for one trial, rounded up, times c. For k = 3 it is ⌈(3 n + 1) (4 / 3) ^ n⌉ c.

theorem Cslib.Algorithms.WordRAM.Schoening.natCeil_natCast_div {m d : ℕ} (hd : 0 < d) :
⌈↑m / ↑d⌉₊ = (m + d - 1) / d

Rounding up a quotient of natural numbers.

theorem Cslib.Algorithms.WordRAM.Schoening.add_pred_div_add_pred_div {v a b : ℕ} (ha : 0 < a) (hb : 0 < b) :
((v + a - 1) / a + b - 1) / b = (v + a * b - 1) / (a * b)

Rounding up in two stages is rounding up once.

The digits of the trial count #

Multiplication by a on digit lists.

Division by d, rounding up, on digit lists: add d - 1, then divide.

The digits of (3 n + 1) (2 (k - 1)) ^ n k ^ (k - 3), the numerator of the trial count.

The digits of the trial count, as the amplified algorithm computes them: the numerator, divided by k n times and by k - 1 k - 3 times, rounding up, then multiplied by c.

A bound on the number of digits of the trial count.

theorem Cslib.Algorithms.WordRAM.Schoening.ofDigits_ceilStep_iterate {d : ℕ} (hd : 0 < d) (m : ℕ) (ds : List ℕ) :
Nat.ofDigits 2 ((ceilStep d)^[m] ds) = (Nat.ofDigits 2 ds + d ^ m - 1) / d ^ m
theorem Cslib.Algorithms.WordRAM.Schoening.schoeningTrials_eq {k : ℕ} (hk : 3 ≤ k) (n c : ℕ) :
schoeningTrials k n c = ((3 * n + 1) * (2 * (k - 1)) ^ n * k ^ (k - 3) + k ^ n * (k - 1) ^ (k - 3) - 1) / (k ^ n * (k - 1) ^ (k - 3)) * c

The trial count as a quotient of natural numbers, rounded up.

The value of the counter digits is the trial count.

The number of digits #

theorem Cslib.Algorithms.WordRAM.Schoening.ceilStep_digit_le {d : ℕ} (hd : 0 < d) (ds : List ℕ) (e : ℕ) :
e ∈ ceilStep d ds → e ≤ 1
theorem Cslib.Algorithms.WordRAM.Schoening.length_mulStep_le {a B : ℕ} {ds : List ℕ} (hds : ∀ d ∈ ds, d ≤ 1) (ha : a ≤ B) :
theorem Cslib.Algorithms.WordRAM.Schoening.length_ceilStep_le {d B : ℕ} {ds : List ℕ} (hds : ∀ e ∈ ds, e ≤ 1) (hd : 0 < d) (hdB : d ≤ B) :
theorem Cslib.Algorithms.WordRAM.Schoening.length_iterate_le {F : List ℕ → List ℕ} {D : ℕ} (hbin : ∀ (ds : List ℕ), (∀ d ∈ ds, d ≤ 1) → ∀ d ∈ F ds, d ≤ 1) (hlen : ∀ (ds : List ℕ), (∀ d ∈ ds, d ≤ 1) → (F ds).length ≤ ds.length + D) (m : ℕ) {ds : List ℕ} (hds : ∀ d ∈ ds, d ≤ 1) :
(F^[m] ds).length ≤ ds.length + m * D ∧ ∀ d ∈ F^[m] ds, d ≤ 1

Iterating a step that keeps digits binary and adds at most D digits.

theorem Cslib.Algorithms.WordRAM.Schoening.length_iterate_mono {F : List ℕ → List ℕ} (hF : ∀ (ds : List ℕ), ds.length ≤ (F ds).length) {i j : ℕ} (hij : i ≤ j) (ds : List ℕ) :
(F^[i] ds).length ≤ (F^[j] ds).length

Iterating a step that does not shorten the list.

theorem Cslib.Algorithms.WordRAM.Schoening.numeratorDigits_bound {k : ℕ} (hk : 3 ≤ k) (n : ℕ) :
(numeratorDigits k n).length ≤ (1 + n + (k - 3)) * (Nat.digits 2 (3 * n + 2 * k)).length ∧ ∀ d ∈ numeratorDigits k n, d ≤ 1

The digits of the numerator are binary, and there are at most (1 + n + (k - 3)) D of them, with D the number of digits of 3 n + 2 k.

The number of digits of the trial count is at most counterLen k n c.

The digits of the trial count are binary.

theorem Cslib.Algorithms.WordRAM.Schoening.length_stages_le (k n c : ℕ) :
(∀ i ≤ n, ((mulStep (2 * (k - 1)))^[i] (mulAddDigits 0 (3 * n + 1) [])).length ≤ (counterDigits k n c).length) ∧ (∀ i ≤ k - 3, ((mulStep k)^[i] ((mulStep (2 * (k - 1)))^[n] (mulAddDigits 0 (3 * n + 1) []))).length ≤ (counterDigits k n c).length) ∧ (∀ i ≤ n, ((ceilStep k)^[i] (numeratorDigits k n)).length ≤ (counterDigits k n c).length) ∧ ∀ i ≤ k - 3, ((ceilStep (k - 1))^[i] ((ceilStep k)^[n] (numeratorDigits k n))).length ≤ (counterDigits k n c).length

Every intermediate digit list of the computation of the trial count is at most as long as the final one: the multiplications by 2 (k - 1), by k, and the divisions by k and by k - 1.

Size bounds #

theorem Cslib.Algorithms.WordRAM.Schoening.div_sub_one_pow_le_three {k : ℕ} (hk : 3 ≤ k) :
(↑k / (↑k - 1)) ^ (k - 3) ≤ 3

(k / (k - 1)) ^ (k - 3) ≤ 3 for k ≥ 3: the constant factor of the trial count.

theorem Cslib.Algorithms.WordRAM.Schoening.schoeningTrials_le {k : ℕ} (hk : 3 ≤ k) (n c : ℕ) :
↑(schoeningTrials k n c) ≤ (9 * ↑n + 4) * (2 * (↑k - 1) / ↑k) ^ n * ↑c

The size of the trial count: at most (9 n + 4) (2 (k - 1) / k) ^ n c.

The number of counter digits is at most 6 (n + k) ^ 2 + c.