Documentation

CslibFrontier.Logics.Propositional.CNF.Branching

Explicit SAT branching rules: covering vs. partitioning and sub-2 ^ n search trees #

Branching SAT algorithms split a CNF formula φ into child formulas. Depending on the rule, child branches either cover satisfying assignments (CNF.CoversModels: φ.eval σ = true iff some branch evaluates to true, sufficient for decision and giving a subadditive model-count bound) or partition them (CNF.PartitionsModels: every model of φ satisfies a unique branch and every non-model satisfies none, conserving modelCountOn exactly across branches).

We package formula-level branching rules with their declared disposition (CNF.BranchMode, CNF.BranchRule) and prove the exact disposition of three standard SAT rules:

Eliminating assigned variables along disjoint prefix branches gives a terminating BranchingVector.BranchingTree (CNF.clausePrefixTree k on CNF.ClauseBranchState V) with step vector prefixSteps b (b ≤ k), conserving modelCountOn, deciding Satisfiable at its leaves, and bounding the search tree by (2 - (1 / 2) ^ k) ^ n leaves (< 2 ^ n for k ≥ 1, n ≥ 1) and goldenBranchFactor ^ n leaves for 2-CNF.

Main definitions #

Main results #

References #

Covering vs. partitioning branch semantics #

def Cslib.Logic.PL.CNF.CoversModels {V : Type u_1} (φ : CNF V) (branches : List (CNF V)) :

branches covers the satisfying assignments of φ: an assignment satisfies φ if and only if it satisfies at least one child formula in branches.

def Cslib.Logic.PL.CNF.PartitionsModels {V : Type u_1} (φ : CNF V) (branches : List (CNF V)) :

branches partitions the satisfying assignments of φ: every satisfying assignment of φ satisfies a unique child formula in branches, and every non-satisfying assignment satisfies no child formula.

Whether a branching rule merely covers satisfying assignments or partitions them into pairwise disjoint branches.

  • covering : BranchMode

    Every model of the parent satisfies at least one child, and every child model satisfies the parent (CoversModels).

  • partitioning : BranchMode

    Every model of the parent satisfies a unique child, and non-models satisfy none (PartitionsModels).

