Ofer Strichman, Technion 1 Decision Procedures in First Order Logic Part I - Introduction.

Slides:



Advertisements
Similar presentations
Model Checking Lecture 4. Outline 1 Specifications: logic vs. automata, linear vs. branching, safety vs. liveness 2 Graph algorithms for model checking.
Advertisements

Completeness and Expressiveness
UIUC CS 497: Section EA Lecture #2 Reasoning in Artificial Intelligence Professor: Eyal Amir Spring Semester 2004.
Propositional and First Order Reasoning. Terminology Propositional variable: boolean variable (p) Literal: propositional variable or its negation p 
Proofs from SAT Solvers Yeting Ge ACSys NYU Nov
Logic Use mathematical deduction to derive new knowledge.
Logic.
Technion 1 Generating minimum transitivity constraints in P-time for deciding Equality Logic Ofer Strichman and Mirron Rozanov Technion, Haifa, Israel.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View SAT.
Heuristics for Efficient SAT Solving As implemented in GRASP, Chaff and GSAT.
1/30 SAT Solver Changki PSWLAB SAT Solver Daniel Kroening, Ofer Strichman.
Properties of SLUR Formulae Ondřej Čepek, Petr Kučera, Václav Vlček Charles University in Prague SOFSEM 2012 January 23, 2012.
SAT and Model Checking. Bounded Model Checking (BMC) A.I. Planning problems: can we reach a desired state in k steps? Verification of safety properties:
SAT-based Bounded Model Checking
Heuristics for Efficient SAT Solving As implemented in GRASP, Chaff and GSAT.
Ofer Strichman, Technion 1 Decision Procedures in First Order Logic Part III – Decision Procedures for Equality Logic and Uninterpreted Functions.
1 Deciding separation formulas with SAT Ofer Strichman Sanjit A. Seshia Randal E. Bryant School of Computer Science, Carnegie Mellon University.
Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis
GRASP-an efficient SAT solver Pankaj Chauhan. 6/19/ : GRASP and Chaff2 What is SAT? Given a propositional formula in CNF, find an assignment.
The Theory of NP-Completeness
Technion 1 Generating minimum transitivity constraints in P-time for deciding Equality Logic Ofer Strichman and Mirron Rozanov Technion, Haifa, Israel.
GRASP SAT solver Presented by Constantinos Bartzis Slides borrowed from Pankaj Chauhan J. Marques-Silva and K. Sakallah.
Knoweldge Representation & Reasoning
Technion 1 (Yet another) decision procedure for Equality Logic Ofer Strichman and Orly Meir Technion.
Ofer Strichman, Technion 1 Decision Procedures in First Order Logic Part II – Equality Logic and Uninterpreted Functions.
SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment.
On Solving Presburger and Linear Arithmetic with SAT Ofer Strichman Carnegie Mellon University.
Ofer Strichman, Technion Deciding Combined Theories.
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic.
1 First order theories. 2 Satisfiability The classic SAT problem: given a propositional formula , is  satisfiable ? Example:  Let x 1,x 2 be propositional.
SAT Solver Math Foundations of Computer Science. 2 Boolean Expressions  A Boolean expression is a Boolean function  Any Boolean function can be written.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
Binary Decision Diagrams (BDDs)
Proof Systems KB |- Q iff there is a sequence of wffs D1,..., Dn such that Dn is Q and for each Di in the sequence: a) either Di is in KB or b) Di can.
Logics for Data and Knowledge Representation Propositional Logic: Reasoning Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto.
Boolean Satisfiability and SAT Solvers
Quantified Formulas - Decision Procedure Daniel Kroening, Ofer Strichman Presented by Changki Hong 07 NOV 08.
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
Theory of Computation, Feodor F. Dragan, Kent State University 1 NP-Completeness P: is the set of decision problems (or languages) that are solvable in.
INTRODUCTION TO ARTIFICIAL INTELLIGENCE COS302 MICHAEL L. LITTMAN FALL 2001 Satisfiability.
Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011 TexPoint fonts used in EMF. Read the TexPoint manual before you.
1 Agenda Modeling problems in Propositional Logic SAT basics Decision heuristics Non-chronological Backtracking Learning with Conflict Clauses SAT and.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Logical Agents Chapter 7. Knowledge bases Knowledge base (KB): set of sentences in a formal language Inference: deriving new sentences from the KB. E.g.:
LDK R Logics for Data and Knowledge Representation Propositional Logic: Reasoning First version by Alessandro Agostini and Fausto Giunchiglia Second version.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
On the Relation between SAT and BDDs for Equivalence Checking Sherief Reda Rolf Drechsler Alex Orailoglu Computer Science & Engineering Dept. University.
CS6133 Software Specification and Verification
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
Nikolaj Bjørner Microsoft Research DTU Winter course January 2 nd 2012 Organized by Flemming Nielson & Hanne Riis Nielson.
1 First order theories (Chapter 1, Sections 1.4 – 1.5) From the slides for the book “Decision procedures” by D.Kroening and O.Strichman.
Heuristics for Efficient SAT Solving As implemented in GRASP, Chaff and GSAT.
Daniel Kroening and Ofer Strichman Decision Procedures An Algorithmic Point of View Deciding Combined Theories.
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
SAT Solving As implemented in - DPLL solvers: GRASP, Chaff and
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background.
Knowledge Repn. & Reasoning Lecture #9: Propositional Logic UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2005.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
Heuristics for Efficient SAT Solving As implemented in GRASP, Chaff and GSAT.
Chapter 7. Propositional and Predicate Logic
Knowledge Representation and Reasoning
Heuristics for Efficient SAT Solving
Propositional Calculus: Boolean Algebra and Simplification
Elementary Metamathematics
Decision Procedures An Algorithmic Point of View
GRASP-an efficient SAT solver
Presentation transcript:

