Transcript lecture7

Wumpus World
•
•
•
•
•
•
•
•
1 Wumpus and 1 pile of gold in a pit-filled cave
Starts in [1,1] facing right - Random cave
Percepts: [smell, breeze, gold, bump, scream] - does not know own location
Actions: forward, right, left, grab, shoot (1 arrow), climb (only from 1,1)
Wumpus smells bad – adjacent squares (4 connected) have odor
Breeze next to pits
If you run into a wumpus or a pit, you die
Goal: Climb out of cave with the gold (1000 pts) with minimal actions (-1 for each action, and
–1000 if you die, -10 for using the arrow).
•
•
Must have knowledge to infer new facts - e.g. no stench -> no wumpus in adjacent squares
Must remember inferred facts (OK states, etc.) and use them in order to properly fulfill goals KB construction
Knowledge Based Agents
•
•
Have a Knowledge Base - set of representations of facts (rules) about the world
Use knowledge about world/problem to reason about action, infer new knowledge, act quickly and more
efficiently
•
•
•
Can accept new tasks
Can adapt to changes
Can learn new facts
–
–
•
•
•
•
•
•
Representation in KB of knowledge is a sentence (a sentence for each item known)
TELL: method to add new sentences to KB
ASK: method to find out new stuff from KB – anything ASK returns should “follow” from KB
Background knowledge vs. added (telled) - KB construction
Iteratively Tell (percept input(s)) and Ask (action output(s)) over time
Levels of abstraction
–
–
–
•
(add to KB) from environment
infer them from known facts (KB)
Knowledge Level - what KB knows (most abstract)
Logical Level - Encoding into sentences - e.g. Mother (Mary, John)
Implementation Level - how encoding is actually implemented
Must choose representation language and Tell/Ask algorithms which efficiently support the above levels of
abstraction
Definitions: Representation
and Inference
•
Representation Language
– Syntax – describes legal sentences
– Semantics – describes interpretation/meaning of a given sentence
•
Entailment - KB |= s (KB entails s) - sentence is necessarily true given KB
– “one fact follows from another (set of) fact(s)”
– Note that it all rests on the KB being correct in the first place!
– a |= b iff in every model in which a is true, b is true
•
An inference procedure can do one of two things:
– Generate (entail) new sentences
– Determine whether a specific sentence can be entailed from KB
More Definitions on Inference
•
If a given inference procedure i can derive s from a KB we write
–
KB |-i s
•
•
•
A proof of s is the record of operation of KB |-i s of a sound inference procedure i.
A sound inference procedure generates only entailed sentences
An inference procedure is complete if it can generate any entailed sentence
•
Hey? Should an inference procedure be sound? Should it be complete? Obviously, right?
•
•
•
A sentence may be true, false or unknown (standard logic)
logical inference = deduction = sound reasoning
Necessarily true = valid = tautology = true under all possible interpretations in all possible
worlds.
A Sentence is satisfiable if there exists some circumstance for which it is true,
Unsatisfiable = contradiction = a sentence that is not satisfiable
Being able to deduce tautologies and contradictions is important, since a computer does not
understand meaning of variables, for example (if A then B), and A, a computer can deduce B
regardless of interpretation. Thus, the inference procedure should be useful in arbitrary
domains.
•
•
•
Representation Language – design decisions
•
Expressiveness
–
–
–
Natural language - very expressive, but too ambiguous, assumes contextual knowledge
Computer languages (expect too much completeness) - how to handle uncertainty (wumpus in location
a or b)
Balance of expressiveness, unambiguousness, easy support of inference
Representation Language Syntax and Semantics: if
precisely defined then language is a logic
A logic consists of:
1. Formal system for describing knowledge which includes:
a) syntax of the system
b) semantics of the system
2. Proof theory or an inference engine - a set of rules for deducing the
entailments from a KB
Book concentrates on 2 kinds of logic:
1. Propositional logic (boolean)
(a  b  c)
Symbols represent facts (propositions) which may or may
not be true.
2. first-order logic
x  professor ( x)  veryVerySm art ( x) 
represents world in terms of objects, predicates, and
quantifiers.
Propositional Logic (Some Salient Points)
•
•
•
•
•
•
You can use a truth table to determine if a given KB entails a given sentence! How?
Models of a sentence - all worlds in which the sentence is true.
Quote from the book “A sentences s is entailed by a KB if the models of the KB are all models
of the sentence”. What? What about (p  q  p  !p)?
Inference Rules (P210) – Can’t we just use the truth table generation rule?
A Logical Proof is a sequence of Inference rule applications
Let’s try problem 7.10 a,b,c,d,e,f,g (p281)
Propositional Logic - Completeness and Complexity
•
•
•
•
•
•
•
Propositional logic is complete
can always fill out the truth table for n symbols
exponential in n
Is there a polynomial time proof procedure?
Proven that satisfying a set of sentences is NP-complete
Logical inference dependent on monotonicity of propositional and 1st order logic –
Montonicity proclaims that
–
–
•
(KB1 |= s)  ((KB1  KB2) |= s)
Hey! What happens if KB2 = !s !!!!! How in the heck can anything be monotonic??!!?! Oh the
humanity!
Any sentence entailed by KB must still be derivable after KB is augmented by an entailed
sentence. That makes sense!
Solving the Wumpus World with propositional logic
•
•
•
•
Inferring there is a Wumpus in a square - Could do by truth table, but..., can derive it directly
Inferred and Background Knowledge in WW
Problems with propositional logic - Just propositions
Action - shooting the arrow - How many rules are needed?
First Order Logic
• Objects, Properties, Relations (Function a special type of relation)
• Quantifiers allow general rules, etc. (properties, relations of collections of objects)
• o Much more expressive than propositions (facts)
• Term is an object – a function is a term since it can be thought of as an alias for an
object - NoseOf(John)
• Examples, interpretation, equivalence
o
xcat (x)
x professor ( x)  verySmart( x)
x professor ( x)  verySmart( x)
• There isn’t anything you can do that I can’t
do better
• Nobody likes everybody
• There’s somebody for everyone
• Some people like Raymond
• If you go to the beach you get sand in your
toes
Unify
•
•
•
•
•
•
•
•
Knows(John, x), Knows(John, Jane)
Knows(John, x) Knows(y, Todd)
Knows(John, x) Knows(y, Mother(y))
Knows(John, x) Knows(x, Todd)
A(x, y, B(x, y, z)), A(a, Bob, a)
A(x, y, B(x, y, z)), A(a, Bob, B(c, b, a))
A(John, y, B(x, y, z)), A(a, Bob, B(a, b, c))
A(John, y, B(x, y, z)), A(a, b, B(a, M(b), c))
Inference in FOL
•
•
Propositional inference rules all hold
Inference rules for quantifiers
o Universal Elimination - from (x)(P(x)) we can infer P(Waffle) under substitution
{x/Waffle}
o Existential Elimination (constant symbol must not occur elsewhere) - from (x)(P(x))
can infer P(Biscuit) - Biscuit is arbitrary (unique) name for the object which satisfies
(x)(P(x))
o Existential Introduction - from P(Cheese) can infer (x)(P(x))
Nothing bigger than the ocean can live in the ocean. The earth is much
bigger than the ocean. Sea turtles must spend at least part of their lives
living in the ocean. Therefore the earth is not riding on the back of a
giant sea turtle.