Presentation is loading. Please wait.

Presentation is loading. Please wait.

Logics for Data and Knowledge Representation Propositional Logic: Reasoning Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto.

Similar presentations


Presentation on theme: "Logics for Data and Knowledge Representation Propositional Logic: Reasoning Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto."— Presentation transcript:

1 Logics for Data and Knowledge Representation Propositional Logic: Reasoning Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto Giunchiglia, Rui Zhang and Vincenzo Maltese

2 Outline  Review of PL: Syntax and semantics  Reasoning in PL  Typical tasks  Calculus  Problems with reasoning  Calculus using tableaux  The DPLL Procedure for PSAT  Main steps  The algorithm  Examples  Observations about the DPLL  Conclusions on PL  Pros and cons  Examples 2

3 Summary about PL so far  PROPOSITIONS  Propositional logic (PL) is the simplest logic which deals with propositions (no individuals, no quantifiers)  Propositions are something true or false  SYNTAX  We need to provide a language, including the alphabet of symbols and formation rules to articulate complex formulas (sentences)  A propositional theory is formed by a set of PL formulas  SEMANTICS  Providing semantics means providing a pair (M, ⊨ ), namely a formal model satisfying the theory  A truth valuation ν is a mapping L  {T, F}  Logical implication (  )  Normal Forms: CNF - DNF 3 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

4 Reasoning Services  Basic reasoning tasks for a PL-based system:  Model checking (EVAL)  Satisfiability (SAT) reduced to model checking (we choose an assignment first)  Validity (VAL) reduced to model checking (try for all possible assignments)  Unsatisfiability (unSAT) reduced to model checking (try for all possible assignments)  Entailment (ENT) reduced to previous problems NOTE: SAT/UNSAT/VAL on generic formulas can be reduced to SAT/UNSAT/VAL on CNF formulas See for instance: http://www.satisfiability.orghttp://www.satisfiability.org 4 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

5 Reasoning in PL  Reasoning in PL is the simplest case of reasoning  We use truth tables  In model checking we just verify a given assignment ν  In SAT we try with all possible assignments but we stop when we find the first one which makes the formula true. 5 Given ν(A) = T, ν(B) = F is the formula A  B true? YES! Is A  B satisfiable? With ν(A)=T, ν(B)=F we have ν(A  B) = F With ν(A)=F, ν(B)=T we have ν(A  B) = F With ν(A)=T, ν(B)=T we have ν(A  B) = T STOP! REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

6 Calculus  Semantic tableau is a decision procedure to determine the satisfiability of finite sets of formulas.  There are rules for handling each of the logical connectives thus generating a truth tree.  A branch in the tree is closed if a contradiction is present along the path (i.e. of an atomic formula, e.g. B and  B)  If all branches close, the proof is complete and the set of formulas are unsatisfiable, otherwise are satisfiable.  With refutation tableaux the objective is to show that the negation of a formula is unsatisfiable. 6 Γ = {(A  B), B} B A   B A BB closed REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

7 Rules of the semantic tableaux  Conjunctions lie on the same branch  Disjunctions generate new branches  The initial set of formulas are considered in conjunction and are put in the same branch of the tree (  ) A  B(  ) A  B --------- --------- A A | B B (  )   A A --------- --------- A   A 7  (A  B)  B B A   B A closed BB  (A   B) REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

8 What is the problem in reasoning in PL? (I)  Given a proposition P with n atomic formulas, we have 2 n possible assignments ν !  SAT is NP-complete In the worst case reasoning time is exponential in n (in the case we test all possible assignments), but potentially less if we find a way to look for “good” assignments (if there is at least an assignment such that ν ⊨ P. We stop when we find it.) NOTE: the worst case is when the formula is unsatisfiable  Testing validity (VAL) of a formula P is even harder, since we necessarily need to try ALL the assignments. We stop when we find a ν such that ν ⊭ P 8 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

9 What is the problem in reasoning in PL? (II)  Reducing unSAT to SAT Unsatisfiability is the opposite of SAT. We stop when we find an assignment ν such that ν ⊨ P.  SAT, VAL, unSAT are search problems  How complex is the task?  Notice that what makes reasoning exponential are disjunctions (  ) because we need to test all possible options  Trivially, in case of conjunctions (  ) all the variables must be true  IMPORTANT: Often (when we do not use individuals or quantifiers) we can reduce reasoning in complex logics to reasoning in PL 9 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

10 PSAT-Problem (Boolean SAT)  Definition: PSAT = find ν such that ν ⊨ P (Satisfiability problem)  Is PSAT decidable? YES, BUT EXPENSIVE! Theorem [Cook,1971] PSAT is NP-complete The theorem established a “limitative result” of PL (and Logic). A problem is NP-complete when it is very difficult to be computed!  DPLL (Davis-Putnam-Logemann-Loveland, 1962)  It is the most widely used algorithm for PSAT  It works on CNF formulas  It can take from constant to exponential time 10 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

