Conflict-Driven Clause Learning Armin Biere SAT/SMT/AR Summer - - PowerPoint PPT Presentation

conflict driven clause learning
SMART_READER_LITE
LIVE PREVIEW

Conflict-Driven Clause Learning Armin Biere SAT/SMT/AR Summer - - PowerPoint PPT Presentation

Conflict-Driven Clause Learning Armin Biere SAT/SMT/AR Summer School 2019 Lisbon, Portugal July 4, 2019 Dress Code Summer School Speaker as SAT Problem propositional logic: variables tie shirt negation (not) disjunction (or)


slide-1
SLIDE 1

Conflict-Driven Clause Learning

Armin Biere

SAT/SMT/AR Summer School 2019

Lisbon, Portugal

July 4, 2019

slide-2
SLIDE 2

Dress Code Summer School Speaker as SAT Problem

propositional logic: variables tie shirt negation ¬ (not) disjunction ∨ (or) conjunction ∧ (and) clauses (conditions / constraints)

  • 1. clearly one should not wear a tie without a shirt

¬tie∨shirt

  • 2. not wearing a tie nor a shirt is impolite

tie∨shirt

  • 3. wearing a tie and a shirt is overkill

¬(tie∧shirt) ≡ ¬tie∨¬shirt

Is this formula in conjunctive normal form (CNF) satisfiable? (¬tie∨shirt) ∧ (tie∨shirt) ∧ (¬tie∨¬shirt)

slide-3
SLIDE 3
slide-4
SLIDE 4
slide-5
SLIDE 5
slide-6
SLIDE 6
slide-7
SLIDE 7
slide-8
SLIDE 8

What is Practical SAT Solving?

simplifying

encoding

inprocessing

CDCL

search

reencoding

slide-9
SLIDE 9

Equivalence Checking If-Then-Else Chains

  • riginal C code
  • ptimized C code

if(!a && !b) h(); if(a) f(); else if(!a) g(); else if(b) g(); else f(); else h();

⇓ ⇑

if(!a) { if(a) f(); if(!b) h();

else { else g(); if(!b) h();

} else f();

else g(); } How to check that these two versions are equivalent?

slide-10
SLIDE 10

Compilation

  • riginal

≡ if ¬a∧¬b then h else if ¬a then g else f ≡ (¬a∧¬b)∧h ∨ ¬(¬a∧¬b)∧ if ¬a then g else f ≡ (¬a∧¬b)∧h ∨ ¬(¬a∧¬b)∧(¬a∧g ∨ a∧ f)

  • ptimized

≡ if a then f else if b then g else h ≡ a∧ f ∨ ¬a∧ if b then g else h ≡ a∧ f ∨ ¬a∧(b∧g ∨ ¬b∧h) (¬a∧¬b)∧h ∨ ¬(¬a∧¬b)∧(¬a∧g ∨ a∧ f) ⇔ a∧ f ∨ ¬a∧(b∧g ∨ ¬b∧h) satisfying assignment gives counter-example to equivalence

slide-11
SLIDE 11

Tseitin Transformation: Circuit to CNF

c b a w v w u

  • x

y

(x ↔ a∧c) ∧ (y ↔ b∨x) ∧ (u ↔ a∨b) ∧ (v ↔ b∨c) ∧ (w ↔ u∧v) ∧ (o ↔ y⊕w)

  • ∧(x → a)∧(x → c)∧(x ← a∧c)∧ ...
  • ∧(x∨a)∧(x∨c)∧(x∨a∨c)∧ ...
slide-12
SLIDE 12

Tseitin Transformation: Gate Constraints