Ofer Strichman, Technion 1 Decision Procedures in First Order Logic Part I - Introduction

Technion2 Part I - Introduction Reminders -  What is Logic  Proofs by deduction  Proofs by enumeration  Decidability, Soundness and Completeness  Some notes on Propositional Logic Deciding Propositional Logic  SAT tools  BDDs

Technion3 What is Logic ? Some useful definitions on the web:  “science dealing with the principles of valid reasoning and argument”  “A formal and powerful method of explaining why the program doesn't work”  “The art of being wrong with confidence”

Technion4 So what is Logic? Defined by  Syntax (including the Signature of the logic  : variables and their domain, function and predicate symbols, quantifiers, etc)  Axioms and Inference rules. A logic allows us to infer theorems.

Technion5 Example: Propositional Logic Syntax formula: Boolean-var | : formula | formula Ç formula | ( formula ) | T | F (Can also use: formula Æ formula | formula ! formula…) Axioms: 1. ` (A ! (B ! A)) 2. ` ((A ! (B ! C)) ! ((A ! B) ! (A ! C))) 3. ` ( : B ! : A) ! (A ! B) Inference Rule: Modus Ponens (MP) ` A ` A ! B ` B A specific (one of many possible) Deductive System for Propositional Logic. Known as the Hilbert System H.

Technion6 A proof by deduction: example Notation: ` H  ‘there exists a proof of  in H’ Theorem: ` H (A ! B) ! ((B ! C) ! (A ! C)) 1. {A ! B, B ! C, A} ` H AAssumption 2. {A ! B, B ! C, A} ` H A ! BAssumption 3. {A ! B, B ! C, A} ` H BM.P. 1,2 4. {A ! B, B ! C, A} ` H B ! CAssumption 5. {A ! B, B ! C, A} ` H CM.P. 3,4 6. {A ! B, B ! C} ` H (A ! C)Deduction 5 7. {A ! B} ` H ((B ! C) ! (A ! C))Deduction 6 8. ` H (A ! B) ! ((B ! C) ! (A ! C))Deduction 7

Technion7 Semantics Can be given via axioms and inference rules, or Can be given via truth tables x1x1 x2x2 x1 Æx2x1 Æx2 x1 Ç x2x1 Ç x2... TTTT TFFT FTFT FFFF

Technion8 Satisfying interpretations If an assignment  satisfies (according to the truth tables) a formula , we write:  ² . Example:  : : ( x 1 Æ : ( x 2 Ç :x 3 ))    : ( x 1 = T, x 2 = F, x 3 = F)   ²     : ( x 1 = T, x 2 = F, x 3 = T)  2 2 

