0% found this document useful (0 votes)
3 views

Chapter 4 - Knowledge and Reasoning(II)

Chapter Four discusses knowledge representation and reasoning using First Order Logic (FOL), highlighting the limitations of propositional logic and the expressive power of predicate logic. It covers key concepts such as syntax, semantics, quantifiers, and inference rules, illustrating how FOL can represent complex relationships and properties of objects. The chapter also provides examples of how to formulate logical statements using FOL, emphasizing the importance of quantifiers in expressing properties of collections of objects.

Uploaded by

nataniumcscbe
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Chapter 4 - Knowledge and Reasoning(II)

Chapter Four discusses knowledge representation and reasoning using First Order Logic (FOL), highlighting the limitations of propositional logic and the expressive power of predicate logic. It covers key concepts such as syntax, semantics, quantifiers, and inference rules, illustrating how FOL can represent complex relationships and properties of objects. The chapter also provides examples of how to formulate logical statements using FOL, emphasizing the importance of quantifiers in expressing properties of collections of objects.

Uploaded by

nataniumcscbe
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 80

Chapter Four

KNOWLEDGE & REASONING - II


KNOWLEDGE REPRESENTATION AND INFERENCING UNSING FIRST ORDER LOGIC

1
Outline
 Limitations of Proposition Logic
 Power of predicate logic
 FOL function and predicate symbol
 Syntax and semantics of FOPC
 FOL sentence
 Quantifier in FOL
 Proprty of Quantifier
 Free and bounded variable
 Well formed formula
 Normal forms
 Conversion into CNF
 Substitution
 Inference Rules Involving Quantifiers
 Unification
 Skolen functions
 Generalized modus ponens
 Generalized resoulution
 Conversion into CNF
 Backward and forward chaining
2
Propositional Logic Limitations
 Some of the limitations of prepositional logic includes
 Context dependency: unlike natural language, where meaning depends on
context, meaning in propositional logic is context-independent
 Example of statements which are not a propositional statement
 Then she saw it (context depends the preceding and succeeding
sentences)
 All of them submit the requirement
 very limited expressive power: unlike natural language, propositional
logic has very limited expressive power
 Example cannot say “pits cause breezes in adjacent squares” except
by writing one sentence for each square
 It only represent declarative sentences: Propositional logic is declarative
(sentence always have truth value)
 Deals with only finite sentences: propositional logic deals satisfactorily
with finite sentences composed using not, and, or, if . . . Then, iff

3
Limitations….
 e.g., if there are 3 students A, B and C
taking p = “A has red hat”,
q = “B has red hat” and
r = “C has red hat”,
the formula “there exists a student with a red hat” may be modeled as p q  r.
 on infinite models this may require infinite formulas;
 example, “each natural number is even or odd” has to be translated as
(p0  q0)(p1  q1) (p2  q2)  …
where p0 ,p1,p2,… are even and q0,q1,q2,… are odd. .
 The pprepositional logic assumes the world consists of facts.
 Cannot express the following:

All men are mortal


Socrates is a man
Therefore, Socrates is mortal
 Propositional
4 Logic has thus limited expressive power.
Predicate Logic power
 Equivalent names
 Predicate logic
 First Order Logic (FOL)
 First Order Predicate Calculus (FOPC).

 Predicate logic is an extension of propositional logic using


variables for objects
 It is much richer and complex than propositional logic.
 Predicate logic has complex expressive power
 e.g., If x represents a natural number, then “each natural number
is even or odd” ”;may be written shortly as
 x(E(x)  O(x)) where E(x) = “x is even” and O(x) = “x is odd”
5
FOL function and predicate symbols
 Function symbols are symbols that takes argument as a set of terms
(variables, constant, functions) that represents a new object
 Father(John)
 Sucessor(X)
 Sucessor(Sucessor(2))
 A predicate symbols is a symbol which describes a relation between
objects or property of an object
 Father(solomon, gizaw)
 Male(teshome)

6
Example1
Let: s(x) is the successor function and
L(x,y) represents the relation “x < y”,
The statement “a number is smaller than its successor ” can be represented as
 x L(x,s(x))
where domain is implicitly known
 x N(x) L(x,s(x))
where domain is explicitly mentioned
Example2
Represent the statement “Not all birds can fly”
Let B(x) denotes “x is a bird.”
Let F(x): denotes “x can fly”;
~(x (B(x)  F(x)))
Does this equivalent to
x (B(x)  F(x))
7 some birds couldn’t fly
Example3
Represent the statement “All men are mortal. Socrates is man.
Therefore, Socrates is Mortal”
Let:
H(x) denotes “x is man”;
M(x) denotes “x is mortal ”, and
s denotes Socrates;
The statement (2) may be described as:
 x(H(x)  M(x)), H(s) |- M(s)
