Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Ofer Strichman, Technion 1 Decision Procedures in First Order Logic Part I - Introduction."— Presentation transcript:

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

2 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

3 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”

4 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.

5 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.

6 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

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

8 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 

9 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.

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

11 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

12 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.

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

14 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.

15 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.

16 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…).

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

18 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.

19 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

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

21 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.

22 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

23 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

24 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.

25 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 = 0 7. 8 x 8 y : x * (y + 1) = x * y + x + * Undecidable! These axioms define the semantics of ‘+’

26 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 = 0 7. 8 x 8 y : x * (y + 1) = x * y + x + * Decidable!

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

28 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

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

30 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

31 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

32 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.

33 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.

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

35 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 }

36 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.

37 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      

38 Technion38 Next: Deciding Propositional Formulas SAT solvers Binary Decision Diagrams

39 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

40 Technion40 SAT made some progress…

41 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

42 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=v@d x 2 {0,1} is assigned to v at decision level d

43 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 = 0@1 {(x 1,0), (x 2,0), (x 3,1)} x 2 x 2 = 0@2 {(x 1,1), (x 2,0), (x 3,1), (x 4,0)} x 1 = 1@1  x 3 = 1@2  x 4 = 0@1  x 2 = 0@1  x 3 = 1@1 No backtrack in this example, regardless of the decision!

44 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 = 0@1  x 2 = 0@1  x 3 = 1@1 conflict {(x 1,0), (x 2,0), (x 3,1)} x 2 x 2 = 0@2  x 3 = 1@2 x 1 = 0@1 x 1 x 1 = 1@1

45 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

46 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

47 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

48 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.

49 Technion49 55 55 x 6 =1@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 =0@1,x 10 =0@3, x 11 =0@3, x 12 =1@2, x 13 =1@2} Current decision assignment: {x 1 =1@6} 66 66  conflict x 9 =0@1 x 1 =1@6 x 10 =0@3 x 11 =0@3 x 5 =1@6 44 44 22 22 x 3 =1@6 11 x 2 =1@6 33 33 x 4 =1@6 We learn the conflict clause  10 : ( : x 1 Ç x 9 Ç x 11 Ç x 10 )

50 Technion50 Implication graph, flipped assignment option #1 x 1 =0@6 x 11 =0@3 x 10 =0@3 x 9 =0@1 x 7 =1@6 x 12 =1@2 77 77 x 8 =1@6 88  10 99 99 ’’ x 13 =1@2 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 ?

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

52 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.

53 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

54 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 =1@6 66 66  conflict x 9 =0@1 x 1 =1@6 x 10 =0@3 x 11 =0@3 x 5 =1@6 44 44 22 22 x 3 =1@6 11 x 2 =1@6 33 33 x 4 =1@6 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

55 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” ?

56 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.

57 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

58 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 =0@3 x 11 =0@3 x 4 =1@6

59 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...

60 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

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

62 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

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

64 Technion64 (Implemented in Chaff) VSIDS (Variable State Independent Decaying Sum) Decision heuristics - VSIDS 1.Each variable in each polarity has a counter initialized to 0. 2. 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.

65 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.

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

67 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.

68 Technion68 Berkmin heuristic tail- first conflict clause

69 Technion69 The SAT competitions

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

71 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 …

72 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

73 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.

74 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

75 Technion75 Reduction Rule #1 Merge equivalent leaves aa a

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

77 Technion77 Reduction Rule #3 Eliminate Redundant Tests y x y

78 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

79 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 ? …

80 Technion80 Effect of Variable Ordering Good OrderingBad Ordering Linear GrowthExponential Growth

81 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

82 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’.

83 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,

84 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

85 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 2. 1. 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 ) 0 1 1 Ç = 0 1 0 Æ =

86 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

87 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

88 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 2 01 0 Ç 0 = 0 1 Ç 1 = 1

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

90 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.

91 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”,…


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

Similar presentations


Ads by Google