Encoding Applications into SAT Marijn J.H. Heule Warren A. Hunt Jr. - - PowerPoint PPT Presentation

encoding applications into sat
SMART_READER_LITE
LIVE PREVIEW

Encoding Applications into SAT Marijn J.H. Heule Warren A. Hunt Jr. - - PowerPoint PPT Presentation

Encoding Applications into SAT Marijn J.H. Heule Warren A. Hunt Jr. The University of Texas at Austin Heule & Hunt (UT Austin) Encoding Applications into SAT 1 / 34 Introduction Dress Code as Satisability Problem Propositional logic:


slide-1
SLIDE 1

Encoding Applications into SAT

Marijn J.H. Heule Warren A. Hunt Jr. The University of Texas at Austin

Heule & Hunt (UT Austin) Encoding Applications into SAT 1 / 34

slide-2
SLIDE 2

Introduction

Dress Code as Satisability Problem

Propositional logic: Boolean variables : tie and shirt negation : ¬ (not) disjunction ∨ disjunction (or) conjunction ∧ conjunction (and) Three conditions / clauses: clearly one should not wear a tie without a shirt ¬tie ∨ shirt not wearing a tie nor a shirt is impolite tie ∨ shirt wearing a tie and a shirt is overkill ¬(tie ∧ shirt) ≡ ¬tie ∨ ¬shirt Is the formula (¬tie ∨ shirt) ∧ (tie ∨ shirt) ∧ (¬tie ∨ ¬shirt) satisable?

Heule & Hunt (UT Austin) Encoding Applications into SAT 2 / 34

slide-3
SLIDE 3

Introduction

Overview Encoding common constraints Applications: Equivalence checking

Hardware and software optimization

Bounded model checking

Hardware and software verification

Arithmetic operations

Factorization, term rewriting

Graph coloring

Sudoku, timetabling

Heule & Hunt (UT Austin) Encoding Applications into SAT 3 / 34

slide-4
SLIDE 4

Common Constraints

Common Constraints

Heule & Hunt (UT Austin) Encoding Applications into SAT 4 / 34

slide-5
SLIDE 5

Common Constraints

AtLeastOne Given a set of Boolean variables x1, . . ., xn, how to encode AtLeastOne (x1, . . ., xn) into SAT? Hint: This is easy...

Heule & Hunt (UT Austin) Encoding Applications into SAT 5 / 34

slide-6
SLIDE 6

Common Constraints

AtLeastOne Given a set of Boolean variables x1, . . ., xn, how to encode AtLeastOne (x1, . . ., xn) into SAT? Hint: This is easy... (x1 ∨ x2 ∨ · · · ∨ xn)

Heule & Hunt (UT Austin) Encoding Applications into SAT 5 / 34

slide-7
SLIDE 7

Common Constraints

AtMostOne (1) Given a set of Boolean variables x1, . . ., xn, how to encode AtMostOne (x1, . . . , xn) into SAT?

Heule & Hunt (UT Austin) Encoding Applications into SAT 6 / 34

slide-8
SLIDE 8

Common Constraints

AtMostOne (1) Given a set of Boolean variables x1, . . ., xn, how to encode AtMostOne (x1, . . . , xn) into SAT? The direct encoding requires n(n − 1)/2 binary clauses:

  • 1≤i<j≤n

(¬xi ∨ ¬xj)

Heule & Hunt (UT Austin) Encoding Applications into SAT 6 / 34

slide-9
SLIDE 9

Common Constraints

AtMostOne (1) Given a set of Boolean variables x1, . . ., xn, how to encode AtMostOne (x1, . . . , xn) into SAT? The direct encoding requires n(n − 1)/2 binary clauses:

  • 1≤i<j≤n

(¬xi ∨ ¬xj) Is it possible to use fewer clauses?

Heule & Hunt (UT Austin) Encoding Applications into SAT 6 / 34

slide-10
SLIDE 10

Common Constraints

