First order logic

rushdishams 14,714 views 49 slides Sep 30, 2013
Slide 1
Slide 1 of 49
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49

About This Presentation

No description available for this slideshow.


Slide Content

Rushdi Shams, Dept of CSE, KUET, Bangladesh 1
Knowledge RepresentationKnowledge Representation
First Order LogicFirst Order Logic
Artificial IntelligenceArtificial Intelligence
Version 2.0Version 2.0
There are 10 types of people in this world- who understand binary There are 10 types of people in this world- who understand binary
and who do not understand binaryand who do not understand binary

Rushdi Shams, Dept of CSE, KUET, Bangladesh 2
Introduction
Propositional logic is declarative
Propositional logic allows partial/disjunctive/negated
information
(unlike most data structures and databases)
Meaning in propositional logic is context-independent
(unlike natural language, where meaning depends on context)
Propositional logic has very limited expressive power
(unlike natural language)
E.g., cannot say “if any student sits an exam they either pass or
fail”.
Propositional logic is compositional
(meaning of B ^ P is derived from meaning of B and of P)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 3
Introduction
You see that we can convert the sentences into
propositional logic but it is difficult
Thus, we will use the foundation of propositional
logic and build a more expressive logic

Rushdi Shams, Dept of CSE, KUET, Bangladesh 4
Introduction
Whereas propositional logic assumes the world
contains facts,
first-order logic (like natural language) assumes the
world contains
Objects: people, houses, numbers, colors, baseball
games, wars, …
Relations: red, round, prime, brother of, bigger than,
part of, comes between, …
Functions: father of, best friend, one more than, plus, …

Rushdi Shams, Dept of CSE, KUET, Bangladesh 5
Syntax of FOL: Basic Elements
Constants KingJohn, 2, NUS,...
Predicates Brother, >,...
Functions Sqrt, LeftLegOf,...
Variables x, y, a, b,...
ConnectivesØ, Þ, Ù, Ú, Û
Equality =
Quantifiers ", $

Rushdi Shams, Dept of CSE, KUET, Bangladesh 6
Examples
King John and Richard the Lion heart are
brothers
Brother(KingJohn,RichardTheLionheart)
The length of left leg of Richard is greater than
the length of left leg of King John
> (Length(LeftLegOf(Richard)),
Length(LeftLegOf(KingJohn)))

Rushdi Shams, Dept of CSE, KUET, Bangladesh 7
Atomic Sentences

Rushdi Shams, Dept of CSE, KUET, Bangladesh 8
Atomic Sentences

Rushdi Shams, Dept of CSE, KUET, Bangladesh 9
Complex Sentences
Complex sentences are made from atomic sentences using
connectives:
ØS, S
1
Ù S
2
, S
1
Ú S
2
, S
1
Þ S
2
, S
1
Û

S
2
,
Example

Sibling(KingJohn,Richard) Þ Sibling(Richard,KingJohn)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 10
Complex Sentences

Rushdi Shams, Dept of CSE, KUET, Bangladesh 11
FOL illustrated
Five objects-
1.Richard the Lionheart
2.Evil King John
3.Left leg of Richard
4.Left leg of John
5.The crown

Rushdi Shams, Dept of CSE, KUET, Bangladesh 12
FOL illustrated
Objects are related with
Relations
For example, King John and
Richard are related with
Brother relationship
This relationship can be
denoted by
(Richard,John),(John,Richard)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 13
FOL illustrated
Again, the crown and King
John are related with
OnHead Relationship-
OnHead (Crown,John)
Brother and OnHead are
binary relations as they
relate couple of objects.

Rushdi Shams, Dept of CSE, KUET, Bangladesh 14
FOL illustrated
Properties are relations that
are unary.
In this case, Person can be
such property acting upon
both Richard and John
Person (Richard)
Person (John)
Again, king can be acted
only upon John
King (John)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 15
FOL illustrated
Certain relationships are
best performed when
expressed as functions.
Means one object is related
with exactly one object.
Richard -> Richard’s left leg
John -> John’s left leg

Rushdi Shams, Dept of CSE, KUET, Bangladesh 16
Universal quantification
"<variables> <sentence>
"x P(x)
Translated into the English language, the expression is understood
as:
"For all x, P(x) holds",
"for each x, P(x) holds" or
“for every x, P(x) holds"
"All cars have wheels" could be transformed into the
propositional form, "x P(x)
P(x) is the predicate denoting: x has wheels, and
the universe of discourse is only populated by cars.