Example4
Represent the statement“ Ann likes Mary’s brother”
x (B(x,m)  L(a,x))
Every natural language sentence which is not semantically ambiguous can be
represented using logic
8
• First-order logic is used to model the world in terms of
– objects which are things with individual identities
e.g., individual students, lecturers, companies, cars ...
– properties of objects that distinguish them from other objects
e.g., mortal, blue, oval, even, large, ...
– classes of objects (often defined by properties)
e.g., human, mammal, machine, red-things...
– relations that hold among objects
e.g., brother of, bigger than, outside, part of, has color, occurs
after, owns, a member of, ...
– functions which are a subset of the relations in which there is only
one ``value'' for any given ``input''.
e.g., father of, best friend, second half, one more than ...
9
Syntax & Semantics of FOPC
Sentence : Atomic Sentence  Sentence Connective Sentence  Quantifier
Variable,… Sentence ~ Sentence  (Sentence)
AtomicSentence : Predicate(Term1, Term2,…,Termn)Term = Term
Term: Function(Term,…)  Constant  Variable
Connective : 
Quantifier :   
Constant : A X1 KingJohn  ...
Variable : a  x  s  …
Predicate : Before HasColor  Raining …
Function : Mother LeftLegOf ...

10
Term
 A term is a logical expression that refers to an object .
 It is a name for a thing.
 Arguments of predicates must be terms
 There are three kinds of terms which allows us to name things in the
world.:
1. Constant symbol,
Example: John, Japan, Bacterium
2. Variable symbol, a variable is instantiated when it is assigned a
constant as its value
Example: x,y a, t,…
3. Function symbols,
Example: f(f(x)); mother_of(John); LeftLegOf(John)
 Note: A term with no variables is called a ground term. For example
John, father(solomon)
 A ground atom has value true or false (like a proposition in PL)
 Predicates, though special functions, are not terms in FOL
11
• Predicates: P(x[1], ..., x[n])
– P: predicate name; (x[1], ..., x[n]): argument list
– A special function with range = {T, F};
– Examples: human(x), /* x is a human */
father(x, y) /* x is the father of y */
– When all arguments of a predicate is assigned values (said to be
instantiated), the predicate becomes either true or false, i.e., it becomes
a proposition.
• Ex. Father(Fred, Joe)
– A predicate, like a membership function, defines a set (or a class) of
objects

12
Equality (=)
 Two terms term1 and term2 are equal under a given interpretation if and
only if term1 and term2 refer to the same object

Example1:
 If the object referred by Father(John) and the object referred to by Henry
are the same, then
Father(John) = Henry

Example2:
 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) }

13
Predicate symbols
 Predicate symbols: are symbols that stands to show a relationship
among terms or to indicate property of a term

For example:
On(A,B) to mean A is on B (relation between A & B)
Sister(Senait, Biruk) to mean Senait is sister of Biruk
Female(Azeb) to mean Azeb is female (proprty of azeb being female)

Here ‘On’, ‘Sister’ and Female are predicate symbols, ‘A’, ‘B’,
‘Senait’, ‘Biruk’ and Azeb are terms.

14
Atomic sentences
 Atomic sentences states the facts of world and is formed from a predicate
symbol followed by a parenthesis list of terms.
Example:
Brother(Richard, John)

 Atomic sentences can have arguments that are complex terms:


 Sister(mother_of(John),Jane)
 Married(FatherOf(Richard),MotherOf(John))

 An atomic sentence is true if the relation referred to by the predicate


symbol holds between the objects referred to by the arguments.

15
Complex Sentence

 Complex sentences are sentences which is a combination of one or more


atomic sentences with logical connectives
Example:
 Older(John,30)  Younger(John,30);
represents John is above 30

 ~Brother(Robin,John)
represents Robin is not Brother of John

 Hana = daughter(brother(mother(Selam))) ;
represents Hana is Selam’s cousin

 Father(Solomon, Tesfaye)father(Solomon, Biruk)


Represents if solomon is father of Tesfaye then he is also father of
Biruk

16
Sentences are built from terms and
atoms
• A term (denoting a individual in the world) is a constant
symbol, a variable symbol, or a function of terms.
• An atom (atomic sentence) is a predicate P(x[1], ..., x[n])
– Ground atom: all terms in its arguments are ground terms (does
not involve variables)
– A ground atom has value true or false (like a proposition in PL)
• A literal is either an atom or a negation of an atom
• A sentence is an atom, or,
– ~P, P v Q, P ^ Q, P => Q, P <=> Q, (P) where P and Q are
sentences
– If P is a sentence and x is a variable, then (x)P and (x)P
are sentences

17
Quantifiers
 A quantifier is a symbol that permits one to declare, or identify the
range or scope of the variables in a logical expression.
 A quantifier express properties of entire collection of objects.
 There are two types of quantifier
 Universal quantifier 
 Existential quantifier 

18
Universal Quantification ()
 Universal quantifier defines the domain of a variable in a logical
expression to be the any element in the universe
 (x)P(x) means that P holds for all values of x in the domain associated
with that variable.
 If x is a variable, then,  x is read as
 for all x OR for each x OR for every x
 The scope of universal quantifier is the whole element in the domain
 Universal quantifiers often used with "implication (=>)" to form "rules"
about properties of a class
Syntax: <variables> <sentence>
" x P is true in a model m iff P is true with x being each possible
object in the model
One or more variables can be quantified by a single quantifier by separating
with comma
Example1: “Every student is smart:”
x (Student(x)  Smart(x))
Example2:
19 “All cats are mammals”
Universal Quantification ()
 Roughly speaking,  is equivalent to the conjunction of an instantiations
of P

 x (Student(x)  Smart(x)) is equivalent to


(Student(KingJohn)  Smart(KingJohn)) 
(Student(Abera)  Smart(Abera)) 
(Student(MyDog)  Smart(MyDog)) ...

 x(cats(x) Mammals(x)) is equivalent to


