outline
play

Outline Knowledge base Propositional logic Syntax and semantics - PDF document

Outline Knowledge base Propositional logic Syntax and semantics Propositional Logic Inference Backtracking (DPLL) CS 486/686 Resolution Sept 23, 2008 Local search (GSAT, WALKSAT) University of Waterloo 1 2


  1. Outline • Knowledge base • Propositional logic – Syntax and semantics Propositional Logic • Inference – Backtracking (DPLL) CS 486/686 – Resolution Sept 23, 2008 – Local search (GSAT, WALKSAT) University of Waterloo 1 2 CS486/686 Lecture Slides (c) 2008 P. Poupart CS486/686 Lecture Slides (c) 2008 P. Poupart Introduction Logic • General language • Many tasks can be formalized as search problems – Can encode any kind of deterministic and discrete knowledge • How to design search algorithms that are general, yet efficient? – Well defined syntax and semantics – Knowledge base: store domain knowledge • Generality: problem independent algorithm • Efficiency: exploit domain knowledge • General algorithms – Heuristic function – Search by inference – Constraints – Can infirm or confirm conclusions • Is there a good language for this? 3 4 CS486/686 Lecture Slides (c) 2008 P. Poupart CS486/686 Lecture Slides (c) 2008 P. Poupart Declarative Approach Syntax of a very simple logic • Do not program the solution • Just describe the problem • Sentence � AtomicSentence | ComplexSentence • AtomicSentence � True | False | Symbol • Symbol � P | Q | R | … • Knowledge base • ComplexSentence � ¬ Sentence – Set of logic sentences | (Sentence ∧ Sentence ) | (Sentence ∨ Sentence) • Goal: | (Sentence ⇒ Sentence ) – Logical formula to be confirmed/infirmed | (Sentence ⇔ Sentence) • Solution Symbols are binary variables – Inference algorithm 5 6 CS486/686 Lecture Slides (c) 2008 P. Poupart CS486/686 Lecture Slides (c) 2008 P. Poupart 1

  2. Logical connector semantics Recall the Street Puzzle 1 2 3 4 5 N i = {English, Spaniard, Japanese, Italian, Norwegian} P Q ¬ P P ∧ Q P ∨ Q P ⇒ Q P ⇔ Q C i = {Red, Green, White, Yellow, Blue} D i = {Tea, Coffee, Milk, Fruit-juice, Water} J i = {Painter, Sculptor, Diplomat, Violinist, Doctor} false false true false false true true A i = {Dog, Snails, Fox, Horse, Zebra} The Englishman lives in the Red house Who owns the Zebra? Who owns the Zebra? false true true false true true false The Spaniard has a Dog Who drinks Water? Who drinks Water? The Japanese is a Painter The Italian drinks Tea true false false false true false false The Norwegian lives in the first house on the left The owner of the Green house drinks Coffee The Green house is on the right of the White house true true false true true true true The Sculptor breeds Snails The Diplomat lives in the Yellow house The owner of the middle house drinks Milk The Norwegian lives next door to the Blue house The Violinist drinks Fruit juice The Fox is in the house next to the Doctor’s 7 8 The Horse is next to the Diplomat’s CS486/686 Lecture Slides (c) 2008 P. Poupart CS486/686 Lecture Slides (c) 2008 P. Poupart Example – Street Puzzle Example – Street Puzzle • Symbols: V in , V ic , V id , V ij , V ia • Constraint: the Spaniard has a dog (V 1spaniard ⇔ V 1dog ) ∧ (V 2spaniard ⇔ V 2dog ) ∧ i ∈ {1,2,3,4,5} n ∈ {English, Spaniard, Japanese, Italian, Norwegian} (V 3spaniard ⇔ V 3dog ) ∧ (V 4spaniard ⇔ V 4dog ) ∧ c ∈ {Red, Green, White, Yellow, Blue} (V 5spaniard ⇔ V 5dog ) d ∈ {Tea, Coffee, Milk, Fruit-juice, Water} j ∈ {Painter, Sculptor, Diplomat, Violinist, Doctor} • Constraint: the green house is on the a ∈ {Dog, Snails, Fox, Horse, Zebra} immediate left of the red house • Example: V 2red = true: the 2 nd house is red ¬ V 1red ∧ (V 1green ⇔ V 2red ) ∧ (V 2green ⇔ V 3red ) ∧ V 2red = false: the 2 nd house is not red (V 3green ⇔ V 4red ) ∧ (V 4green ⇔ V 5red ) ∧ ¬ V 5green 9 10 CS486/686 Lecture Slides (c) 2008 P. Poupart CS486/686 Lecture Slides (c) 2008 P. Poupart Example: 4-Queens problem Example: 4-Queens problem 1 2 3 4 1 2 3 4 • At least one queen in row 1: • Symbols: Q ij i,j ∈ {1,2,3,4} 1 1 Q 11 ∨ Q 12 ∨ Q 13 ∨ Q 14 • Q ij = true: queen at 2 location (i,j) 2 • At most one queen in row 1: • Q ij = false: no queen at Q 11 ⇒ ¬ Q 12 ∧ ¬ Q 13 ∧ ¬ Q 14 3 3 location (i,j) Q 12 ⇒ ¬ Q 11 ∧ ¬ Q 13 ∧ ¬ Q 14 4 4 Q 13 ⇒ ¬ Q 11 ∧ ¬ Q 12 ∧ ¬ Q 14 Q 14 ⇒ ¬ Q 11 ∧ ¬ Q 12 ∧ ¬ Q 13 11 12 CS486/686 Lecture Slides (c) 2008 P. Poupart CS486/686 Lecture Slides (c) 2008 P. Poupart 2

  3. Knowledge Base (KB) Semantics • Semantics • Knowledge base – define the “meaning” of each sentence – Encode problem description and any knowledge – define the truth of each sentence with respect to each that could help solve the problem possible world – Database of facts and constraints • Model: – Possible language: propositional logic – a possible world – each possible configuration of the variables • Entailment • Examples: – What can we derive/conclude from KB? – P, Q, R: 8 models (all possible configurations of P, Q and R) – KB |= α : α follows from KB – 4-queens problem: 2 16 models – Street puzzle: 2 25 models 13 14 CS486/686 Lecture Slides (c) 2008 P. Poupart CS486/686 Lecture Slides (c) 2008 P. Poupart Semantics Inference • Entailment: KB |= α • Process of verifying the truth of a formula – α is true in all the models in which KB is true • Simple inference algorithm: – Build a truth table that enumerates all models models models models α KB α – Verify that formula is true in all models KB α KB where KB is true KB |= α KB | ≠ α KB | ≠ α 15 16 CS486/686 Lecture Slides (c) 2008 P. Poupart CS486/686 Lecture Slides (c) 2008 P. Poupart Truth table Efficiency P Q R KB • Building a truth table is inefficient: KB: P ⇒ Q, exponential in the number of variables true true true false Q ⇒ R, true true false false ¬ Q true false true false • Alternative: backtracking search true false false false – Rewrite “KB |= α ?” as KB |= P? no KB’ = (KB and ¬α ) KB |= ¬ P? false true true false yes – Show that KB’ is not satisfiable (e.g., there KB |= Q? no false true false false KB |= ¬ Q? doesn’t exist any model for which KB is yes false false true true true, but α is false) KB |= R? no false false false true KB |= ¬ R? no 17 18 CS486/686 Lecture Slides (c) 2008 P. Poupart CS486/686 Lecture Slides (c) 2008 P. Poupart 3

  4. Convenience Logical equivalence • KB may contain any formula that follows the • How do we transform a KB in CNF? syntax of our simple logic. • Logical equivalence rules – ¬ ( ¬ A) ≡ A – Inconvenient: too many possible formula – (A ⇒ B) ≡ ¬ A ∨ B – Can we simplify syntax? – (A ⇔ B) ≡ (A ⇒ B) ∧ (B ⇒ A) – ¬ (A ∨ B) ≡ ( ¬ A ∧ ¬ B) • Conjunctive normal form (CNF) – ¬ (A ∧ B) ≡ ( ¬ A ∨ ¬ B) – Only use ∧ , ∨ , ¬ – (A ∨ (B ∧ C)) ≡ ((A ∨ B) ∧ (A ∨ C)) • Can every KB be transformed in CNF in polynomial – Conjunction of clauses, where each clause is a time and space? disjunction of (possibly negated) literals – No: last rule may yield exponentially many clauses – Example: (V1 ∨ V2 ∨ V3) ∧ ( ¬ V1 ∨ V2) ∧ ( ¬ V3 ∨ V2) 19 20 CS486/686 Lecture Slides (c) 2008 P. Poupart CS486/686 Lecture Slides (c) 2008 P. Poupart Inference Properties Resolution • Soundness: an inference algorithm that • Idea: generate new sentences by implications derives only entailed sentence is sound – Unit resolution: A ∧ (A ⇒ B) |= B – General resolution: (A ⇒ B) ∧ (B ⇒ C) |= (A ⇒ C) • Completeness: an inference algorithm is complete if it can derive any sentence that is • How do we do this with KB in CNF? entailed – Unit resolution: A ∧ ( ¬ A ∨ B) |= B • Time and space complexity – General resolution: ( ¬ A ∨ B) ∧ ( ¬ B ∨ C) |= ( ¬ A ∨ C) • Backtracking search and truth table building are sound and complete 21 22 CS486/686 Lecture Slides (c) 2008 P. Poupart CS486/686 Lecture Slides (c) 2008 P. Poupart Resolution Local Search • Algorithm: apply resolution to every possible • Idea: start with a variable configuration and pair of clauses until flip the truth values of some variables until a satisfiable assignment is found – Empty clause is generated: false KB – No more clauses can be generated: all generated clauses are entailed • Examples: – GSAT: greedy SAT • Complete? Yes – WALKSAT: randomized version of GSAT • Sound? Yes 23 24 CS486/686 Lecture Slides (c) 2008 P. Poupart CS486/686 Lecture Slides (c) 2008 P. Poupart 4

Recommend


More recommend