AtMostOne (2) Given a set of Boolean variables x1, . . ., xn, how to encode

AtMostOne (x1, . . . , xn)

into SAT using a linear number of binary clauses?

Heule & Hunt (UT Austin) Encoding Applications into SAT 7 / 34

slide-11
SLIDE 11

Common Constraints

AtMostOne (2) Given a set of Boolean variables x1, . . ., xn, how to encode

AtMostOne (x1, . . . , xn)

into SAT using a linear number of binary clauses? By splitting the constraint using additional variables. Apply the direct encoding if n ≤ 4 otherwise replace

AtMostOne (x1, . . . , xn) by AtMostOne (x1, x2, x3, y) ∧ AtMostOne (¬y, x4, . . . , xn)

resulting in 3n − 6 clauses and (n − 3)/2 new variables

Heule & Hunt (UT Austin) Encoding Applications into SAT 7 / 34

slide-12
SLIDE 12

Common Constraints

Exclusive OR Given a set of Boolean variables x1, . . ., xn, how to encode XOR (x1, . . . , xn) into SAT?

Heule & Hunt (UT Austin) Encoding Applications into SAT 8 / 34

slide-13
SLIDE 13

Common Constraints

Exclusive OR Given a set of Boolean variables x1, . . ., xn, how to encode XOR (x1, . . . , xn) into SAT? The direct encoding requires 2n−1 clauses of length n:

  • even #¬

((¬)x1 ∨ (¬)x2 ∨ · · · ∨ (¬)xn)

Heule & Hunt (UT Austin) Encoding Applications into SAT 8 / 34

slide-14
SLIDE 14

Common Constraints

Exclusive OR Given a set of Boolean variables x1, . . ., xn, how to encode XOR (x1, . . . , xn) into SAT? The direct encoding requires 2n−1 clauses of length n:

  • even #¬

((¬)x1 ∨ (¬)x2 ∨ · · · ∨ (¬)xn) Make it compact: XOR (x1, x2, y) ∧ XOR (¯ y, x3, . . . , xn)

Heule & Hunt (UT Austin) Encoding Applications into SAT 8 / 34

slide-15
SLIDE 15

Applications

Applications

Heule & Hunt (UT Austin) Encoding Applications into SAT 9 / 34

slide-16
SLIDE 16

Equivalence Checking

Equivalence checking introduction Given two formulae, are they equivalent? Applications: Hardware and software optimization Software to FPGA conversion

Heule & Hunt (UT Austin) Encoding Applications into SAT 10 / 34

slide-17
SLIDE 17

Equivalence Checking

Equivalence checking example

  • riginal C code

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

Heule & Hunt (UT Austin) Encoding Applications into SAT 11 / 34

slide-18
SLIDE 18

Equivalence Checking

Equivalence checking example

  • riginal C code

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

Heule & Hunt (UT Austin) Encoding Applications into SAT 11 / 34

slide-19
SLIDE 19

Equivalence Checking

Equivalence checking example

  • riginal C code

if(!a && !b) h(); else if(!a) g(); else f(); ⇓ if(!a) { if(!b) h(); else g(); } else f(); ⇒ if(a) f(); else { if(!b) h(); else g(); }

Heule & Hunt (UT Austin) Encoding Applications into SAT 11 / 34

slide-20
SLIDE 20

Equivalence Checking

Equivalence checking example

  • riginal C code

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

  • ptimized C code

if(a) f(); else if(b) g(); else h(); ⇓ ⇑ if(!a) { if(!b) h(); else g(); } else f(); ⇒ if(a) f(); else { if(!b) h(); else g(); }

Heule & Hunt (UT Austin) Encoding Applications into SAT 11 / 34

slide-21
SLIDE 21

Equivalence Checking

Equivalence checking example

  • riginal C code

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

  • ptimized C code

if(a) f(); else if(b) g(); else h(); ⇓ ⇑ if(!a) { if(!b) h(); else g(); } else f(); ⇒ if(a) f(); else { if(!b) h(); else g(); } How to check that these two versions are equivalent?

