Abstract DPLL with learning #
Nieuwenhuis, Oliveras and Tinelli [NieuwenhuisOliverasTinelli2006, §2] describe DPLL and conflict
driven clause learning as transition systems. A state (Cslib.Algorithms.Lean.CDCL.State) is
either the distinguished fail state or a trail M with a clause database F. The trail
(Cslib.Algorithms.Lean.CDCL.Trail) is the sequence of assigned literals, kept here newest first,
each marked as a decision or not (Cslib.Algorithms.Lean.CDCL.Entry). The rules are:
- the Basic DPLL rules (
Cslib.Algorithms.Lean.CDCL.BasicStep, their Definition 2.4):- UnitPropagate: if a clause of
Fhas every literal butlfalse andlis undefined, addl; - Decide: add an undefined literal over a variable occurring in
Fas a decision; - Fail: if a clause of
Fis false andMhas no decision, go tofail; - Backjump: if a clause of
Fis false,M = N ++ dᵈ :: M₀, and a clauseCentailed byFhas every literal butlfalse inM₀, withlundefined inM₀and occurring inForM, go tol :: M₀;
- UnitPropagate: if a clause of
- Learn (
Cslib.Algorithms.Lean.CDCL.Learn, their Definition 2.5): add a clause entailed byFwhose variables occur inForM; - Forget (
Cslib.Algorithms.Lean.CDCL.Forget, their Definition 2.5): remove a clause entailed by the rest ofF.
Entailment. The source (§2.1) works with partial assignments: a set of literals is a model of a
clause set if it contains a literal of every clause, and F entails C if every such model of F
contains a literal of C (Cslib.Algorithms.Lean.CDCL.PEntails). Forget uses this entailment,
which the partial-model conclusion of Theorem 2.12 needs: entailment by total assignments would let
Forget remove the tautology b ∨ ¬b from a, b ∨ ¬b, ending at the trail a, which has no
literal of b ∨ ¬b. Backjump and Learn use entailment by total assignments. The §2.1 entailment
implies it (Cslib.Algorithms.Lean.CDCL.PEntails.eval), so every step of the source is a step
here, and the results below hold for at least the source's runs.
DPLL with learning (Cslib.Algorithms.Lean.CDCL.Step) is the union of the three. The invariant
Cslib.Algorithms.Lean.CDCL.Inv is their Lemma 2.7, over a list V of variables containing those
of the input formula φ: the database has the models of φ, its partial models are partial
models of φ, and it uses variables of V, the trail assigns each variable of V at most once,
and every implied literal holds in every model of φ satisfying the older literals; in fail, φ
is unsatisfiable. Every step keeps it
(Cslib.Algorithms.Lean.CDCL.Step.inv). Their results then hold, from the initial state with the
empty trail and F = φ, taking V to be the variables of φ:
- Lemma 2.8: in a state with a false clause, Fail applies if there is no decision, and
otherwise Backjump applies (
Cslib.Algorithms.Lean.CDCL.RunInv.fail_or_backjump). - Theorem 2.10: there is no infinite run of Basic DPLL steps
(
Cslib.Algorithms.Lean.CDCL.wellFounded_basicStep). WithNvariables, a literal at levelkweighs(N + 1) ^ (N - k), and every step increases the weight of the trail, which is at mostN * (N + 1) ^ N(Cslib.Algorithms.Lean.CDCL.Trail.measure); this replaces their lexicographic order on the numbers of literals per level with a single number. - Theorem 2.11: every run of DPLL with learning without an infinite stretch of Learn and Forget
steps is finite, stated as the well-foundedness of "Learn and Forget steps, then a Basic DPLL
step" (
Cslib.Algorithms.Lean.CDCL.wellFounded_learnOrForget_basicStep). - Theorem 2.12: a reachable state that is final for Basic DPLL is
failexactly whenφis unsatisfiable, and otherwise its trail is a model ofφin the sense of §2.1, containing a literal of every clause (Cslib.Algorithms.Lean.CDCL.final_of_reachable). The invariant keeps every partial model of the database a partial model ofφ, and Forget's side condition is what preserves this.
Representations. Clause sets are lists, so Learn prepends a clause and Forget removes one occurrence. The trail is kept newest first. Locators refer to the authors' manuscript, printed pp. 5–16.
Main definitions #
Cslib.Algorithms.Lean.CDCL.BasicStep,Cslib.Algorithms.Lean.CDCL.Learn,Cslib.Algorithms.Lean.CDCL.Forget,Cslib.Algorithms.Lean.CDCL.Step: the transition systems.Cslib.Algorithms.Lean.CDCL.Inv: the invariant.
Main results #
Cslib.Algorithms.Lean.CDCL.Step.inv: steps keep the invariant (Lemma 2.7).Cslib.Algorithms.Lean.CDCL.RunInv.fail_or_backjump: Fail or Backjump applies (Lemma 2.8).Cslib.Algorithms.Lean.CDCL.wellFounded_basicStep,Cslib.Algorithms.Lean.CDCL.wellFounded_learnOrForget_basicStep: termination (Theorems 2.10, 2.11).Cslib.Algorithms.Lean.CDCL.final_of_reachable: final states decide satisfiability (Theorem 2.12).
References #
An entry of a trail: a literal and whether it is a decision.
- lit : Logic.PL.Literal ℕ
The literal.
- decision : Bool
Whether the literal is a decision.
The variable of an entry.
A trail: the assigned literals, newest first.
A partial assignment satisfies a clause if it makes one of its literals true [NieuwenhuisOliverasTinelli2006, §2.1]: the variable of the literal is assigned, with its polarity.
A partial assignment is a model of a clause set if it satisfies every clause.
Entailment [NieuwenhuisOliverasTinelli2006, §2.1]: every partial model of F satisfies
C. It implies entailment by total assignments (Cslib.Algorithms.Lean.CDCL.PEntails.eval), but
not conversely: the tautology b ∨ ¬b holds under every total assignment, while the partial
model {a} of the clause a does not satisfy it.
Entailment by partial assignments implies entailment by total ones.
The literals of a trail.
A trail falsifies a clause if it contains the negation of every literal of the clause.
The level of a trail: its number of decisions.
Every implied literal of the trail holds in every model of φ satisfying the older
literals.
- nil {φ : Logic.PL.CNF ℕ} : Entailed φ []
- decision {φ : Logic.PL.CNF ℕ} {M : Trail} (l : Logic.PL.Literal ℕ) : Entailed φ M → Entailed φ ({ lit := l, decision := true } :: M)
- implied {φ : Logic.PL.CNF ℕ} {M : Trail} (l : Logic.PL.Literal ℕ) : Entailed φ M → (∀ (σ : ℕ → Bool), Logic.PL.CNF.eval σ φ = true → Sat σ M → Logic.PL.Literal.eval σ l = true) → Entailed φ ({ lit := l, decision := false } :: M)
The total assignment of a trail: a variable is true if the trail makes it true.
The negation of the decisions of a trail.
A state: the distinguished failure state, or a trail and a clause database.
- fail : State
The failure state.
- run (trail : Trail) (db : Logic.PL.CNF ℕ) : State
A trail and a clause database.
The Basic DPLL rules [NieuwenhuisOliverasTinelli2006, Definition 2.4].
- unitPropagate {M : Trail} {F : Logic.PL.CNF ℕ} {c : Logic.PL.Clause ℕ} {l : Logic.PL.Literal ℕ} (hc : c ∈ F) (hl : l ∈ c) (hfalse : ∀ l' ∈ c, l' ≠ l → Std.Sat.Literal.negate l' ∈ M.lits) (hundef : l.1 ∉ M.vars) : BasicStep (State.run M F) (State.run ({ lit := l, decision := false } :: M) F)
UnitPropagate: a clause with every literal but
lfalse makeslimplied. - decide {M : Trail} {F : Logic.PL.CNF ℕ} {l : Logic.PL.Literal ℕ} (hundef : l.1 ∉ M.vars) (hv : l.1 ∈ F.vars) : BasicStep (State.run M F) (State.run ({ lit := l, decision := true } :: M) F)
Decide: an undefined literal over a variable occurring in the database becomes a decision.
- fail {M : Trail} {F : Logic.PL.CNF ℕ} {c : Logic.PL.Clause ℕ} (hc : c ∈ F) (hconf : M.Falsifies c) (hnodec : ∀ e ∈ M, e.decision = false) : BasicStep (State.run M F) State.fail
Fail: a false clause and no decision.
- backjump {N M₀ : Trail} {F : Logic.PL.CNF ℕ} {d : Logic.PL.Literal ℕ} {c C : Logic.PL.Clause ℕ} {l : Logic.PL.Literal ℕ} (hc : c ∈ F) (hconf : (N ++ { lit := d, decision := true } :: M₀).Falsifies c) (hC : ∀ (σ : ℕ → Bool), Logic.PL.CNF.eval σ F = true → Logic.PL.Clause.eval σ C = true) (hl : l ∈ C) (hfalse : ∀ l' ∈ C, l' ≠ l → Std.Sat.Literal.negate l' ∈ M₀.lits) (hundef : l.1 ∉ M₀.vars) (hocc : l.1 ∈ F.vars ∨ l.1 ∈ (N ++ { lit := d, decision := true } :: M₀).vars) : BasicStep (State.run (N ++ { lit := d, decision := true } :: M₀) F)
(State.run ({ lit := l, decision := false } :: M₀) F)
Backjump: going back below a decision and adding the literal that an entailed clause
Cimplies there.
Learn [NieuwenhuisOliverasTinelli2006, Definition 2.5]: adding a clause entailed by the database, whose variables occur in the database or the trail.
Forget [NieuwenhuisOliverasTinelli2006, Definition 2.5]: removing a clause entailed by the
rest of the database, in the sense of §2.1 (Cslib.Algorithms.Lean.CDCL.PEntails).
DPLL with learning [NieuwenhuisOliverasTinelli2006, Definition 2.5]: a Basic DPLL step, a Learn step or a Forget step.
The invariant of a running state [NieuwenhuisOliverasTinelli2006, Lemma 2.7].
The database has the models of
φ.Every partial model of the database is a partial model of
φ.The trail assigns each variable at most once.
The trail assigns variables of
V.The database uses variables of
V.- entailed : Trail.Entailed φ M
Every implied literal follows from
φand the older literals.
The invariant for the formula φ over the variables V: in a running state
Cslib.Algorithms.Lean.CDCL.RunInv, and in fail, φ is unsatisfiable.
A trail assigning each variable once does not contain a literal and its negation.
A model of φ that satisfies the decisions of an entailed trail satisfies the trail.
A clause that holds, with every literal but l false, forces l.
Steps keep the invariant #
Adding a literal over an unassigned variable of V keeps the trail's variables distinct and
in V.
Steps keep the invariant [NieuwenhuisOliverasTinelli2006, Lemma 2.7].
Final states #
With each variable assigned once, the partial assignment of a trail makes a literal true exactly when the literal is on the trail.
A trail that falsifies no clause of F and assigns every variable of F has a literal of
every clause of F.
The trail is a model [NieuwenhuisOliverasTinelli2006, §2.1]: in a running state with no
false clause that assigns every variable, every clause of φ has a literal on the trail.
A running state with no false clause that assigns every variable gives a total model: the assignment making the trail's literals true.
Backjump with the negation of the decisions: below the newest decision d, a false clause
lets Backjump add the negation of d.
Fail or Backjump applies [NieuwenhuisOliverasTinelli2006, Lemma 2.8]: in a running state
with a false clause, Fail applies if the trail has no decision, and otherwise Backjump applies,
going below the newest decision d and adding its negation.
Progress: a running state from which no Basic DPLL step applies has no false clause and
assigns every variable occurring in the database (the first two parts of
[NieuwenhuisOliverasTinelli2006, Lemma 2.9]): otherwise Fail or Backjump applies by
Cslib.Algorithms.Lean.CDCL.RunInv.fail_or_backjump, or Decide applies.
A state that satisfies the invariant and is final for Basic DPLL is fail exactly when φ is
unsatisfiable, and otherwise its trail is a model of φ: every clause of φ has a literal on the
trail, so the total assignment making the trail's literals true is a model too.
The states reachable from the initial state satisfy the invariant.
Final states decide satisfiability [NieuwenhuisOliverasTinelli2006, Theorem 2.12]: a state
reachable from the initial state by DPLL with learning and final for Basic DPLL is fail exactly
when φ is unsatisfiable, and otherwise its trail is a model of φ in the sense of §2.1: every
clause of φ has a literal on the trail. The total assignment making the trail's literals true is
then a model as well.
Termination #
The measure of a trail over N variables: a literal at level k weighs (N + 1) ^ (N - k).
The length of a trail is at most the number of variables it may use.
The measure of a trail satisfying the invariant is at most N * (N + 1) ^ N.
Termination of Basic DPLL [NieuwenhuisOliverasTinelli2006, Theorem 2.10]: there is no infinite run of Basic DPLL steps from the initial state.
Learn and Forget steps keep the trail, hence the rank.
Learn and Forget steps from a reachable state reach states of the same rank.
Termination of DPLL with learning [NieuwenhuisOliverasTinelli2006, Theorem 2.11]: a run from the initial state in which no stretch of Learn and Forget steps is infinite is finite. It is stated as: there is no infinite sequence of moves from the initial state, each a finite run of Learn and Forget steps followed by a Basic DPLL step.