Satisfiability Checking
Total Page:16
File Type:pdf, Size:1020Kb
Satisfiability Checking Propositional Logic Prof. Dr. Erika Ábrahám RWTH Aachen University Informatik 2 LuFG Theory of Hybrid Systems WS 14/15 Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 1 / 1 Propositional logic The slides are partly taken from: www.decision-procedures.org/slides/ Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 2 / 1 Propositional logic - Outline Syntax of propositional logic Semantics of propositional logic Satisfiability and validity Modeling with propositional logic Normal forms Enumeration and deduction Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 3 / 1 Propositional logic - Outline Syntax of propositional logic Semantics of propositional logic Satisfiability and validity Modeling with propositional logic Normal forms Enumeration and deduction Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 4 / 1 Syntax of propositional logic Abstract syntax of well-formed propositional formulae: ' := a j (:') j (' ^ ') where Prop is a set of (atomic) propositions (Boolean variables) and a 2 Prop. We write PropFormulae for the set of all propositional logic formulae. Syntactic sugar: ? := (a ^ :a) > := (a _:a) ( '1 _ '2 ) := :((:'1) ^ (:'2)) ( '1 ! '2 ) := ((:'1) _ '2) ( '1 $ '2 ) := (('1 ! '2) ^ ('2 ! '1)) L ( '1 '2 ) := ('1 $ (:'2)) Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 5 / 1 Formulae Examples of well-formed formulae: (:a) (:(:a)) (a ^ (b ^ c)) (a ! (b ! c)) We omit parentheses whenever we may restore them through operator precedence: binds stronger : ^ _ ! $ Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 6 / 1 Propositional logic - Outline Syntax of propositional logic Semantics of propositional logic Satisfiability and validity Modeling with propositional logic Normal forms Enumeration and deduction Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 7 / 1 Semantics: Assignments Structures for predicate logic: The domain is B = f0; 1g. The interpretation assigns Boolean values to the variables: α : Prop ! f0; 1g We call these special interpretations assignments and use V to denote the set of all assignments. Example: Prop = fa; bg; α(a) = 0; α(b) = 1 Equivalently, we can see an assignment α as a set of variables (α 2 2Prop), defining the variables from the set to be true and the others false. Example: Prop = fa; bg; α = fbg An assignment can also be seen as being of type α 2 f0; 1gProp, if we have an order on the propositions. Example: Prop = fa; bg; α = 01 Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 8 / 1 Only the projected assignment matters... Let α1; α2 2 V and ' 2 PropFormulae. Let AP(') be the atomic propositions in '. Clearly AP(') ⊆ Prop. Lemma: if α1jAP(') = α2jAP(') , then Projection (α1 satisfies ') iff (α2 satisfies ') We will assume, for simplicity, that Prop = AP('). Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 9 / 1 Semantics I: Truth tables Truth tables define the semantics (=meaning) of the operators. They can be used to define the semantics of formulae inductively over their structure. Convention:0= false,1= true p q :p p ^ q p _ q p ! q p $ q p L q 0 0 1 0 0 1 1 0 0 1 1 0 1 1 0 1 1 0 0 0 1 0 0 1 1 1 0 1 1 1 1 0 Each possible assignment is covered by a line of the truth table. α satisfies ' iff in the line for α and the column for ' the entry is1. Q: How many binary operators can we define that have different semantics? A: 16 Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 10 / 1 Semantics I: Example Let ' be defined as (a _ (b ! c)). Let α : fa; b; cg ! f0; 1g be an assignment with α(a) = 0, α(b) = 0, and α(c) = 1. Q: Does α satisfy '? A1: Compute with truth table: a b c b ! c a _ (b ! c) 0 0 0 1 1 0 0 1 1 1 0 1 0 0 0 0 1 1 1 1 1 0 0 1 1 1 0 1 1 1 1 1 0 0 1 1 1 1 1 1 Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 11 / 1 Semantics II: Satisfaction relation Satisfaction relation: j= ⊆ V × PropFormulae Instead of (α; ') 2 j= we write α j= ' and say that α satisfies ' or ' holds for α or α is a model of '. j= is defined recursively: α j= p iff α(p) = true α j= :' iff α 6 j= ' α j= '1 ^ '2 iff α j= '1 and α j= '2 α j= '1 _ '2 iff α j= '1 or α j= '2 α j= '1 ! '2 iff α j= '1 implies α j= '2 α j= '1 $ '2 iff α j= '1 iff α j= '2 Note: More elegant but semantically equivalent to truth tables. Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 12 / 1 Semantics II: Example Let ' be defined as (a _ (b ! c)). Let α : fa; b; cg ! f0; 1g be an assignment with α(a) = 0, α(b) = 0, and α(c) = 1. Q: Does α satisfy '? A2: Compute with the satisfaction relation: α j= (a _ (b ! c)) iff α j= a or α j= (b ! c) iff α j= a or (α j= b implies α j= c) iff 0 or (0 implies 1) iff 0 or 1 iff 1 Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 13 / 1 Semantics III: The algorithmic view Using the satisfaction relation we can define an algorithm for the problem to decide whether an assignment α : AP ! f0; 1g is a model of a propositional logic formula ' 2 PropFormulae: Eval(α; ') { i f ' ≡ a return α(a) ; i f ' ≡ (:'1) return not Eval(α; '1) ; i f ' ≡ ('1 op '2) return Eval(α; '1) [[op]] Eval(α; '2) ; } Equivalent to the j= relation, but from the algorithmic view. Q: Complexity? A: Polynomial (time and space). Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 14 / 1 Semantics III: Example Recall our example ' =( a _ (b ! c)) α : fa; b; cg ! f0; 1g with α(a) = 0, α(b) = 0, and α(c) = 1. Eval(α; ') = Eval(α; a) or Eval(α; b ! c) = 0 or (Eval(α; b) implies Eval(α; c)) = 0 or (0 implies 1) = 0 or 1 = 1 Hence, α j= '. Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 15 / 1 Satisfying assignments Intuition: each formula specifies a set of assignments satisfying it. Remember: V denotes the set of all assignments. Function sat : PropFormulae ! 2V (a formula ! set of its satisfying assignments) Recursive definition: sat(a) = fα j α(a) = 1g; a 2 Prop sat(:'1) = V n sat('1) sat('1 ^ '2) = sat('1) \ sat('2) sat('1 _ '2) = sat('1) [ sat('2) sat('1 ! '2) = (V n sat('1)) [ sat('2) For ' 2 PropFormulae and α 2 V it holds that α j= ' iff α 2 sat(') Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 16 / 1 Satisfying assignments: Example sat(a _ (b ! c)) = sat(a) [ sat(b ! c) = sat(a) [ ((V n sat(b)) [ sat(c)) = fα 2 V j α(a) = 1g[ fα 2 V j α(b) = 0g[ fα 2 V j α(c) = 1g = fα 2 V j α(a) = 1 or α(b) = 0 or α(c) = 1g Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 17 / 1 Extensions of j= We define j= ⊆ 2V × PropFormulae by T j= ' iff T ⊆ sat(') for formulae ' 2 PropFormulae and assignment sets T ⊆ 2V . Examples: fα 2 V j α(a) = α(c) = 1gj= a _ (b ! c) fα 2 V j α(x1) = 1gj= x1 _ x2 We define j= ⊆ 2PropFormulae × 2PropFormulae by '1 j= '2 iff sat('1) ⊆ sat('2) for formulae '1;'2 2 PropFormulae. Examples: a ^ c j= a _ (b ! c) x1 j= x1 _ x2 Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 18 / 1 Short summary for propositional logic Syntax of propositional formulae ' 2 PropFormulae: ' := prop j (:') j (' ^ ') Semantics: Assignments α 2 V : α : Prop ! f0; 1g α 2 2Prop α 2 f0; 1gProp Satisfaction relation: j= ⊆ V × PropFormulae ; (e.g., α j=' ) V j= ⊆ 2 × PropFormulae ; (e.g., fα1; : : : ; αngj=' ) j= ⊆ PropFormulae × PropFormulae; (e.g., '1 j='2) sat : PropFormulae ! 2V ; (e.g., sat(')) Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 19 / 1 Propositional logic - Outline Syntax of propositional logic Semantics of propositional logic Satisfiability and validity Modeling with propositional logic Normal forms Enumeration and deduction Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 20 / 1 Semantic classification of formulae A formula ' is called valid if sat(') = V . (Also called a tautology). A formula ' is called satisfiable if sat(') 6= ;. A formula ' is called unsatisfiable if sat(') = ;. (Also called a contradiction). satisfiable unsatisfiable valid Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 21 / 1 Some notations We can write: j= ' when ' is valid 6j= ' when ' is not valid 6j= :' when ' is satisfiable j= :' when ' is unsatisfiable Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 22 / 1 Examples (x1 ^ x2) ! (x1 _ x2) is valid (x1 _ x2) ! x1 is satisfiable (x1 ^ x2) ^ :x1 is unsatisfiable Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 23 / 1 Examples Here are some valid formulae: j= a ^ 1 $ a j= a ^ 0 $ 0 j= ::a $ a (double-negation rule) j= a ^ (b _ c) $ (a ^ b) _ (a ^ c) Some more (De Morgan rules): j= :(a ^ b) $ (:a _:b) j= :(a _ b) $ (:a ^ :b) Satisfiability Checking — Prof.