Lecture 5 · CDCL: Conflict-Driven Clause Learning

Introduction to Automated Reasoning · Lecture 05。个人学习讲义与配套实验,按主题整理并持续修订。

课程源码 ZIP ↓

个人整理的学习笔记,非官方讲义;课程来源与整理说明见课程介绍。配套示例未逐一运行验证。

本篇目录

Maps to: Stanford CS 257 Introduction to Automated Reasoning (Winter 2026), Lecture 5 · Tue 01/20/2026 · Propositional logic: CDCL (Caroline Trippel). Homework 2 released. Reading: Kroening & Strichman, Decision Procedures (DP), Chapter 2 (conflict-driven clause learning, the implication graph, decision heuristics). Basis: The Stanford slides are on Canvas and not public. This lecture follows the second half of the public deck DPLL and CDCL of the Iowa course CS:4980 (Cesare Tinelli, Spring 2024). The deck says it is adapted from slides by Clark Barrett, Caroline Trippel and Andrew (Haoze) Wu at Stanford and by Emina Torlak at the University of Washington. “The slides” below means that deck. Reused from it:

  • the three shortcomings of DPLL;
  • the CDCL states ⟨M,Δ,C⟩\langle M, \Delta, C\rangle and the rules CONFLICT, EXPLAIN, BACKJUMP, FAIL, LEARN, FORGET, RESTART;
  • the derivation example on {{1},{1ˉ,2},{3ˉ,4},{5ˉ,6ˉ},{1ˉ,5ˉ,7},{2ˉ,5ˉ,6,7ˉ}}\{\{1\}, \{\bar 1, 2\}, \{\bar 3, 4\}, \{\bar 5, \bar 6\}, \{\bar 1, \bar 5, 7\}, \{\bar 2, \bar 5, 6, \bar 7\}\};
  • implication graphs, separating cuts, unique implication points (UIPs) and first-UIP learning;
  • the correctness theorems of Basic CDCL and the basic strategy.

These notes add:

  • a machine check of the correctness claims, which turns up a precondition that Lemma 2 needs;
  • the concrete algorithms: first-UIP analysis on a trail, clause minimization, VSIDS, Luby restarts, phase saving, LBD-based clause deletion;
  • DRUP/DRAT proofs and an independent checker;
  • CDCL runs as resolution proofs;
  • five experiments, including the adder miters of Lectures 1–4 up to 256 bits.

The experiments and their code were designed for these notes and do not reflect what was said in class. Code: code/lecture05/ (5 scripts + 2 modules; Python standard library only, matplotlib optional; from 2 seconds to about 90 seconds each, none over 2 minutes) Reading time: 4 hours including running the code


0. How to read this lecture

0.1 Learning goals

After this lecture you should be able to:

  1. Name the three shortcomings of DPLL and show the first one on a measured example.
  2. Run Abstract CDCL by hand: CONFLICT, EXPLAIN, BACKJUMP, FAIL; read its derivation tables.
  3. Draw the implication graph of a conflict, find its UIPs, and compute the first-UIP learned clause by resolution.
  4. Explain why a learned clause is sound (entailed), why it is asserting, and to which level CDCL jumps back.
  5. Prove Basic CDCL terminating, and state exactly which strategies make every run end in SAT or UNSAT.
  6. Explain the roles of VSIDS, restarts, phase saving and clause deletion, and read an ablation table critically.
  7. Explain how an UNSAT answer is certified: DRUP/DRAT proofs, RUP and RAT checks, unsatisfiable cores, and why every CDCL refutation is a resolution proof.
  8. Say where CDCL is dramatically better than DPLL (structured problems), where it is only somewhat better (random 3-SAT), and where every resolution-based solver fails (pigeonholes).

0.2 Prerequisites and scope

AssumedIntroduced hereDeveloped later
resolution, refutations, Haken’s theorem (Lecture 2)learned clauses as resolvents; DAG vs tree proofs of a solver run—
proof systems, invariants, strategies (Lecture 3)Abstract CDCL and its correctnessCDCL(T) (Lecture 10)
DPLL, trails, decision levels, watched literals (Lecture 4)conflict analysis, backjumping, VSIDS, restarts, deletionthe SAT engine of Lectures 9–20
the adder miters (Lectures 1, 2, 4)CDCL on them, up to 256 bitsbit-blasting (Lecture 16), model checking (Lecture 9)

0.3 Map

§1  why DPLL is not enough: three shortcomings, one measurement
§2  the idea of CDCL in one picture: learn from every conflict
§3  Abstract CDCL: states, rules, the slides' derivation; correctness, checked by machine   ← code 01
§4  conflict analysis: implication graphs, cuts, UIPs; learning schemes; minimization      ← code 02
§5  the concrete solver: trail, reasons, analysis, backjumping                               ← cdcl.py
§6  decisions: VSIDS                                                                          ← code 03
§7  restarts, heavy tails and phase saving                                                    ← code 03
§8  forgetting: clause deletion and LBD; the full ablation                                    ← code 03
§9  trusting UNSAT: DRUP and DRAT proofs; CDCL runs as resolution proofs                    ← code 04
§10 CDCL against DPLL: adders up to 256 bits, bugs, random 3-SAT, pigeonholes                ← code 05
§11 summary   §12 common pitfalls   §13 exercises   §14 further reading   §15 next lecture

0.4 Notation

SymbolMeaning
1,2,3ˉ,…1, 2, \bar 3, \dotsliterals, with pnp_n abbreviated as nn (as in the slides); in code output 3ˉ\bar 3 is written ¬3
MM, ∙l\bullet lthe assignment, a sequence of literals; ∙l\bullet l marks a decision
lev(l)\mathrm{lev}(l)the decision level of ll: the number of decisions in MM up to and including ll
M[i]M^{[i]}the prefix of MM up to and including level ii (everything before the (i+1)(i{+}1)-th decision)
CCthe conflict clause under analysis, or no when there is none
⟨M,Δ,C⟩\langle M, \Delta, C\ranglea state of Abstract CDCL; UNSAT is the failure state
l≺Ml′l \prec_M l'll occurs before l′l' in MM
l@kl@k(implication graphs) literal ll assigned at level kk
reason of llthe clause that propagated ll (its antecedent); decisions have none

0.5 The code of this lecture

Two modules.

cdcl.py is the SAT engine that every later lecture of the course uses. It contains:

  • AbstractCDCL: the slides’ proof system on states ⟨M,Δ,C⟩\langle M, \Delta, C\rangle. It prints derivation tables in the slides’ format and runs under any strategy and three “readings” of the rules (§3.3).
  • CDCLSolver: a complete solver. It has:
    • two watched literals and first-UIP learning, with the alternatives last UIP, decisions only, and no learning;
    • recursive clause minimization and non-chronological backjumping (chronological as an option);
    • VSIDS (a static order as an option), Luby or geometric restarts, phase saving, and LBD-based clause deletion;
    • DRUP proof logging and, optionally, every learned clause written out as resolution steps;
    • machine-independent work counters.
  • Teaching tools: first_conflict, explain_steps, uip_clauses and graph_text show the implication graph of a conflict, its UIPs and the clause of every cut.

drup_check.py is an independent proof checker. It shares no code with the solver and does:

  • forward and backward checking;
  • RUP and RAT checks;
  • unsatisfiable cores.

1. Why DPLL is not enough

Lecture 4 ended with a sobering measurement. On the miter of two nn-bit adders, which asks “is there an input on which the two adders disagree?”, DPLL needed ×3.8 more decisions per extra bit: 119,031 decisions at 9 bits. That is the growth rate of the truth table, 4n4^n rows. On this problem DPLL is a smarter way of enumerating, but it is still enumerating.

The slides list three shortcomings of DPLL:

  1. No learning. When a branch fails, DPLL throws away all the work that showed why it failed. It then meets conflicts with the same root cause again and again in other branches.
  2. Chronological backtracking. DPLL undoes only the most recent decision, even when that decision had nothing to do with the conflict. The assignment may have been doomed many levels earlier.
  3. Naive decisions. The heuristics of Lecture 4 look at clause counts, not at what the search has found out so far.

An analogy. Picture a detective who interviews suspects in a fixed order. Every time an alibi collapses, the detective forgets which facts made it collapse. With the next suspect the same contradiction comes up again, and it is “discovered” again. CDCL is the detective who writes down every contradiction as a short rule (“whoever was at the station at 9 cannot have been at the bank at 9:15”). The rule is checked automatically against every future suspect. When a contradiction turns out to have nothing to do with the last interview, the detective goes straight back to the interview that caused it.

On the adders the cost of forgetting is concrete. A contradiction about the carries of the low bits does not depend on the high bits at all. Yet DPLL, having forgotten it, can meet it again under every combination of the bits decided above it, and so it ends up enumerating.


2. The idea of CDCL in one picture

