Ai - Fol
Ai - Fol
Ai - Fol
&
INFERENCE IN FIRST ORDER LOGIC
By
Predicate Logic
C.PABITHA., AP
1/17/16
Propositional Logic
Propositional logic isnt powerful enough as a
16 rules
Find Wumpus
Sx,y (Wx,y+1 Wx,y-1 Wx+1,y Wx-1,y) (stench next to Wumpus) 16 rules
At least one Wumpus in world
W1,1 W1,2 W4,4 (at least 1 Wumpus) 1 rule
At most one Wumpus
W1,1 W1,2 (155 RULES)
Predicate Logic
1/17/16
First-order logic
Whereas propositional logic assumes the world
contains facts,
first-order logic (like natural language) assumes
the world contains
games, wars,
Predicate Logic
1/17/16
Connectives
Equality
Quantifiers
Predicate Logic
Sqrt( ), LeftLegOf,...
x, y, a, b,...
, , , ,
,
1/17/16
Terms
Term = logical expression that refers to an object.
There are 2 kinds of terms:
Pat_Grandfather(x) = father(father(x))
Predicate Logic
1/17/16
Atomic Sentences
Atomic sentences state facts using terms and predicate symbols
P(x,y) interpreted as x is P of y
Examples:
LargerThan(2,3) is false.
Brother_of(Mary,Pete) is false.
Married(Father(Richard), Mother(John)) could be true or false
Note: Functions do not state facts and form no sentence:
Brother(Pete) refers to John (his brother) and is neither true nor false.
Brother_of(Pete,Brother(Pete)) is True.
Binary relation
Predicate Logic
Function
1/17/16
Complex Sentences
We make complex sentences with connectives (just
property
function
objects
connectives
Predicate Logic
1/17/16
Universal Quantification
Allows
Can
Note that
x King(x) Person(x) is not correct!
This would imply that all objects x are Kings and are People
x King(x) => Person(x) is the correct way to say
10
Predicate Logic
1/17/16
Existential Quantification
x means there exists an x such that.
King(x)
Lives_in(John, Castle(x))
Integer(i) GreaterThan(i,0)
11
Predicate Logic
1/17/16
connective with
12
Predicate Logic
1/17/16
connective with
13
Predicate Logic
1/17/16
Examples
Everyone likes McDonalds
x, likes(x, McDonalds)
Someone likes McDonalds
x, likes(x, McDonalds)
All children like McDonalds
x, child(x) likes(x, McDonalds)
Everyone likes McDonalds unless they are allergic to it
x, likes(x, McDonalds) allergic(x, McDonalds)
x, allergic (x, McDonalds) likes(x, McDonalds)
14
Predicate Logic
1/17/16
x ( Student(x) Smart(x) )
There exists a student.
x Student(x).
15
Predicate Logic
1/17/16
Predicate Logic
1/17/16
x SisterOf(x,Bill)
Predicate Logic
1/17/16
Properties of Quantifiers
x y is the same as y x
x y is the same as y x
x y Loves(x, y)
There is a person who loves everyone in the world
y x Loves(x, y)
18
Predicate Logic
1/17/16
Nesting Quantifiers
Everyone likes some kind of food
y x, food(x) likes(y, x)
x y, food(x) likes(y, x)
y x, food(x) likes(y, x)
x y, food(x) likes(y, x)
19
Predicate Logic
1/17/16
Example Domains
Kinship domain
What is a second cousin once removed, anyway?
Numbers, sets, and lists
This one is a classic. You should understand these, even if
you dont memorize them.
The Wumpus World
Note how much simpler the description is in FOL!
Whatever your domain, if the axioms correctly and
20
Predicate Logic
1/17/16
Remember:
proposition
al
logic
21
Predicate Logic
1/17/16
Reminder
Ground term: A term that does not contain a
variable.
A constant symbol
A function applies to some ground term
22
Predicate Logic
1/17/16
Proofs
23
Predicate Logic
1/17/16
Proofs
The three new inference rules for FOL (compared to propositional logic) are:
Universal Elimination (UE):
x {g/x}
24
Predicate Logic
1/17/16
Proofs
The three new inference rules for FOL (compared to propositional logic) are:
Universal Elimination (UE):
25
Predicate Logic
1/17/16
26
1/17/16
The
problem instances to answers. This step is analogous to the PEAS process for designing
agents.
PEAS
PAGE
Assemble
The
work with real experts to extract what they know-a process called knowledge
acquisition
Decide
That
27
Predicate Logic
1/17/16
The knowledge engineer writes down the axioms for all the vocabulary terms. This
pins down (to the extent possible) the meaning of the terms, enabling the expert to
check the content
For a logical agent, problem instances are supplied by the sensors/ percepts
28
Predicate Logic
1/17/16
30
Predicate Logic
1/17/16
entailed by it:
v
Subst({v/g}, )
31
Predicate Logic
1/17/16
Crown(C1) OnHead(C1,John)
provided C1 is a new constant symbol, called
a Skolem constant
32
Predicate Logic
1/17/16
33
hostile nations
34
hostile nations
35
hostile nations
hostile nations
37
hostile nations
nations
Enemy(Nono, America)
Unification
We can get the inference immediately if we can find a substitution such that King(x) and
Greedy(x) match King(John) and Greedy(y)
= {x/John,y/John} works
Unify(,) = if =
p q
Knows(John,x)
Knows(John,x)
Knows(John,x)
Knows(John,x)
Knows(John,Jane)
Knows(y,OJ)
Knows(y,Mother(y))
Knows(x,OJ)
{x/Jane}}
Unification
We can get the inference immediately if we can find a substitution such that King(x) and
Greedy(x) match King(John) and Greedy(y)
= {x/John,y/John} works
Unify(,) = if =
p q
Knows(John,x)
Knows(John,x)
Knows(John,x)
Knows(John,x)
Knows(John,Jane) {x/Jane}}
Knows(y,OJ) {x/OJ,y/John}}
Knows(y,Mother(y))
Knows(x,OJ)
Unification
We can get the inference immediately if we can find a substitution such that King(x) and
Greedy(x) match King(John) and Greedy(y)
= {x/John,y/John} works
Unify(,) = if =
p q
Knows(John,x)
Knows(John,x)
Knows(John,x)
Knows(John,x)
Knows(John,Jane) {x/Jane}}
Knows(y,OJ) {x/OJ,y/John}}
Knows(y,Mother(y))
{y/John,x/Mother(John)}}
Knows(x,OJ)
Unification
We can get the inference immediately if we can find a substitution such
that King(x) and Greedy(x) match King(John) and Greedy(y)
= {x/John,y/John} works
Unify(,) = if =
p q
Knows(John,x)
Knows(John,x)
Knows(John,Jane)
{x/Jane}}
Knows(y,OJ) {x/OJ,y/John}}
Knows(John,x)
Knows(John,x)
Knows(y,Mother(y))
Knows(x,OJ) {fail}
{y/John,x/Mother(John)}}
Unification
Examples
UNIFY(Knows(John,x), Knows(z,Elizabeth))
This is solvable:
Unification
To unify Knows(John,x) and Knows(y,z)
Can use = {y/John, x/z }
Or = {y/John, x/John, z/John}
The first unifier is more general than the
second.
There is a single most general unifier
(MGU) that is unique up to renaming of
variables.
MGU = { y/John, x/z }
Unification
Unification algorithm:
side
Build up a unifier along the way
Fail if two corresponding points do not match
FORWARD CHAINING
&
BACKWARD CHAINING
49
Predicate Logic
1/17/16
Forward Chaining
Forward Chaining
Idea:
Start with atomic sentences in the KB
Apply Modus Ponens
Add new atomic sentences until no further inferences
can be made
Works well for a KB consisting of Situation
Backward Chaining
Idea:
the query.
Algorithm:
THANK YOU
63
Predicate Logic
1/17/16