Heule & Hunt (UT Austin) Encoding Applications into SAT 11 / 34

slide-22
SLIDE 22

Equivalence Checking

Equivalence checking encoding (1)

  • 1. represent procedures as independent Boolean variables
  • riginal C code :=

if ¬a ∧ ¬b then h else if ¬a then g else f

  • ptimized C code :=

if a then f else if b then g else h

Heule & Hunt (UT Austin) Encoding Applications into SAT 12 / 34

slide-23
SLIDE 23

Equivalence Checking

Equivalence checking encoding (1)

  • 1. represent procedures as independent Boolean variables
  • riginal C code :=

if ¬a ∧ ¬b then h else if ¬a then g else f

  • ptimized C code :=

if a then f else if b then g else h

  • 2. compile if-then-else into Conjunctive Normal Form

compile(if x then y else z) ≡ (¬x ∨ y) ∧ (x ∨ z)

Heule & Hunt (UT Austin) Encoding Applications into SAT 12 / 34

slide-24
SLIDE 24

Equivalence Checking

Equivalence checking encoding (1)

  • 1. represent procedures as independent Boolean variables
  • riginal C code :=

if ¬a ∧ ¬b then h else if ¬a then g else f

  • ptimized C code :=

if a then f else if b then g else h

  • 2. compile if-then-else into Conjunctive Normal Form

compile(if x then y else z) ≡ (¬x ∨ y) ∧ (x ∨ z)

  • 3. check equivalence of Boolean formulae

compile(original C code) ⇔ compile(optimized C code)

Heule & Hunt (UT Austin) Encoding Applications into SAT 12 / 34

slide-25
SLIDE 25

Equivalence Checking

Equivalence checking encoding (2) compile(original C code):

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 ))

Heule & Hunt (UT Austin) Encoding Applications into SAT 13 / 34

slide-26
SLIDE 26

Equivalence Checking

Equivalence checking encoding (2) compile(original C code):

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 ))

compile(optimized C code):

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))

Heule & Hunt (UT Austin) Encoding Applications into SAT 13 / 34

slide-27
SLIDE 27

Equivalence Checking

Equivalence checking encoding (2) compile(original C code):

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 ))

compile(optimized C code):

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))

Heule & Hunt (UT Austin) Encoding Applications into SAT 13 / 34

slide-28
SLIDE 28

Equivalence Checking

Checking (in)equivalence

Reformulate it as a satisfiability (SAT) problem: Is there an assignment to a, b, f , g, and h, which results in different evaluations of the compiled codes?

Heule & Hunt (UT Austin) Encoding Applications into SAT 14 / 34

slide-29
SLIDE 29

Equivalence Checking

Checking (in)equivalence

Reformulate it as a satisfiability (SAT) problem: Is there an assignment to a, b, f , g, and h, which results in different evaluations of the compiled codes?

  • r equivalently:

Is the Boolean formula compile(original C code) compile(optimized C code) satisfiable? Such an assignment would provide a counterexample

Heule & Hunt (UT Austin) Encoding Applications into SAT 14 / 34

slide-30
SLIDE 30

Equivalence Checking

Checking (in)equivalence

Reformulate it as a satisfiability (SAT) problem: Is there an assignment to a, b, f , g, and h, which results in different evaluations of the compiled codes?

  • r equivalently:

Is the Boolean formula compile(original C code) compile(optimized C code) satisfiable? Such an assignment would provide a counterexample Note: by concentrating on counterexamples we moved from Co-NP to NP (not really important for applications)

Heule & Hunt (UT Austin) Encoding Applications into SAT 14 / 34

slide-31
SLIDE 31

Bounded Model Checking

Bounded Model Checking (BMC) Given a property p: (e.g. signal a = signal b)

Heule & Hunt (UT Austin) Encoding Applications into SAT 15 / 34

slide-32
SLIDE 32

