Documentation

CslibFrontier.Foundations.BooleanAnalysis.DNFWidth

Approximating small formulas by narrow ones #

A term of a formula in disjunctive normal form on k distinct variables (Term.width) fixes those k bits, so it is satisfied on at most 2 ^ (n - k) of the 2 ^ n inputs (Logic.PL.Term.card_filter_eval_le). Hence deleting from a DNF of size s the terms on more than log₂ (s / ε) variables changes the computed function on at most an ε fraction of the inputs, by the union bound: a function computed by a DNF of size s is ε-close to one computed by a DNF of width log₂ (s / ε) (BitString.exists_dnf_hammingDist_div_le), and likewise for formulas in conjunctive normal form, by De Morgan duality (BitString.exists_cnf_hammingDist_div_le) O'Donnell, Proposition 4.9. Closeness is the relative Hamming distance, as in the rest of the Boolean-analysis library.

The formulas here are lists of literals, which may repeat a literal or contain a literal and its negation; the book excludes the latter O'Donnell, Definition 4.1. The probability bound uses the number of distinct variables of a term, Term.width. The narrow formula keeps each surviving term without repeated literals (Term.length_dedup_of_consistent) and drops the contradictory ones, which are never satisfied. So, as the theorems state, every term of the narrow DNF has no repeated literal (List.Nodup) and is consistent (Term.consistent), and every clause of the narrow CNF has no repeated literal and is not a tautology (CNF.isTautClause): Definition 4.1's restriction, carried to clauses by Definition 4.4. Its width, the length of its terms, is then the book's number of literals.

Main results #

Usage #

Open Cslib.BitString and Cslib.Logic.PL. Formulas are DNF ι and CNF ι over a finite type of variables ι, read on the cube ι → Bool through DNF.eval and CNF.eval; their size is List.length and the width of a surviving term is its List.length; the narrow DNF's terms satisfy t.Nodup and Term.consistent t = true, and the narrow CNF's clauses c.Nodup and CNF.isTautClause c = false (Cslib.Logic.PL.Term.isTautClause_negate relates the two). A function f is ε-close to g when (hammingDist f g : ℝ) / 2 ^ Fintype.card ι ≤ ε, the form of the junta and affinity closeness results. Only 0 < ε is assumed; the book takes ε ∈ (0, 1]. For the per-term probability bound alone, use Cslib.Logic.PL.Term.card_filter_eval_le, an instance of Cslib.BitString.card_le_of_forall_agree for words that pairwise agree on a set of coordinates.

The checked clients in CslibFrontierTests/BooleanAnalysisDNFWidth.lean apply both forms to the formula (x₀ ∧ x₁ ∧ x₂) ∨ ¬x₀ on three variables, with a width-three term, and to its dual, with ε = 1 / 2, and check that the per-term bound is attained by x₀ ∧ ¬x₁.

References #

theorem Cslib.BitString.exists_dnf_hammingDist_div_le {ι : Type u_1} [Fintype ι] [DecidableEq ι] (φ : Logic.PL.DNF ι) {ε : ℝ} (hε : 0 < ε) :
∃ (ψ : Logic.PL.DNF ι), List.length ψ ≤ List.length φ ∧ (∀ t ∈ ψ, List.Nodup t ∧ t.consistent = true ∧ ↑(List.length t) ≤ Real.logb 2 (↑(List.length φ) / ε)) ∧ ↑(hammingDist (fun (x : ι → Bool) => Logic.PL.DNF.eval x φ) fun (x : ι → Bool) => Logic.PL.DNF.eval x ψ) / 2 ^ Fintype.card ι ≤ ε

A small DNF is close to a narrow one: a function computed by a formula in disjunctive normal form with s terms is ε-close to one computed by a formula with at most s terms, each consistent, without repeated literals and with at most log₂ (s / ε) literals O'Donnell, Proposition 4.9. The book takes ε ∈ (0, 1]; 0 < ε suffices.

theorem Cslib.BitString.exists_cnf_hammingDist_div_le {ι : Type u_1} [Fintype ι] [DecidableEq ι] (φ : Logic.PL.CNF ι) {ε : ℝ} (hε : 0 < ε) :
∃ (ψ : Logic.PL.CNF ι), List.length ψ ≤ List.length φ ∧ (∀ c ∈ ψ, List.Nodup c ∧ Logic.PL.CNF.isTautClause c = false ∧ ↑(List.length c) ≤ Real.logb 2 (↑(List.length φ) / ε)) ∧ ↑(hammingDist (fun (x : ι → Bool) => Logic.PL.CNF.eval x φ) fun (x : ι → Bool) => Logic.PL.CNF.eval x ψ) / 2 ^ Fintype.card ι ≤ ε

A small CNF is close to a narrow one: a function computed by a formula in conjunctive normal form with s clauses is ε-close to one computed by a formula with at most s clauses, none a tautology or with a repeated literal, and each with at most log₂ (s / ε) literals. The book's "(or CNF)" is read, following its proof, as giving a CNF in this case O'Donnell, Proposition 4.9. The book takes ε ∈ (0, 1]; 0 < ε suffices.