(Cat(Spot)  Mammals(Spot)) 
(Cat(Rebecca)  Mammals (Rebecca)) 
(Cat(Felix)  Mammals (Felix)) 
(Cat(John)  Mammals (John))  …

20
Universal Quantification ()
 Note1: Typically,  is the main connective with 
 Note2: Avoid the mistake of using  as the main connective with :

Example:
 x (Student(x)  Smart(x)) means “Everyone is a student and everyone is
smart”
 x(cats(x)  Mammals(x)) means “Everything is a cat and every thing is
mammal”

 This doesn’t agree in concept with the original sentence which is every
student is smart, every cat are mammal respectively
 Often associated with English words “all”, “everyone”, “always”, etc.
 You rarely use universal quantification to make blanket statements about
every individual in the world (because such statement is hardly true)
(x)student(x)^smart(x)
means everyone in the world is a student and is smart.
21
Existential quantification ()
 Existential quantifier defines the domain of a variable in a logical expression to be
a non empty set which is the subset of the universal set
 (x)P(x) means that P holds for some value(s) of x in the domain associated with
that variable.
 if y is a variable, then  y is read as

there exists a y OR for some y OR for at least one y


Syntax: <variables> <sentence>
x P is true in a model m iff P is true with x being some possible
object in the model
 one or more variables can be quantified by a single quantifier by separating with
comma

Example1: “Some students are smart”


x (student(x)  Smart(x))

Example2: “Spot has a sister who is a cat”


22 x(Sister(x, Spot)  Cat(x))
Existential quantification ()
 Roughly speaking,  is equivalent to the disjunction of instantiations of P
 x(student(x)  Smart(x)) is equivalent to
(Student(KingJohn)  Smart(KingJohn)) 
(Student(Abera)  Smart(Abera)) 
(Student(MyDog)  Smart(MyDog)) ...
 x(Sister(x, Spot)  Cat(x)) is equivalent to
(Sister(Felix, Spot)  Cat(x)) 
(Sister(Rabicca, Spot)  Cat(x)) 
(Sister(chichu, Spot)  Cat(x)) …

23
Existential quantification ()
Note1: Typically,  is the main connective with .
Note2: Avoid the mistake of using  as the main connective with :
 Existential quantifiers usually used with “^ (and)" to specify a list of properties about an individual.
 (x) student(x) ^ smart(x) (there is a student who is smart.)
 Often associated with English words “someone”, “sometimes”, etc.

Example:
Some students are smart is to mean that
there are entities that satisfy the property of both being a student and smart. In the figure, the yellow
part indicates the set of such groups

However, x(student(x)  Smart(x)) is to means any thing which is either


smart or not a student
It also holds if there no student exists in the domain because student(x) =>
smart(x) holds for any individual who is not a student
Hence
24 this doesn’t infer what we need to say
Examples using Quantifiers
 Man(John)
John is a man

 x(Man(x)  ~Woman(x))
Every man is not a woman (there is no man who is a woman)

 x(Man(x)  Handsome(x))
Some man are handsome

 x(Man(x)  y(Woman(y)  Loves(x,y)))


Every man has a woman that he loves

 y(Woman(y)  (x)(Man(x)  Loves(x,y)))


There are some woman that are loved by every man

25
Nested quantifiers
 Universal and existential quantifiers can be nested one into
another.
 It is possible to have one or more quantifier nested in another
quantifier

Example1
 “For all x and all y, if x is the parent of y then y is the child of x”
can be represented as
x,y (Parent(x,y)Child(y,x))
 Note: Here x,y means x y

Example2
 “There is someone who is loved by everyone

yx Loves(x,y)
26
Nested quantifiers
 Difficulty may arise when two quantifiers are used with the same
variable name.
 For example
x (Cat(x)  x Brother(Richard,x)))
 in the sentence above, x in Brother(Richard,x) is existentially
qualified and the universal quantifier has no effect on it.

 Rule: To identify which quantifier quantify a variable if the variable


is quantified by two or more of them, the innermost quantifier that
mentions it will be chosen.

27
Examples of Translating English to FOL
1. Every gardener likes the sun.
(x) (gardener(x)likes (x,sun))
2. All purple mushrooms are poisonous
(x) [(mushrooms(x) purple(x))  poisonous(x)]
3. No purple mushroom is poisonous
~(x) (purple(x)  mushroom(x)  poisonous(x))
4. There are exactly two purple mushrooms
(x)(y) {mushroom (x)  purple(x)  mushroom(y)  purple(y) 
~(x=y)  (z)[(mushroom(z)  purple(z))  ((x=z)(y=z))]}

28
Examples of Translating English to FOL
5. You can fool some of the people all of the time
(x)(person(x)  ( t) (time(t) can-fool(x,t)))
6. You can fool all of the people some of the time
( x)(person(x)  ( t) (time(t)  can-fool(x,t)))

7. Jane is a tall surveyor


Tall(Jane)  Surveyor(Jane)
8. Everybody loves somebody
x y Loves(x,y)
y x Loves(x,y)

9. Nobody loves Jane


x ~Loves(x,Jane)
~y Loves (y,Jane)