Bounded Model Checking

Bounded Model Checking (BMC) Given a property p: (e.g. signal a = signal b) Is there a state reachable in k cycles, which satisfies ¬p? S0 S1 S2 S3 Sk−1 Sk p p p p ¬p p

Heule & Hunt (UT Austin) Encoding Applications into SAT 15 / 34

slide-33
SLIDE 33

Bounded Model Checking

Bounded Model Checking (BMC) Given a property p: (e.g. signal a = signal b) Is there a state reachable in k cycles, which satisfies ¬p? S0 S1 S2 S3 Sk−1 Sk p p p p ¬p p Turing award 2007 for Model Checking Edmund M. Clarke, E. Allen Emerson and Joseph Sifakis

Heule & Hunt (UT Austin) Encoding Applications into SAT 15 / 34

slide-34
SLIDE 34

Bounded Model Checking

BMC Encoding (1) The reachable states in k steps are captured by: I(S0) ∧ T(S0, S1) ∧ · · · ∧ T(Sk−1, Sk) The property p fails in one of the k steps by: ¬P(S0) ∨ ¬P(S1) ∨ · · · ∨ ¬P(Sk)

Heule & Hunt (UT Austin) Encoding Applications into SAT 16 / 34

slide-35
SLIDE 35

Bounded Model Checking

BMC Encoding (2)

The safety property p is valid up to step k if and only if F(k) is unsatisfiable: F(k) = I(S0) ∧

k−1

  • i=0

T(Si, Si+1)) ∧

k

  • i=0

¬P(Si)

S0 S1 S2 S3 Sk−1 Sk p p p p ¬p p

Heule & Hunt (UT Austin) Encoding Applications into SAT 17 / 34

slide-36
SLIDE 36

Bounded Model Checking

Bounded model checking Example

Two bit counter 00 01 10 11 Initial state I: l0 = 0, r0 = 0 Transition T: li+1 = li ⊕ ri, ri+1 = ¬ri Property P: ¬li ∨ ¬ri

Heule & Hunt (UT Austin) Encoding Applications into SAT 18 / 34

slide-37
SLIDE 37

Bounded Model Checking

Bounded model checking Example

Two bit counter 00 01 10 11 Initial state I: l0 = 0, r0 = 0 Transition T: li+1 = li ⊕ ri, ri+1 = ¬ri Property P: ¬li ∨ ¬ri F(2) = (¬l0 ∧ ¬r0) ∧ l1 = l0 ⊕ r0 ∧ r1 = ¬r0 ∧ l2 = l1 ⊕ r1 ∧ r2 = ¬r1

  (¬l0 ∨ ¬r0) ∧ (¬l1 ∨ ¬r1) ∧ (¬l2 ∨ ¬r2)  

Heule & Hunt (UT Austin) Encoding Applications into SAT 18 / 34

slide-38
SLIDE 38

Bounded Model Checking

Bounded model checking Example

Two bit counter 00 01 10 11 Initial state I: l0 = 0, r0 = 0 Transition T: li+1 = li ⊕ ri, ri+1 = ¬ri Property P: ¬li ∨ ¬ri F(2) = (¬l0 ∧ ¬r0) ∧ l1 = l0 ⊕ r0 ∧ r1 = ¬r0 ∧ l2 = l1 ⊕ r1 ∧ r2 = ¬r1

  (¬l0 ∨ ¬r0) ∧ (¬l1 ∨ ¬r1) ∧ (¬l2 ∨ ¬r2)   For k = 2, F(k) is unsatisfiable; for k = 3 it is satisfiable

Heule & Hunt (UT Austin) Encoding Applications into SAT 18 / 34

slide-39
SLIDE 39

Arithmetic Operations

Arithmetic operations: Introduction How to encode arithmetic operations into SAT?

Heule & Hunt (UT Austin) Encoding Applications into SAT 19 / 34

slide-40
SLIDE 40

Arithmetic Operations

