Notes
Slide Show
Outline
1
Logical Agents
  • Chapter 7 (continued)
2
Outline: Inference
  • Resolution in CNF
    • Sound and Complete
  • Forward and Backward Chaining using Modus Ponens in Horn Form
    • Sound and Complete


3
Proof methods
  • Proof methods divide into (roughly) two kinds:
    • Application of inference rules
      • Legitimate (sound) generation of new sentences from old
      • Proof = a sequence of inference rule applications
        Can use inference rules as operators in a standard search algorithm
      • Typically require transformation of sentences into a normal form
    • Model checking
      • truth table enumeration (always exponential in n)
      • improved backtracking, e.g., Davis-Putnam-Logemann-Loveland (DPLL)
      • heuristic search in model space (sound but incomplete)
      • e.g., min-conflicts like hill-climbing algorithms
4
Inference by enumeration
  • Depth-first enumeration of all models is sound and complete










  • For n symbols, time complexity is O(2n), space complexity is O(n)
5
Wumpus world sentences
  • Let Pi,j be true if there is a pit in [i, j].
  • Let Bi,j be true if there is a breeze in [i, j].
    • ØP1,1
    • ØB1,1
    • B2,1


  • "Pits cause breezes in adjacent squares"
    • B1,1  Û (P1,2 Ú P2,1)
    • B2,1  Û (P1,1 Ú P2,2 Ú P3,1)
6
Truth tables for inference
7
Proof methods
  • Proof methods divide into (roughly) two kinds:
    • Application of inference rules
      • Legitimate (sound) generation of new sentences from old
      • Proof = a sequence of inference rule applications
        Can use inference rules as operators in a standard search algorithm
      • Typically require transformation of sentences into a normal form
    • Model checking
      • truth table enumeration (always exponential in n)
      • improved backtracking, e.g., Davis-Putnam-Logemann-Loveland (DPLL)
      • heuristic search in model space (sound but incomplete)
      • e.g., min-conflicts like hill-climbing algorithms
8
Reasoning Patterns in Prop Logic
  • Given(s)
  • Conclusion



  • A Þ B, A
  • B


  • B Ù A
  • A


  • Rules that allow us to introduce new propositions while preserving truth values: logically equivalent


  • Two Examples:
  • Modus Ponens


  • And Elimination


9
Logical equivalence
  • Two sentences are logically equivalent iff true in same models: α ≡ ß iff α╞ β and β╞ α
10
Resolution
  • Conjunctive Normal Form (CNF)
    •    conjunction of disjunctions of literals
    • clauses
    • E.g., (A Ú ØB) Ù (B Ú ØC Ú ØD)


  • Resolution inference rule (for CNF):
  • li Ú… Ú lk, m1 Ú … Ú mn
  • li Ú … Ú li-1 Ú li+1 Ú … Ú lk Ú m1 Ú … Ú mj-1 Ú mj+1 Ú... Ú mn
  • where li and mj are complementary literals.
  • E.g., P1,3 Ú P2,2, ØP2,2
  •      P1,3


  • Resolution is sound and complete
    for propositional logic
11
Resolution example
  • KB = (B1,1 Û (P1,2Ú P2,1)) ÙØ B1,1
  • α = ØP1,2 (negate the premise for proof by refutation)
12
The power of false
  • Given: (P) Ù (ØP)
  • Prove: Z




  • Can we prove ØZ using the givens above?
13
Applying inference rules
  • Equivalent to a search problem


  • KB state = node
  • Inference rule application = edge


14
Inference
  • Define: KB ├i α = sentence α can be derived from KB by procedure i
  • Soundness: i is sound if whenever KB ├i α, it is also true that KB╞ α
  • Completeness: i is complete if whenever KB╞ α, it is also true that KB ├i α
  • Preview: we will define a logic (first-order logic) which is expressive enough to say almost anything of interest, and for which there exists a sound and complete inference procedure.
  • That is, the procedure will answer any question whose answer follows from what is known by the KB.
15
Completeness
  • Completeness: i is complete if whenever KB╞ α, it is also true that KB ├i α


  • An incomplete inference algorithm cannot reach all possible conclusions
    • Equivalent to completeness in search (chapter 3)
16
Resolution
  • Conjunctive Normal Form (CNF)
    •    conjunction of disjunctions of literals
    • clauses
    • E.g., (A Ú ØB) Ù (B Ú ØC Ú ØD)


  • Resolution inference rule (for CNF):
  • li Ú… Ú lk, m1 Ú … Ú mn
  • li Ú … Ú li-1 Ú li+1 Ú … Ú lk Ú m1 Ú … Ú mj-1 Ú mj+1 Ú... Ú mn
  • where li and mj are complementary literals.
  • E.g., P1,3 Ú P2,2, ØP2,2
  •      P1,3


  • Resolution is sound and complete
    for propositional logic
17
Resolution
  • Soundness of resolution inference rule:


  • Ø(li Ú … Ú li-1 Ú li+1 Ú … Ú lk) Þ li
  •        Ømj Þ (m1 Ú … Ú mj-1 Ú mj+1 Ú... Ú mn)
  • Ø(li Ú … Ú li-1 Ú li+1 Ú … Ú lk) Þ (m1 Ú … Ú mj-1 Ú mj+1 Ú... Ú mn)


  • where li and mj are complementary literals.


  • What if li and Ømj are false?
  • What if li and Ømj are true?
18
Completeness of Resolution
  • That is, that resolution can decide the truth value of S


  • S = set of clauses
  • RC(S) = Resolution closure of S = Set of all clauses that can be derived from S by the resolution inference rule.
  • RC(S) has finite cardinality (finite number of symbols P1, P2, … Pk), thus resolution refutation must terminate.