11 CNFSAT-Problem  Definition: CNFSAT = find ν s.t. ν ⊨ P, with P in CNF  Is CNFSAT decidable? YES, BUT STILL EXPENSIVE! Like PSAT, CNFSAT is NP-complete.  Converting a formula in CNF  It is always possible to convert a generic formula in CNF, but in exponential time (polynomial in most of the cases).  It causes an exponential blow up in the length of the formula. 11 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

12 The DPLL Procedure  DPLL employs a backtracking search to explore the space of propositional variables truth-valuations of a proposition P in CNF, looking for a satisfying truth-valuation of P  DPLL solves the CNFSAT-Problem by searching a truth- assignment that satisfies all clauses θ i in the input proposition P = θ 1  …  θ n  The basic intuition behind DPLL is that we can save time if we first test for some assignments before others 12 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

13 DPLL Procedure: Main Steps 1. It identifies all literal in the input proposition P 2. It assigns a truth-value to each variable to satisfy them 3. It simplifies P by removing all clauses in P which become true under the truth- assignments at step 2 and all literals in P that become false from the remaining clauses (this may generate empty clauses) 4. It recursively checks if the simplified proposition obtained in step 3 is satisfiable; if this is the case then P is satisfiable, otherwise the same recursive checking is done assuming the opposite truth value (*). 13 B  ¬C  (B  ¬A  C)  (¬ B  D) B  ¬C  (B  ¬A  C)  (¬ B  D) ν(B) = T; ν(C) = F D DYES, it is satisfiable for ν(D) = T. NOTE: ν(A) can be T/F REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

14 DPLL algorithm  Input: a proposition P in CNF  Output: true if "P satisfiable" or false if "P unsatisfiable" boolean function DPLL(P) { if consistent(P) then return true; if hasEmptyClause(P) then return false; foreach unit clause C in P do P = unit-propagate(C, P); foreach pure- literal L in P do P = pure-literal-assign(L, P); L = choose-literal(P); return DPLL(P  L) OR DPLL(P   L); } 14 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

15 DPLL algorithm  Input: a proposition P in CNF  Output: true if "P satisfiable" or false if "P unsatisfiable" boolean function DPLL(P) { if consistent(P) then return true; if hasEmptyClause(P) then return false; foreach unit clause C in P do P = unit-propagate(C, P); foreach pure- literal L in P do P = pure-literal-assign(L, P); L = choose-literal(P); return DPLL(P  L) OR DPLL(P   L); } 15 It tests the formula P for consistency, namely it does not contain contradictions (e.g. A   A) and all clauses are unit clauses. REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

16 DPLL algorithm  Input: a proposition P in CNF  Output: true if "P satisfiable" or false if "P unsatisfiable" boolean function DPLL(P) { if consistent(P) then return true; if hasEmptyClause(P) then return false; foreach unit clause C in P do P = unit-propagate(C, P); foreach pure- literal L in P do P = pure-literal-assign(L, P); L = choose-literal(P); return DPLL(P  L) OR DPLL(P   L); } 16 An empty clause does not contain literals. It can be due to previous iterations of the algorithm where some simplifications has been done. If any of them exists then P is unsatisfiable. REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

17 DPLL algorithm  Input: a proposition P in CNF  Output: true if "P satisfiable" or false if "P unsatisfiable" boolean function DPLL(P) { if consistent(P) then return true; if hasEmptyClause(P) then return false; foreach unit clause C in P do P = unit-propagate(C, P); foreach pure- literal L in P do P = pure-literal-assign(L, P); L = choose-literal(P); return DPLL(P  L) OR DPLL(P   L); } 17 (a) It assigns the right truth value to each literal (true for positives and false for negatives). (b) It simplifies P by removing all clauses in P which become true under the truth- assignment and all literals in P that become false from the remaining clauses. REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

18 DPLL algorithm  Input: a proposition P in CNF  Output: true if "P satisfiable" or false if "P unsatisfiable" boolean function DPLL(P) { if consistent(P) then return true; if hasEmptyClause(P) then return false; foreach unit clause C in P do P = unit-propagate(C, P); foreach pure- literal L in P do P = pure-literal-assign(L, P); L = choose-literal(P); return DPLL(P  L) OR DPLL(P   L); } 18 For all literals which appear pure in the formula (i.e. with only one polarity) assign the corresponding value: - true if positive literal - false if negative Not all DPLL versions perform this step. REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