CDCL keeps DPLL’s loop of decide → propagate. When propagation produces a conflict, it adds a third step before backtracking:

                 ┌──────────────── no conflict, unassigned variables ───────────────┐
                 ▼                                                                  │
  DECIDE  ──►  PROPAGATE ──► conflict? ──yes──► ANALYZE: resolve the conflict back   │
  (VSIDS)     (watched lits)     │             to a learned clause D (first UIP)    │
                                 │             LEARN D, BACKJUMP to the level        │
                                 │             where D is unit ─────────────────────►┤
                                 │             (conflict at level 0: UNSAT)          │
                                 no, all assigned: SAT                               │
  occasionally: RESTART (keep D's), FORGET (delete useless D's) ─────────────────────┘

The heart of the method is the learned clause. When the clause CC is false under MM, we follow the propagations that made its literals false backwards. Each step replaces a literal by the reasons that forced it, and that replacement is one resolution step (Lecture 2). We stop at a clause DD that has exactly one literal from the current decision level. Three properties follow:

  • sound: DD is derived by resolution from Δ\Delta, so Δ⊨D\Delta \models D. Adding it changes no model.
  • general: DD mentions only the literals that caused the conflict, not the whole assignment. It blocks every future assignment that contains those literals, however the search gets there.
  • asserting: after undoing every level above the second-highest level in DD, all literals of DD but one are still false. DD is then unit and propagates the one remaining literal, exactly the literal that must flip. Undoing several levels at once is backjumping.

So CDCL is, at the same time:

  • a search procedure, DPLL;
  • a deduction procedure, resolution, producing exactly the lemmas the search needs;
  • in Lecture 2’s terms, a strategy for building a resolution refutation that the search itself guides.

3. Abstract CDCL

3.1 States and rules

To model learning and backjumping, the slides add a third component to the states of Abstract DPLL:

  • States are UNSAT, or ⟨M,Δ,C⟩\langle M, \Delta, C\rangle, where CC is no or a clause, the conflict clause.
  • Initial state: ⟨ϵ,Δ0,no⟩\langle \epsilon, \Delta_0, \texttt{no}\rangle.
  • Expected final states: UNSAT if Δ0\Delta_0 is unsatisfiable, otherwise ⟨M,Δn,no⟩\langle M, \Delta_n, \texttt{no}\rangle with Δn\Delta_n equisatisfiable to Δ0\Delta_0 (in fact equivalent) and M⊨ΔnM \models \Delta_n.

PROPAGATE, PURE and DECIDE are unchanged from Lecture 4. BACKTRACK is replaced by three rules, and FAIL is modified:

rulepremisesconclusion
CONFLICTC=noC = \texttt{no}, {l1,…,ln}∈Δ\{l_1, \dots, l_n\} \in \Delta, lˉ1,…,lˉn∈M\bar l_1, \dots, \bar l_n \in MC:={l1,…,ln}C := \{l_1, \dots, l_n\}
EXPLAINC={l}∪C′C = \{l\} \cup C', {l1,…,ln,lˉ}∈Δ\{l_1, \dots, l_n, \bar l\} \in \Delta, lˉ1,…,lˉn,lˉ∈M\bar l_1, \dots, \bar l_n, \bar l \in M, lˉ1,…,lˉn≺Mlˉ\bar l_1, \dots, \bar l_n \prec_M \bar lC:={l1,…,ln}∪C′C := \{l_1, \dots, l_n\} \cup C'
BACKJUMPC=D={l1,…,ln,l}C = D = \{l_1, \dots, l_n, l\}, lev(lˉ1),…,lev(lˉn)≤i<lev(lˉ)\mathrm{lev}(\bar l_1), \dots, \mathrm{lev}(\bar l_n) \le i < \mathrm{lev}(\bar l)M:=M[i] lM := M^{[i]}\, l, C:=noC := \texttt{no}, Δ:=Δ∪{D}\Delta := \Delta \cup \{D\}
FAILC≠noC \neq \texttt{no}, no decision in MMUNSAT

Read them like this:

  • CONFLICT notices that a clause is false and starts an analysis with it.
  • EXPLAIN picks a literal ll of CC, whose complement lˉ\bar l is true in MM. It looks for a clause that could have propagated lˉ\bar l: all of that clause’s other literals were false before lˉ\bar l. It then replaces ll by those other literals. This is resolution of CC with that clause on ll.
  • BACKJUMP needs a clause with exactly one literal ll at the highest level of CC. It cuts MM back to some level ii between the second-highest level of DD and lev(lˉ)−1\mathrm{lev}(\bar l) - 1. At level ii, DD is unit, so ll is appended, as a deduction and not as a decision. DD is learned.
  • FAIL: a conflict clause and no decision left means that nothing can be undone.

The slides also add the rules of the full CDCL system:

rulepremisesconclusionpurpose
LEARNΔ⊨D\Delta \models D, D∉ΔD \notin \DeltaΔ:=Δ∪{D}\Delta := \Delta \cup \{D\}add any entailed clause (e.g., preprocessing)
FORGETC=noC = \texttt{no}, Δ=Δ′∪{D}\Delta = \Delta' \cup \{D\}, Δ′⊨D\Delta' \models DΔ:=Δ′\Delta := \Delta'delete a redundant clause: memory (§8)
RESTART—M:=M[0]M := M^{[0]}, C:=noC := \texttt{no}abandon the current search, keep the learned clauses (§7)

FORGET may delete only clauses that the rest still entails. Learned clauses always qualify, since they were derived from the input. A RESTART keeps level 0 and every learned clause, so it is not a restart “from scratch”.

3.2 The slides’ derivation

Δ={C1: {1}, C2: {1ˉ,2}, C3: {3ˉ,4}, C4: {5ˉ,6ˉ}, C5: {1ˉ,5ˉ,7}, C6: {2ˉ,5ˉ,6,7ˉ}}\Delta = \{C_1{:}\ \{1\},\ C_2{:}\ \{\bar 1, 2\},\ C_3{:}\ \{\bar 3, 4\},\ C_4{:}\ \{\bar 5, \bar 6\},\ C_5{:}\ \{\bar 1, \bar 5, 7\},\ C_6{:}\ \{\bar 2, \bar 5, 6, \bar 7\}\}. With the slides’ strategy (propagate first, decide the smallest variable true, and EXPLAIN the literal assigned last), script 01 prints:

                    M   Δ                 C                 rule
                    ε   Δ                 no                (initial state)
                    1   Δ                 no                PROPAGATE (by C1)
                  1 2   Δ                 no                PROPAGATE (by C2)
               1 2 •3   Δ                 no                DECIDE
             1 2 •3 4   Δ                 no                PROPAGATE (by C3)
          1 2 •3 4 •5   Δ                 no                DECIDE
       1 2 •3 4 •5 ¬6   Δ                 no                PROPAGATE (by C4)
     1 2 •3 4 •5 ¬6 7   Δ                 no                PROPAGATE (by C5)
     1 2 •3 4 •5 ¬6 7   Δ                 {¬2, ¬5, 6, ¬7}   CONFLICT
     1 2 •3 4 •5 ¬6 7   Δ                 {¬1, ¬2, ¬5, 6}   EXPLAIN with C5
     1 2 •3 4 •5 ¬6 7   Δ                 {¬1, ¬2, ¬5}      EXPLAIN with C4
               1 2 ¬5   Δ, {¬1, ¬2, ¬5}   no                BACKJUMP to level 0
            1 2 ¬5 •3   Δ, {¬1, ¬2, ¬5}   no                DECIDE
          1 2 ¬5 •3 4   Δ, {¬1, ¬2, ¬5}   no                PROPAGATE (by C3)
       1 2 ¬5 •3 4 •6   Δ, {¬1, ¬2, ¬5}   no                DECIDE
    1 2 ¬5 •3 4 •6 •7   Δ, {¬1, ¬2, ¬5}   no                DECIDE
                        no rule applies, C = no: M is a model -> SAT

These rows reproduce the slides’ table. The slides write “SAT!” after 1 2 5ˉ∙3 41\,2\,\bar 5 \bullet 3\, 4, since every clause is satisfied at that point. The rules as written still DECIDE the unassigned variables 6 and 7, which explains the last two rows.

Script 01 runs Lecture 4’s Abstract DPLL on the same set and the same decisions. It meets the same conflict at 1 2∙3 4∙5 6ˉ 71\,2 \bullet 3\,4 \bullet 5\, \bar 6\, 7 and BACKTRACKs to 1 2∙3 4 5ˉ1\,2 \bullet 3\,4\, \bar 5. The decision 3 stays, although it had nothing to do with the conflict, and nothing is remembered.

