21
1 Logical Inference Algorithms CS 171/271 (Chapter 7, continued) Some text and images in these slides were drawn from Russel & Norvig’s published material

1 Logical Inference Algorithms CS 171/271 (Chapter 7, continued) Some text and images in these slides were drawn from Russel & Norvig’s published material

Embed Size (px)

Citation preview

1

Logical Inference Algorithms

CS 171/271(Chapter 7, continued)

Some text and images in these slides were drawn fromRussel & Norvig’s published material

2

Inference Rules Modus Ponens

,

And-Elimination

Logical Equivalences

3

Logical Equivalences

4

Validity and Satisfiability A sentence is valid if it is true in all

models KB╞ iff (KB ) is valid

(deduction theorem) A sentence is satisfiable if it is true in some model KB╞ iff (KB ) is unsatisfiable

(proof by contradiction) is satisfiable iff is not valid

is valid iff is unsatisfiable

5

Resolution Inference Rule Simple case:

a b, b c a c(b and b are complementary literals that are eliminated)

General case:replace a and c with disjunctions of any number of literals

6

Conjunctive Normal Form Any sentence can be converted to a

logically equivalent sentence that is a conjunction of disjunctions of literals Ands of or-clauses This can be done by repeated applications of

biconditional elimination, implication elimination and distributivity

Motivation: if KB is in CNF, can devise an inference algorithm based on resolution

7

Algorithm Using Resolution Convert (KB ) to conjunctive

normal form (CNF) Get pairs of clauses and eliminate

complementary literals if they exist If an empty clause results, (KB

) is unsatisfiable, which means KB╞ Proof by contradiction

8

Resolution

9

Resolution Example

KB = (B1,1 (P1,2 P2,1)) B1,1 α = P1,2

10

Restricted Knowledge Bases If sentences in the KB are of a

particular form, inference may turn out to be easier, simpler, quicker

Full power of resolution not really needed in many practical situations

Case in point: Horn Clauses

11

Horn Clauses Horn-Clause

Clause of or-ed literals where at most one literal is positive

Can be converted to an implication Example: ( a b c ) ( a b c )

Can use Modus Ponens and chaining in an entailment procedure

12

Forward Chaining Algorithm Assume KB contains

single (positive) symbols known to be true implications

Implications with premises that contain the symbols yield new symbols once premise has been satisfied

Continue until q (the query symbol) is encountered

13

Forward Chaining

14

Forward-Chaining Example

15

Backward-Chaining Variant of chaining that starts with

target query q Look for implications that conclude q

Take note of its premises If one of those premises can be shown

true (also by backward chaining), then q is true

Goal-directed reasoning

16

Analysis of Inference Algorithms Soundness Completeness Time Complexity

17

Improvement toModel Checking DPLL algorithm Same as Model Enumeration with

some improvements: Early termination Pure symbol heuristic Unit clause heuristic

18

DPLL (Backtracking)

19

An Inference Agentin the Wumpus World KB initially contains sets of sentences

that: State absence of pit in room [1,1] State absence of wumpus in room [1,1] State how a breeze arises State how a stench arises Knows there is exactly one wumpus

At least one wumpus Of two squares, one should not have wumpus

155 sentences with 64 distinct symbols

20

An Inference Agentin the Wumpus World

On each percept: TELL status of stench or breeze Grab if glitter is perceived ASK if there is a provably safe

square, or at least a possible safe square, then go there May need a list of actions to go there

21