Negation: x ↔ y ⇔ (x → y)∧(y → x) ⇔ (x∨y)∧(y∨x) Disjunction: x ↔ (y∨z) ⇔ (y → x)∧(z → x)∧(x → (y∨z)) ⇔ (y∨x)∧(z∨x)∧(x∨y∨z) Conjunction: x ↔ (y∧z) ⇔ (x → y)∧(x → z)∧((y∧z) → x) ⇔ (x∨y)∧(x∨z)∧((y∧z)∨x) ⇔ (x∨y)∧(x∨z)∧(y∨z∨x) Equivalence: x ↔ (y ↔ z) ⇔ (x → (y ↔ z))∧((y ↔ z) → x) ⇔ (x → ((y → z)∧(z → y))∧((y ↔ z) → x) ⇔ (x → (y → z))∧(x → (z → y))∧((y ↔ z) → x) ⇔ (x∨y∨z)∧(x∨z∨y)∧((y ↔ z) → x) ⇔ (x∨y∨z)∧(x∨z∨y)∧(((y∧z)∨(y∧z)) → x) ⇔ (x∨y∨z)∧(x∨z∨y)∧((y∧z) → x)∧((y∧z) → x) ⇔ (x∨y∨z)∧(x∨z∨y)∧(y∨z∨x)∧(y∨z∨x)

slide-13
SLIDE 13

Bit-Blasting of Bit-Vector Addition

addition of 4-bit numbers x,y with result s also 4-bit: s = x+y [s3,s2,s1,s0]4 = [x3,x2,x1,x0]4 +[y3,y2,y1,y0]4 [s3, · ]2 = FullAdder(x3,y3,c2) [s2,c2]2 = FullAdder(x2,y2,c1) [s1,c1]2 = FullAdder(x1,y1,c0) [s0,c0]2 = FullAdder(x0,y0,false) where [ s , o ]2 = FullAdder(x,y,i) with s = x xor y xor i

  • =

(x∧y)∨(x∧i)∨(y∧i) = ((x+y+i) ≥ 2)

slide-14
SLIDE 14

Boolector Architecture

Expr

SAT Solver

CNF

  • ptimize

encode SMT BTOR API Expr parse O2 subst norm slice O3 synthesize O1 = bottom up simplification O1 rewrite AIG Vector AIG O3 = normalizing (often non−linear) [default] O2 = global but almost linear Lingeling / PicoSAT / MiniSAT / CaDiCaL

slide-15
SLIDE 15

Intermediate Representations

encoding directly into CNF is hard, so we use intermediate levels:

  • 1. application level
  • 2. bit-precise semantics world-level operations (bit-vectors)
  • 3. bit-level representations such as And-Inverter Graphs (AIGs)
  • 4. conjunctive normal form (CNF)

encoding “logical” constraints is another story

slide-16
SLIDE 16

XOR as AIG

y x negation/sign are edge attributes

not part of node

x xor y ≡ (x∧y)∨(x∧y) ≡ (x∧y)∧(x∧y)

slide-17
SLIDE 17

2 1[1] 4 2[1] 6 1[2] 8 2[2] 10 1[3] 12 2[3] 14 1[0] 16 2[0] 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 O0 O1 O2 O3

ΦΜΞΕΗΗΙς

2 1[1] 4 2[1] 6 1[2] 8 2[2] 10 1[3] 12 2[3] 14 1[4] 16 2[4] 18 1[5] 20 2[5] 22 1[6] 24 2[6] 26 1[7] 28 2[7] 30 1[0] 32 2[0] 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 O0 O1 O2 O3 O4 O5 O6 O7

ΦΜΞΕΗΗΙς

slide-18
SLIDE 18

2 2[0] 4 2[1] 6 2[2] 8 1[0] 10 2[3] 12 1[1] 14 1[2] 16 1[3] 18 1[4] 20 1[5] 22 1[6] 24 1[7] 26 1[8] 28 1[9] 30 1[10] 32 1[11] 34 1[12] 36 1[13] 38 1[14] 40 1[15] 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 156 158 160 162 164 166 168 170 172 174 176 178 180 182 184 186 188 190 192 194 196 198 200 202 204 206 208 210 212 214 216 218 220 222 224 226 228 230 232 234 236 238 240 242 244 246 248 250 252 254 256 258 260 262 264 266 268 270 272 274 276 278 280 282 284 286 288 290 292 294 296 298 300 302 304 306 308 310 312 314 316 318 320 322 324 326 328 330 332 334 336 338 340 342 344 346 348 350 352 354 356 358 360 362 364 O0 O1 O2 O3 O4 O5 O6 O7 O8 O9 O10 O11 O12 O13 O14 O15

bit-vector of length 16 shifted by bit-vector of length 4

slide-19
SLIDE 19 2 1[6] 4 2[7] 6 1[7] 8 2[6] 10 1[5] 12 2[5] 14 1[4] 16 2[4] 18 1[3] 20 2[3] 22 1[2] 24 2[2] 26 1[1] 28 2[1] 30 1[0] 32 2[0] 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 156 158 160 162 164 166 168 170 172 174 176 178 180 182 184 186 188 190 192 194 196 198 200 202 204 206 208 210 212 214 216 218 220 222 224 226 228 230 232 234 236 238 240 242 244 246 248 250 252 254 256 258 260 262 264 266 268 270 272 274 276 278 280 282 284 286 288 290 292 294 296 298 300 302 304 306 308 310 312 314 316 318 320 322 324 326 328 330 332 334 336 338 340 342 344 346 348 350 352 354 356 358 360 362 364 366 368 370 372 374 376 378 380 382 384 386 388 390 392 394 396 398 400 402 404 406 408 410 412 414 416 418 420 422 424 426 428 O0 O1 O2 O3 O4 O5 O6 O7
slide-20
SLIDE 20

Encoding Logical Constraints

Tseitin construction suitable for most kinds of “model constraints” assuming simple operational semantics: encode an interpreter small domains: one-hot encoding large domains: binary encoding harder to encode properties or additional constraints temporal logic / fix-points environment constraints example for fix-points / recursive equations: x = (a∨y), y = (b∨x) has unique least fix-point x = y = (a∨b) and unique largest fix-point x = y = true but unfortunately ... ... only largest fix-point can be (directly) encoded in SAT

  • therwise need stable models / logical programming / ASP
slide-21
SLIDE 21

Example of Logical Constraints: Cardinality Constraints

given a set of literals {l1,...ln} constraint the number of literals assigned to true l1 +···+ln ≥ k

  • r

l1 +···+ln ≤ k

  • r

l1 +···+ln = k combined make up exactly all fully symmetric boolean functions multiple encodings of cardinality constraints na¨ ıve encoding exponential: at-most-one quadratic, at-most-two cubic, etc. quadratic O(k ·n) encoding goes back to Shannon linear O(n) parallel counter encoding [Sinz’05] many variants even for at-most-one constraints for an O(n·logn) encoding see Prestwich’s chapter in Handbook of SAT Pseudo-Boolean constraints (PB) or 0/1 ILP constraints have many encodings too 2·a+b+c+d +2·e ≥ 3

actually used to handle MaxSAT in SAT4J for configuration in Eclipse

slide-22
SLIDE 22

BDD-Based Encoding of Cardinality Constraints

2 ≤ l1 +···l9 ≤ 3

l1 l2 l2 l3 l3 l4 l4 l5 l6 l6 l5 l7 l7 l8 l8 l9 l9 l3 l4 l5 l6 l7 l8 l9 l4 l5 l6 l7 l8 l9 1 1

If-Then-Else gates (MUX) with “then” edge downward, dashed “else” edge to the right

slide-23
SLIDE 23

Tseitin Encoding of If-Then-Else Gate

t x

1

e c

x ↔ (c ? t : e) ⇔ (x → (c → t)) ∧ (x → (¯ c → e)) ∧ (¯ x → (c → ¯ t)) ∧ (¯ x → (¯ c → ¯ e)) ⇔ (¯ x∨ ¯ c∨t) ∧ (¯ x∨c∨e) ∧ (x∨ ¯ c∨ ¯ t) ∧ (x∨c∨ ¯ e) minimal but not arc consistent: if t and e have the same value then x needs to have that too possible additional clauses (¯ t ∧ ¯ e → ¯ x) ≡ (t ∨e∨ ¯ x) (t ∧e → x) ≡ (¯ t ∨ ¯ e∨x) but can be learned or derived through preprocessing (ternary resolution) keeping those clauses redundant is better in practice

slide-24
SLIDE 24

DIMACS Format

$ cat example.cnf c comments start with ’c’ and extend until the end of the line c c variables are encoded as integers: c c ’tie’ becomes ’1’ c ’shirt’ becomes ’2’ c c header ’p cnf <variables> <clauses>’ c p cnf 2 3

  • 1

2 0 c !tie

  • r

shirt 1 2 0 c tie

  • r

shirt

  • 1 -2 0

c !tie

  • r !shirt

$ picosat example.cnf s SATISFIABLE v -1 2 0

slide-25
SLIDE 25

SAT Application Programmatic Interface (API)

incremental usage of SAT solvers add facts such as clauses incrementally call SAT solver and get satisfying assignments

  • ptionally retract facts

retracting facts remove clauses explicitly: complex to implement push / pop: stack like activation, no sharing of learned facts MiniSAT assumptions [E´ enS¨

  • rensson’03]

assumptions unit assumptions: assumed for the next SAT call easy to implement: force SAT solver to decide on assumptions first shares learned clauses across SAT calls IPASIR: Reentrant Incremental SAT API used in the SAT competition / race since 2015 [BalyoBiereIserSinz’16]

slide-26
SLIDE 26

IPASIR Model

slide-27
SLIDE 27

#include "ipasir.h" #include <assert.h> #include <stdio.h> #define ADD(LIT) ipasir_add (solver, LIT) #define PRINT(LIT) \ printf (ipasir_val (solver, LIT) < 0 ? " -" #LIT : " " #LIT) int main () { void * solver = ipasir_init (); enum { tie = 1, shirt = 2 }; ADD (-tie); ADD ( shirt); ADD (0); ADD ( tie); ADD ( shirt); ADD (0); ADD (-tie); ADD (-shirt); ADD (0); int res = ipasir_solve (solver); assert (res == 10); printf ("satisfiable:"); PRINT (shirt); PRINT (tie); printf ("\n"); printf ("assuming now: tie shirt\n"); ipasir_assume (solver, tie); ipasir_assume (solver, shirt); res = ipasir_solve (solver); assert (res == 20); printf ("unsatisfiable, failed:"); if (ipasir_failed (solver, tie)) printf (" tie"); if (ipasir_failed (solver, shirt)) printf (" shirt"); printf ("\n"); ipasir_release (solver); return res; } $ ./example satisfiable: shirt -tie assuming now: tie shirt unsatisfiable, failed: tie

slide-28
SLIDE 28

#include "cadical.hpp" #include <cassert> #include <iostream> using namespace std; #define ADD(LIT) solver.add (LIT) #define PRINT(LIT) \ (solver.val (LIT) < 0 ? " -" #LIT : " " #LIT) int main () { CaDiCaL::Solver solver; solver.set ("quiet", 1); enum { tie = 1, shirt = 2 }; ADD (-tie), ADD ( shirt), ADD (0); ADD ( tie), ADD ( shirt), ADD (0); ADD (-tie), ADD (-shirt), ADD (0); int res = solver.solve (); assert (res == 10); cout << "satisfiable:" << PRINT (shirt) << PRINT (tie) << endl; cout << "assuming now: tie shirt" << endl; solver.assume (tie), solver.assume (shirt); res = solver.solve (); assert (res == 20); cout << "unsatisfiable, failed:"; if (solver.failed (tie)) cout << " tie"; if (solver.failed (shirt)) cout << " shirt"; cout << endl; return res; }

$ ./example satisfiable: shirt -tie assuming now: tie shirt unsatisfiable, failed: tie

slide-29
SLIDE 29

IPASIR Functions

const char * ipasir_signature (); void * ipasir_init (); void ipasir_release (void * solver); void ipasir_add (void * solver, int lit_or_zero); void ipasir_assume (void * solver, int lit); int ipasir_solve (void * solver); int ipasir_val (void * solver, int lit); int ipasir_failed (void * solver, int lit); void ipasir_set_terminate (void * solver, void * state, int (*terminate)(void * state));

slide-30
SLIDE 30

DP / DPLL

dates back to the 50’ies: 1st version DP is resolution based ⇒ preprocessing 2nd version D(P)LL splits space for time ⇒

CDCL

ideas: 1st version: eliminate the two cases of assigning a variable in space or 2nd version: case analysis in time, e.g. try x = 0,1 in turn and recurse most successful SAT solvers are based on variant (CDCL) of the second version works for very large instances recent (≤ 25 years) optimizations: backjumping, learning, UIPs, dynamic splitting heuristics, fast data structures (we will have a look at each of them)

slide-31
SLIDE 31

DP Procedure

forever if F = ⊤ return satisfiable if ⊥ ∈ F return unsatisfiable pick remaining variable x add all resolvents on x remove all clauses with x and ¬x ⇒ Bounded Variable Elimination

slide-32
SLIDE 32

Bounded Variable Elimination

[E´ enBiere-SAT’05] Replace (¯ x∨a)1 (¯ x∨c)4 (¯ x∨b)2 (x∨d)5 (x∨ ¯ a∨ ¯ b)3 by (a∨ ¯ a∨ ¯ b)13 (a∨d)15 (c∨d)45 (b∨ ¯ a∨ ¯ b)23 (b∨d)25 (c∨ ¯ a∨ ¯ b)34 number of clauses not increasing strengthen and remove subsumbed clauses too most important and most effective preproessing we have

Bounded Variable Addition

[MantheyHeuleBiere-HVC’12] Replace (a∨d) (a∨e) (b∨d) (b∨e) (c∨d) (c∨e) by (¯ x∨a) (¯ x∨b) (¯ x∨c) (x∨d) (x∨e) number of clauses has to decrease strictly reencodes for instance naive at-most-one constraint encodings

slide-33
SLIDE 33

D(P)LL Procedure

DPLL(F) F := BCP(F) boolean constraint propagation if F = ⊤ return satisfiable if ⊥ ∈ F return unsatisfiable pick remaining variable x and literal l ∈ {x,¬x} if DPLL(F ∧{l}) returns satisfiable return satisfiable return DPLL(F ∧{¬l}) ⇒

CDCL

slide-34
SLIDE 34

DPLL Example

a clauses

v b v c

a a v b v c a v b v c a v b v c a v b v c a v b v c a v b v c a v b v c b c c c b b a b c b = a = c = 1 1 BCP

decision decision

slide-35
SLIDE 35

Conflict Driven Clause Learning (CDCL)

[MarqueSilvaSakallah’96] first implemented in the context of GRASP SAT solver name given later to distinguish it from DPLL not recursive anymore essential for SMT learning clauses as no-goods notion of implication graph (first) unique implication points

slide-36
SLIDE 36

Conflict Driven Clause Learning (CDCL)

c a v b a v b

learn

a b b = a = c = 1 1 BCP

decision decision

clauses

v b v c

a a v b v c a v b v c

v c

a v b v c a v b v c a v b v c a v b v c

slide-37
SLIDE 37

Conflict Driven Clause Learning (CDCL)

a v b b c b a a b = a = c = 1 clauses

v b v c

a a v b v c a v b v c

v c

a v

v c

a v b v c a v b v c a v b v c

v b

BCP BCP decision a learn

slide-38
SLIDE 38

Conflict Driven Clause Learning (CDCL)

a v b b a a c b a a v b v c b = a = c = 1 clauses

v b v c

a a v b v c a v b v c

v c

a v

v c

a v b v c a v b v c

v b

BCP decision BCP

c

learn

slide-39
SLIDE 39

Conflict Driven Clause Learning (CDCL)

a v b b a a a b = a = c = 1 clauses

v b v c

a a v b v c a v b v c

v c

a v

v c

a v b v c a v b v c

v b

a

BCP BCP

c c BCP b a v b v c learn

empty clause

slide-40
SLIDE 40

Implication Graph

d = 1 @ 1 e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f g = 1 @ 2 h = 1 @ 2 i = 1 @ 2 l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4 s = 1 @ 4 t = 1 @ 4 y = 1 @ 4 = 1 @ 4 x z = 1 @ 4 κ

top−level decision decision decision unit unit conflict decision

slide-41
SLIDE 41

Conflict

d = 1 @ 1 e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f g = 1 @ 2 i = 1 @ 2 l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4 s = 1 @ 4 = 1 @ 4 x

top−level decision decision decision unit unit

= 1 @ 4 = 1 @ 4 y z

conflict

κ h = 1 @ 2 t = 1 @ 4

decision

slide-42
SLIDE 42

Antecedents / Reasons

e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f h = 1 @ 2 i = 1 @ 2 = 1 @ 1 c r = 1 @ 4 y = 1 @ 4 = 1 @ 4 x z = 1 @ 4 κ

top−level decision decision decision unit unit conflict decision

d g s t = 1 @ 2 = 1 @ 1 = 1 @ 4 = 1 @ 4 k = 1 @ 3 = 1 @ 3 l

d ∧g∧s → t ≡ (d ∨g∨s∨t)

slide-43
SLIDE 43

Conflicting Clauses

d = 1 @ 1 e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f g = 1 @ 2 i = 1 @ 2 l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4 s = 1 @ 4 = 1 @ 4 x

top−level decision decision decision unit unit

= 1 @ 4 = 1 @ 4 y z

conflict

κ h = 1 @ 2 t = 1 @ 4

decision

¬(y∧z) ≡ (y∨z)

slide-44
SLIDE 44

Resolving Antecedents 1st Time

d = 1 @ 1 e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f g = 1 @ 2 l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4 s = 1 @ 4 = 1 @ 4 x

top−level decision decision decision unit unit

= 1 @ 4 = 1 @ 4 y z

conflict

κ

decision

h i t = 1 @ 2 = 1 @ 2 = 1 @ 4

(h∨i∨t ∨y) (y∨z)

slide-45
SLIDE 45

Resolving Antecedents 1st Time

d = 1 @ 1 e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f g = 1 @ 2 l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4 s = 1 @ 4 = 1 @ 4 x

top−level decision decision decision unit unit

= 1 @ 4 = 1 @ 4 y z

conflict

κ

decision

h i t = 1 @ 2 = 1 @ 2 = 1 @ 4

(h∨i∨t ∨y) (y∨z) (h∨i∨t ∨z)

slide-46
SLIDE 46

Resolvents = Cuts = Potential Learned Clauses

d = 1 @ 1 e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f g = 1 @ 2 l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4 s = 1 @ 4 = 1 @ 4 x d = 1 @ 1 e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f g = 1 @ 2 l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4 s = 1 @ 4 = 1 @ 4 x

top−level decision decision decision unit unit

= 1 @ 4 = 1 @ 4 y z

conflict

κ

decision

h i t = 1 @ 2 = 1 @ 2 = 1 @ 4

top−level decision decision decision unit unit

= 1 @ 4 = 1 @ 4 y z

conflict

κ

decision

h i t = 1 @ 2 = 1 @ 2 = 1 @ 4

(h∨i∨t ∨y) (y∨z) (h∨i∨t ∨z)

slide-47
SLIDE 47

Potential Learned Clause After 1 Resolution

d = 1 @ 1 e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f g = 1 @ 2 l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4 = 1 @ 4 x

top−level decision decision decision unit unit

z

decision

h i t = 1 @ 2 = 1 @ 2 = 1 @ 4 s = 1 @ 4 = 1 @ 4 = 1 @ 4 κ

conflict

y

(h∨i∨t ∨z)

slide-48
SLIDE 48

Resolving Antecedents 2nd Time

e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4 = 1 @ 4 x

top−level decision decision decision unit unit

z

decision

h i t = 1 @ 2 = 1 @ 2 = 1 @ 4 = 1 @ 4 = 1 @ 4 κ

conflict

y s g d = 1 @ 1 = 1 @ 2 = 1 @ 4

(d ∨g∨s∨t) (h∨i∨t ∨z) (d ∨g∨s∨h∨i∨z)

slide-49
SLIDE 49

Resolving Antecedents 3rd Time

e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4

top−level decision decision decision unit unit

z

decision

h i = 1 @ 2 = 1 @ 2 = 1 @ 4 = 1 @ 4 κ

conflict

y = 1 @ 4 t = 1 @ 4 = 1 @ 2 = 1 @ 1 d g s = 1 @ 4 x (x∨z) (d ∨g∨s∨h∨i∨z) (x∨d ∨g∨s∨h∨i)

slide-50
SLIDE 50

Resolving Antecedents 4th Time

e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4

top−level decision decision decision unit unit decision

h i = 1 @ 2 = 1 @ 2 = 1 @ 4 κ

conflict

y s g d = 1 @ 4 = 1 @ 2 = 1 @ 1 x = 1 @ 4 = 1 @ 4 = 1 @ 4 t z (s∨x) (x∨d ∨g∨s∨h∨i) (d ∨g∨s∨h∨i) self subsuming resolution

slide-51
SLIDE 51

1st UIP Clause after 4 Resolutions

e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4

top−level decision decision decision unit unit decision

h i = 1 @ 2 = 1 @ 2 = 1 @ 4 κ

conflict

y s g d = 1 @ 4 = 1 @ 2 = 1 @ 1 t z = 1 @ 4 x = 1 @ 4 = 1 @ 4

1st UIP

backjump level

(d ∨g∨s∨h∨i) UIP = unique implication point dominates conflict on the last level

slide-52
SLIDE 52

Backjumping

x y x y If y has never been used to derive a conflict, then skip y case. Immediately jump back to the x case – assuming x was used.

slide-53
SLIDE 53

Resolving Antecedents 5th Time

e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f = 1 @ 1 c k = 1 @ 3

top−level decision decision decision unit unit decision

h i = 1 @ 2 = 1 @ 2 = 1 @ 4 κ

conflict

y s g d = 1 @ 4 = 1 @ 2 = 1 @ 1 t z = 1 @ 4 x = 1 @ 4 = 1 @ 4 l = 1 @ 3 = 1 @ 4 r

(l ∨r ∨s) (d ∨g∨s∨h∨i) (l ∨r ∨d ∨g∨h∨i)

slide-54
SLIDE 54

Decision Learned Clause

e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f = 1 @ 1 c

top−level decision decision decision unit unit decision

h i = 1 @ 2 = 1 @ 2 = 1 @ 4 κ

conflict

y g d = 1 @ 2 = 1 @ 1 t z = 1 @ 4 x = 1 @ 4 = 1 @ 4 r = 1 @ 4 = 1 @ 4 s l = 1 @ 3 = 1 @ 3 k

backtrack level

last UIP

(d ∨g∨l ∨r ∨h∨i)

slide-55
SLIDE 55

1st UIP Clause after 4 Resolutions

e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4

top−level decision decision decision unit unit decision

h i = 1 @ 2 = 1 @ 2 = 1 @ 4 κ

conflict

y s g d = 1 @ 4 = 1 @ 2 = 1 @ 1 t z = 1 @ 4 x = 1 @ 4 = 1 @ 4

(d ∨g∨s∨h∨i)

slide-56
SLIDE 56

Locally Minimizing 1st UIP Clause

e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4

top−level decision decision decision unit unit decision

i = 1 @ 2 = 1 @ 4 κ

conflict

y s g d = 1 @ 4 = 1 @ 2 = 1 @ 1 t z = 1 @ 4 x = 1 @ 4 = 1 @ 4 h = 1 @ 2

(h∨i) (d ∨g∨s∨h∨i) (d ∨g∨s∨h) self subsuming resolution

slide-57
SLIDE 57

Locally Minimized Learned Clause

e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4

top−level decision decision decision unit unit decision

= 1 @ 4 κ

conflict

y s g d = 1 @ 4 = 1 @ 2 = 1 @ 1 t z = 1 @ 4 x = 1 @ 4 = 1 @ 4 = 1 @ 2 i = 1 @ 2 h

(d ∨g∨s∨h)

slide-58
SLIDE 58

Minimizing Locally Minimized Learned Clause Further?

e = 1 @ 1 b = 1 @ 0 a = 1 @ 0 = 1 @ 2 f l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4

top−level decision decision decision unit unit decision

= 1 @ 4 κ

conflict

y s g d = 1 @ 4 = 1 @ 2 = 1 @ 1 t z = 1 @ 4 x = 1 @ 4 = 1 @ 4 = 1 @ 2 i

Remove ?

h = 1 @ 2

(d ∨g∨s∨ h)

slide-59
SLIDE 59

Recursively Minimizing Learned Clause

a = 1 @ 0 = 1 @ 2 f l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4

top−level decision decision decision unit decision

= 1 @ 4 κ

conflict

y s g d = 1 @ 4 = 1 @ 2 = 1 @ 1 t z = 1 @ 4 x = 1 @ 4 = 1 @ 4 = 1 @ 2 i = 1 @ 2 h

unit

b e = 1 @ 0 = 1 @ 1

(b) (d ∨b∨e) (e∨g∨h) (d ∨g∨s∨h) (e∨d ∨g∨s) (b∨d ∨g∨s) (d ∨g∨s)

slide-60
SLIDE 60

Recursively Minimized Learned Clause

a = 1 @ 0 = 1 @ 2 f l = 1 @ 3 = 1 @ 1 c k = 1 @ 3 r = 1 @ 4

top−level decision decision decision unit decision

= 1 @ 4 κ

conflict

y s g d = 1 @ 4 = 1 @ 2 = 1 @ 1 t z = 1 @ 4 x = 1 @ 4 = 1 @ 4 = 1 @ 2 i

unit

= 1 @ 2 = 1 @ 1 = 1 @ 0 h e b

(d ∨g∨s)

slide-61
SLIDE 61

Decision Heuristics

number of variable occurrences in (remaining unsatisfied) clauses (LIS) eagerly satisfy many clauses with many variations studied in the 90ies actually expensive to compute dynamic heuristics focus on variables which were usefull recently in deriving learned clauses can be interpreted as reinforcement learning started with the VSIDS heuristic [MoskewiczMadiganZhaoZhangMalik’01] most solvers rely on the exponential variant in MiniSAT (EVSIDS) recently showed VMTF as effective as VSIDS [BiereFr¨

  • hlich-SAT’15] survey

look-ahead spent more time in selecting good variables (and simplification) related to our Cube & Conquer paper [HeuleKullmanWieringaBiere-HVC’11] “The Science of Brute Force” [Heule & Kullman CACM August 2017] EVSIDS during stabilization VMTF otherwise [Biere-SAT-Race-2019]

slide-62
SLIDE 62

Fast VMTF Implementation

Siege SAT solver [Ryan Thesis 2004] used variable move to front (VMTF) bumped variables moved to head of doubly linked list search for unassigned variable starts at head variable selection is an online sorting algorithm of scores classic “move-to-front” strategy achieves good amortized complexity fast simple implementation for caching searches in VMTF [BiereFr¨

  • hlich’SAT15]

doubly linked list does not have positions as an ordered array bump = move-to-front = dequeue then insertion at the head time-stamp list entries with “insertion-time” maintained invariant: all variables right of next-search are assigned requires (constant time) update to next-search while unassigning variables

  • ccassionally (32-bit) time-stamps will overflow:

update all time stamps

slide-63
SLIDE 63

idx: 5 val: x time: 6 idx: 3 val: 1 time: 8 idx: 4 val: 0 time: 9 next−search next−search’

unassign 9

val: 1 time: 12

idx: 9

idx: 7 val: 0 time: 15 idx: 5 val: x time: 6 idx: 3 val: 1 time: 8 val: 0 next−search

bump 4 idx: 4

time: 16 idx: 9 time: 12 val: x idx: 7 time: 15 val: 0

slide-64
SLIDE 64

Variable Scoring Schemes

[BiereFr¨

  • hlich-SAT’15]

s old score s′ new score variable score s′ after i conflicts bumped not-bumped STATIC s s static decision order INC s+1 s increment scores SUM s+i s sum of conflict-indices VSIDS h256

i

·s+1 h256

i

·s

  • riginal implementation in Chaff

NVSIDS f ·s+(1− f) f ·s normalized variant of VSIDS EVSIDS s+gi s exponential MiniSAT dual of NVSIDS ACIDS (s+i)/2 s average conflict-index decision scheme VMTF1 i s variable move-to-front VMTF2 b s variable move-to-front variant 0 < f < 1 g = 1/f hm

i = 0.5

if m divides i hm

i = 1 otherwise

i conflict index b bumped counter

slide-65
SLIDE 65

Basic CDCL Loop

int basic_cdcl_loop () { int res = 0; while (!res) if (unsat) res = 20; else if (!propagate ()) analyze (); // analyze propagated conflict else if (satisfied ()) res = 10; // all variables satisfied else decide (); // otherwise pick next decision return res; }

slide-66
SLIDE 66

Reducing Learned Clauses

keeping all learned clauses slows down BCP kind of quadratically so SATO and RelSAT just kept only “short” clauses better periodically delete “useless” learned clauses keep a certain number of learned clauses “search cache” if this number is reached MiniSAT reduces (deletes) half of the clauses then maximum number kept learned clauses is increased geometrically LBD (glucose level / glue) prediction for usefulness [AudemardSimon-IJCAI’09] LBD = number of decision-levels in the learned clause allows arithmetic increase of number of kept learned clauses keep clauses with small LBD forever ( ≤ 2...5)

slide-67
SLIDE 67

Restarts

  • ften it is a good strategy to abandon what you do and restart

for satisfiable instances the solver may get stuck in the unsatisfiable part for unsatisfiable instances focusing on one part might miss short proofs restart after the number of conflicts reached a restart limit avoid to run into the same dead end by randomization (either on the decision variable or its phase) and/or just keep all the learned clauses during restart for completeness dynamically increase restart limit arithmetically, geometrically, Luby, Inner/Outer Glucose restarts [AudemardSimon-CP’12] short vs. large window exponential moving average (EMA) over LBD if recent LBD values are larger than long time average then restart interleave “stabilizing” (no restarts) and “non-stabilizing” phases [Chanseok Oh]

slide-68
SLIDE 68

Luby’s Restart Intervals

70 restarts in 104448 conflicts

5 10 15 20 25 30 35 10 20 30 40 50 60 70

slide-69
SLIDE 69

Luby Restart Scheduling

unsigned luby (unsigned i) { unsigned k; for (k = 1; k < 32; k++) if (i == (1 << k) - 1) return 1 << (k - 1); for (k = 1;; k++) if ((1 << (k - 1)) <= i && i < (1 << k) - 1) return luby (i - (1 << (k-1)) + 1); } limit = 512 * luby (++restarts); ... // run SAT core loop for ’limit’ conflicts

slide-70
SLIDE 70

Reluctant Doubling Sequence

[Knuth’12] (u1,v1) = (1,1) (un+1,vn+1) = ((un & −un == vn) ? (un +1,1) : (un,2vn)) (1,1), (2,1), (2,2), (3,1), (4,1), (4,2), (4,4), (5,1), ...

slide-71
SLIDE 71

Restart Scheduling with Exponential Moving Averages

[BiereFr¨

  • hlich-POS’15]
  • LBD

— fast EMA of LBD with α = 2−5 | restart — slow EMA of LBD with α = 2−14 (ema-14) | inprocessing — CMA of LBD (average)

slide-72
SLIDE 72

Phase Saving and Rapid Restarts

phase assignment: assign decision variable to 0 or 1? “Only thing that matters in satisfiable instances” [Hans van Maaren] “phase saving” as in RSat [PipatsrisawatDarwiche’07] pick phase of last assignment (if not forced to, do not toggle assignment) initially use statically computed phase (typically LIS) so can be seen to maintain a global full assignment rapid restarts varying restart interval with bursts of restarts not only theoretically avoids local minima works nicely together with phase saving reusing the trail can reduce the cost of restarts [RamosVanDerTakHeule-JSAT’11] target phases of largest conflict free trail / assignment [Biere-SAT-Race-2019]

slide-73
SLIDE 73

CDCL Loop with Reduce and Restart

int basic_cdcl_loop_with_reduce_and_restart () { int res = 0; while (!res) if (unsat) res = 20; else if (!propagate ()) analyze (); // analyze propagated conflict else if (satisfied ()) res = 10; // all variables satisfied else if (restarting ()) restart (); // restart by backtracking else if (reducing ()) reduce (); // collect useless learned clauses else decide (); // otherwise pick next decision return res; }

slide-74
SLIDE 74

Code from our SAT Solver CaDiCaL

new Version 1.0.0 from last Sunday

int Internal::cdcl_loop_with_inprocessing () { int res = 0; while (!res) { if (unsat) res = 20; else if (!propagate ()) analyze (); // propagate and analyze else if (iterating) iterate (); // report learned unit else if (satisfied ()) res = 10; // found model else if (terminating ()) break; // limit hit or async abort else if (restarting ()) restart (); // restart by backtracking else if (rephasing ()) rephase (); // reset variable phases else if (reducing ()) reduce (); // collect useless clauses else if (probing ()) probe (); // failed literal probing else if (subsuming ()) subsume (); // subsumption algorithm else if (eliminating ()) elim (); // variable elimination else if (compacting ()) compact (); // collect variables else res = decide (); // next decision } return res; }

https://github.com/arminbiere/cadical https://fmv.jku.at/cadical

slide-75
SLIDE 75

Two-Watched Literal Schemes

  • riginal idea from SATO

[ZhangStickel’00] invariant: always watch two non-false literals if a watched literal becomes false replace it if no replacement can be found clause is either unit or empty

  • riginal version used head and tail pointers on Tries

improved variant from Chaff [MoskewiczMadiganZhaoZhangMalik’01] watch pointers can move arbitrarily SATO: head forward, tail backward no update needed during backtracking

  • ne watch is enough to ensure correctness

but looses arc consistency reduces visiting clauses by 10x particularly useful for large and many learned clauses blocking literals [ChuHarwoodStuckey’09] special treatment of short clauses (binary [PilarskiHu’02] or ternary [Ryan’04]) cache start of search for replacement [Gent-JAIR’13]

slide-76
SLIDE 76

two papers at

SAT’19

7 - 12 July

Lisbon, Portugal

Incremental Inprocessing in SAT Solving

Katalin Fazekas1(), Armin Biere1, Christoph Scholl2

1 Johannes Kepler University, Linz, Austria

katalin.fazekas@jku.at, armin.biere@jku.at

2 Albert–Ludwigs–University, Freiburg, Germany

scholl@informatik.uni-freiburg.de

  • Abstract. Incremental SAT is about solving a sequence of related SAT

problems efficiently. It makes use of already learned information to avoid repeating redundant work. Also preprocessing and inprocessing are con- sidered to be crucial. Our calculus uses the most general redundancy property and extends existing inprocessing rules to incremental SAT

  • solving. It allows to automatically reverse earlier simplification steps,

which are inconsistent with literals in new incrementally added clauses. Our approach to incremental SAT solving not only simplifies the use of inprocessing but also substantially improves solving time.

1 Introduction

Solving a sequence of related SAT problems incrementally [1–4] is crucial for the efficiency of SAT based model checking [5–8], and important in many do- mains [9–12]. Utilizing the effort already spent on a SAT problem by keeping learned information (such as variable scores and learned clauses) can significantly speed-up solving similar problems. Equally important are formula simplification techniques such as variable elimination, subsumption, self-subsuming resolution, and equivalence reasoning [13–16]. These simplifications are not only applied before the problem solving starts (preprocessing), but also periodically during the actual search (inprocessing) [17]. In this paper we focus on how to efficiently combine simplification techniques with incremental SAT solving. Consider the SAT problem F 0 = (a∨b)∧(¬a∨¬b). Both clauses are redundant and can be eliminated by for instance variable or blocked clause elimination [14, 16]. The resulting empty set of clauses is of course satisfiable and the SAT solver could for example simply just assign false to both variable as a solution. That is of course not a satisfying assignment of F 0, but can be transformed into one by solution reconstruction [17, 18], taking eliminated clauses into account. As we will see later, this would set the truth value of either a or b to true. Now consider the SAT problem F 1 = (a∨b)∧(¬a∨¬b)∧(¬a)∧(¬b) which is actually an extension of F 0 with the clauses (¬a) and (¬b). Simply adding them to our simplified F 0 (i.e. to the empty set of clauses) would result in a formula that again is satisfied by assigning false to each variable. However, using solution reconstruction on that assignment leads to the same solution as before, one that

Backing Backtracking⋆

Sibylle M¨

  • hle and Armin Biere

Johannes Kepler University Linz, Austria

  • Abstract. Non-chronological backtracking was considered an important

and necessary feature of conflict-driven clause learning (CDCL). How- ever, a SAT solver combining CDCL with chronological backtracking suc- ceeded in the main track of the SAT Competition 2018. In that solver, multiple invariants considered crucial for CDCL were violated. In partic- ular, decision levels of literals on the trail were not necessarily increasing

  • anymore. The corresponding paper presented at SAT 2018 described the

algorithm and provided empirical evidence of its correctness, but a for- malization and proofs were missing. Our contribution is to fill this gap. We further generalize the approach, discuss implementation details, and empirically confirm its effectiveness in an independent implementation.

1 Introduction

Most state-of-the-art SAT solvers are based on the CDCL framework [8,9]. The performance gain of SAT solvers achieved in the last two decades is to some extent attributed to combining conflict-driven backjumping and learning. It en- ables the solver to escape regions of the search space with no solution. Non-chronological backtracking during learning enforces the lowest decision level at which the learned clause becomes unit and then is used as a reason. While backtracking to a higher level still enables propagation of a literal in the learned clause, the resulting propagations might conflict with previous assign-

  • ments. Resolving these conflicts introduces additional work which is prevented

by backtracking non-chronologically to the lowest level [15]. However, in some cases a significant amount of the assignments undone is repeated later in the search [10,16], and a need for methods to save redundant work has been identified. Chronological backtracking avoids redundant work by keeping assignments which otherwise would be repeated at a later stage of the search. As our experiments show, satisfiable instances benefit most from chronological backtracking. Thus this technique should probably also be seen as a method to optimize SAT solving for satisfiable instances similar to [2,14]. The combination of chronological backtracking with CDCL is challenging since invariants classically considered crucial to CDCL cease to hold. Nonethe- less, taking appropriate measures preserves the solver’s correctness, and the

⋆ Supported by Austrian Science Fund (FWF) grant S11408-N23 (RiSE) and by the

LIT Secure and Correct Systems Lab funded by the State of Upper Austria.

slide-77
SLIDE 77

Proofs / RUP / DRUP

  • riginal idea for proofs:

proof traces / sequence consisting of “learned clauses” can be checked clause by clause through unit propagation reverse unit implied clauses (RUP) [GoldbergNovikov’03] [VanGelder’12] deletion information (DRUP): trace of added and deleted clauses [HeuleHuntWetzler-FMCAD’13/STVR’14] RUP in SAT competition 2007, 2009, 2011, DRUP since 2013 to certify UNSAT

Blocked Clauses

[Kullman-DAM’99] [J¨ arvisaloHeuleBiere-JAR’12] clause

C

(a∨l) “blocked” on l w.r.t. CNF

F

  • ( ¯

a∨b)∧(l ∨c)∧(¯ l ∨ ¯ a)

D

all resolvents of C on l with clauses D in F are tautological blocked clauses are “redundant” too adding or removing blocked clauses does not change satisfiability status however it might change the set of models

slide-78
SLIDE 78

Resolution Asymmetric Tautologies (RAT)

“Inprocessing Rules” [J¨ arvisaloHeuleBiere-IJCAR’12] justify complex preprocessing algorithms in Lingeling examples are adding blocked clauses or variable elimination interleaved with research (forgetting learned clauses = reduce) need more general notion of redundancy criteria simply replace “resolvents are tautological” by “resolvents on l are RUP” (a∨l) RAT on l w.r.t. ( ¯ a∨b)∧(l ∨c)∧(¯ l ∨b)

D

deletion information is again essential (DRAT) [HeuleHuntWetzler-FMCAD’13/STVR’14] now mandatory in the main track of the SAT competitions since 2013 pretty powerful: can for instance also cover symmetry breaking

slide-79
SLIDE 79

Propagation Redundant (PR)

“Short Proofs Without New Variables” [HeuleKieslBiere-CADE’17]

best paper

more general than RAT: short proofs for pigeon hole formulas without new variables C propagation redundant (PR) if exists assignment ω satisfying C with

F |C ⊢1 F |ω

Satisfaction Driven Clause Learning (SDCL) [HeuleKieslSeidlBiere-HVC’17]

best paper

first automatically generated PR proofs prune paths for which we have other at least as satisfiable paths (filtered) positive reduct in SaDiCaL [HeuleKieslBiere-TACAS’19]

nominated best paper

translate PR to DRAT [HeuleBiere-TACAS’18]

  • nly one additional variable needed

shortest proofs for pigeon hole formulas translate DRAT to extended resolution [KieslRebolaPardoHeule-IJCAR’18]

best paper

slide-80
SLIDE 80

Mutilated Chessboard

[HeuleKieslBiere-NFM’19]

CDCL SDCL

slide-81
SLIDE 81

Parallel SAT

application level parallelism guiding path principle portfolio (with sharing) (concurrent) cube & conquer ⇒ Handbook of Parallel Constraint Reasoning ⇒ still many low-level programming issues left

slide-82
SLIDE 82

Personal SAT Solver History

1980 1960 2000 2010 1970

DPL DP CDCL LBD Phase Tseitin Encoding BMC SAT NP complete Solvers Arithmetic WalkSAT GSAT Handbook of SAT ProbSAT Saving Avatar Inprocessing Cube & Conquer VSIDS SMT Bounded Variable Elimination competition Look Ahead SAT for Planing 1st SAT

1990

Portfolio QBF working Massively Parallel Donald Knuth SAT Chapter everywhere SAT Proofs

*