19 DPLL algorithm  Input: a proposition P in CNF  Output: true if "P satisfiable" or false if "P unsatisfiable" boolean function DPLL(P) { if consistent(P) then return true; if hasEmptyClause(P) then return false; foreach unit clause C in P do P = unit-propagate(C, P); foreach pure- literal L in P do P = pure-literal-assign(L, P); L = choose-literal(P); return DPLL(P  L) OR DPLL(P   L); } 19 The splitting rule: Select a variable whose value is not assigned yet. Recursively call DPLL for the cases in which the literal is true or false. REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

20 DPLL Procedure: Example 1 P = A ∧ (A ∨ ¬A) ∧ B  There are still variables and clauses to analyze, go ahead  P does not contain empty clauses, go ahead  It assigns the right truth-value to A and B: ν (A) = T, ν (B) = T  It simplifies P by removing all clauses in P which become true under ν (A) = T and ν (B) = T This causes the removal of all the clauses in P  It simplifies P by removing all literals in the clauses of P that become false from the remaining clauses: nothing to remove  It assigns values to pure literals. nothing to assign  All variables are assigned: it returns true 20 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

21 DPLL Procedure: Example 2 P = C ∧ (A ∨ ¬A) ∧ B  There are still variables and clauses to analyze, go ahead  P does not contain empty clauses, go ahead  It assigns the right truth-value to C and B: ν (C) = T, ν (B) = T  It simplifies P by removing all clauses in P which become true under ν (C) = T and ν (B) = T. P is then simplified to (A ∨ ¬A)  It simplifies P by removing all literals in the clauses of P that become false from the remaining clauses: nothing to remove  It assigns values to pure literals: nothing to assign  It selects A and applies the splitting rule by calling DPLL on  A ∧ (A ∨ ¬A) AND ¬A ∧ (A ∨ ¬A) which are both true (the first call is enough). It returns true 21 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

22 DPLL Procedure: Example 3 P = A ∧ ¬B ∧ (¬A ∨ B)  There are still variables and clauses to analyze, go ahead  P does not contain empty clauses, go ahead  It assigns the right truth-value to A and B ν (A) = T, ν (B) = F  It simplifies P by removing all clauses in P which become true under ν (A) = T and ν (B) = F. P is simplified to (¬A ∨ B)  It simplifies P by removing all literals in the clauses of P that become false from the remaining clauses: the last clause becomes empty  It assigns values to pure literals: nothing to assign  All variables are assigned but there is an empty clause: it returns false 22 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

23 The branching literal  The branching literal is the literal considered in the backtracking step (the one chosen for the splitting rule)  The DPLL algorithm (and corresponding efficiency) highly depends on the choice of the branching literal  DPLL as a family of algorithms:  One for each possible way of choosing the branching literal  The running time can be constant or exponential depending on the choice of the branching literals  Researches mainly focus on smart choices for the branching literal 23 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

24 Final observations on the DPLL  There are several versions of the DPLL. We presented one.  Finding solutions to propositional logic formulas is an NP-complete problem  A DPLL SAT solver:  works on formulas in CNF  employs a systematic backtracking search procedure to explore the (exponentially-sized) space of variable assignments looking for satisfying assignments  Modern SAT solvers (developed in the last ten years) come in two flavors: "conflict-driven" and "look-ahead“ approaches 24 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

25 Using DPLL for reasoning tasks  Model checkingDoes ν satisfy P? ( ν ⊨ P?) Check if ν (P) = true  Satisfiability Is there any ν such that ν ⊨ P? Check that DPLL(P) succeeds and returns a ν  UnsatisfiabilityIs it true that there are no ν satisfying P? Check that DPLL(P) fails  Validity Is P a tautology? (true for all ν ) Check that DPLL(  P) fails NOTE: typical DPLL implementations take two parameters: the proposition P and a model ν. Therefore, in case of model checking the real call would be DPLL(P, ν) and check that it succeeds 25 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

26 Pros and Cons of PL PROS  PL is declarative: the syntax captures facts  PL allows disjunctive (partial) and negated knowledge (unlike most databases)  PSAT is fundamental in important applications 26 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS CONS  PL has limited expressive power (yet useful in lots of applications)  No enumerations  No qualifiers (exists, for all)  No instances

27 Example (KB) Consider the following propositions: AreaManager → ManagerTopManager → Manager Manager → EmployeeTopManager(John) Since we cannot reason on instances, we can’t deduce the following: Manager(John), Employee(John) 27 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

28 Example (KB) Consider the following: AreaManager(x) → Manager(x)Manager(x) → Employee(x) TopManager(x) → Manager(x)TopManager(John) They are not propositions because of the variables. 28 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS

29 Example (DB) If we codify it as a database: - No negations - No disjunctions the reasoning is polynomial. 29 REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVATIONS :: CONCLUSIONS


Download ppt "Logics for Data and Knowledge Representation Propositional Logic: Reasoning Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto."

Similar presentations


Ads by Google