Technion9 Satisfiability, Validity etc. Definition (Satisfiability): a formula  is satisfiable if 9  ²  Definition (Validity): a formula  is valid if 8   ² . If  is valid we write ² . Observation:  is valid if and only if :  is unsatisfiable.

Technion10 A proof by enumeration: same example ABC (A ! B) ! ((B ! C) ! (A ! C)) TTTT TTFT TFTT TFFT FTTT FTFT FFTT FFFT ²

Technion11 Soundness and completeness of a deductive system Given a deductive system D,  D is sound for a logic L, if for every formula f in L, ` D f ! ² f  D is complete if for every formula f in L, ² f ! ` D f

Technion12 The decision problem Definition (the decision problem): The decision problem for a formula: given , is  valid ? Definition (decision Procedure for a logic): A decision procedure for a logic is an algorithm that solves the decision problem for any formula in this logic. We are naturally interested in a sound and complete decision procedure.

Technion13 Soundness and Completeness What does it mean that a decision procedure is sound and complete ?  Soundness: the answer returned by the decision-procedure is always correct (question: ‘correct’ according to what?)  Completeness: returns with a yes/no answer in a finite time. (question: how does this definition relate to the definition of completeness of a deduction system? )

Technion14 Soundness and Completeness Soundness: “when I say that it rains, it rains, and when I say it doesn’t rain, it doesn’t rain” Completeness: “If asked, I always reply (in a finite time…) whether it rains” A logic is decidable  there is a sound and complete algorithm that decides if a well-formed expression in this logic is valid.

Technion15 Soundness and Completeness (cont’d) Algorithm #1: for checking if it rains outside: “stand right outside the door and say ‘it rains’” It is not sound because you might say it rains when it doesn’t. But it is complete: you always get an answer in a finite time.

Technion16 Soundness and Completeness (cont’d) Algorithm #2 for checking if it rains outside: “stand right outside the door and say ‘it rains’ if and only if you feel the rain” It is sound because you say it rains only if it actually rains. It is incomplete because you do not say anything if it doesn’t rain (we do not know whether it doesn’t rain, or it takes the person too long to answer…).