CDCL instead asks why the conflict happened:

  • EXPLAIN with C5C_5 resolves {2ˉ,5ˉ,6,7ˉ}\{\bar 2, \bar 5, 6, \bar 7\} with {1ˉ,5ˉ,7}\{\bar 1, \bar 5, 7\} on 7.
  • EXPLAIN with C4C_4 resolves the result with {5ˉ,6ˉ}\{\bar 5, \bar 6\} on 6.
  • The result is {1ˉ,2ˉ,5ˉ}\{\bar 1, \bar 2, \bar 5\}: “with 1 and 2, 5 is impossible”.

Its literals sit at levels 0, 0 and 2. BACKJUMP can choose i∈{0,1}i \in \{0, 1\}, and the strategy takes the lowest, i=0i = 0. This skips the irrelevant decision 3.

3.3 Correctness, and a precondition the slides leave implicit

The slides state four results for Basic CDCL = {PROPAGATE, PURE, DECIDE, CONFLICT, EXPLAIN, BACKJUMP, FAIL}. Here an execution is a derivation from ⟨ϵ,Δ0,no⟩\langle\epsilon, \Delta_0, \texttt{no}\rangle, and an exhausted execution is one that ends in a state where no rule applies.

  1. Strong termination: every execution is finite.
  2. Lemma 2: every exhausted execution ends with C=noC = \texttt{no} or UNSAT.
  3. Refutation soundness: if an exhausted execution ends with UNSAT, then Δ0\Delta_0 is unsatisfiable.
  4. Solution soundness: if it ends with C=noC = \texttt{no}, then M⊨Δ0M \models \Delta_0.

The invariants. Every rule preserves:

  1. Δ≡Δ0\Delta \equiv \Delta_0. BACKJUMP adds D=CD = C, and CC is entailed (next item).
  2. When C≠noC \ne \texttt{no}: Δ⊨C\Delta \models C and every literal of CC is false in MM.
    • CONFLICT copies a clause of Δ\Delta that is false in MM.
    • EXPLAIN replaces CC by a resolvent of CC and a clause of Δ\Delta, and resolution is sound (Lecture 2). The new literals l1,…,lnl_1, \dots, l_n are false in MM by the premise.
  3. Every non-decision literal of MM is entailed by Δ\Delta together with the decisions before it. This is Lecture 4’s invariant; BACKJUMP’s ll is entailed because DD is unit at level ii.

Termination has two parts.

  • Steps that change MM (PROPAGATE, PURE, DECIDE, BACKJUMP) increase the tuple of level sizes (∣M0∣,∣M1∣,… )(|M_0|, |M_1|, \dots) lexicographically. BACKJUMP to level ii adds a literal at level ii and empties the levels above, exactly like BACKTRACK in Lecture 4. There are finitely many such tuples.
  • EXPLAIN replaces one literal of CC by literals assigned strictly earlier in MM. So the multiset of MM-positions of CC‘s literals decreases in the multiset order, which is well-founded (Dershowitz–Manna).

Between two BACKJUMPs there is at most one CONFLICT.

Soundness. When FAIL fires, CC is false in MM, which contains no decisions. By invariant 3, every literal of MM is entailed by Δ≡Δ0\Delta \equiv \Delta_0. And Δ⊨C\Delta \models C while those literals falsify CC. So Δ0\Delta_0 is unsatisfiable. When no rule applies and C=noC = \texttt{no}:

  • no clause is false, otherwise CONFLICT would apply;
  • every variable is assigned, otherwise DECIDE would apply.

So MM is a model.

Checked by machine. Script 01 runs 1,500 random clause sets (2–6 variables). Each run uses a random strategy, choosing a uniformly random applicable rule instance at every step, and checks every invariant at every step. It does this under three readings of the rules:

checkpropagate firstconflict firstrules as written
final state correct (SAT with a model / UNSAT iff unsatisfiable)1,500 / 1,5001,219 / 1,500959 / 1,500
derivations ending STUCK (C≠C \ne no, no rule applies)0281541
violations of any invariant, of the measure, or of “CONFLICTs ≤ BACKJUMPs + 1”000
BACKJUMPs that skip at least one level / all BACKJUMPs2 / 36254 / 1,379366 / 1,669

The three readings are:

  • Propagate first: CONFLICT as soon as a clause is false; DECIDE and PURE only when no PROPAGATE applies.
  • Conflict first: conflicts first, but DECIDE may preempt a pending PROPAGATE.
  • Rules as written: no priorities at all.

What the table shows.

  • The invariants and the measure hold under every reading: no run ever gives a wrong answer. Soundness and termination are robust.
  • Lemma 2 fails without propagate-first. The shortest stuck derivation is:
      M   Δ   C     rule
      ε   Δ   no    (initial state)
    •¬2   Δ   no    DECIDE
    •¬2   Δ   {2}   CONFLICT
    •¬2   Δ   {}    EXPLAIN with C2
          no rule applies, but C ≠ no: a stuck state

on Δ0={{2},{2ˉ}}\Delta_0 = \{\{2\}, \{\bar 2\}\}.

Why it gets stuck. EXPLAIN only requires a clause that would have propagated lˉ\bar l. It does not check that lˉ\bar l was propagated. A strategy that decides 2ˉ\bar 2 although the unit clause {2ˉ}\{\bar 2\} would have propagated it lets EXPLAIN “explain” a decision. Every literal of CC can then disappear, leaving C={}C = \{\}. At that point:

  • Δ⊨{}\Delta \models \{\} proves UNSAT;
  • but FAIL requires “no decision in MM”, and MM still holds the decision ∙2ˉ\bullet\bar 2;
  • and BACKJUMP needs a literal in CC.

The same happens when a strategy postpones a conflict whose literals are all at level 0.

Repairs. Either of two fixes restores Lemma 2:

  1. The strategy repair, which is what solvers do: propagate exhaustively before every decision and detect conflicts at once. Then no decision dd is ever explainable. A clause that could explain dd would have been unit before dd was decided, so PROPAGATE would have applied. EXPLAIN therefore never removes the last literal of the conflict level, and BACKJUMP always becomes applicable.
  2. The rule repair: let FAIL also fire when C={}C = \{\}. This is sound, because Δ⊨{}\Delta \models \{\}.

The slides’ own strategy (“apply PROPAGATE to completion”, conflicts first) is the propagate-first reading, so its runs are not affected. But the four results above are stated for every exhausted execution of Basic CDCL, and that is too strong as written.

A slip on slide 25. The slide says to backjump “to the second lowest decision level among DD‘s literals”. The BACKJUMP premise allows any ii with (all other levels) ≤i<\le i < (the highest level). The lowest allowed level is the second highest level of DD. The two phrases agree only when DD has at most three distinct levels, as in the example (levels 0 and 2).

For example, take a clause with levels 1, 2, 3, 5. It must jump to level 3 or 4. Jumping to level 2 would unassign the level-3 literal, and the clause would no longer be unit.


4. Conflict analysis

4.1 The implication graph

The slides represent the propagations as a graph:

  • Nodes: one per literal of MM, labelled with its level (l@kl@k).
  • Edges: from each literal of a reason clause to the literal that clause propagated, labelled with the clause. Decisions have no incoming edges.
  • Conflict graph: also contains a node ⊥\bot, with edges from the literals of the falsified clause.

For the slides’ conflict, first_conflict and graph_text print it in trail order:

       1@0        <- unit clause
       2@0        <- reason {¬1, 2}
      •3@1        <- decision
       4@1        <- reason {¬3, 4}
      •5@2        <- decision
       ¬6@2       <- reason {¬5, ¬6}
       7@2        <- reason {¬1, ¬5, 7}
       ⊥@2        <- falsified clause {¬2, ¬5, 6, ¬7}

Cuts give conflict clauses. Cut the graph into a reason side, which contains all decisions and level-0 literals, and a conflict side, which contains ⊥\bot. The reason-side nodes with an edge across the cut cannot all be true. Negating them gives a clause, and the clause is entailed: from those literals, propagation reaches ⊥\bot.

There are many cuts, so many possible learned clauses. Which one should we learn?

4.2 Unique implication points

A UIP of the conflict level is a node other than ⊥\bot that lies on every path from the current decision to ⊥\bot. The decision itself is always a UIP; it is the last UIP. The first UIP is the one closest to ⊥\bot.

There is a simple way to compute every UIP. Run EXPLAIN on the literal assigned last, again and again. Whenever the clause has exactly one literal of the conflict level, that literal’s node is a UIP, and the clause is the one of the cut just behind it. Script 02 prints these steps:

  step  conflict clause C  one literal at the conflict level?  next
     0  {¬2, ¬5, 6, ¬7}    -                                   EXPLAIN ¬7 with {¬1, ¬5, 7}
     1  {¬1, ¬2, ¬5, 6}    -                                   EXPLAIN 6 with {¬5, ¬6}
     2  {¬1, ¬2, ¬5}       UIP 5                               (the decision: stop)

In the slides’ example the decision 5 is the only UIP, as the slides note.