29
Examples of Translating English to FOL
10. Everybody has a father
x y Father(y,x)
11. Everybody has a father and mother
x y,z (Father(y,x)  Mother(z,x))
12. Whoever has a father has a mother
x y (Father(y,x)  z Mother(z,x))
13. Every son of my father is my brother
xy ((MyFather(x)  Son(y,x))  MYBrother(y))

30
Properties of quantifiers (commutativity)
i. xy is the same as y x
ii. xy is the same as y x
iii. xy is not the same as y x,

Example
 x y Loves(x,y) means “There is a person who loves everyone
in the world”
 y x Loves(x,y) means “Everyone in the world is loved by at
least one person”

31
Properties of quantifiers (duality)
 Quantifier duality refers to the possibility of expressing one
quantifier with the other equivalently

 Universal quantifier can be completely replaced by existential


quantifier without affected the meaning and vise versa

Example
x Likes(x,IceCream)  x Likes(x,IceCream)
x Likes(x,IceCream)  Everyone likes ice cream
x Likes(x,IceCream)  there is no one who does not like ice cream.

x Likes(x,Broccoli)  x Likes(x,Broccoli)


x Likes(x,Broccoli)  Some one likes Broccoli
x Likes(x,Broccoli)  It is not true that every one doesn’t like
Broccoli

32
Properties of quantifiers (duality)
 Quantifiers are intimately connected with each other, through
negation.
Example
 If one says that everyone dislikes bitter guard
one is also saying that there does not exists someone who likes them
or vice versa.
  is really conjunction over the universe of objects and  is a
disjunction over the universe, they obey De Morgan’s rules.

33
Properties of quantifiers (duality)
The De Morgan rules for quantified and un-quantified sentences are as follows:
x ~P  ~ x P
~x P  x ~P
x P  ~ x ~P
x P  ~x ~P
 Example: no one likes everyone
 ~ (x)(y)likes(x,y)
 (x)(y)~likes(x,y)

In fact, one quantifier can do both works, if used with negation in appropriate
place.
Consider a world consists of only three object A
Hence x P(x)  (P(A)  P(B)  P(C))
  (P(A)  P(B)  P(C))
 ( P(A)   P(B)   P(C))
 (x  P(x) )
34
Syntax & Semantics of FOPC

x [~P(x)] P is false for all x

x [~P(x)] P is false for some x

x [P(x)] P is true for all x

x [P(x)] P is true for some x

35
Scope of Quantifiers
 Each quantified variable has its scope
 (x)[human(x) => (y) [human(y) ^ father(y, x)] ]
 All occurrences of x within the scope of the quantified x refer to the
same thing.
 Better to use different variables for different things, even if they are in
scopes of different quantifiers
 Switching the order of universal quantifiers does not change the
meaning:
 (x)(y)P(x,y) <=> (y)(x)P(x,y), can write as (x,y)P(x,y)
 Similarly, you can switch the order of existential quantifiers.
 (x)(y)P(x,y) <=> (y)(x)P(x,y)
 Switching the order of universals and existential does change
meaning:
 Everyone likes someone: (x)(y)likes(x,y)
 Someone is liked by everyone: (y)(x) likes(x,y)
36
Free and Bound variables
 A variable in a formula is free iff its occurrence is outside the scope of
the quantifier having the variable.
 A variable in a formula is bound iff its occurrence is within the scope of
the quantifier.
 The scope of a quantifier is the first complete sentence directly following
the quantifier.
 Example1

x P(x)   t Q(t)  R(x,t)


 The scope of the variable x quantified by the universal quantifier is only
in predicate P
 The scope of the variable t quantified by the existential quantifier is only
in predicate Q
 The variables x and t in R are not quantified at all

x (P(x)   t Q(t))  R(x,t)


37
Free and Bound variables
 Example2
x (P(x)   t R(x,t))  Q(t)
 The scope of the variable x quantified by the universal quantifier is the
preposition P(x)   t R(x,t)
 The scope of the variable t quantified by the existential quantifier is only
in predicate R
Example-1:
 In the formula given below, the variables x and y are free and z is
bound variables.
S(x,y)  z(P(z) Q(z)) ----(1)

38
Free and Bound variables
Example-2:
 Consider the formula: x (A(x)B(x)) ----(2)
 In this formula, the quantifier  applies over the entire formula
(A(x)B(x)).
 Hence the scope of the quantifier is entire (A(x)B(x)).
 A variable is bound in situation where at least one occurrence of it is
bound.
 Similarly a variable is free in a formula, if all of its occurrence is free.
Example-3:
 In the formula  x y (A(x,y,z))  z (B(y,z)), ----(3)
 the variable z is free in the first portion of the formula and bound in the
second portion of the formula.
 Hence the two occurrence of z are different variables

39
Well formed formula
Well formed formula is a formula written in logical expression that can be
interpreted perfectly into equivalent natural language sentence.
we can use inductive definition to define wff as follows:
Every atomic sentence is wff
If W is wff then ~W is also wff
If W and V are wff so are

 W V  WV
 WV  WV

If W is wff so are


 x W
 z W
40
Normal Forms:
 A well formed formula can be represented in different standard normal
forms

 Some of the normal forms are

1. Clause Form: disjunction of literals (atomic sentences)

2. Conjunctive Normal Forms (CNF): conjunction of disjunction of


literals or atomic sentences. It can also be defined as conjunction of
clauses

