CSCE 420 Lecture 13
« previous | Tuesday, February 26, 2013 | next »
Midterm exam next week!
Wumpus World
4 × 4 Grid, Agent at starting position, pits and Wumpuses (foul-smelling creatures that will kill the agent) scattered throughout, goal is to find gold. Assume that Wumpuses cannot move.
- pits cause breeze in adjacent cells
- wumpuses cause stench in adjacent cells
- gold has a glitter in its own cell
Here might be a set of rules:
pickup_gold <- in(x,y) and glitter go_north <- in(x,y) and not glitter and safe(x,y+1) and not visited(x,y+1) safe(x,y) <- not wumpus(x,y) and not pit (x,y) wumpus(x,y) <- stench(x+1,y) and stench(x-1,y) and stench(x,y+1) and stench(x,y-1)
Is it true that ?
- How do we answer a query?
- How do we decide entailments?
In general means "does follow from our knowledge base"
Entailment
Defined: KB entails if all the models of KB are a subset of all models of
Brute-force: enumerate and check all models; is it decidable?
KB represented as a list of sentences, which are interpreted to all be conjoined with AND operations
Brute force:
| KB | |||||
|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 0 |
| 0 | 0 | 1 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 1 | 1 |
is not true because a model that satisfies KB, namely , does not satisfy (satisfiability is co-NPC)
Natural Deduction
Proof of from initial sentences KB by syntactic transformations
A finite-length proof is a sequence of sentences starting with KB and ending with such that each step is a sound derivation.
Logical equivalences are truth-preserving
The last symbol is read "derives" and may be subscripted with rule name.
Derivations may not be truth-preserving, but still represent sound transformations:
- AND-elimination:
- Modus Ponens:
- Resolution:
In general, a transformation is sound if . This implies
Algorithm
function NatDed(KB, q) returns Bool
proof <- append(KB)
while true
select inference transformation
select pair of sentences to which transformation applies
create derived sentence by applying transformation
if q = derived, return true
proof.append(derived)
end while
end function
Example Trace:
. . . ?
- [1, Implication elimination]
- [5, 6, AND introduction]
- [4, Modus ponens]
- [6, 9, AND introduction]
- [10, 3, Modus ponens]
- [9,11, AND introduction]
- [2, 12, Modus ponens]
- [12, 1, Modus ponens]
Proof Tree (And-Or Tree)
Q (P -> Q)
`-- P (L && M -> P)
|-- L (A && B -> L)
| |-- A
| `-- B
`-- M (L && B -> M)
|-- L (A && B -> L)
| |-- A
| `-- B
`-- B (fact)
Forward Chaining
Working bottom-up on proof tree using only modus ponens
Agenda: pattern-matching to antecedents of rules to see which can be "activated"
Using above example:
- A = {A, B} Rule 4 is activated, add L
- A = {A, B, L} Rule 3 is activated, add M
- A = {A, B, L, M} Rule 2 is activated, add P
- A = {A, B, L, M, P} Rule 4 is activated, add Q
- Done
Only restricted to Horn-Clause knowledge bases: disjunction with at most one positive literal
- (As opposed to conjunctive rules with all positive literals)
- Won't work for
Algorithm
function Forward-Chaining(KB, q) returns Bool
queue.push(facts(KB))
for each r in literals(KB)
count(r) := 0 (* number of antecedents of r satisfied *)
end for
while queue is not empty
p := queue.pop
if p = q, return true
else if inferred(p) = F then (* not already on agenda *)
inferred(p) = T
for each rule r for which p in antecedents(r)
count(r) := count(r) - 1
if count(r) = 0, queue.push(consequence(r))
end for
end if
end while
return false
end function
Summary
Forward-Chaining and Natural Deduction can generate many irrelevant consequences
Tomorrow: Back-Chaining is a top-down ("goal-directed") approach that starts with query and works backwards to establish truth of query