Arithmetic operations: Introduction How to encode arithmetic operations into SAT? Efficient encoding using electronic circuits

Heule & Hunt (UT Austin) Encoding Applications into SAT 19 / 34

slide-41
SLIDE 41

Arithmetic Operations

Arithmetic operations: Introduction How to encode arithmetic operations into SAT? Efficient encoding using electronic circuits Applications: factorization (not competitive) term rewriting

Heule & Hunt (UT Austin) Encoding Applications into SAT 19 / 34

slide-42
SLIDE 42

Arithmetic Operations

4x4 Multiplier circuit

Heule & Hunt (UT Austin) Encoding Applications into SAT 20 / 34

slide-43
SLIDE 43

Arithmetic Operations

Multiplier encoding

  • 1. Multiplication mi,j = xi × yj = And (xi, yj)

(mi,j ∨ ¬xi ∨ ¬yj) ∧ (¬mi,j ∨ xi) ∧ (¬mi,j ∨ yj)

Heule & Hunt (UT Austin) Encoding Applications into SAT 21 / 34

slide-44
SLIDE 44

Arithmetic Operations

Multiplier encoding

  • 1. Multiplication mi,j = xi × yj = And (xi, yj)

(mi,j ∨ ¬xi ∨ ¬yj) ∧ (¬mi,j ∨ xi) ∧ (¬mi,j ∨ yj)

  • 2. Carry out cout = 1 if and only if pin + mi,j + cin > 1

(cout ∨ ¬pin ∨ ¬mi,j) ∧ (cout ∨ ¬pin ∨ ¬cin) ∧ (cout ∨ ¬mi,j ∨ ¬cin) ∧ (¬cout ∨ pin ∨ mi,j) ∧ (¬cout ∨ pin ∨cin) ∧ (¬cout ∨ mi,j ∨ cin)

Heule & Hunt (UT Austin) Encoding Applications into SAT 21 / 34

slide-45
SLIDE 45

Arithmetic Operations

Multiplier encoding

  • 1. Multiplication mi,j = xi × yj = And (xi, yj)

(mi,j ∨ ¬xi ∨ ¬yj) ∧ (¬mi,j ∨ xi) ∧ (¬mi,j ∨ yj)

  • 2. Carry out cout = 1 if and only if pin + mi,j + cin > 1

(cout ∨ ¬pin ∨ ¬mi,j) ∧ (cout ∨ ¬pin ∨ ¬cin) ∧ (cout ∨ ¬mi,j ∨ ¬cin) ∧ (¬cout ∨ pin ∨ mi,j) ∧ (¬cout ∨ pin ∨cin) ∧ (¬cout ∨ mi,j ∨ cin)

  • 3. Parity out pout of variables pin, mi,j and cin

(pout ∨ ¬pin ∨ ¬mi,j ∨ ¬cin) ∧ (¬pout ∨ pin ∨ ¬mi,j ∨ ¬cin) ∧ (¬pout ∨ ¬pin ∨ mi,j ∨ ¬cin) ∧ (¬pout ∨ ¬pin ∨ ¬mi,j ∨ cin) ∧ (pout ∨ pin ∨ mi,j ∨ ¬cin) ∧ (pout ∨ pin ∨ ¬mi,j ∨ cin) ∧ (pout ∨ ¬pin ∨ mi,j ∨ cin) ∧ (¬pout ∨ pin ∨ mi,j ∨ cin)

Heule & Hunt (UT Austin) Encoding Applications into SAT 21 / 34

slide-46
SLIDE 46

Arithmetic Operations

Arithmetic operations: Is 27 prime?

x3 x2 x1 x0

x3y0 x2y0 x1y0 x0y0 y0 x3y1 x2y1 x1y1 x0y1

y1

x3y2 x2y2 x1y2 x0y2

y2

x3y3 x2y3 x1y3 x0y3

y3

1 1 1 1

Heule & Hunt (UT Austin) Encoding Applications into SAT 22 / 34