3. Disjunctive Normal Form (DNF): disjunction of conjunction of literals.

4. Horn Form: conjunction of literals (atomic sentences) implies a literal


(atomic sentence).

5. Others
41
Normal Forms:

Conjunctive Normal Form (CNF) is the focus here since:


1. any well formed formula (logical expression) can be converted into
CNF
2. Generalized resolution is a complete inference procedure on CNF
expression KB
3. It provides an easy way of inference procedure for the computer
through resolution and refutation

A single literal (atomic sentence) or a single clause is in CNF form


Q  Q  False
~Q  ~Q  False

42
 Steps to convert form predicate logic formula to CNF.

1) Eliminate implications and bi-conditionals.


(A  B) = ~A B
(AB) = (AB)  (B  A)
2) Reduce the scope of negation and apply De Morgan’s
theorem to bring negations before the atoms
~(AB) = ~A  ~B
~(A  B) = ~A  ~B
3) To bring the signs before the atoms, use the duality relation formulae
~x(A(x)) =  x(~A(x))
~( x (A(x)) =  x( ~A(x))
4) For the sake of clarity (to avoid repetition) rename bound variables if
necessary.
5) Use the equivalent formula to move the quantifiers to the left of the
formulae to obtain the normal form

43
Conjunctive Normal Forms
Formula to be used in CNF conversion
1) (Qx) A[x]B  (Qx) (A[x]  B)
2) (Qx) A[x]B  (Qx) (A[x]  B)
3) ~(x) (A[x])  x (~A[x])
4) ~( x) (A[x])   x (~A[x])
5) x A[x]  x B[x]  (x) (A[x]  B[x])
6) x A[x]  x B[x]  (x) (A[x]  B[x])
7) (Q1 x) A[x]  (Q2x) B[x]  (Q1 x) (Q2y) (A[x]  B[y])
8) (Q1 x) A[x]  (Q2x) B[x]  (Q1 x) (Q2y) (A[x]  B[y])
Note 1. Q represents either  or 
Note 2. A[x] means the variable x is free in A
Note 3. B represents a formula that does not contain variable x.
Note 4. Q1 and Q2 are either  or . And y does not appear in A[x].

44
Conversion exercise into CNF
1. x (A(x) y B(x,y)) ---(1)
 x (~A(x)  y B(x,y)) implication elimination
 x  y(~A(x)  B(x,y)) pushing  to the front
- (solution)
2. x (A(x)  x B(x))
 x (A(x)  y B(y)) variable renaming
 x (~A(x)  y B(y)) eliminating 
 xy (~A(x)  B(y)) pushing  to the front
3. x A(x)  x B(x)
 (x A(x))  y B(y) scoping
 ~(xA(x))  y B(y)  elimination
 x ~A(x)  yB(y) pushing ~ inward
 xy (~A(x)  B(y)) pushing  to the front
 x,y (~A(x)  B(y)) using single quantifier
45
Conversion exercise into CNF
4. x y [z (A(x,y,z)  B(y))  x C(x,z)]
=x y [z (A(x,y,z)  B(y))  t C(t,s))]
renaming the variable x to t, z to s to avoid confusion
=x y [~ z (A(x,y,z)  B(y))  t C(t,s))]
 elimination
=x y [ z ~(A(x,y,z)  B(y))  t C(t,s))]
pushing ~ inward
=x y [ z (~A(x,y,z)  ~B(y))  t C(t,s))]
pushing  to the front
=x y  z (~A(x,y,z)  ~B(y))  t C(t,s))
renaming the free variable z to s
=x y  z t (~A(x,y,z)  ~B(y))  C(t,s))
pushing  to the front
=x y  z t (~A(x,y,z)  C(t,z))  (~B(y)  C(t,s))
46 distributive propert of  over 
Substitution
Idea:
 if we replace a valid sentence with any constant uniformly, the new
sentence is also valid. i.e.
 given a sentence with free variables, we can have multiple
instance of the sentence by uniformly substituting one or more of
its variables.
 This process is very important during inferencing by the agent which
we will see soon.

47
Substitution
 Given a sentence S, free variable x, and a ground term t then we can
