1.03k likes | 1.21k Views
Nikolaj Bjørner Senior Researcher Microsoft Research Redmond. Modern Satisfiability Modulo Theories Solvers in Program Analysis. Lectures. Wednesday 10:45–12:15 An Introduction to Z3 with Applications Thursday August 30 th 15:45–17:15 Introduction to SAT and SMT Friday 10:30–10:45
E N D
Nikolaj Bjørner Senior Researcher Microsoft Research Redmond Modern Satisfiability Modulo Theories Solvers in Program Analysis
Lectures Wednesday10:45–12:15An Introduction to Z3 with Applications Thursday August 30th15:45–17:15 Introduction to SAT and SMT Friday 10:30–10:45 Theories and Solving Algorithms Friday 15:45–17:15 Advanced: Quantifiers, Arrays, Fixed-points
Plan • Logic: Calculus of Computation • SAT, First-order Theorem Proving, SMT • Introduction to Propositional Logic(SAT): • Language, Satisfiability, Validity, • Normal forms, CNF, • Search, Resolution, DPLL search • Introduction to SMT by example • SMT solving, Combining theories
Takeaways The syntax and semantics of propositional and predicate logic Algorithmic principles of modern SAT solvers: • DPLL algorithm • Conflict Directed Clause Learning (CDCL) • Two-watch literal indexing Principles of modern SMT solvers
Background Reading September 2011
Logic: Calculus of Computation Formal Logic: Language: Precise syntax of well-formed formulas Examples: propositional logic, equational logic, first-order logic, higher-order logic, and modal logics. Model theory: Precise semantics of truth and valid consequences Proof theory: Axioms and inference rules for truth and consequences Calculus: Basis for specifications and reasoning about computation Mechanized Formal Logic: Symbolic: The art and science of effective symbolic reasoning Automatic: Computers can automate symbolic calculations
Symbolic Engines: SAT, FTP and SMT SAT: Propositional Satisfiability. (Tie Shirt) (Tie Shirt) (Tie Shirt) FTP: First-order Theorem Proving. X,Y,Z [X*(Y*Z) = (X*Y)*Z] X [X*inv(X) = e] X [X*e = e] SMT: Satisfiability Modulo background Theoriesb + 2 = c A[3]≠ A[c-b+1]
SAT - Milestones Problems impossible 10 years ago are trivial today Concept 2002 2010 Millions of variables from HW designs Courtesy Daniel le Berre
FTP - Milestones • Some successstories: • Open Problems (of 25 years):XCB: X ((X Y) (Z Y)) Z)is a single axiom for equivalence • Knowledge Ontologies GBs of formulas Courtesy Andrei Voronkov, U of Manchester
SMT - Milestones Z3 (of ’07) Time On BoogieRegression 1sec Simplify (of ’01) time Z3 Time On VCC Regression Includes progress from SAT: 15KLOC + 285KLOC = Z3 Nov 08 March 09
Propositional Logic Syntax, Semantics and Normal Forms Resolution, Classical DPLL, Modern DPLL
Propositional Logic: Language Logical symbols: , , ,true, false, - fixed interpretation Non-logical symbols: p, q, r - interpretations vary Well-formed formulas: built by combining logical and non-logical symbols
Propositional Logic: Language Formulas: := p | 12| 12|1 | 1 2 Examples: p q q p p q (p q) We say pand qare propositional variables.
Propositional Logic Syntax, Semantics and Normal Forms Resolution, Classical DPLL, Modern DPLL
Interpretation An interpretation M assigns values {true, false} to propositional variables. Let F and G range over PL formulas.
Satisfiability & Validity A formula is: • satisfiable if it has an interpretation that makes it logically true. In this case, we say the interpretation is a model. • unsatisfiable if it does not have any model. • valid if it is logically true in any interpretation. • A propositional formula is valid if and only if its negation is unsatisfiable.
Satisfiability & Validity: examples p q q p p q q p q (p q)
Satisfiability & Validity: examples p q q p VALID p q q SATISFIABLE p q (p q) UNSATISFIABLE
Equivalence We say two formulas F and G are equivalent if and only if they evaluate to the same value (true or false) in every interpretation
Equisatisfiable We say formulas A and B are equisatisfiable if and only if A is satisfiable if and only if B is. equisat. During this tutorial, we describe transformations that preserve equivalence and equisatisfiability.
Propositional Logic Syntax, Semantics, Normal Forms Resolution, Classical DPLL, Modern DPLL
Normal Forms Literal – either a propositional atom or its negation NNF – Negation Normal Form Formula with negation only used for literals CNF – Conjunctive Normal Form Conjunction of disjunctions of literals DNF – Disjunctive Normal Form Disjunction of conjunctions of literals
Normal Forms Conditional normal form Formula with only collectives BDD – (reduced ordered) Binary Decision Diagram Formula with only collectives test only uses atomsAtoms are ordered such that DAG: Share common sub-expressions Exercises: • Show that every propositional formula is equivalent to a formula in • (1) NNF, (2) CNF, (3) DNF, (4)CondNF, (5) BDD • In each case, what is the size overhead of the conversion? • Show that every n-ary Boolean function can be expressed using and
Normal Forms NNF? (p q) (q (r p))
Normal Forms NNF? NO
Normal Forms NNF? NO
Normal Forms NNF? NO
Normal Forms NNF? NO
Normal Forms CNF? ((p s) (q r)) (q p s) (r s)
Normal Forms CNF? NO ((p s) (q r)) (q p s) (r s)
Normal Forms CNF? NO ((p s) (q r)) (q p s) (r s) Distributivity 1. A(BC) (AB)(AC) 2. A(BC) (AB)(AC)
Normal Forms CNF? NO ((p s) (q r)) (q p s) (r s) ((p s) q)) ((p s) r)) (q p s) (r s) Distributivity 1. A(BC) (AB)(AC) 2. A(BC) (AB)(AC)
Normal Forms CNF? NO Distributivity
Normal Forms CNF? .. yes ((p s) (q r)) (q p s) (r s) ((p s) q)) ((p s) r)) (q p s) (r s) (p q) (s q) ((p s) r)) (q p s) (r s) (p q) (s q) (p r) (s r) (q p s) (r s)
Normal Forms DNF? p (p q) (q r)
Normal Forms DNF? NO, actually this formula is in CNF p (p q) (q r)
Normal Forms DNF? NO, actually this formula is in CNF p (p q) (q r) Distributivity 1. A(BC) (AB)(AC) 2. A(BC) (AB)(AC)
Normal Forms DNF? NO, actually this formula is in CNF p (p q) (q r) ((p p) (p q)) (q r) Distributivity 1. A(BC) (AB)(AC) 2. A(BC) (AB)(AC)
Normal Forms DNF? NO, actually this formula is in CNF p (p q) (q r) ((p p) (p q)) (q r) (p q) (q r) Distributivity 1. A(BC) (AB)(AC) 2. A(BC) (AB)(AC) Other Rules AA A A
Normal Forms DNF? … yes p (p q) (q r) ((p p) (p q)) (q r) (p q) (q r) ((p q) q) ((p q) r) (pq) (p r) (q r) Distributivity 1. A(BC) (AB)(AC) 2. A(BC) (AB)(AC) Other Rules AA A A
Efficient CNF Translation CNF translation using distributivity rule is too expensive (exponential blowup). Linear time/space translation produces equisatisfiable formula: where is a fresh variable. Exercise: show that each transformation preserves satisfiability. Exercise: finish the transformation for:
Propositional Logic Syntax, Semantics, Normal Forms Resolution, Classical DPLL, Modern DPLL
Resolution Formula must be in CNF Resolution rule: Example: The result of resolution is the resolvent(clause). Original clauses are kept (not deleted). Duplicate literals are deleted from the resolvent. Note: No branching. Termination: Only finite number of possible derived clauses.
Unit & Input Resolution Unit resolution: (is subsumed by Input resolution: ( member of input F). Exercise: Set of clauses F: F has an input refutation iffF has a unit refutation.
Propositional Logic Syntax, Semantics, Normal Forms Resolution, Classical DPLL, Modern DPLL
DPLL DPLL: David Putnam Logeman Loveland = Unit resolution + split rule. split unit Ingredient of most efficient SAT solvers
Pure Literals A literal is pure if only occurs positively or negatively.