slide-47
SLIDE 47

Arithmetic Operations

Arithmetic operations: Is 27 prime?

x3 x2 x1 x0

x3y0 x2y0 x1y0 x0y0 y0 x3y1 x2y1 x1y1 x0y1

y1

x3y2 x2y2 x1y2 x0y2

y2

x3y3 x2y3 x1y3 x0y3

y3

1 1 1 1 Prime: (x1 ∨ x2 ∨ x3) ∧ (y1 ∨ y2 ∨ y3)

Heule & Hunt (UT Austin) Encoding Applications into SAT 22 / 34

slide-48
SLIDE 48

Arithmetic Operations

Arithmetic operations: Is 27 prime?

x3 x2 x1 x0

x3y0 x2y0 x1y0 x0y0 y0 x3y1 x2y1 x1y1 x0y1

y1

x3y2 x2y2 x1y2 x0y2

y2

x3y3 x2y3 x1y3 x0y3

y3

1 1 1 1 Prime: (x1 ∨ x2 ∨ x3) ∧ (y1 ∨ y2 ∨ y3)

Heule & Hunt (UT Austin) Encoding Applications into SAT 22 / 34

slide-49
SLIDE 49

Arithmetic Operations

Arithmetic operations: Is 29 prime?

x3 x2 x1 x0

x3y0 x2y0 x1y0 x0y0 y0 x3y1 x2y1 x1y1 x0y1

y1

x3y2 x2y2 x1y2 x0y2

y2

x3y3 x2y3 x1y3 x0y3

y3

1 1 1 1 Prime: (x1 ∨ x2 ∨ x3) ∧ (y1 ∨ y2 ∨ y3)

Heule & Hunt (UT Austin) Encoding Applications into SAT 23 / 34

slide-50
SLIDE 50

Arithmetic Operations

Arithmetic operations: Is 29 prime?

x3 x2 x1 x0

x3y0 x2y0 x1y0 x0y0 y0 x3y1 x2y1 x1y1 x0y1

y1

x3y2 x2y2 x1y2 x0y2

y2

x3y3 x2y3 x1y3 x0y3

y3

1 1 1 1 Prime: (x1 ∨ x2 ∨ x3) ∧ (y1 ∨ y2 ∨ y3)

Heule & Hunt (UT Austin) Encoding Applications into SAT 23 / 34

slide-51
SLIDE 51

Arithmetic Operations

Arithmetic operations: Term rewriting

Given a set of rewriting rules, will rewriting always terminate?

Heule & Hunt (UT Austin) Encoding Applications into SAT 24 / 34

slide-52
SLIDE 52

Arithmetic Operations

Arithmetic operations: Term rewriting

Given a set of rewriting rules, will rewriting always terminate? Example set of rules: aa →R bc bb →R ac cc →R ab

Heule & Hunt (UT Austin) Encoding Applications into SAT 24 / 34

slide-53
SLIDE 53

Arithmetic Operations

Arithmetic operations: Term rewriting

Given a set of rewriting rules, will rewriting always terminate? Example set of rules: aa →R bc bb →R ac cc →R ab bbaa →R bbbc →R bacc →R baab →R bbcb →R accb →R aabb →R aaac →R abcc →R abab

Heule & Hunt (UT Austin) Encoding Applications into SAT 24 / 34

slide-54
SLIDE 54

Arithmetic Operations

Arithmetic operations: Term rewriting

Given a set of rewriting rules, will rewriting always terminate? Example set of rules: aa →R bc bb →R ac cc →R ab bbaa →R bbbc →R bacc →R baab →R bbcb →R accb →R aabb →R aaac →R abcc →R abab Strongest rewriting solvers use SAT (e.g. aprove) Example solved by Hofbauer, Waldmann (2006)

Heule & Hunt (UT Austin) Encoding Applications into SAT 24 / 34

slide-55
SLIDE 55

Arithmetic Operations

Arithmetic operations: Term rewriting proof outline