Rushdi Shams, Dept of CSE, KUET, Bangladesh 17
Universal quantification
If all the elements in the universe of discourse can
be listed then the universal quantification "x P(x)
is equivalent to the conjunction:
P(x
1
)Ù P(x
2
)Ù P(x
3
) Ù   ...  Ù P(x
n
) .
For example, in the above example of "x P(x), if
we knew that there were only 4 cars in our
universe of discourse (c1, c2, c3 and c4) then we
could also translate the statement as:
P(c1) Ù  P(c2) Ù  P(c3)  Ù P(c4)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 18
Universal quantification
Remember, we had five
objects, let us replace them
with a variable x-
1.x ―›Richard the Lionheart
2.x ―› Evil King John
3.x ―› Left leg of Richard
4.x ―› Left leg of John
5.x ―› The crown

Rushdi Shams, Dept of CSE, KUET, Bangladesh 19
Universal quantification
Now, for the quantified
sentence
"x King (x) Þ Person (x)
Richard is king Þ Richard is Person
John is king Þ John is person
Richard’s left leg is king Þ Richard’s
left leg is person
John’s left leg is king Þ John’s left leg
is person
The crown is king Þ the crown is
person

Rushdi Shams, Dept of CSE, KUET, Bangladesh 20
Universal quantification
Richard is king Þ Richard is
Person
John is king Þ John is person
Richard’s left leg is king Þ
Richard’s left leg is person
John’s left leg is king Þ John’s left
leg is person
The crown is king Þ the crown is
person
Only the second 
sentence is correct, 
the rest is incorrect

Rushdi Shams, Dept of CSE, KUET, Bangladesh 21
Existential quantification
$ <variables> <sentence>
$ x P(x)
Translated into the English language, the expression is understood
as:
"There exists an x such that P(x)"
"There is at least one x such that P(x)"
"Someone loves you" could be transformed into the
propositional form, $ x P(x)
P(x) is the predicate meaning: x loves you,
The universe of discourse contains (but is not limited
to) all living creatures.

Rushdi Shams, Dept of CSE, KUET, Bangladesh 22
Existential quantification
If all the elements in the universe of discourse can
be listed, then the existential quantification $ x
P(x) is equivalent to the disjunction:
P(x
1
)Ú P(x
2
) Ú  P(x
3
) Ú  ...   Ú  P(x
n
) .
For example, in the above example of $ x P(x), if
we knew that there were only 5 living creatures in
our universe of discourse (say: me, he, she, rex and
fluff), then we could also write the statement as:
P(me) Ú  P(he) Ú   P(she) Ú  P(rex) Ú  P(fluff)

Order of application of quantifiers
When more than one variables are quantified in a wff
such as   $ y  " x P( x, y ), they are applied from the
inside, that is, the one closest to the atomic formula is
applied first.
Thus  $ y  " x P( x, y ) reads $ y  [" x P( x, y )], and
we say "there exists a y such that for every x, P( x, 
y ) holds" or "for some y, P( x, y ) holds for every x".
Rushdi Shams, Dept of CSE, KUET, Bangladesh 23

Order of application of quantifiers
The positions of the same type of quantifiers can be
switched without affecting the truth value as long as
there are no quantifiers of the other type between the
ones to be interchanged.
For example   $ x  $  y   $ z P(x, y , z) is equivalent to  
$ y  $  x  $  z P(x, y , z),   $ z  $  y   $ x P(x, y , z),
etc.
It is the same for the universal quantifier.
Rushdi Shams, Dept of CSE, KUET, Bangladesh 24

Order of application of quantifiers
However, the positions of different types of
quantifiers can not be switched.
For example $ x   " y P( x, y ) is not equivalent to   $
y  " x P( x, y ).
Rushdi Shams, Dept of CSE, KUET, Bangladesh 25

Rushdi Shams, Dept of CSE, KUET, Bangladesh 26
Order of application of quantifiers
" x $ y x < y
“for every number x, there is a number y that is greater than x ”
$ y " x x < y
“there is a number that is greater than every (any) number ”

Rushdi Shams, Dept of CSE, KUET, Bangladesh 27
Properties of quantifiers
"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

Rushdi Shams, Dept of CSE, KUET, Bangladesh 28
Properties of quantifiers
Quantifier duality: each can be expressed using the other
"x Likes(x,IceCream) is equivalent to
Ø$x ØLikes(x,IceCream)
$x Likes(x,Broccoli) is equivalent to
Ø"x ØLikes(x,Broccoli)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 29
Properties of quantifiers
Equivalences-
1.$x P is equivalent to Ø"x ØP
2.Ø$x ØP is equivalent to "x P
3.$x ØP is equivalent to Ø"x P
4.Ø$x P is equivalent to "x ØP

Rushdi Shams, Dept of CSE, KUET, Bangladesh 30

