You are on page 1of 25

10-7-2013

Review HW#4
First Order Logic (aka The Predicate Calculus)
Representing

knowledge in FOL

Reading: AIMA Chapter 9 (Inference in FOL)


Exam#1, Tuesday, October 8th, SC166, 7:00 pm

Must interpret variables, constants, functions, and


predicate symbols by associating them with objects,
functions and relations in the world.
Truth values are relative to an interpretation (model)
Express

Johns father is a diplomat. with


diplomat(father-of(john))).

Express

All birds fly. with

( x) bird(x) => fly(x).


An atomic sentence predicate(term1,...,termn) is true
iff the objects referred to by term1,...,termn
are in the relation referred to by predicate

( x) p(x) means

for all objects x in the domain, p(x) is true


that is, it is true in a model m iff p is true with x
being each possible object in the model

example:
All boojums are snarks.
expressed by
(x) [boojum(x) snark(x)].
where
boojum(x) means x is a boojum
snark(x) means x is a snark

( x) p(x) means

there exist one or more objects x in the domain


s.t. p(x) is true
that is, it is true in a model m iff P is true with x
being some possible object in the model

example:
Not all snarks are boojums.
expressed by
( x) [snark(x) ~boojum(x)].
where
boojum(x) means x is a boojum
snark(x) means x is a snark

<variables> <sentence>
Everyone at Clarkson is smart:
x [At(x , Clarkson) Smart(x)].
Roughly speaking, equivalent to the conjunction
of instantiations of P
[At(KingJohn, Clarkson) Smart(KingJohn)]

[At(Richard, Clarkson) Smart(Richard)]

[At(Clarkson, Clarkson) Smart(Clarkson)]


...

Typically, is the main connective with

Common mistake: using as the main


connective with :
x At(x , Clarkson) Smart(x)

means Everyone is at Clarkson and also


everyone is smart

<variables> <sentence>
Someone at SLU is smart:
(x) [At(x, SLU) Smart(x)].
Roughly speaking, equivalent to the disjunction
of instantiations of P
[At(KingJohn, SLU) Smart(KingJohn)]

[At(Richard, SLU) Smart(Richard)]

[At(SLU, SLU) Smart(SLU)]


...

Typically, is the main connective with


Common mistake: using as the main
connective with :
x At(x , SLU) Smart(x)
is true if there is anyone who is not at SLU!

x y is the same as y x

x y is the same as y x
x y is not the same as y x
x y Loves(x,y)
There

is a person who loves everyone in the world


(including him/herself)

y x Loves(x,y)
Everyone

person

in the world is loved by at least one

Quantifier duality: each can be expressed using the


other; e.g. consider the predicate likes(X,Y)
meaning X likes Y.

Everyone dislikes parsnips.

(x) [~likes(x,parsnips)]. ~(x) [likes(x,parsnips)].

Everyone likes ice cream.

(x) likes(x,iceCream) ~(x) [~likes(x,iceCream)].

Someone likes persimmons.

(x) likes(x,persimmons) ~(x) ~likes(x,persimmons)].

term1 = term2 is true under a given


interpretation if and only if term1 and term2
refer to the same object
E.g., definition of Sibling in terms of Parent:

x,y Sibling(x,y) [(x = y) m,f (m = f)


Parent(m,x) Parent(f,x)
Parent(m,y) Parent(f,y)]

1. Choose the task domain or world you want to


represent.
the real world
Clarkson Univ. microcosm
Middle Earth
Bizarro World
internet
virtual world without gravity
2. Associate constants in the language with
individuals in the world.
john
book
pizza
john23
AIbook0-13-790395-2

3. (a) Relations

For each relation you want to represent, associate a


predicate symbol in the language. Each n-ary
predicate symbol denotes a function from Dn to
{true,false}
e.g.
cat(X)
pizza(X)
likes(X,Y)
isin(X,cat)
isa(pizza, food) father-of(X,Y)
isa(cat, mammal)

3. (b) Functions
For each function you want to represent, associate a
function symbol in the language. Each n-ary function
denotes a function from Dn to D s.t.
for each tuple (x1,x2, xn) there is a unique y in D s.t.
f(x1, x2, , xn) = y
dad(X)
ssn(X)
sqrt(x)
signal(t)

