Title: Knowledge Representation I
1A sentence is true if and only if A sentence is
satisfiable if and only if A sentence is
unsatisfiable if and only if A sentence is
valid if and only if
2Overview
We plan to represent the world (or some subset
thereof, ie our domain) in FOL, and to TELL this
information into our Knowledge Base KB. We
will represent our problem (ie the statement we
want to prove) in FOL. We will sometimes call the
statement to be proved a goal. So proving a
statement is equivalent to seeing if the goal is
in the KB, or if not in it, can be deduced
(entailed) from it.
3The simplest example
Suppose our KB consists of P Q R
A simple goal is Q. Literally we are asking is
it the case that Q is true. In this case, the
answer is yes!
4Another simple example
Suppose our KB consists of P Q R
Now suppose the goal is P ? Q. We are
literally asking is it the case that P is true
and Q is true. In this case, the fact P ? Q is
not in our KB. But we can infer it by using the
And-Introduction rule.
5A more interesting example
- Suppose our KB consists of facts about
containment - General facts about containment
- ?x,y,z in(x,y) ? in(y,z) ? enclosedby(x,z)
- ?x,y in(x,y) ? enclosedby(x,y)
- Specific facts for our particular problem
- in(A,B) in(B,C) in(F,C)
Note, in means directly inside with nothing in
between, encloses means inside, possibly with
other items in between.
A
F
B
A goal might be ?x enclosedby(B,x) (ie, is
there any thing inside B?) or ?x,y,z
enclosedby(x,y) ? enclosedby(y,z)
C
6Models I
A model is simply a world in which a sentence
is true. Consider the sentence P ? Q , given
that P Means is tall. Q Means is rich. We
can now ask if the following interpretations of P
? Q are models Bill Gates is not a model of
P ? Q Eamonn Keogh is not a model of P ? Q
Michael Jordan is a model of P ? Q
7Models II
If we have the sentence P ? Q, and P Means is
astronaut. Q Means is female. Which of the
following interpretations of P ? Q are
models? Neil Armstrong, Eamonn Keogh, Sally
Ride, Dolly Parton, Bill Clinton, Valentina
Tereshkova,
8Models III
Models are important because they allow a simple
definition of entailment. A Knowledge Base KB
entails a sentence ? if and only if, all models
of KB are also models of ?. For example the KB
P ? Q can be said to entail the sentence P ?
Q, since all models of P ? Q are also models of P
? Q.
9In propositional logic, proof is easy I
Suppose we had P and P ? Q in our KB, and we have
a goal of Q We can always build a truth table
with an entry for each symbol and each item from
our KB
P ? Q P
Goal Q?
We need to look at all rows where the statements
in our KB are true
10In propositional logic, proof is easy I
Suppose we had P and P ? Q in our KB, and we have
a goal of Q We can always build a truth table
with an entry for each symbol and each item from
our KB
P ? Q P
Q?
We need to look at all rows where the statements
in our KB are true. Since in every case where our
KB statements are true, Q is also true, thus we
have proved Q! (I.e our KB entails Q) All
models of P ? Q , P are also models of Q.
11In FOL, proof is harder
Suppose we had P(A) and ?x P(x) ? Q(x) in our KB,
and we have a goal of Q(A) We can build a truth
table but we cannot fill it in.
?x P(x) ? Q(x) P(A)
Q(A)?
I.e. the general sentence never follows from any
of these instances. How are we to know if the KB
entails the sentence Q(A)
12Substitution (Binding, Instantiation)
Substitution is a variable (or set of variables)
paired with a term. Example SUBSTx/Harpois a
substitution indicating that Harpo should be
substituted for x. Brother(x,Groucho)
becomes Brother(Harpo,Groucho) Example
SUBSTx/YoungestSonOF(Minnie)is a substitution
indicating that YoungestSonOF(Minnie) should be
substituted for x. Brother(x,Groucho)
becomes Brother(YoungestSonOF(Minnie),Grouch
o)
13Universal Elimination(Universal Instantiation)
?x ? SUBST(x/g, ?)
For any sentence ?, variable x, and term g.
For example, from ?x loves(x, Beatles) We can
use the substitution x/Nick to
infer loves(Nick, Beatles) Or can use the
substitution x/MotherOf(Joe) to
infer loves(MotherOf(Joe) , Beatles)
- Terms (A term is an expression that refers to
an object). - Either
- A symbol
- A function application
- Symbols can be constants John, Mary, 17, 56
- or variables F_name, L_name, X, Y
- Function applications are usually written as
SomethingOf - MotherOf(John)
- AgeOf(Mary)
- EyeColorOf(MotherOf(John))
14Existential Elimination(Existential
Instantiation)
For any sentence ?, variable x, and constant term
k. Where k does not already exist in our KB
?x ? SUBST(x/k, ?)
For example from ?x President(x, USA) We can
use substitution x/someoldwhiteguy to
infer President(someoldwhiteguy, USA) Later on,
if we happen to learn the president is Bush we
can assign someoldwhiteguy Bush
- Terms (A term is an expression that refers to
an object). - Either
- A symbol
- A function application
- Symbols can be constants John, Mary, 17, 56
- or variables F_name, L_name, X, Y
- Function applications are usually written as
SomethingOf - MotherOf(John)
- AgeOf(Mary)
- EyeColorOf(MotherOf(John))
15Existential Introduction
For any sentence ?, term g that occurs in ? and x
that does not occur in ?.
? ?x SUBST(g/x, ?)
For example from President(Bush, USA) We
can infer ?x President(x, USA)
16We can now take these new tools Universal
Elimination Existential Elimination Existential
Introduction Combined with some tools we have
already defined To prove facts in First Order
Logic
17A sample proof in FOL
Bob is a buffalo Buffalo(Bob) Pat is a
pig Pig(Pat) Buffaloes outrun pigs ?x,y
Buffalo(x) ? Pig(y) ? Faster(x,y)
Can Bob outrun Pat? Faster(Bob,Pat)
1. We can use And Introduction to add the
following to our database Buffalo(Bob) ?
Pig(Pat) 2. We can do Universal Elimination to
get x/Bob, y/Pat Buffalo(Bob) ? Pig(Pat) ?
Faster(Bob, Pat) 3. We then use Modus Ponens to
derive Faster(Bob, Pat)
18The need for a better proof mechanism
The proof mechanism we have just seen can be
imagined as search. The operators are inference
rules (Existential Introduction, Universal
Elimination, etc) The states are set of sentences
(The KB itself) The goal test is to see if a
state contains the query sentence.
This idea works, but It seriously slows down
when the KB gets larger, because the number of
possible substitutions grows exponentially. One
possible solution is to reduce the number of
operators This leads us to Generalized Modus
Ponens (GMP).
19Generalized Modus Ponens Combines
And-Introduction, Universal-Elimination, and
Modus Ponens
For atomic sentences p1, p2, and q, where there
is a substitution ? such that SUBST(?/ pi )
SUBST(?/ pi)
Example p1 Faster(Bob,Pat) p2
Faster(Pat,Steve) p1 ? p2 ? q
Faster(x,y) ? Faster(y,z) ? Faster(x,z)
SUBST(?/q) SUBST(x/Bob, y/Pat, z/Steve )
Then using GMP we can conclude
Faster(Bob,Steve) Note that GMP only works for a
KB of definite clauses (Exactly one positive
literal) either a single atom or (conjunction of
atomic sentences) ? atomic sentence Sentences in
this form are known as horn clauses. Note also
that all sentences are assumed to be universally
qualified
20Forward Chaining
- Proofs start with the given axioms/premises in
KB, deriving new sentences using GMP until the
goal/query sentence is derived. This defines a
forward chaining inference procedure because it
moves "forward" from the KB to the goal. - Example KB All cats like fish, cats eat
everything they like, and Ziggy is a cat. In FOL,
KB - ?x cat(x) ? likes(x, Fish)
- ?x ?y (cat(x) ? likes(x,y)) ? eats(x,y)
- cat(Ziggy)
- Goal query Does Ziggy eat fish?
- Proof
- Use GMP with (1) and (3) to derive 4.
likes(Ziggy, Fish) - Use GMP with (3), (4) and (2) to derive
eats(Ziggy, Fish) - So, Yes, Ziggy eats fish.
21Backward Chaining
- Backward-chaining deduction using GMP is complete
for KBs containing only Horn clauses. Proofs
start with the goal query, find implications that
would allow you to prove it, and then prove each
of the antecedents in the implication, continuing
to work "backwards" until we get to the axioms,
which we know are true. - Example Does Ziggy eat fish?
- To prove eats(Ziggy, Fish), first see if this is
known from one of the axioms directly. Here it is
not known, so see if there is a Horn clause that
has the consequent (i.e., right-hand side) of the
implication matching the goal. Here, - Proof
- Goal matches RHS of Horn clause (2), so try and
prove new sub-goals cat(Ziggy) and likes(Ziggy,
Fish) that correspond to the LHS of (2) - cat(Ziggy) matches axiom (3), so we've "solved"
that sub-goal - likes(Ziggy, Fish) matches the RHS of (1), so try
and prove cat(Ziggy) - cat(Ziggy) matches (as it did earlier) axiom (3),
so we've solved this sub-goal - There are no unsolved sub-goals, so we're done.
Yes, Ziggy eats fish.
- ?x cat(x) ? likes(x, Fish)
- ?x ?y (cat(x) ? likes(x,y)) ? eats(x,y)
- cat(Ziggy)