represent a substitution of every occurrence of x by t in S as:
SUBST({x/t}, S).
 e.g., SUBST({x/f(x,y)}, S(x,y)  x (P(x) Q(x))  { S(f(x,y),y)  x
(P(x)  Q(x))}
 A sentence with free variable is called open sentence and a sentence
with only bounded variable is called closed sentence.
 Substitution can be applied only on open sentence.
 Hence, it is important to know the principles how to make a variable in
an expression free

48
Inference Rules Involving Quantifiers
 Those rules we have seen for prepositional logic are also valid for
FOPL
 A variable which is bound under the universal quantifier can be free if
the world is clearly stated.
 For example: all normal human beings has two legs
 x( Normal-human(x)  has-legs(x, 2)). Here x is bounded
variable
 This can be written in known world as Normal-human(x)  has-legs(x,
2). Here x is free variable

49
Inference Rules Involving Quantifiers
Example
Axioms: x (Bird(x) Flies(x))
Bird(Tweety)
Goal: Flies(Tweety)
 By removing the universal quantifier and converting to clausal form,
we will get
~Bird(x)  Flies(x)
Bird(Tweety)
 Without further operation, no resolution is possible
 Apply SUBST({x/Tweety}, ~Bird(x)  Flies(x)) gives
~Bird(Tweety)  Flies(Tweety)
Bird(Tweety)
 Using resolution, it results Flies(Tweety)

50
Inference Rules Involving Quantifiers
 To help the agent for better inferencing, we have three more inference
rules mentioned bellow:
1. Universal Elimination: for any sentence  variable x and ground term
g:
x, 
SUBST({x/g}, )

example:
x Likes(x, IceCream} we can use substitution {x/Helen}
and infer
Likes(Helen, IceCream}

51
Inference Rules Involving Quantifiers
 To help the agent for better inferencing, we have three more inference
rules mentioned bellow:

2. Existential Elimination: for any sentence  variable x and constant symbol


k that doesn’t appear elsewhere in the knowledge base:

x, 
SUBST({x/k}, )
example:
from x Kill(x, victim) we can infer
Kill(Murderer, victim) as long as Murderer doesn’t appear in the KB.

52
Inference Rules Involving Quantifiers
3. Existential Introduction: for any sentence  variable x that doesn’t
occur in  and ground term g that occur in :


x, SUBST({g/x}, )

example:
from Likes(Jerry, IceCream) we can infer
x Like(x, IceCream).

53
Unification
 Unification: is a process of finding a substitution that makes two
expressions match exactly each other.
 A substitution that makes two clauses resolvable is called a unifier.
 In other words, unification is a “pattern matching” procedure that takes
two atomic sentences (literals), as input and returns:
 “failure” if they do not match
 a substitute list , if they do match.

 If p and q are two atomic sentences, a unification routine (UNIFY) takes


p and q as arguments and returns a substitution that would make p and q
look the same
 if there is no valid substitution it fails.
 UNIFY (p,q)=  means
SUBST(,p) = SUBST(,q), where  is called the unifier of the two
sentences.
54
Unification
Example
 Assume the KB contains the following:

Knows(John,x) Hates(John,x)
Knows(John, Jane)
Knows(y,Leonid)
Knows(y,Mothers(y))
Knows(x, Elizabeth)
Knows(solomon, mother(Jane))
 Ask the question ?Hates(John, z).
 Now, consult KB to know the ‘sentences’ that unify with Knows(John,
z) and then apply the unifier to Hates(John,z).

55
Unification
UNIFY(Knows(John,z), Knows(John,Jane)) = {z/Jane}

UNIFY(Knows(John,z), Knows(y,Leonid)) ={z/Leonid, y/John}

UNIFY(Knows(John,z), Knows(y,Mothers(y))) = {y/John, z/mother(John)}

UNIFY(Knows(John,z), Knows(x, Elizabeth)) = {x/John, z/ Elizabeth}

UNIFY(Knows(John,z), Knows(solomon, mother(Jane)) = fail(Different


constants or predicates cannot match)

Therefore, x can be Jane, Leonid, and Mother(John).


 Hence Hates(John, x) can assume the values Jane, Leonid, and Mother(John).
 Thus a unifier is a function that assigns bindings to variables.
 A56
binding is either a constant, a function, or another variable
Generalized Modus-ponens
 For atomic sentences, pi, pi’ and q where there is a substitution  such that
SUBST(, pi’) = SUBST(, pi), for all i:
P1’, p2’, … pn’, (p1  p2  ….  pn  q)
SUBST(, q)
 The generalized modes ponens is an efficient inference rule for three
reasons:
1. Combines several small inferences into one
2. It takes sensible steps (transitivity as a property and unification as a
mechanism for matching substitution)
3. We can represent knowledge in a canonical form during pre-
compilation step (i.e. horn Normal form)

57
Generalized Modus-ponens
 Generalized Modus Ponens is complete for KBs containing only Horn
clauses.
 A Horn clause is a sentence of the form:
(vList) P1 (vList),P vList (x), …,  PN (vList) Q(vList) where zero or more Pi’s
and Q which are positive literals (atomic sentences).
 Only Horn clause sentences are acceptable in prolog
 Horn clause represents a subset of the set of sentences representable in
FOL.
 For example R(x)  P(y)  Q(z) is a sentence in FOL, but not in Horn
clause.

58
x King(x)  Greedy(x)  Evil(x)
King(John)
y Greedy(y)
Brother(Richard,John)
 We would like to infer Evil(John)
 Basic Idea: Use Modus Ponens, Resolution when
literals unify.

59
p1', p2', … , pn', ( p1  p2  …  pn q)

Subst(θ,q)
where we can unify pi‘ and pi for all i
Example:

King(John), Greedy(John),x King(x)  Greedy(x)  Evil(x)


Evil(John)

p1' is King(John) p1 is King(x)


p2' is Greedy(John) p2 is Greedy(x)
θ is {x/John} q is Evil(x)
Subst(θ,q) is Evil(John)
60
Resolution for FOPC
 The simplest resolution has exactly two disjunction in the premises
(unit resolution)
 The generalized resolution extended the number of premises to any
number of disjunctions
Generalized Resolution (disjunction):
 For literals (atomic sentences) pi and qi where UNIFY(pj, ~qk) =  then

p1  p2  ….  Pj  ….  pm, q1  q2  ….  qk  ….  qn
SUBST(, (p1  p2  ….  Pj-1  Pj+1  ….  pm  q1  q2  ….  qk-1  qk+1  …. 
qn))

61
Resolution for FOPC
Proving theorem:
 Method1: Start with the given axiom, use the rules of inference and
prove the theorem
 Method2: Prove that the negation of the result can not be TRUE.
Method2 is commonly known as prove by refutation.

62
Resolution for FOPC
The Resolution Refutation Procedure involves five steps:

1. Find the negation of the result to be proved

2. Add as a valid statement to the given set of statements (KB)

3. Perform the resolution on these statements until a contradiction is


encountered.

4. Conclude that the contradiction is due to the assumed negation of the


result

5. Hence, the negated assumption that is made is FALSE or the result is


proved to be valid (TRUE).
63
First Order Resolution Examples
Example1:
Given
x [Physician(x)  Knows_surgery (x)]
Physician(Biruk)

Prove knows_surgery(Biruk) using refutation method:


Assume the negation of the result is valid. That is
~ knows_surgery(Biruk) --- (1)
The given axioms are
Physican(Biruk) ---- (2)
x [Physician(x)  Knows_surgery (x)] ----- (3)

Drop the universal quantifier from equation (3)


~Physician(x)  Knows_surgery (x) ---- (4)

64
First Order Resolution Examples
In equation (4), substitute x = Biruk.
~Physician(Biruk)  Knows_surgery (Biruk) ---- (5)

Resolving equations (1) and (5), we have


~Physican(Biruk) -----
(6)

 Resolving equations (2) and (6), we have contradiction.

 This contradiction was due to the assumption that was made at the
beginning i.e., ~ knows_surgery(Biruk) is valid.

 Hence the assumption (~ knows_surgery(Biruk) ) is false which


implies knows_surgery(Biruk) is true

65
First Order Resolution
 In FOL, to perform resolution, two main tasks are to be completed first:
1. writing expressions in Clausal form, and then
2. Instantiate the variables in the universal statements by substitution and
unification.
Example:
x (P(x)Q(x)) ; All men are mortal
P(A) ; Socrates is a man
Q(A) ; Socrates is mortal
Use equivalence rules to remove implication.
x (~P(x)  Q(x))
P(A)
Q(A)
Substitute A for x, the proposition remains still true.
~P(A)  Q(A)
P(A)
Q(A) ; Propositional resolution
66
Skolem Function
 A Skolem function eliminates existential qualifier() and introduces
a brand new constant symbol known as Skolem constant that is not
used in any other sentence
 So to Skolemize means, to substitute a brand new name for each
existentially quantified variable.
 procedure for systematic elimination of the existential quantifiers in
a first-order formula, by introducing new constant and functional
symbols, called Skolem constants and Skolem functions, in the
formula
 Simple case: the result of Skolemization of the formula xyzA
is the formula yzA[c=x], where c is a new (Skolem) constant.
 For instance, the result of Skolemization of the formula
x  y  z(P(x, y) Q(x, z)) is  y  z(P(c, y) Q(c, z))
  x1…  xk  y1 · · ·  ynA is  y1 · · ·  ynA[c1/x1,…,ck/xk],
where c1,…,ck are new (Skolem) constants.
67
 Note that the resulting formula is not equivalent to the original one, but is
equally satisfiable with it
 The result of Skolemization of yzP(y,z) is yP(y, f(y)), where f is a
new unary function, called Skolem function

Example 1: (some one is a killer)


x Killer(x) can be skolemized as Killer(Murderer) provided that the constant is
a brand new constant

Example 2: (some one teaches some thing)


x,y Teaches(x,y) can be skolemized as Teaches(Teacher, Course) provided that
the constant is a brand new constant

Example 3: (there is some one who teaches every course)


x y (course(y)Teaches(x,y)) can be skolemized as
y(course(y)Teaches(Teacher,y)) provided that the constant is a brand new
constant
68
Skolem Function
Example 3: (every one teach some courses)
 x y (course(y)  Teaches(x,y)) is the following skolemization work:
x(course(TheCourse)  Teaches(x,TheCourse)) provided that the
constant is a brand new constant

69
Skolem Function
 If  is in the scope of  in the formula, then,  is removed by replacing
the variables as functions of variables preceding it.
 e.g., x y Loves(x,y) can be represented as x Loves(x, Beloved(x))
 But x Loves(x, L) says every one loves the same person. But the orignal
sentence says every one has some one to love.
 x (Person(x)  y Heart(y)  Has(x,y)) Every one has a heart
 x (Person(x) Heart(H)  Has(x,H)). Every one has the same heart
(shared)
 x (Person(x) Heart(f(x))  Has(x,f(x))). Where f(x) is heart of x
70
Skolen Function
 Example1:
 Convert the formula into its Skolem Form

P = q r s t (A(q,r)B(s,t)) ---(1)
Solution:
 In this formula, q is not preceded by any  quantifier. Whereas s and
t are in the scope of . Hence replace q by a constant ‘’, and, s and t
by functions of r.
 The Skolem form P* of P is
P* =  r (A(,r)  B(f1(r), f2(r) )

71
Conversion of FOL to CNF by removing quantifier
 The following are guiding line for the conversion
1. Eliminating implications and bi-implication
2. Drive negative symbols inward
3. Apply De Morgan laws on quantifiers
4. Rename variables that may create ambiguity
5. Skolemize existential quantifier
6. Drop universal quantifiers
7. Distribute  over  which return clauses
8. Rename the variables in each clause so that each clause will be distinct

72
FOL to CNF conversion Example
“Everyone who loves all animals is loved by someone”
Representation
Let P(x) is x loves all animal
Loves(y,x) is y loves x

Hence the original sentence is


x (P(x)  y Loves(y,x))

P(x)  x loves all animal can be represented as


y (Animal(y) loves(x,y))

Hence every one who loves animal can be represented as


x P(x)  x (y(Animal(y) loves(x,y)))

Therefore the entire expression becomes:


x73((y(Animal(y)  Loves(x,y) ))  y Loves(y,x) )
FOL to CNF conversion Example
“Everyone who loves all animals is loved by someone”
x ((y(Animal(y)  Loves(x,y)))  yLoves(y,x) )

1. Eliminate bi-conditionals and implications


x ((y(~Animal(y)  Loves(x,y)))  yLoves(y,x) )

x (~(y(~Animal(y)  Loves(x,y)))  yLoves(y,x) )

2. Move ~ inwards: ~x p ≡ x ~p, ~ x p ≡ x ~p


x (( y~(~Animal(y)  Loves(x,y)))  yLoves(y,x))
x (( y (Animal(y)  ~Loves(x,y)))  yLoves(y,x))

74
FOL to CNF conversion Example
3. Standardize variables: each quantifier should use a different one
x (( y (Animal(y)  ~Loves(x,y)))  zLoves(z,x))
4. Skolemization: a more general form of existential instantiation. Each
existential variable is replaced by a Skolem function of the enclosing
universally quantified variables:
x (((Animal(F(x))  ~Loves(x, F(x))))  Loves(G(x),x))

5. Drop universal quantifiers:


((Animal(F(x))  ~Loves(x, F(x))))  Loves(G(x),x)

6. Distribute  over  :
(Animal(F(x))  Loves(G(x),x) )  (~Loves(x, F(x))  Loves(G(x),x) )

75
First Order Resolution Example:
 Given the following premises, use resolution refutation procedure to
prove that “curiosity killed Tuna”
a) John owns a dog
b) Any one who owns a dog is a lover-of-animals
c) Lovers-of-animals do not kill animals
d) Either Jack is killed Tuna or curiosity killed Tuna
e) Tuna is a cat
f) All cats are animals
 Knowledge representation in CNF