evaluates to the person who is Xs father


evalutes to Xs social security number
evalutes to the square root of x
evaluates to the value of the signal at time
step t

question: What is the difference between a

function and a relation?

relation true or false


father(X,Y) means X is the father of Y
function returns a value in the domain
father(X) returns the unique element in the
domain who is Xs father

Cant use the same symbol to mean both

4. You can now write as clauses statements


that are true in the intended
interpretation; this is axiomatizing the
domain, and the clauses are axioms
KB

set of true sentences

5. You can now ask questions about the


intended representation, and interpret
the answers using the meaning that you
have associated with the symbols.
KB i

1.
2.
3.
4.
5.
6.
7.
8.
9.

John likes pizza.


John likes all kinds of food.
Steve only likes easy courses.
All science courses are hard.
Everybody loves somebody.
Abraham is the father of Isaac.
John gave the book to Mary.
Theres a book on the table.
Theres exactly one book on the table.

1. John likes pizza.

interpretation:
constants john, pizza
predicate likes(x,y) means x likes y

likes(john, pizza).
2. John likes all kinds of food.
predicate food(x) means x is food

(x)[ food(x) => likes(john, x) ].

3. Steve only likes easy courses.


predicates: course(x) means x is a course,
easy(x) means x is easy
(x)[ course(x) easy(x) => likes(steve, x) ]
If a course is easy, then Steve likes it (but this doesnt
say that he doesnt like hard courses).
(x)[ likes(steve, x) => course(x) easy(x) ]
The only things that Steve likes are easy courses. (not
pizza, not Mary, not hockey, )
(x)[ course(x) likes(steve, x) => easy(x) ]
If its a course and Steve likes it, then it must be easy.
(x)[ course(x) ~easy(x) => ~likes(steve, x) ]
If its a hard course, then Steve doesnt like it.

3. Steve only likes easy courses.


Which sentence best captures the meaning? B or C?
Answer: C! Why???
B: (x)[ course(x) easy(x) => likes(steve, x) ]
(x)[ ~ course(x) ~ easy(x) likes(steve, x) ]
If its a course and its easy then Steve must like it.
C: (x)[ course(x) likes(steve, x) => easy(x) ]
(x)[ ~ course(x) ~ likes(steve, x) easy(x) ]
If its a course and Steve likes it then it must be easy.

4. All science courses are hard.

predicate: science(x) means x is in a field of science,


hard(x) means x is difficult
(x)[ course(x) science(x) => hard(x) ]
(x)[ course(x) science(x) => ~easy(x) ]

5. Everybody loves somebody.


(x)(y) loves(x,y). says that there is one (possibly
more than one) person whom everyone, including
him/herself, loves.
(y)(x) loves(x,y). says that for every person, you can
find at least one person (possibly him/herself) that
he/she loves.

3.
4.
5.
6.

Steve only likes easy courses.


PH432 is a course.
PH432 is not easy.
likes(Steve, PH432).

Is it possible for Steve to like PH432?


Can sentences 3, 4, 5, and 6 all be true? No.
Can sentences B, 4, 5, and 6 all be true? Yes.
B: (x)[ course(x) easy(x) => likes(steve, x) ]
(x)[ ~ course(x) ~ easy(x) likes(steve, x) ]
If its a course and its easy then Steve must like it.

C: (x)[ course(x) likes(steve, x) => easy(x) ]


(x)[ ~ course(x) ~ likes(steve, x) easy(x) ]
7. BW101 is a course.
8. BW101 is easy.
9. likes(steve, BW101).

Is it possible for Steve to like BW101?


Can sentences C, 7, 8 and 9 all be true? Sure!

What about sentence E?


E: ( course(x))[ likes(steve, x) => easy(x) ]

Not well-formed: can only quantify a variable, not a


predicate ( course(x))

What about sentence F?


F: ( x)[ likes(steve, x) => easy(course(x)) ]

Not well-formed: course(x) is a predicate. Try the


substitution test:
( x)[ likes(steve, x) => easy(true) ] doesnt make

sense

You might also like