Instances For
    structure Cslib.Logic.PL.CNF.BranchRule (V : Type u_2) :
    Type u_2

    Formula-level SAT branching rule bundled with its declared BranchMode and soundness proof.

    theorem Cslib.Logic.PL.CNF.PartitionsModels.coversModels {V : Type u_1} {φ : CNF V} {branches : List (CNF V)} (h : φ.PartitionsModels branches) :
    φ.CoversModels branches

    Every partitioning branching rule is in particular a covering branching rule.

    theorem Cslib.Logic.PL.CNF.CoversModels.satisfiable_iff {V : Type u_1} {φ : CNF V} {branches : List (CNF V)} (h : φ.CoversModels branches) :
    φ.Satisfiable ↔ ∃ ψ ∈ branches, ψ.Satisfiable

    A covering branching rule preserves satisfiability (φ.Satisfiable iff some branch is satisfiable).

    theorem Cslib.Logic.PL.CNF.PartitionsModels.satisfiable_iff {V : Type u_1} {φ : CNF V} {branches : List (CNF V)} (h : φ.PartitionsModels branches) :
    φ.Satisfiable ↔ ∃ ψ ∈ branches, ψ.Satisfiable

    A partitioning branching rule preserves satisfiability.

    theorem Cslib.Logic.PL.CNF.CoversModels.modelCountOn_le_sum {V : Type u_1} [DecidableEq V] {φ : CNF V} {branches : List (CNF V)} (h : φ.CoversModels branches) (declared : Finset V) :
    φ.modelCountOn declared ≤ (List.map (fun (ψ : CNF V) => ψ.modelCountOn declared) branches).sum

    Subadditivity of covering rules. If CoversModels φ branches, then φ.modelCountOn declared is at most the sum of ψ.modelCountOn declared over ψ ∈ branches.

    theorem Cslib.Logic.PL.CNF.PartitionsModels.modelCountOn_eq_sum {V : Type u_1} [DecidableEq V] {φ : CNF V} {branches : List (CNF V)} (h : φ.PartitionsModels branches) (declared : Finset V) :
    φ.modelCountOn declared = (List.map (fun (ψ : CNF V) => ψ.modelCountOn declared) branches).sum

    Additivity of partitioning rules. If PartitionsModels φ branches, then φ.modelCountOn declared equals the sum of ψ.modelCountOn declared over ψ ∈ branches.

    Explicit formula-level SAT branching rules #

    def Cslib.Logic.PL.CNF.varSplitBranches {V : Type u_1} (v : V) (φ : CNF V) :
    List (CNF V)

    Binary variable split on v: add the unit clause [(v, true)] or [(v, false)].

    Binary variable splitting partitions satisfying assignments on every formula.

    Packaged BranchRule for binary variable splitting (mode = .partitioning).

    def Cslib.Logic.PL.CNF.clauseCoverBranches {V : Type u_1} (c : Clause V) (φ : CNF V) :
    List (CNF V)

    Naive clause literal cover on c: one branch [l] :: φ per literal occurrence l ∈ c.

    Naive clause literal branching covers satisfying assignments whenever c ∈ φ.

    Packaged BranchRule for naive clause literal branching (mode = .covering).

    theorem Cslib.Logic.PL.CNF.not_partitionsModels_clauseCoverBranches_two {V : Type u_1} {l₁ l₂ : Literal V} (hne : l₁.1 ≠ l₂.1) :

    Naive clause literal branching does not partition models. On [ [l₁, l₂] ] with distinct variables l₁.1 ≠ l₂.1, setting both literals true satisfies both branches simultaneously.

    Disjoint literal prefixes [l₁], [¬l₁, l₂], …, [¬l₁, …, ¬l_{b-1}, l_b] of a clause c.

    The prefix lengths of clausePrefixLitsList c form the branching vector prefixSteps c.length ([1, 2, …, c.length]).

    theorem Cslib.Logic.PL.CNF.countP_all_clausePrefixLitsList {V : Type u_1} (c : Clause V) (σ : V → Bool) :
    List.countP (fun (lits : List (Literal V)) => lits.all (Literal.eval σ)) (clausePrefixLitsList c) = if Clause.eval σ c = true then 1 else 0

    For any assignment σ, the number of prefixes in clausePrefixLitsList c satisfied by σ is 1 when c.eval σ = true and 0 when c.eval σ = false.

    def Cslib.Logic.PL.CNF.clausePrefixBranches {V : Type u_1} (c : Clause V) (φ : CNF V) :
    List (CNF V)

    Disjoint prefix clause branching ([l₁], [¬l₁, l₂], …) as formula-level unit-clause extensions of φ.

    theorem Cslib.Logic.PL.CNF.partitionsModels_clausePrefixBranches_of_imp {V : Type u_1} {c : Clause V} {φ : CNF V} (himp : ∀ (σ : V → Bool), eval σ φ = true → Clause.eval σ c = true) :

    Whenever c holds on every model of φ (∀ σ, φ.eval σ = true → c.eval σ = true), clausePrefixBranches c φ partitions the models of φ.

    Disjoint prefix clause branching partitions models whenever c ∈ φ.

    Packaged BranchRule for disjoint prefix clause branching (mode = .partitioning).

    Variable-eliminating disjoint prefix k-clause search tree #

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

    Substitute a fixed literal l = (v, b) into φ: drop clauses containing l and delete ¬l from all remaining clauses.

    theorem Cslib.Logic.PL.CNF.eval_substLit {V : Type u_1} [DecidableEq V] (l : Literal V) (φ : CNF V) (σ : V → Bool) :
    eval σ (substLit l φ) = eval (Function.update σ l.1 l.2) φ

    Evaluating substLit l φ at σ agrees with evaluating φ at Function.update σ l.1 l.2.

    theorem Cslib.Logic.PL.CNF.notMem_vars_substLit {V : Type u_1} [DecidableEq V] (l : Literal V) (φ : CNF V) :
    l.1 ∉ (substLit l φ).vars

    substLit l φ eliminates every occurrence of l.1.

    theorem Cslib.Logic.PL.CNF.vars_substLit_subset {V : Type u_1} [DecidableEq V] (l : Literal V) (φ : CNF V) :

    Every variable occurring in substLit l φ belonged to φ.vars.toFinset.erase l.1.

    theorem Cslib.Logic.PL.CNF.length_le_of_mem_substLit {V : Type u_1} [DecidableEq V] {l : Literal V} {φ : CNF V} {k : ℕ} (hk : ∀ c ∈ φ, List.length c ≤ k) {c' : Clause V} (hc' : c' ∈ substLit l φ) :

    substLit never increases maximum clause length.

    theorem Cslib.Logic.PL.CNF.modelCountOn_cons_unit_eq_substLit {V : Type u_1} [DecidableEq V] {l : Literal V} {φ : CNF V} {U : Finset V} (hl : l.1 ∈ U) :
    modelCountOn ([l] :: φ) U = (substLit l φ).modelCountOn (U.erase l.1)

    Adding [l] to φ on U (l.1 ∈ U) has the same model count as substLit l φ on U.erase l.1.

    def Cslib.Logic.PL.CNF.substLits {V : Type u_1} [DecidableEq V] (lits : List (Literal V)) (φ : CNF V) :
    CNF V

    Sequentially substitute a list of literals into φ.

    def Cslib.Logic.PL.CNF.eraseLits {V : Type u_1} [DecidableEq V] (lits : List (Literal V)) (U : Finset V) :

    Sequentially erase the variables of lits from U.

    theorem Cslib.Logic.PL.CNF.card_eraseLits_add {V : Type u_1} [DecidableEq V] {lits : List (Literal V)} {U : Finset V} (hnodup : (List.map Prod.fst lits).Nodup) (hsub : ∀ l ∈ lits, l.1 ∈ U) :
    (eraseLits lits U).card + lits.length = U.card

    Erasing lits with distinct variables contained in U decreases U.card by lits.length.

    theorem Cslib.Logic.PL.CNF.vars_substLits_subset {V : Type u_1} [DecidableEq V] {lits : List (Literal V)} {φ : CNF V} {U : Finset V} (hvars : φ.vars.toFinset ⊆ U) :
    (substLits lits φ).vars.toFinset ⊆ eraseLits lits U

    substLits preserves vars.toFinset ⊆ eraseLits lits U when φ.vars.toFinset ⊆ U.

    theorem Cslib.Logic.PL.CNF.length_le_of_mem_substLits {V : Type u_1} [DecidableEq V] {lits : List (Literal V)} {φ : CNF V} {k : ℕ} (hk : ∀ c ∈ φ, List.length c ≤ k) (c' : Clause V) :
    c' ∈ substLits lits φ → List.length c' ≤ k

    substLits preserves clause-width bounds.

    theorem Cslib.Logic.PL.CNF.modelCountOn_append_units_eq_substLits {V : Type u_1} [DecidableEq V] {lits : List (Literal V)} {φ : CNF V} {U : Finset V} (hnodup : (List.map Prod.fst lits).Nodup) (hsub : ∀ l ∈ lits, l.1 ∈ U) :
    modelCountOn (List.map (fun (l : Literal V) => [l]) lits ++ φ) U = (substLits lits φ).modelCountOn (eraseLits lits U)

    Conjoining unit clauses [l] for l ∈ lits with distinct variables in U has the same model count on U as substLits lits φ on eraseLits lits U.

    Search-tree state for variable-eliminating CNF branching: remaining unassigned variables and residual formula.

    • unassigned : Finset V

      Variables not yet fixed along the current branch.

    • formula : CNF V

      Residual CNF formula over unassigned.

    def Cslib.Logic.PL.CNF.isPivotClause {V : Type u_1} [DecidableEq V] (k : ℕ) (U : Finset V) (c : Clause V) :

    Predicate selecting a non-tautological clause supported in U with deduplicated width in [1, k].

    First pivot clause of s.formula, if [] ∉ s.formula.

    Disjoint prefix k-clause BranchingTree on ClauseBranchState V, measured by s.unassigned.card with branching vector prefixSteps k = [1, 2, …, k].

    theorem Cslib.Logic.PL.CNF.modelCountOn_eq_sum_clausePrefixTree_leaves {V : Type u_1} [DecidableEq V] {k : ℕ} {φ : CNF V} {declared : Finset V} (hwid : ∀ c ∈ φ, List.length c ≤ k) (hvars : φ.vars.toFinset ⊆ declared) :
    φ.modelCountOn declared = (List.map (fun (l : ClauseBranchState V) => if [] ∈ l.formula then 0 else 2 ^ l.unassigned.card) ((clausePrefixTree k).leaves { unassigned := declared, formula := φ })).sum

    Exact model-count conservation across clausePrefixTree k. On any width-≤ k formula φ whose variables lie in declared, φ.modelCountOn declared equals the sum of leaf counts if [] ∈ l.formula then 0 else 2 ^ l.unassigned.card over the leaves of clausePrefixTree k.

    theorem Cslib.Logic.PL.CNF.satisfiable_iff_exists_clausePrefixTree_leaf {V : Type u_1} [DecidableEq V] {k : ℕ} {φ : CNF V} {declared : Finset V} (hwid : ∀ c ∈ φ, List.length c ≤ k) (hvars : φ.vars.toFinset ⊆ declared) :
    φ.Satisfiable ↔ ∃ l ∈ (clausePrefixTree k).leaves { unassigned := declared, formula := φ }, [] ∉ l.formula

    Satisfiability equivalence across clausePrefixTree k. A width-≤ k formula φ with variables in declared is satisfiable if and only if some leaf of clausePrefixTree k contains no empty clause.

    Sub-2 ^ n k-SAT branching-tree leaf bound. For k ≥ 1, clausePrefixTree k expands any state on n = declared.card unassigned variables into at most (2 - (1 / 2) ^ k) ^ n leaves.

    Node-count bound for clausePrefixTree k. For k ≥ 1, clausePrefixTree k visits at most (n + 1) * (2 - (1 / 2) ^ k) ^ n total nodes on n = s.unassigned.card variables.

    Golden-ratio 2-CNF branching-tree leaf bound. For k = 2, clausePrefixTree 2 expands into at most ((1 + √5) / 2) ^ n leaves (goldenBranchFactor ^ s.unassigned.card).