Fachgebiet RechnerSysteme Technische Universität Verification Technology Darmstadt 3. Satisfiability Checking Computer Systems Lab 1 3. Satisfiability Checking 3 3. Satisfiability Checking 3.1 SAT-Checking Procedures Verification Technology Satisfiability (SAT): Content Content A Boolean function f is satisfiable, if there exists an A Boolean function f is satisfiable, if there exists an assignment A of Boolean constants to variables so that f = 1 3.1 Satisfiability-(SAT)-Checking — Example: f = xy + xz + r 3.2 Variants of SAT-Checking is satisfied by the assignment A: (x = 1, y = 0) Boolean functions are tautologies ( = 1), are satisfiable (SAT), or are unsatisfiable (UNSAT, = 0) SAT checker Rather than to demonstrate the tautology f = 1, show that f is unsatisfiable f a b a b 1 ? f ( a b a b ) a b ( a b ) 3. Satisfiability Checking 2 3. Satisfiability Checking 4 3.1 SAT-checking procedures — Statement x y = 1 and original circuit in SAT checkers work on conjunctive normal forms (cnf's) combination: — Example: (a + b + c)·(b + c + d)·(a + d) The sum-terms are called (or)-clauses ( ) Satisfying a cnf means that all clauses have to be satisfied ! a x & For a tautology, the b output must always be 1 y 1 1 This output must Implication always be 0 circuit (unsatisfiable)!
Fachgebiet RechnerSysteme Technische Universität Verification Technology Darmstadt 3. Satisfiability Checking 5 3. Satisfiability Checking 7 3.1 SAT-checking procedures 3.1 Satisfiability checking 3.1 SAT-checking procedures Example: Resolution (Davis/Putnam 1960) Idea: (a + c)(b + c)(a + b)(a + c)(a + c) — Assume that there are two clauses with opposing pp g b: (a + c)(c + a)(a + c)(a + c) b ( + )( + )( + )( + ) values of some variable x, e.g., (x + a)(x + b) a: cc — We have generally (x + a)(x + b) = (x + a)(x + b)(a + b) — Selecting x as a decision variable, we will delete c: 0 (x + a) and (x + b) from our set of clauses and will continue with ( (a + b) b) (a + b)=0 will also make (x + a)(x + b)=0 Systematic application to all variables Unsatisfiability: 0 can be derived 3. Satisfiability Checking 6 3. Satisfiability Checking 8 3.1 SAT-checking procedures 3.1 SAT-checking procedures 3.1 Satisfiability checking A different explanation of the resolution step: Given an assignment A of Boolean constants to variables, each clause is either: In order to prove the unsatisfiability of f, we apply Satisfied (= 1) Boole's expansion theorem to f for some variable x: f f = x*f(0) + x*f(1) *f(0) + *f(1) Unsatisfied (= 0) f = 0 iff f(0)+f(1) = 0 Unresolved (can not be reduced to a constant) Let f be in the form f = Z*(x + a)*(x + b) where Z stands for — Example: (b + e)·(b + c + d)·(a + d) the rest of the cnf. Then f(0) = Z*a and f(1) = Z*b. Thus, unresolved satisfied unsatisfied f(0) + f(1) = Z*(a + b). with the assignment A: (a = 1, b = 1, d = 0) Satisfiability checking of a cnf g: Find an assignment so that all clauses of g are satisfied If this is infeasible then g is equal 0 Problem: how to organize "finding an assignment"?
Fachgebiet RechnerSysteme Technische Universität Verification Technology Darmstadt 3. Satisfiability Checking 9 3. Satisfiability Checking 11 3.1 Satisfiability checking 3.1 SAT-checking procedures 3.1 Satisfiability checking 3.1 SAT-checking procedures — Example: (b + e)·(b + c + d)·(a + d) a 0 1 With the new assignment A: (a = 1, b = 1, d = 1) the first clause remains unresolved c The unresolved clause (b + e) is a unit clause b 1 1 0 0 A unit clause is an unresolved clause which has exactly one unassigned literal (e in the example) c c b b Unit clauses should be used to determine the next 0 1 0 1 0 1 0 1 variable to be assigned a 1 backtrack + d d d d d d d d d d d d d d d d reverse b 1 decision 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 d with b = 1, b + e can 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 clause 0 1 only be satisfied unsatisfied, with e = 1 UNSAT conflicting e assignment 1 3. Satisfiability Checking 10 3. Satisfiability Checking 12 3.1 Satisfiability checking 3.1 SAT-checking procedures 3.1 Satisfiability checking 3.1 SAT-checking procedures Finding an assignment can be organized as a decision tree In the example, a satisfying assignment (Davis/Logemann/Loveland 1962, DLL algorithm) A: (a = 1, b = 1, d = 1, e = 1) was found — Example: (b + e)·(b + c + d)·(a + d) with the assignment A: (a = 1, b = 1, d = 0) ith th i t A ( 1 b 1 d 0) If all branches terminate in conflicting assignments then If ll b h t i t i fli ti i t th the function is unsatisfiable If we arrive at an assignment which results in at least In the worst case, an exponential number of steps has to one unsatisfied clause ( a conflicting assignment) then be executed the last decision has to be reversed and a backtracking step is performed Practically, the selection of decision variables on the a basis of detected unit clauses results in an important 1 backtrack + improvement of efficiency improvement of efficiency reverse b 1 decision d 1 clause 0 1 unsatisfied, conflicting assignment
Fachgebiet RechnerSysteme Technische Universität Verification Technology Darmstadt 3. Satisfiability Checking 13 3. Satisfiability Checking 15 3.1 SAT-checking procedures 3.1 Satisfiability checking 3.1 Satisfiability checking 3.1 SAT-checking procedures GRASP (Silva, Sakallah '95) There are direct and indirect implications of assignments http://portal.acm.org/citation.cfm?id=244560 If a = 0 was decided previously then the decision Systematic investigation of the implications of c = 0@i at a certain decision level i implies d = 1@i at assignments i t the same level i for clause (a + c + d) for satisfiability th l l i f l ( + + d) f ti fi bilit "Learning" d = 1@i has e = 0@i as an indirect implication if we have also clause (d + e) Non-chronological backtracking And so on ... The detection of all implications is called Boolean Constraint Propagation (BCP) 3. Satisfiability Checking 14 3. Satisfiability Checking 16 3.1 Satisfiability checking 3.1 SAT-checking procedures 3.1 Satisfiability checking 3.1 SAT-checking procedures The ordering of decisions is recorded by means of a The implications of a decision are represented by means decision level associated with each decision of an implication graph We refer to a variable assignment at a certain decision Assume n clauses k 1 , ... , k n l level by means of "@", e.g., a = 1@1, b = 1@ 2, etc. l b f "@" 1@1 b 1@ 2 t "Variable assignment va 1 implies variable assignment va 2 due to clause k i " is represented by k i k i d=1@i va 1 va 2 e.g. c=0@i decision a 1 level #1 decision b 1 level #2 decision d level #3 0
Fachgebiet RechnerSysteme Technische Universität Verification Technology Darmstadt 3. Satisfiability Checking 17 3. Satisfiability Checking 19 3.1 SAT-checking procedures 3.1 Satisfiability checking 3.1 Satisfiability checking 3.1 SAT-checking procedures Example: We now know that the assignment a = 0@1, b = 0@2, c = 0 0 0@5 leads to a conflict resulting in a backtracking step c = 1 (c + d)(d + e)(e + c + f + b)(d + a + f)... If the procedure makes the same decision later in the k 1 k 2 k 3 k 4 1 2 3 4 graph then the complex detection of all implications has h th th l d t ti f ll i li ti h Assume the following previous decisions: to be repeated a = 0@1, b = 0@2, ... @3, ... @4 Now assume the decision c = 0@5 at level 5. The implication graph becomes: (c + d)(d + e)(e + c + f + b)(d + a + f)... a = 0@1 k 4 k 4 f = 0@5 f = 0@5 decision decision k 4 a d = 0@5 0 level #1 k 1 k 2 decision b c = 0@5 0 e = 1@5 conflict! level #2 ... k 3 k 3 decision c c decision level #5 k 3 0 level #i b = 0@2 f = 1@5 0 3. Satisfiability Checking 18 3. Satisfiability Checking 20 3.1 Satisfiability checking 3.1 SAT-checking procedures 3.1 SAT-checking procedures 3.1 Satisfiability checking We may also view this procedure as a resolution step We now know that the assignment a = 0@1, b = 0@2, c = after a partial variable assignment. 0@5 leads to a conflict resulting in a backtracking step c = 1 If the procedure makes the same decision later in the — In the example we have with the partial variable assignment a=b=c=0: i t b 0 graph then the complex detection of all implications has h th th l d t ti f ll i li ti h to be repeated (c + d)(d + e)(e + c + f + b)(d + a + f)... = It is possible to "learn" the conflicting assignment by adding the clause (a + b + c): d(d + e)(e + f)(d + f)… (c + d)(d + e)(e + c + f + b)(d + a + f)(a + b + c)... d: d: e(e f)f… e(e + f)f… decision decision a 0 level #1 enforces e: ff c=1 for a=0 decision b 0 and b=0 level #2 ... decision decision c c level #5 0 level #i 0
Recommend
More recommend