Proof termination of: aa →R bc bb →R ac cc →R ab Proof outline: Interpret a, b, c by linear functions [a], [b], [c] from N4 to N4 Interpret string concatenation by function composition Show that if [uaav] (0, 0, 0, 0) = (x1, x2, x3, x4) and [ubcv] (0, 0, 0, 0) = (y1, y2, y3, y4) then x1 > y1 Similar for bb → ac and cc → ab Hence every rewrite step gives a decrease of x1 ∈ N, so terminates

Heule & Hunt (UT Austin) Encoding Applications into SAT 25 / 34

slide-56
SLIDE 56

Arithmetic Operations

Arithmetic operations: Term rewriting linear functions

The linear functions: [a]( x) =     1 3 2 1 1 1     x +     1 1     [b]( x) =     1 2 2 1 1     x +     2     [c]( x) =     1 1 1 1 2     x +     1 3     Checking decrease properties using linear algebra

Heule & Hunt (UT Austin) Encoding Applications into SAT 26 / 34

slide-57
SLIDE 57

Graph Coloring

Combinatorial problems Encoding is critical when dealing with hard combinatorial problems Problems are (relatively) small but very hard The most compact representation is not necessarily the best performing Mostly based on graph coloring encoding

Heule & Hunt (UT Austin) Encoding Applications into SAT 27 / 34

slide-58
SLIDE 58

Graph Coloring

Graph coloring Given a graph G(V , E), can the vertices be colored with k colors such that for each edge (v, w) ∈ E, the vertices v and w are colored differently. Problem: Many symmetries!!!

Heule & Hunt (UT Austin) Encoding Applications into SAT 28 / 34

slide-59
SLIDE 59

Graph Coloring

Graph coloring encoding

Variables Range Meaning xv,i i ∈ {1, . . . , c} v ∈ {1, . . . , |V |} node v has color i Clauses Range Meaning (xv,1 ∨ xv,2 ∨ · · · ∨ xv,c) v ∈ {1, . . . , |V |} v is colored (¬xv,s ∨ ¬xv,t) s ∈ {1, . . . , c − 1} t ∈ {s + 1, . . . , c} v has at most

  • ne color

(¬xv,i ∨ ¬xw,i) (v, w) ∈ E v and w have a different color ??? ??? breaking symmetry

Heule & Hunt (UT Austin) Encoding Applications into SAT 29 / 34

slide-60
SLIDE 60

Graph Coloring

Sudoku

Heule & Hunt (UT Austin) Encoding Applications into SAT 30 / 34

slide-61
SLIDE 61

Graph Coloring

4x4 Sudoku clauses 2 1 2 1 4

Heule & Hunt (UT Austin) Encoding Applications into SAT 31 / 34

slide-62
SLIDE 62

Graph Coloring

4x4 Sudoku clauses 2 1 2 1 4 (xv,1 ∨ xv,2 ∨ xv,3 ∨ xv,4)

Heule & Hunt (UT Austin) Encoding Applications into SAT 31 / 34

slide-63
SLIDE 63

Graph Coloring

4x4 Sudoku clauses 2 1 2 1 4 (xv,1 ∨ xv,2 ∨ xv,3 ∨ xv,4) (¬xv,i ∨ ¬xw,i)

Heule & Hunt (UT Austin) Encoding Applications into SAT 31 / 34

slide-64
SLIDE 64

Graph Coloring

Timetables (1) Suitable for SAT solving

Heule & Hunt (UT Austin) Encoding Applications into SAT 32 / 34

slide-65
SLIDE 65

Graph Coloring

Timetables (2) Not suitable for SAT solving

Heule & Hunt (UT Austin) Encoding Applications into SAT 33 / 34

slide-66
SLIDE 66

Graph Coloring

Encoding Applications into SAT

Marijn J.H. Heule Warren A. Hunt Jr. The University of Texas at Austin

Heule & Hunt (UT Austin) Encoding Applications into SAT 34 / 34