a) John owns a dog


x (D(x)  O(J,x)) ---(1)
 Skolemization . Since only existential qualifier is there in equ.(1), replace
variable x with a name, say “Fido”
D(Fido)  O(J,Fido) ---(2)
76
First Order Resolution Example:
b) Anyone who owns a dog, is a lover of animals
x(y(D(y)  O(x,y)) L(x)) --- (3)
 Convert equ.(3) to Clausal form

x (~y(D(y)  O(x,y)) L(x))


 Drive negatives inside

x(y ~(D(y)  O(x,y))  L(x))


x(y ~D(y)  ~O(x,y)  L(x))
 There is no need to perform Skolemization, as there are no existential
qualifiers.
 Now, universal quantifiers can be dropped to get the required CNF:

~D(y)  ~O(x,y)  L(x)

77
First Order Resolution Example:
c) Lovers-of-animals do not kill animals
x (L(x)  (y (A(y) ~K(x,y))))
x (~L(x) (y (A(y) ~K(x,y))))
x (~L(x) (y (~A(y)  ~K(x,y))))
xy (~L(x) ~A(y)  ~K(x,y))
Drop universal quantifiers
~L(x)  ~A(y)  ~K(x,y)
d) Either Jack killed Tuna or curiosity killed Tuna
K(J,T)  K(C,T)
e) “Tuna is a cat
C(T)
f) All cats are animals
~C(x)  A(x)