Rushdi Shams, Dept of CSE, KUET, Bangladesh 31
Example knowledge base
The law says that it is a crime for an
American to sell weapons to hostile nations.
The country Nono, an enemy of America,
has some missiles, and all of its missiles
were sold to it by Colonel West, who is
American.
Prove that Col. West is a criminal

Rushdi Shams, Dept of CSE, KUET, Bangladesh 32
Example knowledge base
... it is a crime for an American to sell weapons to hostile nations:
American(x) Ù Weapon(y) Ù Sells(x,y,z) Ù Hostile(z) Þ Criminal(x)
Nono … has some missiles,
Owns(Nono,x)
Missile(x)
… all of its missiles were sold to it by Colonel West
Missile(x) Ù Owns(Nono,x) Þ Sells(West,x,Nono)
Missiles are weapons:
Missile(x) Þ Weapon(x)
An enemy of America counts as "hostile“:
Enemy(x,America) Þ Hostile(x)
West, who is American …
American(West)
The country Nono, an enemy of America …
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 33
Forward Chaining
American(x) Ù Weapon(y) Ù Sells(x,y,z) Ù Hostile(z) Þ
Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) Þ Sells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(x,America) Þ Hostile(x)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 34
Forward Chaining
American(x) Ù Weapon(y) Ù Sells(x,y,z) Ù Hostile(z) Þ
Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) Þ Sells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(x,America) Þ Hostile(x)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 35
Forward Chaining
American(West) Ù Weapon(y) Ù Sells(x,y,z) Ù Hostile(z)
Þ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) Þ Sells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(x,America) Þ Hostile(x)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 36
Forward Chaining
American(West) Ù Weapon(y) Ù Sells(West,y,z) Ù
Hostile(z) Þ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) Þ Sells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(x,America) Þ Hostile(x)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 37
Forward Chaining
American(West) Ù Weapon(y) Ù Sells(West,y,z) Ù
Hostile(z) Þ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) Þ Sells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(x,America) Þ Hostile(x)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 38
Forward Chaining
American(West) Ù Weapon(y) Ù Sells(West,y,z) Ù
Hostile(z) Þ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) Þ Sells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(Nono,America) Þ Hostile(x)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 39
Forward Chaining
American(West) Ù Weapon(y) Ù Sells(West,y,z) Ù
Hostile(z) Þ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) Þ Sells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(Nono,America) Þ Hostile(Nono)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 40
Forward Chaining
American(West) Ù Weapon(y) Ù Sells(West,y,z) Ù
Hostile(Nono) Þ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) Þ Sells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(Nono,America) Þ Hostile(Nono)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 41
Backward Chaining
American(West) Ù Weapon(y) Ù Sells(West,y,z) Ù
Hostile(Nono) Þ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) Þ Sells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(Nono,America) Þ Hostile(Nono)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 42
Backward Chaining
American(West) Ù Weapon(y) Ù Sells(West,y,z) Ù
Hostile(Nono) Þ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) Þ Sells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(Nono,America) Þ Hostile(Nono)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 43
Backward Chaining
American(West) Ù Weapon(y) Ù Sells(West,y,z) Ù
Hostile(Nono) Þ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) Þ Sells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(Nono,America) Þ Hostile(Nono)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 44
Backward Chaining
American(West) Ù Weapon(y) Ù Sells(West,y,z) Ù
Hostile(Nono) Þ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) ÞSells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(Nono,America) Þ Hostile(Nono)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 45
Backward Chaining
American(West) Ù Weapon(y) Ù Sells(West,y,z) Ù
Hostile(Nono) Þ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) ÞSells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(Nono,America) Þ Hostile(Nono)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 46
Backward Chaining
American(West) Ù Weapon(y) Ù Sells(West,y,Nono) Ù
Hostile(Nono) Þ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) ÞSells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(Nono,America) Þ Hostile(Nono)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 47
Backward Chaining
American(West) Ù Weapon(y) Ù Sells(West,y,Nono) Ù
Hostile(Nono) Þ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) ÞSells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(Nono,America) Þ Hostile(Nono)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 48
…& the Inference
American(West) Ù Weapon(y) Ù Sells(West,y,Nono) Ù
Hostile(Nono) Þ Criminal(West)
Owns(Nono,x)
Missile(x)
Missile(x) Ù Owns(Nono,x) ÞSells(West,x,Nono)
Missile(x) Þ Weapon(x)
Enemy(Nono,America) Þ Hostile(Nono)
American(West)
Enemy(Nono,America)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 49
References
Artificial Intelligence: A Modern Approach (2
nd

Edition)
by Russell and Norvig Chapter 8
http://www.cs.odu.edu/~toida/nerzic/content/logic/pred_logic/quantification/quantification.html