Predicate Logic
Predicate Logic
PREDICATE LOGIC
Predicate Logic overcomes the limitations of
Prepositional Logic.
2) candy(Lifesaver)
Solution: Let
MAN(x), MORTAL(x) represent ‘x is a man’ and ‘x is mortal’
respectively.
AVC
BASIS OF RESOLUTION
Solution
g(y)/x, B/y, y/z
f(a)/y, x/a
Not Possible
f(y)/x, f(z)/y
MULTIPLE SUBSTITUTIONS
The object of the unification is to discover at least one set of
substitutions that causes two clauses to match.
Usually if there is one substitution than there can be many.
⌐likes(Steve,BK301) (1)
BK301/x
1. ⌐easy(x) ˅ likes(Steve,x)
(3) ⌐easy(BK301) 2. ⌐science(y) ˅ ⌐easy(y)
BK301/z 3. ⌐basketweaving(z) ˅ easy(z)
4. basketweaving(BK301)
⌐basketweaving(BK301) (4)
Contradiction
Since, Contradiction is achieved. Therefore KB does not entail ⌐P. Hence, ⌐P is
false and P is true.
RESOLUTION EXAMPLE 2
Consider the following knowledge base:
1. marcus was a man.
man(Marcus)
2. marcus was a Pompeian.
pompeian(Marcus).
3. All Pompeians were Romans.
x: pompeian(x) roman(x)
4. Caesar was a ruler.
ruler(Caesar).
5. All Pompeians were either loyal to Caesar or hated him.
y: roman(y) loyalto(y, Caesar) hate(y, Caesar).
6. Every one is loyal to someone.
z: u: loyalto(z, u).
7. All men only try to assassinate rulers they are not loyal to.
v: w: man(v) ruler(w) tryassassinate(v, w) loyalto(v,w).
8. marcus tried to assassinate Caesar.
tryassassinate(Marcus, Caesar).
Use resolution, to prove marcus hates Ceaser : hate(marcus,Ceaser)
RESOLUTION EXAMPLE 2
CONTD……
The given axioms (set F) in symbolic form is:
1. man(Marcus).
2. pompeian(Marcus).
3. x: pompeian(x) roman(x).
4. ruler(Caesar).
5. y: roman(y) loyalto(y, Caesar) hate(y, Caesar).
6. z: u: loyalto(z, u).
7. v: w: man(v) ruler(w) tryassassinate(v, w)
loyalto(v,w).
8. tryassassinate(Marcus, Caesar).
and P: hate(marcus,ceaser)
RESOLUTION EXAMPLE 2
CONTD……
Step 1: Convert set F into Clause form
1. man(Marcus)
2. Pompeian(Marcus)
3. x: pompeian(x) roman(x)
(i) x: ⌐pompeian(x) ˅ roman(x)
(ii) ⌐pompeian(x) ˅ roman(x)
4. ruler(Caesar)
5. y: roman(y) loyalto(y, Caesar) hate(y, Caesar).
(i) y: ⌐ roman(y) ˅ [loyalto(y, Caesar) hate(y, Caesar)]
(ii) ⌐ roman(y) ˅ [loyalto(y, Caesar) hate(y, Caesar)]
(iii) ⌐ roman(y) ˅ loyalto(y, Caesar) hate(y, Caesar)
RESOLUTION EXAMPLE 2 CONTD……
6) z: u: loyalto(z, u)
(i) z: loyalto(z, f(z))
(ii) loyalto(z, f(z))
8) tryassassinate(Marcus, Caesar).
Step 2: Negate P: hate(Marcus,Caeser)
It is already is Clause form.
1. man(Marcus)
3. ⌐pompeian(x) ˅ roman(x)
Step 3: ⌐ hate(Marcus,Ceaser) (5) 4. Ruler(Caesar)
Marcus/y
5. ⌐ roman(y) ˅ loyalto(y,
(3) ⌐ roman(Marcus) ˅ loyalto(Marcus, Caesar) Caesar) hate(y, Caesar)
contradiction
EXAMPLE - 3
Consider the following axioms:
1. Anyone whom Mary loves is a football star.
2. Any student who does not pass does not play.
3. John is a student.
4. Any student who does not study does not pass.
5. Anyone who does not play is not a football star.
3. John is a student.
student(John)
RESOLUTION EXAMPLE 4 CONTD…..
4. Any student who does not study does not pass.
y: student(y) study(y) pass(y)
y: (student(y) study(y)) pass(y)
y: ( student(y) study(y)) pass(y)
( student(y) study(y)) pass(y)
student(y) study(y) pass(y)
6a. loves(Mary,John) 1
John/x
footballstar(John) 5
John/z
play(football) 2
John/y
4 student(John) pass(John)
John/y
student(John) study(John) 6b
student(John) 3
Contradiction
EXAMPLE-5
Consider the following axioms:
1. Anyone who rides some Harley is a rough character.
2. Every biker rides something that is either a Harley or a
BMW.
3. Anyone who rides any BMW is a yuppie.
4. Every yuppie is a lawyer.
5. Any nice girl does not date rough characters.
6. Mary is a nice girl, and John is a biker.
Using the following predicate schema, convert the axioms
into Clausal Normal Form
rides(x,y): x rides y isNicegirl(x): x is a nice girl isBiker(x):
x is biker isBMW(x): x is BMW isHarley: x is Harley
isYuppie(x): x is yuppie
date(x,y): x dates y isLawyer(x): x is lawyer
isRoughcharacter(x): x is a rough character
CONVERSION OF AXIOMS INTO WELL-FORMED
FORMULAS:
1. Anyone who rides some Harley is a rough character.
∀x∃y: rides(x,y) ∧isHarley(y) → isRoughcharacter(x)
2. Every biker rides something that is either a Harley or a
BMW.
∀u: biker(u) → ∃v: rides(u,v) ∧ (isHarley(v) ∨isBMW(v))
3. Anyone who rides any BMW is a yuppie.
∀p∃q: rides(p,q) ∧isBMW(q) → isYuppie(p)
4. Every yuppie is a lawyer
∀z: isYuppie(z) → isLawyer(z)
5. Any nice girl does not date rough characters.
∀a∀b: isNicegirl(a,) ∧isRoughcharacter(b) → ¬dates(a,b)
6. Mary is a nice girl, and John is a biker.
isNicegirl(Mary) ∧isBiker(John)
USING RESOLUTION, PROVE THAT “IF JOHN IS NOT
A LAWYER, THEN MARY DOES NOT DATE JOHN.
Step 1: Convert the axioms into CNF
∀x∃y: rides(x,y) ∧isHarley(y) → isRoughcharacter(x)
Remove Conditional Operator:
Put v=f(u)
∀u: ¬biker(u) ∨ (rides(u,f(u)) ∧ (isHarley(f(u)) ∨ isBMW(f(u))))
Remove universal quantifier:
6a. isNicegirl(Mary)
6b. isBiker(John)
QUESTION ANSWERING USING
RESOLUTION
Predicate logic can be used to find answers to questions from the
knowledge base.
The questions can be True/False type or fill in the blanks type.
Does Marcus hate Ceaser? – Yes/ No type
Who tried to assassinate Ceaser? – Fill in the blanks type.
To answer yes/no type questions, it is assumed that the answer of the
question is yes i.e. we assume that we want P(conclusion) as Marcus
hate Ceaser.
We then apply resolution principle (proof by refutation or
contradiction. So, we try to prove ⌐P from KB. If contradiction is
obtained, then ⌐P is not true and P is true. So, the answer to the
question is yes otherwise answer is false.
QUESTION ANSWERING CONTD..
To answer fill in the blanks type questions, following steps are
followed:
1) It is assumed that some answer exists for the question i.e. we
formulate the given question as:
∃x: tryassassinate(x,Ceaser)
2) The statement formulated in the above step is considered as
required conclusion.
3) The conclusion is then proved using resolution and the
substitution made for that variable (using unification
algorithm) in order to prove conclusion is the answer to that
question.
QUESTION ANWERING EXAMPLE
3. “Bread is a food”
food(bread) (3)
4. “Mango is a food”
food( mango) (4)
5. “Alka eats Pizza”
eats( Alka, Pizza) (5)
Pizza/ z
food(Pizza)
(1)
eats(x,y) food(y) Pizza/ y
eats(x , Pizza)
(5)
eats( Alka, Pizza)
Alka/ x
contradiction
Question to be answered : 2. “ what food Alka eats ?”
eats( alka, ??)
there exist something(t) which Alka eats- we have to find the value of t
(8) (5)
eats (Alka , t) eats( Alka, Pizza)
Pizza/ t
contradiction
Alka eats something is true.
And t stores pizza
Therefore we conclude :