78
First Order Resolution Example:
 The next step is to prove the theorem “curiosity killed Tuna” by
refutation
 That is, we should assume curiosity didn’t killed Tuna (~K(C,T)) as a
valid sentence then the set of facts and rules that we have are:

a. D(Fido)  O(J,Fido)
b. ~D(y)  ~O(x,y)  L(x)
c. ~L(x)  ~A(y)  ~K(x,y)
d. K(J,T)  K(C,T)
e. C(T)
f. ~C(x)  A(x)
g. ~K(C,T)

79
First Order Resolution Example:
Step No. Clause Derivation
1 D(Fido) a
2 O(J,Fido) a
3 ~D(y)  ~O(x,y)  L(x) b
4 ~L(x) ~A(y)  ~K(x,y) c
5 K(J,T)  K(C,T) d
6 C(T) e
7 ~C(x)  A(x) f
8 ~K(C,T) g Refutation
9 K(J,T) Resolution of 5,8
10 A(T) Resolution of 6,7 with unifier {x/T}
11 ~L(J) ~A(T) Resolution of 4,9 with unifier {x/J, y/T}
12 ~L(J) Resolution of 10,11
13 ~D(y)  ~O(J,y) Resolution of 3, 12 with unifier {x/J}
14 ~D(Fido) Resolution of 13, 2 with unifier {y/Fido}
15 * Resolution of 14,1

80 Step-15 is a contradiction. Which proves that indeed curiosity killed the cat “Tuna”

You might also like