A real solver also drops literals that are false at level 0: they can never become true. In the clause {1ˉ,2ˉ,5ˉ}\{\bar 1, \bar 2, \bar 5\}, both 1 and 2 are forced at level 0, so two more resolution steps (with C2C_2, then C1C_1) remove them. Script 02’s concrete solver accordingly learns the unit clause {5ˉ}\{\bar 5\}.

A conflict with two UIPs. Script 02 builds a second example:

{1ˉ,2}, {3ˉ,4}, {2ˉ,4ˉ,5}, {4ˉ,6}, {5ˉ,6ˉ,7}, {5ˉ,6ˉ,7ˉ}, {8ˉ,4}\{\bar 1, 2\},\ \{\bar 3, 4\},\ \{\bar 2, \bar 4, 5\},\ \{\bar 4, 6\},\ \{\bar 5, \bar 6, 7\},\ \{\bar 5, \bar 6, \bar 7\},\ \{\bar 8, 4\}

It decides 1 and then 3:

      •1@1        <- decision
       2@1        <- reason {¬1, 2}
      •3@2        <- decision
       4@2        <- reason {¬3, 4}
       5@2        <- reason {¬2, ¬4, 5}
       6@2        <- reason {¬4, 6}
       7@2        <- reason {¬5, ¬6, 7}
       ⊥@2        <- falsified clause {¬5, ¬6, ¬7}

  step  conflict clause C  one literal at the conflict level?  next
     0  {¬5, ¬6, ¬7}       -                                   EXPLAIN ¬7 with {¬5, ¬6, 7}
     1  {¬5, ¬6}           -                                   EXPLAIN ¬6 with {¬4, 6}
     2  {¬4, ¬5}           -                                   EXPLAIN ¬5 with {¬2, ¬4, 5}
     3  {¬2, ¬4}           UIP 4                               EXPLAIN ¬4 with {¬3, 4}
     4  {¬2, ¬3}           UIP 3                               (the decision: stop)

Three learning schemes take different clauses from this conflict:

schemestops whenlearnsmeaning
first UIPone literal of the conflict level is left{2ˉ,4ˉ}\{\bar 2, \bar 4\}“4 and 2 never together”
last UIPthat literal is the decision{2ˉ,3ˉ}\{\bar 2, \bar 3\}“3 and 2 never together”
decisions onlyonly decisions are left (also resolve lower levels){1ˉ,3ˉ}\{\bar 1, \bar 3\}“not both decisions”

The first-UIP clause blames the real culprit: 4, together with 2, causes the conflict, however 4 became true. The clause {8ˉ,4}\{\bar 8, 4\} is a second way to make 4 true; the first-UIP clause covers it, and the other two do not.

The runs show the difference. With each scheme, the solver (decide true first, no restarts) does:

  first UIP        2 conflicts:  •1 •3 ⊥ learn {¬2, ¬4} → level 1   •5 •6 ⊥ learn {¬5, ¬6} → level 2   •7
  last UIP         3 conflicts:  •1 •3 ⊥ learn {¬2, ¬3} → level 1   •4 ⊥ learn {¬2, ¬4} → level 1   •5 •6 ⊥ ...
  decisions only   3 conflicts:  •1 •3 ⊥ learn {¬1, ¬3} → level 1   •4 ⊥ learn {¬1, ¬4} → level 1   •5 •6 ⊥ ...

After a last-UIP or decision clause, the solver simply decides 4 next and meets the same conflict again.

Asserting clauses. All three clauses are asserting: they contain exactly one literal of the conflict level. So after the jump to the second-highest level they are unit and propagate at once. That is what makes BACKJUMP’s "M:=M[i] lM := M^{[i]}\, l" a propagation rather than a guess.

First UIP among the asserting clauses. It is the asserting clause found with the fewest resolution steps. It is also the one that jumps back the farthest: its lower-level literals are a subset of those of later UIP clauses, which only add literals. Zhang, Madigan, Moskewicz and Malik (2001) compared many schemes on industrial benchmarks and found first UIP the most robust; every modern solver uses it.

4.3 Learning schemes, measured

On the adder miters (script 02, conflicts):

scheme4 bits5678910 bits
first UIP386296124130137162
last UIP5296138145184225242
decisions only2561,0244,09610,56011,15415,68218,271
no learning (backjumping only)1272516571,4433,3266,64711,701
4bits4^{\text{bits}} (truth-table rows)2561,0244,09616,38465,536262,1441,048,576

Three lessons:

  1. First-UIP learning makes the miters easy. It needs 162 conflicts at 10 bits, growing by ×1.0 to ×1.6 per bit. (§10 continues to 256 bits.)

  2. Decision clauses reproduce the truth table. Up to 6 bits they need exactly 4bits4^{\text{bits}} conflicts. Script 02 looks inside the runs, with no restarts and no deletion:

    bitsconflictsdecisions on input bits / all decisionslearned clauses of length 1, 2, 3, 4, 5
    51,0241,023 / 1,02310, 45, 120, 210, 252
    64,0964,095 / 4,09512, 66, 220, 495, 792
    711,2919,783 / 11,5775, 37, 173, 496, 1,055
    814,44611,802 / 15,43314, 62, 188, 369, 651

    Up to 6 bits every decision is an input bit. The number of learned clauses of length kk is (2⋅bitsk)\binom{2\cdot\text{bits}}{k}, giving one clause per node of the complete binary tree over the inputs. It is Lecture 1’s truth table, one row per conflict.

    From 7 bits on, VSIDS also decides internal gate variables (15–25% of the decisions). A clause over gate variables blocks many input combinations at once, so the count falls below 4bits4^{\text{bits}}.

  3. Backjumping without learning forgets each clause once it stops justifying a literal. It about doubles per bit (×1.8 to ×2.6): better than DPLL’s ×3.8, because irrelevant decisions are skipped, but still exponential.

Why only first UIP is cheap here. It learns facts about internal signals (“these two carry signals cannot differ”), and such a fact holds in every branch.

On other families (script 02, conflicts, budget 5,000):

schemepigeonhole 6Sudoku (hard)30-queens32-bit miter, bug at bit 20random 3-SAT n=100 (median of 5)
first UIP71361148197486
last UIP87893200501335
decisions only1,109152> 5,000> 5,000704
no learning1,526118> 5,000> 5,000668
  • First UIP wins on all four structured families.
  • On random 3-SAT, last UIP needed fewer conflicts, though five instances are a small sample.
  • Decision clauses are not always longer: their mean length is 6.5 vs 10.6 on the pigeonhole and 5.3 vs 6.4 on the Sudoku. But they need more conflicts.
  • Their LBD equals their length. The LBD (literal block distance) is the number of distinct levels in a clause, and a decision clause has one decision per level. A first-UIP clause can hold several literals of one level: on the Sudoku its mean LBD is 3.1 for a mean length of 6.4.
  • On the buggy adder, first UIP jumps back 13 levels per conflict on average. Its clauses mention a few gates, so the jump goes far back.

4.4 Clause minimization

A literal qq of the learned clause can be dropped if the reason of qˉ\bar q consists only of three kinds of literal:

  • literals already in the clause;
  • level-0 literals;
  • literals that are themselves droppable, checked recursively.

In that case qq is implied by the rest of the clause, and the shorter clause follows by more resolution steps (Sörensson and Biere 2009). Script 02 measures:

instanceconflicts off → onmean length off → onliterals removed
32-bit adder miter568 → 6024.3 → 3.87%
64-bit adder miter1,703 → 1,6145.4 → 4.89%
pigeonhole, 7 holes4,145 → 5,82718.9 → 15.919%
Sudoku (hard)61 → 616.9 → 6.48%
40-queens240 → 265232.9 → 234.80%
random 3-SAT n=125 (median of 15)707 → 70810.0 → 8.222%
  • Minimization shortens clauses by up to 22%.
  • Its effect on the number of conflicts is small and goes both ways. On random 3-SAT it won on 8 of 15 instances, with equal medians.
  • A shorter clause costs less to store and propagates earlier, but each change also redirects the later search. On small instances that noise dominates.

5. The concrete solver

CDCLSolver follows MiniSat (Eén and Sörensson 2003). It keeps three per-variable records:

  • trail: the literals in assignment order, with trail_lim marking where each level starts;
  • level: the level of each variable;
  • reason: the clause that propagated it, or none for a decision.

Unit propagation uses Lecture 4’s two watched literals, with one convention: when a clause becomes the reason of a literal, that literal is in position 0.

Conflict analysis (first UIP; _analyze_uip). It is EXPLAIN on a trail, without building any intermediate clause:

seen := ∅;  learnt := [ _ ];  count := 0;  c := conflicting clause;  p := none
loop:
    for each literal q of c (skipping p itself if c is p's reason):
        if var(q) not seen and level(q) > 0:
            mark seen, bump VSIDS activity of var(q)
            if level(q) = current level:  count += 1        # to be resolved away
            else:                          learnt.append(q)  # lower level: goes into the clause
    p := the most recent trail literal that is marked seen;  unmark it;  count -= 1
    if count = 0: break                                      # p is the first UIP
    c := reason(p)                                           # one resolution step
learnt[0] := ¬p

The rest of the conflict step:

  • Backjump level: the highest level among learnt[1:]. That literal goes to position 1, so the two watched literals are the asserting literal and the last literal to be unassigned.
  • Undo: cancel_until(level) unassigns the levels above. Unassigned variables keep their last value for phase saving and go back into the VSIDS heap.
  • Assert: add the learned clause and enqueue learnt[0] with the new clause as its reason.

The main loop:

propagate
if conflict:   if level = 0: UNSAT
               analyze → learn → backjump → assert; maybe RESTART; maybe FORGET
else:          pick the unassigned variable with the highest activity, with its saved phase
               if none: SAT (the model is checked against the input before it is returned)

Correctness against truth tables. Script 01, Part 4, runs 2,000 random clause sets (1–10 variables; 916 satisfiable) through 11 configurations: every learning scheme, minimization off, the static order, extreme restart and deletion schedules, chronological backtracking, and random decisions.

  • All 22,000 answers agree with the truth tables.
  • All 11 × 1,084 UNSAT answers come with a DRUP proof that drup_check.py accepts.
  • Each also comes with a resolution proof that Lecture 2’s checker accepts (§9).

6. Decisions: VSIDS

Lecture 4’s heuristics score literals by clause counts of the current formula. Chaff (Moskewicz et al. 2001) replaced them with VSIDS (Variable State Independent Decaying Sum):

  • every variable has an activity;
  • each variable that takes part in a conflict analysis is bumped (+1);
  • periodically all activities are multiplied by a decay factor.

We implement the decay as in MiniSat. Instead of shrinking all activities, the bump increment grows by 1/0.951/0.95 after every conflict, and everything is rescaled before the numbers overflow. The decision variable is the unassigned one with the highest activity, kept in a heap.

Why it works:

  • VSIDS keeps the search on the variables of recent conflicts, the part of the problem the solver is stuck on.
  • It costs almost nothing per decision. JW scanned every clause for every decision; VSIDS pops a heap.
  • It needs no knowledge of the encoding.

Script 03 compares it with a static order (Jeroslow–Wang scores of the input, never updated). Conflicts, budget 5,000:

instanceVSIDSstatic order
32-bit adder miter (UNSAT)6021,009
32-bit miter, bug at bit 20 (SAT)197371
pigeonhole, 7 holes (UNSAT)> 5,000322
Sudoku, hard (SAT)61189
20-queens (SAT)111> 5,000
random 3-SAT n=125 (median of 3)1,8051,473

Neither wins everywhere:

  • The static order is a gift on the pigeonhole (322 conflicts) and a disaster on the queens (out of budget).
  • VSIDS wins on four of the six. Its one bad case is the pigeonhole, where no resolution-based method is fast (§9.5).

VSIDS needs no knowledge of the problem, and that robustness is why it and its successors (e.g., the learning-rate heuristic LRB, Liang et al. 2016) are used everywhere.


7. Restarts, heavy tails and phase saving

Heavy tails. Gomes, Selman and Kautz (1998) observed that the runtime of a randomized backtracking solver on one instance often has a heavy-tailed distribution. Most runs are short, but a few take extremely long, because an early bad decision traps the search in a large subtree without solutions.

The cure is to restart: give up after a while and start again. The randomness of the next run, or here the knowledge gathered so far, makes another long run unlikely.

Script 03 solves 20-queens with 20 seeds. A seed gives tiny random initial activities and 2% random decisions. Budget 5,000 conflicts:

restart policyminmedian90th pctmaxover budget
Luby (100×1,1,2,1,1,2,4,…100 \times 1, 1, 2, 1, 1, 2, 4, \dots)1031332202440
geometric (100×1.5k100 \times 1.5^k)1031332364160
no restarts1641,6804,824> 5,0001

Sorted conflicts of 20 seeds per restart policy

Without restarts, the median run needs 13 times more conflicts and the tail reaches the budget. With either policy, every seed finishes within a few hundred conflicts.

Why a CDCL restart is cheap. A restart keeps:

  • all learned clauses;
  • the VSIDS activities;
  • the saved phases.

So a restart is not “start over”. It is “re-decide the top of the tree with what we now know”.

Luby restarts. The Luby sequence 1,1,2,1,1,2,4,1,1,2,1,1,2,4,8,…1, 1, 2, 1, 1, 2, 4, 1, 1, 2, 1, 1, 2, 4, 8, \dots is made of copies of itself. Luby, Sinclair and Zuckerman (1993) proved that, for any runtime distribution, this schedule is within a logarithmic factor of the best fixed restart schedule. It is a safe default when nothing is known.

Restarts are not free. On the 7-hole pigeonhole (UNSAT), the deterministic run without restarts needs 2,761 conflicts, and both restart policies need more than 5,000. An unsatisfiability proof in progress gets interrupted. Modern solvers adapt the restart frequency to the observed LBDs (Glucose) or alternate between restart-heavy and restart-free phases.

Phase saving (Pipatsrisawat and Darwiche 2007) decides a variable with the value it had when it was last unassigned. Backjumps and restarts throw away many consistent assignments, and phase saving puts them back as soon as the variables are decided again.

On script 03’s small instances its effect is mixed:

  • it wins on the adder miters and the queens;
  • “always true” solves the Sudoku with 11 conflicts (61 with phase saving);
  • “always false” needs ten times fewer conflicts on the three random instances (three instances is as much luck as signal).

8. Forgetting: clause deletion and LBD

Every conflict adds a clause. Industrial runs have millions of conflicts, and each learned clause costs memory and propagation time. FORGET deletes clauses that the rest entails: any learned clause qualifies.

The question is which clauses to keep. Audemard and Simon (2009, Glucose) observed that clauses with a low LBD (literal block distance, the number of distinct decision levels in the clause) are the valuable ones. A clause with LBD 2, a “glue clause”, links one decision level to one other and propagates often.

Our policy is a simplified Glucose. At 2,000 conflicts, and then every 2,000+300k2{,}000 + 300k conflicts, it deletes half of the learned clauses with LBD > 2, worst LBD first. It never deletes:

  • binary clauses;
  • glue clauses;
  • clauses that currently justify an assignment.

Script 03, Part 4:

instancedeletionconflictsmost clauses kept at onceclause visits per conflict
pigeonhole, 7 holeson5,8273,300708
off6,0646,0591,197
128-bit adder miteron3,4852,784301
off3,1893,174324
random 3-SAT n=200on13,5535,756532
off12,90712,899921

Learned clauses kept over a run, with and without deletion

  • On the long runs, deletion about halves the clauses kept (54% and 45%), giving a saw-tooth curve. The adder run is short, so only one deletion round happens.
  • Each conflict then visits fewer clauses: 59% and 58% of the visits on the long runs, 93% on the adder.
  • The price is re-learning: deletion cost 9% more conflicts on the adder and 5% on the random instance, and saved 4% on the pigeonhole.

The full ablation. Script 03 switches off one feature at a time (conflicts, budget 5,000):

configurationadder miterbuggy miterpigeonhole 7Sudoku20-queensrandom n=125
all features (default)602197> 5,000611111,805
static order instead of VSIDS1,009371322189> 5,0001,473
no restarts7542942,76161> 5,0001,329
no phase saving8912404,66343124179
no clause deletion602197> 5,000611111,805
no minimization5682584,14561111890
chronological backtracking2,3738223,547891281,438
last-UIP learning1,181501> 5,000931191,725
decision learning> 5,000> 5,000> 5,000152> 5,0002,458
no learning (backjumping only)> 5,000> 5,000> 5,000118> 5,0001,744

How to read it:

  • First-UIP learning is the feature that matters. Without it, the adder miters and the queens run out of budget.
  • Backjumping matters on the circuits. Chronological backtracking needs about four times more conflicts on both miters, although it learns the same clauses.
  • Everything else changes the count by small factors, in both directions, and no family shows the whole picture.
  • Deletion changes no entry: it first acts at 2,000 conflicts, which only the pigeonhole run reaches, and the budget cuts that run off.

A solver’s defaults are a compromise over many benchmarks. That is why SAT competitions use hundreds of instances, and why one table on six instances, like this one, should be read as anecdotes, not rankings.


9. Trusting UNSAT

9.1 DRUP proofs

A SAT answer certifies itself: the model is checked in a moment, and script 05 decodes and re-evaluates every counterexample. An UNSAT answer has no such witness.

Solvers have bugs. Since 2013 the SAT competitions have required solvers to emit a proof in the DRAT format (Wetzler, Heule and Hunt 2014) for every UNSAT answer, and checkers such as drat-trim verify it. The simplest form, DRUP, just lists the learned clauses (“lemmas”) in order, plus deletions, and ends with the empty clause.

RUP check. A lemma LL is accepted if assigning all its literals false and running unit propagation on the current clause set reaches a conflict. Then the clause set entails LL.

For Lecture 4’s UNSAT example {{1,2ˉ},{1ˉ,2ˉ},{2,3},{2,3ˉ},{1,4}}\{\{1, \bar 2\}, \{\bar 1, \bar 2\}, \{2, 3\}, \{2, \bar 3\}, \{1, 4\}\}, the CDCL proof has two lines, 2 0 and 0. Script 04 checks each:

  Lemma {2}: assume it is false, then propagate:
        ¬2   assumption (negated lemma)
         3   unit in {2, 3}
      conflict: {2, ¬3} is false -> lemma accepted

  Lemma {}: assume it is false, then propagate:
         2   unit in {2}
         1   unit in {1, ¬2}
      conflict: {¬1, ¬2} is false -> lemma accepted

Why every CDCL lemma passes. Conflict analysis derived the lemma by resolving backwards along an implication graph. RUP replays that graph forwards, starting from the negated lemma.

9.2 Checking at scale

Forward checking checks every lemma. Backward checking (the idea of drat-trim) works differently:

  • first add all lemmas without checking them;
  • then walk back from the empty clause, checking only the lemmas that some later check actually used. “Used” is found by following the reasons of each RUP conflict.

As a by-product, backward checking reports which input clauses were used: an unsatisfiable core.

Script 04, Part 2:

instanceinput clauseslemmasbackward: lemmas checkedcore
pigeonhole, 6 holes133713700133 (100%)
pigeonhole, 7 holes2045,8275,635204 (100%)
16-bit adder miter572256211479 (84%)
64-bit adder miter2,3481,6141,4152,085 (89%)
128-bit adder miter4,7163,4852,5734,173 (88%)
random 3-SAT n=100, 5 clauses/var500302260420 (84%)
random 3-SAT n=150, 4.5 clauses/var6751,7391,535654 (97%)
  • Every proof checks in both modes. Checking costs about as much as solving, or less.
  • Pigeonhole formulas are minimally unsatisfiable: every clause is needed, so the core is 100%.
  • On the adder miters, almost every core clause belongs to the Plaisted–Greenbaum encoding of Lecture 2 (477 of the 479 at 16 bits). Of each gate definition, only the direction that the polarity of its occurrence requires is used. The refutation hardly ever needs the other direction.

9.3 Lying and buggy solvers

Script 04, Part 3 tampers with the 5-hole pigeonhole proof:

proof offeredchecker’s verdict
the solver’s proofverified: 153 lemmas, all RUP
a non-entailed unit {p1,1}\{p_{1,1}\} inserted as the 4th lemmastep 4: lemma [1] is not RUP
the empty clause removedthe proof never derives the empty clause
the 6-hole proof offered for 5 holesstep 1: … is not RUP
each lemma removed in turn (152 variants)17 of 152 variants still accepted

A simulated buggy solver silently assumes a=0a = 0 on the satisfiable miter of a correct and a buggy 16-bit adder. It answers UNSAT, and its proof is rejected at step 1 when checked against the real input. A valid refutation of a satisfiable formula cannot exist.

Removing one lemma usually breaks the proof too, because a later lemma needed it. In 17 of 152 cases unit propagation re-derives what was missing.

9.4 DRAT: lemmas that are not entailed

RAT (resolution asymmetric tautology) is the other check of DRAT. A lemma LL with first literal pp is RAT if, for every clause DD containing pˉ\bar p, the resolvent L∪(D∖{pˉ})L \cup (D \setminus \{\bar p\}) is RUP (or a tautology).

A RAT lemma need not be entailed, but adding it preserves satisfiability. That is all a refutation needs. Script 04, Part 4 adds the definition 4⇔(1∧2)4 \Leftrightarrow (1 \wedge 2) as three lemmas, {4,1ˉ,2ˉ},{4ˉ,1},{4ˉ,2}\{4, \bar 1, \bar 2\}, \{\bar 4, 1\}, \{\bar 4, 2\}:

inputRUP onlyRUP + RAT
{1,2},{1ˉ,3}\{1, 2\}, \{\bar 1, 3\} (4 is fresh)step 1 rejectedall three accepted
the same plus {4ˉ,3ˉ}\{\bar 4, \bar 3\} (4 already constrained)step 1 rejectedstep 1 rejected: not RUP nor RAT

The definitions are the heart of extended resolution (Tseitin 1966), which has polynomial-size proofs of the pigeonhole formulas (Cook 1976). DRAT lets solvers that introduce new variables (preprocessing, symmetry breaking, cardinality reasoning) still emit checkable proofs.

9.5 CDCL runs are resolution proofs

Every learned clause is the end of a chain of resolution steps (§4). With resolution=True, the solver records each chain. resolution_proof() then writes the run as a refutation in Lecture 2’s format, which Lecture 2’s checker verifies. For Lecture 4’s example:

     1. {p1, ¬p2}    input
     2. {¬p1, ¬p2}   input
     3. {p2, p3}     input
     4. {p2, ¬p3}    input
     5. {p2}         resolve 4, 3 on p3
     6. {¬p2}        resolve 2, 1 on p1
     7. {}           resolve 6, 5 on p2

A learned clause is used again and again, so the proof is a DAG. The proofs from DPLL runs (Lecture 4, §6) are trees. Script 04 compares them:

instanceCDCL: DRUP lemmasCDCL: resolution stepsDPLL (tree-like): resolution steps
adder miter, 2 bits1045165
3 bits25128859
4 bits381963,864
5 bits6242816,383
6 bits9672167,530
pigeonhole, 4 holes28284188
pigeonhole, 5 holes1531,551970

Resolution proof size, DPLL tree vs CDCL DAG, on the adder miters

  • On the adders, tree-like proofs grow ×4 per bit and DAG proofs stay under a thousand steps. The power of learning is the power of reusing derived clauses.
  • On the pigeonhole, the CDCL proof is longer. Writing out one learned clause takes about ten resolution steps, and Haken’s theorem says no resolution proof is short there.
  • A DRUP proof stands for 4.5 to 10 times as many resolution steps as it has lines. The checker pays for that brevity by re-deriving each lemma.

A consequence for lower bounds. CDCL runs are resolution proofs, so Haken’s exponential lower bound for the pigeonhole formulas (Lecture 2) applies to every CDCL solver, however clever its heuristics.

Conversely, Pipatsrisawat and Darwiche (2011) showed that CDCL with restarts, given suitable decisions, can polynomially simulate general resolution. As a proof system it is as strong as resolution: no stronger, and in principle no weaker.


10. CDCL against DPLL

The adder miters. Script 05, Part 1:

bitsvariablesclausesDPLL conflictsCDCL conflictsCDCL time (s)
220548100.00
446128156380.00
6722022,195——
89827631,2721300.01
16202572—2560.03
324101,164—6020.06
648262,348—1,6140.25
1281,6584,716—3,4850.81
2563,3229,452—6,3412.84

Adder equivalence: DPLL vs CDCL

  • DPLL grows ×3.7–4.0 per bit, the truth-table rate.
  • CDCL proves the 64-bit adders equivalent with fewer conflicts than DPLL needs at 6 bits. From 8 bits on it needs 16–27 conflicts per bit: linear growth.
  • The 256-bit miter, with 3,322 variables, takes about 3 seconds of plain Python.

This is the exponential wall of Lecture 1 removed for this family. A clause learned about one bit’s carries holds for every input pattern.

Finding bugs. With a missing carry term in one adder, the miter is satisfiable, and a model is an input on which the adders differ. Script 05 makes the following checks:

  • CDCL finds the counterexample at 8, 16, 32, 64 and 128 bits with 44–460 conflicts.
  • Each one is decoded and re-evaluated on the original circuits: the correct adder computes a+ba + b and the buggy one does not.
  • DPLL finds the 8-bit bug after 1,503 conflicts and is stopped at 20,000 decisions on the 16-bit one.

Random 3-SAT at 4.26 clauses per variable (script 05, medians):

nDPLL conflictsCDCL conflicts
505266
75127185
100350286
125890594
150—1,886
175—5,861
  • Up to 75 variables DPLL needs fewer conflicts. A clause learned on a random formula is rarely useful elsewhere, and Jeroslow–Wang is a strong heuristic there.
  • From 100 on, CDCL needs fewer, and it is faster throughout, because its decisions do not scan the clauses.
  • The gap is a factor, not an exponential. Random 3-SAT near the threshold stays exponentially hard for every complete method.

Pigeonholes (script 05, conflicts):

holesDPLLCDCL
5375153
63,246713
732,7815,827
8—30,051

Both are exponential, as Haken’s theorem demands (§9.5). Solvers that reason with cardinality constraints or cutting planes have short proofs here; resolution-based CDCL does not.

Puzzles. Lecture 4’s DPLL depended on the luck of its heuristic:

  • the fixed order solved the Sudoku and 10-queens at once but not 20-queens;
  • Jeroslow–Wang ran out of budget on the Sudoku and 20-queens.

CDCL solves all three with 31–111 conflicts.


11. Summary

  1. DPLL forgets. CDCL analyses every conflict: EXPLAIN = resolution along the implication graph, until one literal of the conflict level is left, the first UIP.
  2. The learned clause is entailed (sound), general (it mentions only the causes) and asserting (unit after the jump). BACKJUMP goes to the second-highest level of the clause, skipping irrelevant decisions.
  3. Abstract CDCL is sound and terminating under any strategy; checked here at every step of 4,500 random derivations. Every run ends in SAT or UNSAT if propagation is exhaustive before decisions. Otherwise EXPLAIN can explain a decision and leave C={}C = \{\} stuck.
  4. First-UIP learning is the decisive feature: on the adder miters, decision clauses reproduce the truth table exactly ((2nk)\binom{2n}{k} clauses of length kk), backjumping alone doubles per bit, and first UIP grows linearly.
  5. VSIDS, restarts, phase saving, deletion steer and maintain the search. Each helps on some families and hurts on others; robustness, not uniform wins, justifies the defaults. Restarts tame heavy tails (20-queens: 13× in the median); deletion halves memory.
  6. UNSAT answers are certified by DRUP/DRAT proofs and checked independently. Backward checking yields unsatisfiable cores. RAT admits definitions of new variables.
  7. CDCL runs are DAG-like resolution proofs: exponentially smaller than DPLL’s trees on the adders, and as weak as resolution on the pigeonholes.
  8. On structured problems (circuits) CDCL is dramatically better than DPLL: 64 bits with fewer conflicts than DPLL’s 6. On random 3-SAT it is a constant factor better. On pigeonholes both are exponential.

12. Common pitfalls

  • “The learned clause is the conflict clause.” The conflict clause is an input clause that happens to be false. The learned clause is derived from it by EXPLAIN steps and is usually new.
  • “Backjump to the level of the UIP.” The UIP is at the conflict level, which is exactly the level being undone. The jump goes to the second-highest level of the learned clause, where it becomes unit. (Slide 25’s “second lowest” is a slip.)
  • “First UIP = the decision.” Often it is not (§4.2): it is the dominator closest to the conflict.
  • “A restart throws everything away.” It keeps the learned clauses, the activities, the phases and level 0.
  • “CDCL learns arbitrary entailed clauses.” That is the LEARN rule of the abstract system. Real solvers learn the clause their analysis produces; LEARN covers preprocessing.
  • “Deleting learned clauses is unsound.” It is not. FORGET requires the remaining clauses to entail the deleted one, and learned clauses are entailed by the input.
  • “UNSAT proofs list the resolution steps.” DRUP lists only the lemmas, and the checker re-derives them. A RUP check is a unit propagation, not a lookup.
  • “A checker can reuse the solver’s code.” Then it inherits the solver’s bugs. Our drup_check.py shares no code with cdcl.py.
  • “CDCL beats DPLL everywhere.” Not on small random instances in conflicts (§10), and not on pigeonholes, where both are exponential.
  • “One benchmark settles a heuristic.” §6–§8: almost every feature both helps and hurts on six instances.

13. Exercises

Answers are collapsed; try each exercise first.

1. (Abstract CDCL) Run Abstract CDCL with the slides’ strategy on Lecture 4’s set {{1,2ˉ},{1ˉ,2ˉ},{2,3},{3ˉ,2},{1,4}}\{\{1, \bar 2\}, \{\bar 1, \bar 2\}, \{2, 3\}, \{\bar 3, 2\}, \{1, 4\}\}, deciding the smallest variable true first. Write the table.

Answer

No PROPAGATE applies at first, so DECIDE ∙1\bullet 1. Then 2ˉ\bar 2 is propagated by {1ˉ,2ˉ}\{\bar 1, \bar 2\} and 3 by {2,3}\{2, 3\}. Now {3ˉ,2}\{\bar 3, 2\} is false: CONFLICT C={2,3ˉ}C = \{2, \bar 3\}.

EXPLAIN 3 with {2,3}\{2, 3\} gives C={2}C = \{2\}. One literal at level 1, so BACKJUMP to level 0: M=2M = 2, and {2}\{2\} is learned.

PROPAGATE 1 by {1,2ˉ}\{1, \bar 2\}. Then {1ˉ,2ˉ}\{\bar 1, \bar 2\} is false: CONFLICT. There is no decision in MM: FAIL, UNSAT.

The DRUP proof is 2 0 and 0, as in §9.1.

2. (implication graph) For the two-UIP example of §4.2, draw the implication graph. Show that 4 is a UIP and 5 is not.

Answer

Edges:

  • 1→21 \to 2;
  • 3→43 \to 4;
  • 2,4→52, 4 \to 5;
  • 4→64 \to 6;
  • 5,6→75, 6 \to 7;
  • 5,6,7→⊥5, 6, 7 \to \bot.

Every path from 3 to ⊥\bot starts 3→43 \to 4, so 4 is on all of them and is a UIP. The path 3→4→6→⊥3 \to 4 \to 6 \to \bot avoids 5, so 5 is not a UIP.

3. (soundness of learning) Prove that every clause CC produced by CONFLICT followed by EXPLAIN steps is entailed by Δ\Delta.

Answer

By induction on the number of EXPLAIN steps. CONFLICT sets CC to a clause of Δ\Delta. EXPLAIN replaces C={l}∪C′C = \{l\} \cup C' by the resolvent of CC and {l1,…,ln,lˉ}∈Δ\{l_1, \dots, l_n, \bar l\} \in \Delta on ll. Resolution is sound (Lecture 2): any model of both premises satisfies the resolvent. Both premises are entailed by Δ\Delta, so the resolvent is too.

4. (asserting) Let DD be a first-UIP clause with highest level kk (only the UIP literal) and second-highest level j<kj < k. Show that after BACKJUMP to level jj, DD is unit. Why would jumping to j−1j - 1 be wrong?

Answer

At level jj. All other literals of DD are at levels ≤j\le j. They are still false in M[j]M^{[j]}. The UIP literal’s level k>jk > j is undone, so it is unassigned. So DD is unit.

At level j−1j - 1. At least one other literal, the one at level jj, becomes unassigned. DD then has two unassigned literals and propagates nothing. BACKJUMP’s premise lev(lˉi)≤i\mathrm{lev}(\bar l_i) \le i forbids this.

5. (termination) In the derivation of §3.2, list the multiset of MM-positions (counting from 0) of CC‘s literals after CONFLICT and after each EXPLAIN, and check that it decreases.

Answer

M=1 2∙3 4∙5 6ˉ 7M = 1\,2 \bullet 3\, 4 \bullet 5\, \bar 6\, 7 has positions 0–6.

stepCCcomplements in MMpositions
CONFLICT{2ˉ,5ˉ,6,7ˉ}\{\bar 2, \bar 5, 6, \bar 7\}2, 5, 6ˉ\bar 6, 7{1,4,5,6}\{1, 4, 5, 6\}
EXPLAIN with C5C_5{1ˉ,2ˉ,5ˉ,6}\{\bar 1, \bar 2, \bar 5, 6\}{0,1,4,5}\{0, 1, 4, 5\}
EXPLAIN with C4C_4{1ˉ,2ˉ,5ˉ}\{\bar 1, \bar 2, \bar 5\}{0,1,4}\{0, 1, 4\}

Sorted descending, (6,5,4,1)>(5,4,1,0)>(4,1,0)(6,5,4,1) > (5,4,1,0) > (4,1,0): each step decreases.

6. (Lemma 2) Show that under the propagate-first reading, C={}C = \{\} can only arise when MM has no decisions. (Hint: show that EXPLAIN never removes the last literal of the conflict level above level 0.)

Answer

The invariant. Under propagate-first, for every level mm below the current level, the prefix M[m]M^{[m]} is closed under unit propagation and falsifies no clause of the current Δ\Delta.

  • DECIDE happens only after closure.
  • BACKJUMP to level jj keeps the closed prefixes below jj. The new clause DD is not unit below level jj: its literal at level jj is still unassigned there, together with the asserting literal.

The conflict clause starts with a level-kk literal. Let the conflict be at level k≥1k \ge 1. The falsified clause is detected at once. By the invariant it was not false at the end of level k−1k-1, so one of its literals was falsified at level kk.

EXPLAIN never removes the last level-kk literal. Suppose EXPLAIN removes a literal ll with lˉ\bar l at level kk, using R={l1,…,ln,lˉ}R = \{l_1, \dots, l_n, \bar l\}, where the lˉi\bar l_i come before lˉ\bar l.

  • If all lˉi\bar l_i were at levels ≤k−1\le k-1, then RR was unit at the end of level k−1k-1, with lˉ\bar l unassigned. That contradicts the invariant.
  • So some lil_i is false at level kk, and the resolvent keeps a level-kk literal.
  • This also shows that the decision of level kk is never explained: every literal before it is at a lower level.

Conclusion. CC always has at least one level-kk literal.

  • While it has two or more, one of them is implied, and its actual reason clause satisfies EXPLAIN’s premise.
  • When it has exactly one, BACKJUMP applies.

So C={}C = \{\} arises only from conflicts at level 0, where MM has no decisions and FAIL applies.

7. (Luby) Compute the first 15 terms of the Luby sequence, and the conflict counts at which a Luby restart policy with unit 100 restarts during the first 1,000 conflicts.

Answer

The sequence starts 1,1,2,1,1,2,4,1,1,2,1,1,2,4,81, 1, 2, 1, 1, 2, 4, 1, 1, 2, 1, 1, 2, 4, 8. Times 100, the intervals are 100, 100, 200, 100, 100, 200, 400, …

The restarts fall at cumulative conflicts 100, 200, 400, 500, 600, 800. The next one would be at 1,200.

8. (LBD) A learned clause has literals at levels {7,7,7,3,3,1}\{7, 7, 7, 3, 3, 1\}. What are its length and its LBD? Why is a low LBD a good sign?

Answer

Its length is 6 and its LBD is 3 (levels 7, 3, 1).

The literals of one level tend to be propagated together. A clause with LBD 2 needs only one other “block” of literals to be set to become unit, so it propagates often and connects two parts of the search. Glucose keeps such clauses forever.

9. (RUP by hand) Check that {pˉ1,1}\{\bar p_{1,1}\} is RUP for the 2-hole pigeonhole formula with 3 pigeons. The formula has pigeon clauses {pi,1,pi,2}\{p_{i,1}, p_{i,2}\} and hole clauses {pˉi,h,pˉj,h}\{\bar p_{i,h}, \bar p_{j,h}\}.

Answer

Assume p1,1p_{1,1}. The hole-1 clauses {pˉ1,1,pˉ2,1}\{\bar p_{1,1}, \bar p_{2,1}\} and {pˉ1,1,pˉ3,1}\{\bar p_{1,1}, \bar p_{3,1}\} propagate pˉ2,1\bar p_{2,1} and pˉ3,1\bar p_{3,1}. The pigeon clauses then propagate p2,2p_{2,2} and p3,2p_{3,2}. Now {pˉ2,2,pˉ3,2}\{\bar p_{2,2}, \bar p_{3,2}\} is false: a conflict, so the lemma is accepted.

10. (RAT) Is the lemma {x,aˉ}\{x, \bar a\} RUP or RAT (on xx) with respect to (a) Δ1={{xˉ,a},{a,b}}\Delta_1 = \{\{\bar x, a\}, \{a, b\}\} and (b) Δ2={{xˉ,b},{a,b}}\Delta_2 = \{\{\bar x, b\}, \{a, b\}\}?

Answer

(a) Δ1\Delta_1.

  • Not RUP. Assume xˉ\bar x and aa. Both clauses are satisfied, so there is no conflict.
  • RAT. The only clause containing xˉ\bar x is {xˉ,a}\{\bar x, a\}. The resolvent is {aˉ,a}\{\bar a, a\}, a tautology. So the lemma is accepted, although Δ1\Delta_1 does not entail it (take xx true, aa true).

(b) Δ2\Delta_2.

  • Not RUP, as in (a).
  • Not RAT. The resolvent with {xˉ,b}\{\bar x, b\} is {aˉ,b}\{\bar a, b\}. Assume aa and bˉ\bar b: {a,b}\{a, b\} is satisfied and {xˉ,b}\{\bar x, b\} propagates xˉ\bar x. No conflict, so the resolvent is not RUP.
  • Yet adding the lemma keeps Δ2\Delta_2 satisfiable (xx false, aa false, bb true). RAT is a sufficient check, not a necessary one.

11. (decision scheme) Explain why, when every decision is an input bit, the decision scheme on an nn-bit adder miter learns exactly (2nk)\binom{2n}{k} clauses of length kk.

Answer

Every leaf is a conflict. The miter is unsatisfiable and its outputs depend on all inputs. So a conflict appears exactly when all 2n2n inputs are assigned, at a leaf of the binary tree over the inputs.

What gets learned at a leaf. The decision scheme resolves away every implied literal. So the learned clause consists of the negations of the decisions on the path to that leaf. An input that was flipped earlier is not a decision any more: it was implied by an earlier learned clause, and it is resolved away too.

So the clause at a leaf has one literal for each input that still carries its first-tried value.

The search visits every leaf once. After each conflict the clause is unit one level up, so the last decision flips. The run is a depth-first traversal of the complete tree with 22n=4n2^{2n} = 4^n leaves, one conflict per leaf.

Counting.

  • The leaves where exactly kk of the 2n2n inputs carry their first-tried value number (2nk)\binom{2n}{k}.
  • The leaf with k=0k = 0 (every input flipped) is the final conflict at level 0, which gives UNSAT and is not learned.
  • So there are (2nk)\binom{2n}{k} learned clauses of length kk for k=1,…,2nk = 1, \dots, 2n. For n=5n = 5 that is 10, 45, 120, 210, 252, …, as script 02 prints.
  • In total there are 4n−14^n - 1 learned clauses and 4n4^n conflicts.

12. (programming) Add Glucose-style dynamic restarts to CDCLSolver. Restart when the average LBD of the last 50 learned clauses exceeds 1.25 times the average over the whole run. Compare it with Luby on script 03’s six families, and on the 20-queens seeds.

Answer sketch
  1. Keep a deque of the last 50 LBDs and a running sum of all LBDs.
  2. After each conflict, if the deque is full and mean(deque) * 0.8 > total_mean, restart and clear the deque.
  3. Expect fewer restarts on UNSAT instances: the idea of Audemard and Simon (2012) is to restart only when the recent clauses are worse than usual.
  4. Report conflicts as in §8. With six instances, report the numbers, not a verdict.

14. Further reading

  • J. Marques-Silva, I. Lynce, S. Malik, “Conflict-Driven Clause Learning SAT Solvers”, Chapter 4 of the Handbook of Satisfiability (2nd ed., 2021). The standard reference for everything in §4–§8.
  • J. Marques-Silva, K. Sakallah, “GRASP: A Search Algorithm for Propositional Satisfiability”, IEEE Trans. Computers 1999 (conference version 1996). Learning and non-chronological backtracking.
  • M. Moskewicz, C. Madigan, Y. Zhao, L. Zhang, S. Malik, “Chaff: Engineering an Efficient SAT Solver”, DAC 2001. Watched literals and VSIDS.
  • L. Zhang, C. Madigan, M. Moskewicz, S. Malik, “Efficient Conflict Driven Learning in a Boolean Satisfiability Solver”, ICCAD 2001. Learning schemes compared; first UIP.
  • N. Eén, N. Sörensson, “An Extensible SAT-solver” (MiniSat), SAT 2003. The architecture our solver follows.
  • R. Nieuwenhuis, A. Oliveras, C. Tinelli, “Solving SAT and SAT Modulo Theories: From an Abstract Davis–Putnam–Logemann–Loveland Procedure to DPLL(T)”, JACM 2006. The abstract transition-system view.
  • C. Gomes, B. Selman, H. Kautz, “Boosting Combinatorial Search Through Randomization”, AAAI 1998. Heavy tails and restarts.
  • G. Audemard, L. Simon, “Predicting Learnt Clauses Quality in Modern SAT Solvers”, IJCAI 2009. LBD and Glucose.
  • K. Pipatsrisawat, A. Darwiche, “A Lightweight Component Caching Scheme for Satisfiability Solvers”, SAT 2007 (phase saving); and “On the Power of Clause-Learning SAT Solvers as Resolution Engines”, Artificial Intelligence 2011.
  • N. Wetzler, M. Heule, W. Hunt, “DRAT-trim: Efficient Checking and Trimming Using Expressive Clausal Proofs”, SAT 2014.
  • A. Nadel, V. Ryvchin, “Chronological Backtracking”, SAT 2018. When backjumping is not better (cited by the slides).

15. Next lecture

Lecture 6, First-order logic: syntax. Propositional logic cannot say “every adder of any width is correct” or “for all xx, x+0=xx + 0 = x”. First-order logic adds:

  • objects, through terms built from constants and functions;
  • relations between them, through predicates;
  • quantifiers over them.

We build fol.py: signatures, terms, formulas, free and bound variables, and the subtle operation every prover depends on, capture-avoiding substitution.

The SAT solver of this lecture comes back in Lecture 9 (model checking), in Lecture 10, where it becomes the engine of an SMT solver, and in every application lecture after that.

← 返回课程目录