19
Completeness of Resolution (cont)
  • Ground resolution theorem = if S unsatisfiable, RC(S) contains empty clause.
  • Prove by proving contrapositive:
    • i.e., if RC(S) doesn’t contain empty clause, S is satisfiable
    • Do this by constructing a model:
      • For each Pi, if there is a clause in RC(S) containing ØPi and all other literals in the clause are false, assign Pi = false
      • Otherwise Pi = true
    • This assignment of Pi is a model for S.



20
Forward and backward chaining
  • Horn Form (restricted)
    • KB = conjunction of Horn clauses
    • Horn clause =
      • proposition symbol;  or
      • (conjunction of symbols) Þ symbol
    • E.g., C Ù (B Þ A) Ù (C Ù D Þ B)
  • Modus Ponens (for Horn Form): complete for Horn KBs
  • α1, … ,αn, α1 Ù … Ù αn Þ β
  • β


  • Can be used with forward chaining or backward chaining.
  • These algorithms are very natural and run in linear time
21
Forward chaining example
22
Forward chaining example
23
Forward chaining example
24
Proof of completeness
  • FC derives every atomic sentence that is entailed by KB (only for clauses in Horn form)
    • FC reaches a fixed point (the deductive closure) where no new atomic sentences are derived
    • Consider the final state as a model m, assigning true/false to symbols
    • Every clause in the original KB is true in m
      •   a1 Ù  … Ù  ak Þ b
    • Hence m is a model of KB
    • If KB╞ q, q is true in every model of KB, including m
25
Backward chaining example
26
Backward chaining example
27
Backward chaining example
28
Proof methods
  • Proof methods divide into (roughly) two kinds:
    • Application of inference rules
      • Legitimate (sound) generation of new sentences from old
      • Proof = a sequence of inference rule applications
        Can use inference rules as operators in a standard search algorithm
      • Typically require transformation of sentences into a normal form
    • Model checking
      • truth table enumeration (always exponential in n)
      • improved backtracking, e.g., Davis-Putnam-Logemann-Loveland (DPLL)
      • heuristic search in model space (sound but incomplete)
      • e.g., min-conflicts like hill-climbing algorithms
29
Efficient propositional inference
  • Two families of efficient algorithms for propositional inference:


  • Complete backtracking search algorithms
  • DPLL algorithm (Davis, Putnam, Logemann, Loveland)
  • Incomplete local search algorithms
    • WalkSAT algorithm
30
The DPLL algorithm
  • Determine if an input propositional logic sentence (in CNF) is satisfiable.


  • Improvements over truth table enumeration:
    • Early termination
      • A clause is true if any literal is true.
      • A sentence is false if any clause is false.


    • Pure symbol heuristic
      • Pure symbol: always appears with the same "sign" in all clauses.
      • e.g., In the three clauses (A Ú ØB), (ØB Ú  ØC), (C Ú A), A and B are pure, C is impure.
      • Make a pure symbol literal true.


    • Unit clause heuristic
      • Unit clause: only one literal in the clause
      • The only literal in a unit clause must be true.
31
The DPLL algorithm
32
The WalkSAT algorithm
  • Incomplete, local search algorithm
  • Evaluation function: The min-conflict heuristic of minimizing the number of unsatisfied clauses
  • Balance between greediness and randomness
33
The WalkSAT algorithm
34
Hard satisfiability problems
  • Consider random 3-CNF sentences. e.g.,
  • (ØD Ú ØB Ú C) Ù (B Ú ØA Ú ØC) Ù (ØC Ú  ØB Ú E) Ù (E Ú ØD Ú B) Ù (B Ú E Ú ØC)


    • m = number of clauses
    • n = number of symbols


    • Hard problems seem to cluster near m/n = 4.3 (critical point)
35
Hard satisfiability problems
36
Hard satisfiability problems
  • Median runtime for 100 satisfiable random 3-CNF sentences, n = 50
37
Inference-based agents in the wumpus world
  • A wumpus-world agent using propositional logic:


    • ØP1,1
    • ØW1,1
    • Bx,y Û (Px,y+1 Ú Px,y-1 Ú Px+1,y Ú Px-1,y)
    • Sx,y Û (Wx,y+1 Ú Wx,y-1 Ú Wx+1,y Ú Wx-1,y)
    • W1,1 Ú W1,2 Ú … Ú W4,4
    • ØW1,1 Ú ØW1,2
    • ØW1,1 Ú ØW1,3
    • …


  • Þ 64 distinct proposition symbols, 155 sentences
38
 
39
Expressiveness limitation of propositional logic
  • We didn’t keep track of location and time in the KB.  To do this we need more variables:
    • L1,1 to show that agent in L1,1.  Does this work?

  • KB contains "physics" sentences for every single square


  • For every time t and every location [x,y],
  • L x,y Ù FacingRight t Ù Forward t Þ L x+1,y
  • Rapid proliferation of clauses
40
Summary
  • Logical agents apply inference to a knowledge base to derive new information and make decisions
  • Basic concepts of logic:
    • syntax: formal structure of sentences
    • semantics: truth of sentences wrt models
    • entailment: necessary truth of one sentence given another
    • inference: deriving sentences from other sentences
    • soundness: derivations produce only entailed sentences
    • completeness: derivations can produce all entailed sentences
  • Wumpus world requires the ability to represent partial and negated information, reason by cases, etc.
  • Resolution is complete for propositional logic
  • Forward, backward chaining are linear-time, complete for Horn clauses
  • Propositional logic lacks expressive power