Technion17 Decidability Propositional logic is decidable  there is a sound and complete algorithm (e.g. Truth tables) to decide whether a propositional formula is valid. Arithmetic is undecidable (this is Gödel's incompleteness result)

Technion18 Inference engines We saw that we can infer in Propositional Logic with both a deductive system (“deduction”) and truth tables (“enumeration”). Which, in the general case, is a better method? All logics have a deductive definition. NOT all logics can be decided with an enumerative method.

Technion19 Deductive methods Axioms and Inference rules Enumerative methods “Truths tables” Or Requires thinking… Requires pressing ‘Enter’… Whenever we can: build an engine to think for us

Technion20 Expressiveness of a logic Each formula defines a language: the set of satisfying assignments (‘models’) are the words accepted by this language. Consider the logic ‘2-CNF’ formula : ( literal Ç literal ) | formula Æ formula literal: Boolean-var | : Boolran-var ( x 1 Ç :x 2 ) Æ ( :x 3 Ç x 2 )

Technion21 Expressiveness of a logic Now consider a Propositional Logic formula  ( x 1 Ç x 2 Ç x 3 ). Q: Can we express this language with 2-CNF? A: No. Proof:  The language accepted by  has 7 words: all assignments other than x 1 = x 2 = x 3 = F.  The first 2-CNF clause removes ¼ of the assignments, which leaves us with 6 accepted words. Additional clauses only remove more assignments.

Technion22 Expressiveness of a logic Claim: 2-CNF Á Propositional Logic Generally there is only a partial order between logics. Languages defined by L 2 Languages defined by L 1 L 2 is more expressive than L 1. Denote: L 1 Á L 2

Technion23 Tradeoff: expressiveness/computational hardness. Assume we are given logics L 1 Á … Á L n More expressive Easier to decide UndecidableDecidable Intractable (exponential) Tractable (polynomial) Computational Challenge! LnLn L1L1 Our course

Technion24 When is a specific logic useful ? 1. Expressible enough to state something interesting. 2. Decidable (or semi-decidable) and more efficiently solvable than richer logics. 3. More expressible, or more natural for expressing some models in comparison to ‘leaner’ logics.

Technion25 Example: First Order Peano arithmetic constants: 0,1 Function symbols: ‘+’, ‘*’, Predicate symbol: ‘=’ Domain: Natural numbers Axioms (“semantics”): 1. 8 x : (0  x + 1) 2. 8 x : 8 y : (x  y) ! (x + 1  y + 1) 3. Induction 4. 8 x : x + 0 = x 5. 8 x : 8 y : (x + y) + 1 = x + (y + 1) 6. 8 x : x * 0 = x 8 y : x * (y + 1) = x * y + x + * Undecidable! These axioms define the semantics of ‘+’

Technion26 Example: Presburger arithmetic constants: 0,1 Function symbols: ‘+’, ‘*’, Predicate symbol: ‘=’ Domain: Natural numbers Axioms (“semantics”): 1. 8 x : (0  x + 1) 2. 8 x : 8 y : (x  y) ! (x + 1  y + 1) 3. Induction 4. 8 x : x + 0 = x 5. 8 x : 8 y : (x + y) + 1 = x + (y + 1) 6. 8 x : x * 0 = x 8 y : x * (y + 1) = x * y + x + * Decidable!

Technion27 Logic in Computer Science Reasoning in AI Proofs in verification Queries in Databases … many more

Technion28 Some notes on Propositional Logic The simplest of them all NP-complete Exceptionally efficient solvers (SAT engines, BDDs) Formulas with 10 5 variables are being solved regularly All the logics that we will consider can be reduced directly to this logic

Technion29 Some notes on Propositional Logic A literal: v:v positive literal negative literal Also known as ‘the phase’, or ‘the polarity’ of the literal. The “logical phase” of a literal can be computed by counting the number of negations that nest it:  v is logically negative in: :v, : ( : ( : v )), v ! u, : ( u ! v )  v is logically positive in: v, : ( v ! u )

Technion30 Some notes on Propositional Logic Normal forms:  Conjunctive Normal Form (CNF)  Disjunctive Normal Form (DNF) (for which satisfiability is in P)  Negation Normal Form (NNF) (all negations are over literals, not sub formulas) CNF and DNF are special cases of NNF

Technion31 Some notes on Propositional Logic Checking Satisfiability of a Boolean formula  :  Convert  to a CNF: with additional variables, in P time.  Convert  to DNF: Exp time and space  Convert  to NNF: P time

Technion32 The ‘Pure literal rule’  : ( x Ç y ) Æ ( :x Ç z ) Æ ( x Ç y Ç :z ) y is ‘pure’: it only appears in one phase Idea: when trying to satisfy , first assign y = true. Why? If there is a satisfying assignment to , there is a satisfying assignment in which y = true. Generalization: assign all pure literals according to their phase.

Technion33 Pure literals in NNF CNF is a special case of NNF A pure literal is defined in the same way: a literal that only appears in one phase. We can always start satisfiability checking by assigning these pure literals true or false according to their phase. We will rely on a similar principle also when considering other Logics.

Technion34 Monotonicity of NNF Thm: NNF formulas are monotonically satisfied (in CNF this is simply the pure literal rule)  ’’ Satisfied literals  ²  !  ’ ²   :  ’: 1 1  : ( x 1 Æ : x 2 ) Ç ( x 2 Ç ( x 3 Æ x 1 ))

Technion35 Monotonicity of NNF (example)  : ( :x Æ y ) Ç z  : ( x, y, z ) = (0,1,0)  ²  S ={ :x, y }  ’: ( x, y, z ) = (0,1,1)  ’ ²  S ’={ :x, y, z }

Technion36 Some notes… Why is monotonicity relevant to our decision procedures ? We will use the fact that if we make unsatisfied predicates satisfied, we do not make the formula unsatisfied. We will rely heavily on this fact later: it simplifies decision procedures.

Technion37 Part I Reminders -  What is Logic  Proofs by deduction  Proofs by enumeration  Decidability, Soundness and Completeness  some notes on Propositional Logic Deciding Propositional Logic  SAT tools  BDDs      

Technion38 Next: Deciding Propositional Formulas SAT solvers Binary Decision Diagrams

Technion39 Given  in CNF: (x,y,z),(-x,y),(-y,z),(-x,-y,-z) Decide() BCP() Resolve_Conflict()  X XX XX  A Basic SAT algorithm

Technion40 SAT made some progress…

Technion41 While (true) { if (!Decide()) return (SAT); while (!BCP()) if (!Resolve_Conflict()) return (UNSAT); } Choose the next variable and value. Return False if all variables are assigned Apply repeatedly the unit clause rule. Return False if reached a conflict Backtrack until no conflict. Return False if impossible A Basic SAT algorithm

Technion42 Basic Backtracking Search Organize the search in the form of a decision tree  Each node corresponds to a decision  Definition: Decision Level (DL) is the depth of the node in the decision tree.  Notation: x 2 {0,1} is assigned to v at decision level d

Technion43 Backtracking Search in Action  1 = (x 2  x 3 )  2 = (  x 1   x 4 )  3 = (  x 2  x 4 )  1 = (x 2  x 3 )  2 = (  x 1   x 4 )  3 = (  x 2  x 4 ) x 1 x 1 = {(x 1,0), (x 2,0), (x 3,1)} x 2 x 2 = {(x 1,1), (x 2,0), (x 3,1), (x 4,0)} x 1 =  x 3 =  x 4 =  x 2 =  x 3 = No backtrack in this example, regardless of the decision!

Technion44 Backtracking Search in Action  1 = (x 2  x 3 )  2 = (  x 1   x 4 )  3 = (  x 2  x 4 )  4 = (  x 1  x 2   x 3 )  1 = (x 2  x 3 )  2 = (  x 1   x 4 )  3 = (  x 2  x 4 )  4 = (  x 1  x 2   x 3 ) Add a clause  x 4 =  x 2 =  x 3 = conflict {(x 1,0), (x 2,0), (x 3,1)} x 2 x 2 =  x 3 = x 1 = x 1 x 1 =

Technion45 Status of a clause A clause can be  Satisfied: at least one literal is satisfied  Unsatisfied: all literals are assigned but non are satisfied  Unit: all but one literals are assigned but none are satisfied  Unresolved: all other cases Example: C = ( x 1 Ç x 2 Ç x 3 ) x1x1 x2x2 x3x3 C 10Satisfied 000Unsatisfied 00Unit 0Unresolved

Technion46 For a given variable x :  C x p – # unresolved clauses in which x appears positively  C x n - # unresolved clauses in which x appears negatively  Let x be the literal for which C xp is maximal  Let y be the literal for which C yn is maximal  If C xp > C yn choose x and assign it TRUE  Otherwise choose y and assign it FALSE Requires l (#literals) queries for each decision. DLIS (Dynamic Largest Individual Sum) – choose the assignment that increases the most the number of satisfied clauses Decision heuristics - DLIS

Technion47 Compute for every clause  and every variable l (in each phase): J ( l ) := Choose a variable l that maximizes J ( l ). This gives an exponentially higher weight to literals in shorter clauses. Decision heuristics - JW Jeroslow-Wang method

Technion48 Pause... We will see other (more advanced) decision Heuristics soon. These heuristics are integrated with a mechanism called Learning with Conflict-Clauses, which we will learns next.

Technion49 55 55 x 6 Implication graphs and learning: option #1  1 = (  x 1  x 2 )  2 = (  x 1  x 3  x 9 )  3 = (  x 2   x 3  x 4 )  4 = (  x 4  x 5  x 10 )  5 = (  x 4  x 6  x 11 )  6 = (  x 5   x 6 )  7 = (x 1  x 7   x 12 )  8 = (x 1  x 8 )  9 = (  x 7   x 8   x 13 )  1 = (  x 1  x 2 )  2 = (  x 1  x 3  x 9 )  3 = (  x 2   x 3  x 4 )  4 = (  x 4  x 5  x 10 )  5 = (  x 4  x 6  x 11 )  6 = (  x 5   x 6 )  7 = (x 1  x 7   x 12 )  8 = (x 1  x 8 )  9 = (  x 7   x 8   x 13 ) Current truth assignment: {x 9 10 x 11 x 12 x 13 Current decision assignment: {x 1 66 66  conflict x 9 x 1 x 10 x 11 x 5 44 44 22 22 x 3 11 x 2 33 33 x 4 We learn the conflict clause  10 : ( : x 1 Ç x 9 Ç x 11 Ç x 10 )

Technion50 Implication graph, flipped assignment option #1 x 1 x 11 x 10 x 9 x 7 x 12 77 77 x 8 88  10 99 99 ’’ x 13 99 Due to the conflict clause  1 = (  x 1  x 2 )  2 = (  x 1  x 3  x 9 )  3 = (  x 2   x 3  x 4 )  4 = (  x 4  x 5  x 10 )  5 = (  x 4  x 6  x 11 )  6 = (  x 5  x 6 )  7 = (x 1  x 7   x 12 )  8 = (x 1  x 8 )  9 = (  x 7   x 8   x 13 )  10 : ( : x 1 Ç x 9 Ç x 11 Ç x 10 )  1 = (  x 1  x 2 )  2 = (  x 1  x 3  x 9 )  3 = (  x 2   x 3  x 4 )  4 = (  x 4  x 5  x 10 )  5 = (  x 4  x 6  x 11 )  6 = (  x 5  x 6 )  7 = (x 1  x 7   x 12 )  8 = (x 1  x 8 )  9 = (  x 7   x 8   x 13 )  10 : ( : x 1 Ç x 9 Ç x 11 Ç x 10 ) No decision here Another conflict clause:  11 : ( :x 13 Ç :x 12 Ç x 11 Ç x 10 Ç x 9 ) where should we backtrack to now ?

Technion51 Non-chronological backtracking Non- chronological backtracking x ’’ Decision level Which assignments caused the conflicts ? x 9 = x 10 = x 11 = x 12 = x 13 = Backtrack to DL = 3 3 These assignments Are sufficient for Causing a conflict.

Technion52 Non-chronological backtracking So the rule is: backtrack to the largest decision level in the conflict clause. This works for both the initial conflict and the conflict after the flip. Q: What if the flipped assignment works ? A: Change the decision retroactively.

Technion53 Non-chronological Backtracking x 1 = 0 x 2 = 0 x 3 = 1 x 4 = 0 x 5 = 0 x 7 = 1 x 9 = 0 x 6 = 0... x 5 = 1 x 9 = 1 x 3 = 0

Technion54 More Conflict Clauses Def: A Conflict Clause is any clause implied by the formula Let L be a set of literals labeling nodes that form a cut in the implication graph, separating the conflict node from the roots. Claim: Ç l2L :l is a Conflict Clause. 55 55 x 6 66 66  conflict x 9 x 1 x 10 x 11 x 5 44 44 22 22 x 3 11 x 2 33 33 x 4 1. (x 10 Ç : x 1 Ç x 9 Ç x 11 ) 2. (x 10 Ç : x 4 Ç x 11 ) 3. (x 10 Ç : x 2 Ç : x 3 Ç x 11 )  1 2 3

Technion55 Conflict clauses How many clauses should we add ? If not all, then which ones ?  Shorter ones ?  Check their influence on the backtracking level ?  The most “influential” ?

Technion56 Conflict clauses Def: An Asserting Clause is a Conflict Clause with a single literal from the current decision level. Backtracking (to the right level) makes it a Unit clause. Asserting clauses are those that force an immediate change in the search path. Modern solvers only consider Asserting Clauses.

Technion57 Unique Implication Points (UIP’s) Definition: A Unique Implication Point (UIP) is an internal node in the Implication Graph that all paths from the decision to the conflict node go through it. The First-UIP is the closest UIP to the conflict. 55 55 66 66  conflict 44 44 22 22 11 33 33 UIP

Technion58 Conflict-driven backtracking (option #2) Conflict clause: ( x 10 Ç :x 4 Ç x 11 ) With standard Non-Chronological Backtracking we backtracked to DL = 6. Conflict-driven Backtrack: backtrack to the second highest decision level in the clause (without erasing it). In this case, to DL = 3. Q: why?  conflict x 10 x 11 x 4

Technion59 Conflict-driven Non-chronological Backtracking x 1 = 0 x 2 = 0 x 3 = 1 x 4 = 0 x 5 = 0 x 5 = 1 x 7 = 1 x 3 = 1 x 9 = 0 x 9 = 1 x 6 = 0...

Technion60 Decision Conflict Decision Level Time work invested in refuting x=1 (some of it seems wasted) C x=1 Refutation of x=1 C1C1 C5C5 C4C4 C3C3 C2C2 Progress of a SAT solver BCP

Technion61 Conflict-Driven Backtracking So the rule is: backtrack to the second highest decision level dl, but do not erase it. This way the literal with the currently highest decision level will be implied in DL = dl. Q: what if the conflict clause has a single literal ?  For example, from ( xÇ :y ) Æ ( x Ç y ) and decision x =0, we learn the conflict clause ( x ).

Technion62 The Resolve-Graph keeps track of the “inference relation” 11 22 33 44 55 66  10 77 88 99  11 77 77 88  10 99 99  ’ conflict 55 55 66 66  conflict 44 44 22 22 11 33 33 99 Resolve Graph

Technion63 The resolve graph What is it good for ? Example: for computing an Unsatisfiable core

Technion64 (Implemented in Chaff) VSIDS (Variable State Independent Decaying Sum) Decision heuristics - VSIDS 1.Each variable in each polarity has a counter initialized to When a clause is added, the counters are updated. 3. The unassigned variable with the highest counter is chosen. 4. Periodically, all the counters are divided by a constant.

Technion65 Decision heuristics – VSIDS (cont’d) Chaff holds a list of unassigned variables sorted by the counter value. Updates are needed only when adding conflict clauses. Thus - decision is made in constant time.

Technion66 VSIDS is a ‘quasi-static’ strategy: - static because it doesn’t depend on current assignment - dynamic because it gradually changes. Variables that appear in recent conflicts have higher priority. This strategy is a conflict-driven decision strategy. “..employing this strategy dramatically (i.e. an order of magnitude) improved performance... “ Decision heuristics VSIDS (cont’d)

Technion67 Decision Heuristics - Berkmin Keep conflict clauses in a stack Choose the first unresolved clause in the stack  If there is no such clause, use VSIDS Choose from this clause a variable + value according to some scoring (e.g. VSIDS) This gives absolute priority to conflicts.

Technion68 Berkmin heuristic tail- first conflict clause

Technion69 The SAT competitions

Technion70 End of SAT (for now) Beginning of Binary Decision Diagrams

Technion71 Next: Binary Decision Diagrams SAT looked for a satisfying solution to CNF We will now examine a graph-based data structure called Binary Decision Diagrams. It has several advantages and disadvantages comparing to SAT Developed by Bryant [1986]. Next few slides are from the source …

Technion72 Alternate Approach Generate complete representation of function Canonicity: functions are equal iff representations are identical (A Æ C) Ç (C Æ B) (A Ç B) Æ (C) B 01C AB 01C A

Technion73 Decision Structures Truth TableDecision Tree  Vertex represents decision  Follow green (dashed) line for value 0  Follow red (solid) line for value 1  Function value determined by leaf value.

Technion74 Variable Ordering  Assign arbitrary total ordering to variables e.g., x 1 < x 2 < x 3  Variables must appear in ascending order along all paths OKNot OK x 3 x 2 x 1 x 1 x3x3

Technion75 Reduction Rule #1 Merge equivalent leaves aa a

Technion76 Reduction Rule #2 y x z x Merge isomorphic nodes y x z x y x z x

Technion77 Reduction Rule #3 Eliminate Redundant Tests y x y

Technion78 Example OBDD Initial GraphReduced Graph Canonical representation of Boolean functions o For a given variable ordering  Two functions are equivalent iff graphs are isomorphic Can be tested in linear time  Desirable property: simplest form is canonical. (x 1 Ç x 2 ) Æ x 3

Technion79 Satisfiability etc. Constants Unique unsatisfiable function Unique tautology Conclusion: given a BDD it takes constant time to check:  Validity  Contradiction  Satisfiability Is this a free lunch ? …

Technion80 Effect of Variable Ordering Good OrderingBad Ordering Linear GrowthExponential Growth

Technion81 Selecting Good Variable Ordering Intractable Problem  Even when problem represented as OBDD i.e., to find optimum improvement to current ordering Application-Based Heuristics  Exploit characteristics of application  e.g., Ordering for functions of combinational circuit Traverse circuit graph depth-first from outputs to inputs

Technion82 Building BDDs ‘from below’ Starting from a binary decision tree is too hard for formulas with many variables. Goal: construct the BDD ‘from below’.

Technion83 Building BDDs ‘from below’ For this we will need a function called APPLY:  Given the BDDs for f 1 and f 2,  and a binary connective F 2 { Æ, Ç, !, $...} (any one of the 16 binary connectives),  Construct the BDD for f 1 F f 2,

Technion84 Building BDDs ‘from below’ Def: a restriction of a function f to x = d, denoted f | x = d where x 2 vars( f ), d 2 {0,1}, is equal to f after assigning x = d. Given the BDD of f, deriving the BDD of f | x =0 is simple: f : ( x 1 Ç x 2 ) Æ x 3 01 x 3 x 1 01 x 3 f | x 2=1

Technion85 Now, APPLY (1/3) Let v 1, v 2 denote the root nodes of f 1, f 2, respectively, with var( v 1 ) = x 1 and var( v 2 )= x If v 1 and v 2 are leafs, f 1 F f 2 is a leaf node with value val( v 1 ) F val( v 2 ) Ç = Æ =

Technion86 Now, APPLY (2/3) 2. If x 1 = x 2 = x, apply Shanon expansion: f 1 F f 2 = ( :x Æ f 1 | x=0 F f 2 | x=0 Ç x Æ f 1 | x=1 F f 2 | x=1 ) x BDD for f 1 | x=0 BDD for f 1 | x=1 x BDD for f 2 | x=0 BDD for f 2 | x=1 Æ = x BDD for f 1 | x=1 Æ f 2 | x=1 BDD for f 1 | x=0 Æ f 2 | x=0

Technion87 Now, APPLY (3/3) 3. else, suppose x 1 < x 2 in the variable order. f 1 F f 2 = ( :x 1 Æ f 1 | x=0 F f 2 Ç x 1 Æ f 1 | x=1 F f 2 ) x1x1 BDD for f 1 | x 1=0 BDD for f 1 | x1=1 x2x2 BDD for f 2 | x 2=0 BDD for f 2 | x 2=1 Æ = x1x1 BDD for f 1 | x1 =1 Æ f 2 BDD for f 1 | x1 =0 Æ f 2

Technion88 BDDs from below: example. x 2 01 x 1 x 2 f 1 : x 1 $ x 2 Ç x 2 10 f 2 : : x 2 = x 1 BDD for f 1 | x1=0 Ç f 2 BDD for f 1 | x1=1 Ç f 2 BDD for f 1 | x1=0 Ç f 2 = x2x2 0 1 Ç x 2 10 = x Ç 0 = 0 1 Ç 1 = 1

Technion89 BDDs from below: example. x 2 01 x 1 x 2 f 1 : x 1 $ x 2 x 2 10 Ç f 2 : :x 2 = x 1 BDD for f 1 | x 1=0 Ç f 2 BDD for f 1 | x 1=1 Ç f 2 = x 1 x 2 10 x 2 1 = x 1 x 2 10 x 2 f 1 Ç f 2 = x 1 Ç ( :x 1 Æ :x 2 )

Technion90 Comparing SAT to BDDs BDD is a canonical data structure that represents the semantic of a function, i.e. all its solutions  Some applications (e.g. symbolic model checking) need canonicity to detect when two sets are equivalent.  Can require exponential space & time (highly sensitive to variable ordering) SAT searches through CNF for a single solution  CNF is not canonical.  Poly-space algorithms exists. Time can be exponential.

Technion91 Theories Axioms, inference rules and the set of theorems we can infer from them, are commonly referred to as a Theory. An informal term used to describe ‘everything related to some logic’ Examples: “Set theory”, “Theory of Arithmetic over the Reals”, “Theory of linear arithmetic over the integers”,…