Foundations of Artificial Intelligence
Total Page:16
File Type:pdf, Size:1020Kb
Foundations of Artificial Intelligence 31. Propositional Logic: DPLL Algorithm Martin Wehrle Universit¨atBasel April 25, 2016 Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Propositional Logic: Overview Chapter overview: propositional logic 29. Basics 30. Reasoning and Resolution 31. DPLL Algorithm 32. Local Search and Outlook Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Motivation Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Propositional Logic: Motivation Propositional logic allows for the representation of knowledge and for deriving conclusions based on this knowledge. many practical applications can be directly encoded, e.g. constraint satisfaction problems of all kinds circuit design and verification many problems contain logic as ingredient, e.g. automated planning general game playing description logic queries (semantic web) Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Propositional Logic: Algorithmic Problems main problems: reasoning (Θ j= '?): Does the formula ' logically follow from the formulas Θ? equivalence (' ≡ ): Are the formulas ' and logically equivalent? satisfiability (SAT): Is formula ' satisfiable? If yes, find a model. German: Schlussfolgern, Aquivalenz,¨ Erf¨ullbarkeit Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary The Satisfiability Problem The Satisfiability Problem (SAT) given: propositional formula in conjunctive normal form (CNF) usually represented as pair hV ; ∆i: V set of propositional variables (propositions) ∆ set of clauses over V (clause = set of literals v or :v with v 2 V ) find: satisfying interpretation (model) or proof that no model exists SAT is a famous NP-complete problem (Cook 1971; Levin 1973). Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Relevance of SAT The name \SAT" is often used for the satisfiability problem for general propositional formulas (instead of restriction to CNF). General SAT can be reduced to CNF (conversion in time O(n)). All previously mentioned problems can be reduced to SAT (conversion in time O(n)). SAT algorithms important and intensively studied this and next chapter: SAT algorithms Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Systematic Search: DPLL Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary SAT vs. CSP SAT can be considered as constraint satisfaction problem: CSP variables = propositions domains= fF; Tg constraints = clauses However, we often have constraints that affect > 2 variables. Due to this relationship, all ideas for CSPs are applicable to SAT: search inference variable and value orders Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary The DPLL Algorithm The DPLL algorithm (Davis/Putnam/Logemann/Loveland) corresponds to backtracking with inference for CSPs. recursive call DPLL(∆; I ) for clause set ∆ and partial interpretation I result is consistent extension of I ; unsatisfiable if no such extension exists first call DPLL(∆; ;) inference in DPLL: simplify: after assigning value d to variable v, simplify all clauses that contain v forward checking (for constraints of potentially higher arity) unit propagation: variables that occur in clauses without other variables (unit clauses) are assigned immediately minimum remaining values variable order Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary The DPLL Algorithm: Pseudo-Code function DPLL(∆; I ): if 2 ∆: [empty clause exists unsatisfiable] return unsatisfiable else if ∆ = ;: [no clauses left interpretation I satisfies formula] return I else if there exists a unit clause fvg or f:vg in ∆:[unit propagation] Let v be such a variable, d the truth value that satisfies the clause. ∆0 := simplify(∆; v; d) return DPLL(∆0; I [ fv 7! dg) else: [splitting rule] Select some variable v which occurs in ∆. for each d 2 fF; Tg in some order: ∆0 := simplify(∆; v; d) I 0 := DPLL(∆0; I [ fv 7! dg) if I 0 6= unsatisfiable return I 0 return unsatisfiable Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary The DPLL Algorithm: simplify function simplify(∆; v; d) Let ` be the literal for v that is satisfied by v 7! d. Let `¯ be the complementary (opposite) literal to `. ∆0 := fC j C 2 ∆ such that `2 = Cg ∆00 := fC n f`¯g j C 2 ∆0g return ∆00 Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Example (1) ∆ = ffX ; Y ; :Zg; f:X ; :Y g; fZg; fX ; :Y gg 1. unit propagation: Z 7! T ffX ; Y g; f:X ; :Y g; fX ; :Y gg 2. splitting rule: 2a. X 7! F 2b. X 7! T ffY g; f:Y gg ff:Y gg 3a. unit propagation: Y 7! T 3b. unit propagation: Y 7! F fg fg Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Example (1) ∆ = ffX ; Y ; :Zg; f:X ; :Y g; fZg; fX ; :Y gg 1. unit propagation: Z 7! T ffX ; Y g; f:X ; :Y g; fX ; :Y gg 2. splitting rule: 2a. X 7! F 2b. X 7! T ffY g; f:Y gg ff:Y gg 3a. unit propagation: Y 7! T 3b. unit propagation: Y 7! F fg fg Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Example (1) ∆ = ffX ; Y ; :Zg; f:X ; :Y g; fZg; fX ; :Y gg 1. unit propagation: Z 7! T ffX ; Y g; f:X ; :Y g; fX ; :Y gg 2. splitting rule: 2a. X 7! F 2b. X 7! T ffY g; f:Y gg ff:Y gg 3a. unit propagation: Y 7! T 3b. unit propagation: Y 7! F fg fg Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Example (1) ∆ = ffX ; Y ; :Zg; f:X ; :Y g; fZg; fX ; :Y gg 1. unit propagation: Z 7! T ffX ; Y g; f:X ; :Y g; fX ; :Y gg 2. splitting rule: 2a. X 7! F 2b. X 7! T ffY g; f:Y gg ff:Y gg 3a. unit propagation: Y 7! T 3b. unit propagation: Y 7! F fg fg Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Example (1) ∆ = ffX ; Y ; :Zg; f:X ; :Y g; fZg; fX ; :Y gg 1. unit propagation: Z 7! T ffX ; Y g; f:X ; :Y g; fX ; :Y gg 2. splitting rule: 2a. X 7! F 2b. X 7! T ffY g; f:Y gg ff:Y gg 3a. unit propagation: Y 7! T 3b. unit propagation: Y 7! F fg fg Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Example (1) ∆ = ffX ; Y ; :Zg; f:X ; :Y g; fZg; fX ; :Y gg 1. unit propagation: Z 7! T ffX ; Y g; f:X ; :Y g; fX ; :Y gg 2. splitting rule: 2a. X 7! F 2b. X 7! T ffY g; f:Y gg ff:Y gg 3a. unit propagation: Y 7! T 3b. unit propagation: Y 7! F fg fg Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Example (1) ∆ = ffX ; Y ; :Zg; f:X ; :Y g; fZg; fX ; :Y gg 1. unit propagation: Z 7! T ffX ; Y g; f:X ; :Y g; fX ; :Y gg 2. splitting rule: 2a. X 7! F 2b. X 7! T ffY g; f:Y gg ff:Y gg 3a. unit propagation: Y 7! T 3b. unit propagation: Y 7! F fg fg Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Example (1) ∆ = ffX ; Y ; :Zg; f:X ; :Y g; fZg; fX ; :Y gg 1. unit propagation: Z 7! T ffX ; Y g; f:X ; :Y g; fX ; :Y gg 2. splitting rule: 2a. X 7! F 2b. X 7! T ffY g; f:Y gg ff:Y gg 3a. unit propagation: Y 7! T 3b. unit propagation: Y 7! F fg fg Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Example (1) ∆ = ffX ; Y ; :Zg; f:X ; :Y g; fZg; fX ; :Y gg 1. unit propagation: Z 7! T ffX ; Y g; f:X ; :Y g; fX ; :Y gg 2. splitting rule: 2a. X 7! F 2b. X 7! T ffY g; f:Y gg ff:Y gg 3a. unit propagation: Y 7! T 3b. unit propagation: Y 7! F fg fg Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Example (2) ∆ = ffW ; :X ; :Y ; :Zg; fX ; :Zg; fY ; :Zg; fZgg 1. unit propagation: Z 7! T ffW ; :X ; :Y g; fX g; fY gg 2. unit propagation: X 7! T ffW ; :Y g; fY gg 3. unit propagation: Y 7! T ffW gg 4. unit propagation: W 7! T fg Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Example (2) ∆ = ffW ; :X ; :Y ; :Zg; fX ; :Zg; fY ; :Zg; fZgg 1. unit propagation: Z 7! T ffW ; :X ; :Y g; fX g; fY gg 2. unit propagation: X 7! T ffW ; :Y g; fY gg 3. unit propagation: Y 7! T ffW gg 4. unit propagation: W 7! T fg Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Example (2) ∆ = ffW ; :X ; :Y ; :Zg; fX ; :Zg; fY ; :Zg; fZgg 1. unit propagation: Z 7! T ffW ; :X ; :Y g; fX g; fY gg 2. unit propagation: X 7! T ffW ; :Y g; fY gg 3. unit propagation: Y 7! T ffW gg 4. unit propagation: W 7! T fg Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Example (2) ∆ = ffW ; :X ; :Y ; :Zg; fX ; :Zg; fY ; :Zg; fZgg 1. unit propagation: Z 7! T ffW ; :X ; :Y g; fX g; fY gg 2. unit propagation: X 7! T ffW ; :Y g; fY gg 3. unit propagation: Y 7! T ffW gg 4. unit propagation: W 7! T fg Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Example (2) ∆ = ffW ; :X ; :Y ; :Zg; fX ; :Zg; fY ; :Zg; fZgg 1. unit propagation: Z 7! T ffW ; :X ; :Y g; fX g; fY gg 2. unit propagation: X 7! T ffW ; :Y g; fY gg 3. unit propagation: Y 7! T ffW gg 4. unit propagation: W 7! T fg Motivation Systematic Search: DPLL DPLL on Horn Formulas Summary Example (2) ∆ = ffW ; :X ; :Y ; :Zg; fX ; :Zg; fY ; :Zg; fZgg 1.