PREDICATE LOGIC
PREDICATE LOGIC
Predicate Logic overcomes the limitations of
Prepositional Logic.
1. In Predicate logic we can define individuals
from the statements (variables, constants, or
function).
2. We can define properties of individuals or
relations between individuals.
3. We can represent generalizations, patterns
or regularities about the individuals.
SYNTAX OF PREDICATE LOGIC
Predicate logic has three more logical notions in addition
to propositional logic
Term:
A term is either a variable, constant or a n-map
function. A variable is denoted by small letters x,y,z etc.
Initial letters of constants are capatilized or enclosed in a
single quoted commas. A function is a mapping that maps ‘n’
terms to a term. In other words, it represents a relation that
is functional. Ex: the cosine of any angle can be only one
number : Cosine(angle,number)
Predicate: A predicate is defined as a relation that maps n
terms to truth value True or False. Predicate symbols are
denoted by small letters. p(term1, term2………..term n).
Quantifiers: Quantifiers specify the scope of the variables.
o
o
Universal Quantifier: It specify that the scope of variable is
universal (for all). It is denoted by ∀
Existential Quantifier: It specify that the scope of variable is true
for some values (there exists). It is denoted by ∃.
FIRST ORDER- PREDICATE CALCULUS
If the quantification in predicate formula is only on
simple variables and not on predicates then it is called
first-order predicate calculus.
If the quantification is over predicate and functions
then it becomes higher order predicate calculus.
For example, ∀x ∀y: p(x)↔p(y) is a first-order predicate logic
statement whereas ∀p: p(x)↔p(y) is a second order predicate
logic statement.
When inference rules are added to first order predicate
calculus, it becomes first order-predicate logic (FOPL).
WELL FORMED FORMULA (WFF)
Atomic formula (also called atom) p(t1,t2,t3… ,tn) is
a well formed formula. where p is a predicate and
t1, t2,t3…..tn are terms.
For example: brother(x,y) –x is brother of y.
loves(peter,son(peter) )- Peter loves his son
If A and B are well formed formula then ~(A), A˅B,
A˄B, A→B, A<→B are all well formed formulas.
For example: brother (x,y) ˄ son(x,z) is a wff indicating x is
brother of y and son of z.
WELL FORMED FORMULAS CONTD….
If A is a formula and x is a free variable in A, then
∀x: A (also written as ∀x(A)) and ∃x: A (also written
as ∃x(A)) are also well formed formulas. Scope of the
variable is same for all occurrences of the variable.
For example, ∀x: human(x) → mortal(x) is a wff indicating
All human are mortal.
Well formed formulas can be generated by applying
the rules described above finite number of times.
CONVERTING FACTS INTO WFFS (EXAMPLES)
1)
2)
3)
4)
5)
6)
John buys a pumpkin.
Lifesavers is a candy.
Every child loves every candy.
Any child who loves some candy is not a
nutrition fanatic.
Any child who eats any pumpkin is a nutrition
fanatic.
Any child who buys any pumpkin either carves
it or eats it.
CONVERTING FACTS INTO WFFS (EXAMPLES)
1)
buys(John,Pumpkin)
2)
candy(Lifesaver)
3)
x y: child(x)˄ candy(y) -> loves(x,y)
4)
x y: child(x) ˄ candy(y) ˄ loves(x,y) -> ⌐nutritionfanatic(x)
5)
x y: child(x) ˄ pumpkin(y) ˄ eat(x,y) -> nutritionfanatic(x)
6)
x y: child(x) ˄ pumpkin(y) ˄ buys(x,y) -> carves(x,y) ˅ eats(x, y)
MORE EXAMPLE:
Not all cars have carburetors
¬∀x [car(x) → carburetors(x)]
Some people are either religious or pious
∃x((R(x) ∧ ¬P(x)) ∨ (¬R(x) ∧ P(x))
No dogs are intelligent
∀x (dog(x) → ¬Intelligent(x))
All babies are illogical
∀x (baby(x) → illogical(x))
Every number is either negative or has a square root
∀x((negative(x) ∧ ¬sqroot(x)) ∨ (¬negative(x) ∧ sqroot(x))
Some numbers are not real
∃x¬Real(x)
MORE EXAMPLE:
Every connected and circuit-free graph is a tree
∀x [(conn(x) ∧ ¬cir(x)) → tree(x)]
Not every graph is connected
¬∀x connected(x)
All that glitters is not gold
∀x [glitter(x) → ¬gold(x)]
Not all that glitters is gold
¬∀x(glitter(x) → gold(x)) o
There is a barber who shaves all men in the town who
do not shave themselves
∃x [Barber(x) ∧ ∀y [man(y) ∧ ¬shaves(y, y)] → shaves(x, y)]
No one has climbed every mountain in the Himalayas
∀x (person(x) → ∃ y(Mountain(y) ∧ ¬Climb(x, y))
Example: Translate the text "Every man is mortal. John is a
man. Therefore, John is mortal" into Predicate Calculus
formula.
Solution: Let
MAN(x), MORTAL(x) represent ‘x is a man’ and ‘x is mortal’
respectively.
•Every man is mortal :(∀x) (MAN(x) →MORTAL(x))
•John is a man: MAN(john)
•John is mortal: MORTAL(john)
The whole text can be represented by the following formula.
(∀x) ((MAN(x) →MORTAL(x)) ΛMAN(john))
→MORTAL(john)
RESOLUTION
Resolution is an iterative procedure, in which at each
step, two clauses (called the parent clauses), are
compared (resolved) to yield a new clause (called
resolvent).
The parent clauses must be disjunction of literals,
such that one statement is in positive form in one
parent clause and in negated form in another parent
clause.
The resolvent is the disjunction of other literals in
both the parent clauses.
A˅(⌐B)
B˅C
AVC
BASIS OF RESOLUTION
o For applying resolution in predicate logic;
1)
2)
the wffs should be in Clause Form
The arguments of the predicate must be matched using
Unification mechanism.
CLAUSE FORM
A
well formed formula is said to be in Clausal
Normal (CNF) if:
It is free from conditional and biconditional
operators.
There are no quantifiers (existential or universal)
in the formula.
The wffs should be conjunct of disjuncts(and of or)
so that each conjunct can be considered as a
separate clause.
STEPS TO CONVERT A WFF INTO CLAUSE FORM
1) Eliminate implications and equivalences using formulas:
Conditional Elimination : a→b = ⌐a ˅ b
Bi Conditional Elimination: a↔b = (⌐a ˅ b) ˄ (⌐b ˅ a)
2) Reduce the scope of negation to individual term using following
formulas:
Demorgan’s law : ⌐(a ˅ b) = ⌐ a ˄ (⌐b)
⌐(a ˄ b) = ⌐ a ˅ (⌐b)
Negation Law: ⌐(⌐a) = a
x: P x: P
x: p x: P
3) Standardize variables so that each quantifier binds a
unique variable. Since variables are dummy names so
this process does not effect the truth value of wff.
(x: P(x)) (x: Q(x)) (x: P(x)) (y: Q(y))
STEPS TO CONVERT A WFF INTO CLAUSE FORM
Move all quantifiers to the left without changing
their relative order. This is possible because there is
no conflict in variable names. At this stage, the formula
is said to be in prefix normal form i.e. The quantifiers
are prefixed to the rest of clauses
(x: P(x)) (y: Q(y)) x y: P(x) Q(y) prenex
normal form
5) Remove existential quantifier: A formula that
contains existentially quantified variable, means that
there exist some value of the variable for which the
formula is true.
So, we can eliminate the existentially quantified
variable with a function that produces the desired
value.
For example, y: president(y) can be written as
president (S1) where S1 is a function with no
arguments
4)
STEPS TO CONVERT A WFF INTO CLAUSE FORM
Similarly, x y :loves(x,y) can be replaced with loves(x,f(x))
where f(x) is a function with one argument that provides
love-of depends on particular value of x.
• We must generate the functions with same numbers of
arguments as the number of universal quantifiers in whose
scope the expression occurs.
• The functions so generated are called skolem functions and
the process of replacing existential quantifiers with skolem
function is called skolemization. The function with no
argument is also called skolem constants.
6) Drop the prefix i.e. all quantifiers. At this point, all
remaining variables are universally quantified so we can
drop the quantifiers because it is clear that the variable if
occurs is universally quantified.
•
STEPS TO CONVERT A WFF INTO CLAUSE FORM
7)
Convert the wff into conjunction of disjuncts. Apply
distributive law if required.
P ˅ (Q ˄ R)= (P˅Q) ˄ (P˅R)
8)
Create a separate clause corresponding to each
conjunct. In order for a wff to be true, all the clauses
that are generated from it must be true.
CLAUSE FORM EXAMPLE
Consider the statement, All Romans who know Ceaser either
hate Ceaser or think that anyone who hates anyone is crazy.
The statements can be expressed as wff:
x: roman(x) ˄ knows(x, Ceaser) -> [hate(x,Ceaser) ˅ (y: z:
hate(y,z)-> thinkcrazy(x,y))]
Step 1: Remove Conditional Operator
x: ⌐[roman(x) ˄ knows(x, Ceaser)] ˅ [hate(x,Ceaser) ˅ (y: z: ⌐
(hate(y,z)) ˅ thinkcrazy(x,y)]
Step 2: Reduce the scope of NOT operator to individual clauses:
x: [⌐roman(x) ˅ ⌐knows(x, Ceaser)] ˅ [hate(x,Ceaser) ˅ (yz:
⌐(hate(y,z) ˅ thinkcrazy(x,y))]
CLAUSE FORM EXAMPLE CONTD...
Step 3: Not required as all the variables are
standardized.
Step 4: Prenex Normal Form is:
x: y: z: [⌐roman(x) ˅ ⌐knows(x, Ceaser)]
[hate(x,Ceaser) ˅ ⌐(hate(y,z) ˅ thinkcrazy(x,y)]
˅
Step 5: Skolemization is not required as there is no
existential quantifier.
CLAUSE FORM EXAMPLE CONTD...
Step 6: Remove all universal quantifiers.
[⌐roman(x) ˅ ⌐knows(x, ceaser)] ˅ [hate(x,Ceaser) ˅
⌐(hate(y,z) ˅ thinkcrazy(x,y)]
Step7: The Clusal form is:
⌐roman(x) ˅ ⌐knows(x, Ceaser)
⌐hate(y,z) ˅ thinkcrazy(x,y)
˅
hate(x,Ceaser)
˅
THE UNIFICATION MECHANISM
In prepositional logic, it is easy to determine that two
complimentary literals cannot be true like winter and
⌐winter.
But, in predicate logic the procedure is complicated as the
arguments of the predicate must also be matched.
For example, man(John) and ⌐man(John) is a contradiction but
man(John) and ⌐man(Ram) is not.
So, in predicate logic there must exist some matching
procedure that compares two clauses and discovers whether
exists a set of substitutions that makes them identical.
The recursive procedure that returns a set of substitutions that
makes the two clauses identical is called unification.
THE UNIFICATION MECHANISM CONTD…..
To attempt to unify two literals, we first check
if their initial symbols are the same and
complimentary. If they are same, then they can
be unified otherwise not.
For example: tryassasinate (Marcus, Ceaser)
hate (Marcus, Ceaser)
cannot be unified.
II. If the predicate symbol match, then we must
check the arguments one pair at a time by
calling the unification procedure recursively.
III. Different
constants or predicates cannot
match, identical ones can.
I.
THE UNIFICATION MECHANISM CONTD…..
IV.
A variable can match another variable,
any constant, or any predicate expression,
with the restriction that the predicate
expression must not contain any instances
of the variable being matched.
Suppose we were attempting to unify the expressions
f(x, x)
f(g(x), g(x))
If we accepted g(x) as a substitution for x, then we would
have to substitute it for x in the remainder of the
expressions. But this leads to infinite recursion since it
will never be possible to eliminate x.
Unify P(x,x) and P(y, z)
V. There must be a single, consistent substitution for entire literal, not
separate ones for each piece of it.
For example, suppose we want to unify the expressions
P(x, x)
and
P(y, z)
The two instances of P match fine.
Next we compare x and y, and decide that if we substitute y for x, they could match. We
will write that substitution as y/x i.e. P(y,x) and P(y,z)
But now, if we simply continue and match x and z, we produce the substitution z/ x.
we cannot substitute both y and z for x, so we have not produced a consistent
substitution.
What we need to do after finding the first substitution y/x is to make that substitution
throughout the literals, giving
P(y,y)
and P(y, z)
Now we can attempt to unify arguments y and z, which succeeds with the substitution
z/y.
The entire unification process has now succeeded with a substitution that is the
composition of the two substitutions we found. We write the composition as
(y/x)
(z/y)
THE UNIFICATION ALGORITHM
Unify algorithm takes two clauses L1 and L2 as input and returns a list SUBST
that provides set of substitutions required to match L1 and L2.
1. If the initial predicate symbols in L1 and L2 are not identical, then return {FAIL}.
2. If L1 and L2 have a different number of arguments, then return {FAIL}.
3. Set SUBST to NIL.(At the end of this procedure , SUBST will contain all the
substitutions used to unify L1 and L2.)
4. For i 1 to number of arguments in L1:
(a) Apply following steps with the ith argument of L1 and the ith argument of L2,
putting result in S.
If L1 or L2 are both variables or constants then:
(i) If L1 and L2 are identical, then return NIL.
(ii) Else if L1 is a variable, then if L1 occurs in L2 then return
{FAIL},else
return {L2/L1}
(iii) Else if L2 is a variable, then if L2 occurs in L1 then return
{FAIL},else
return{L1/L2}.
other,
(iv) If L1 and L2 are both variables and both does not occur in each
then return [l1/l2] or [l2/l1] or [constant/L1],[constant/l2]
(v) Else return {FAIL}.
THE UNIFICATION ALGORITHM CONTD…
(b) if S contains FAIL then return {FAIL}.
(c) if S is not equal to Nil then:
i. Apply S to the remainder of both L1 and L2.
ii. SUBST:= APPEND(S,SUBST).
5. Return SUBST.
EXAMPLE- UNIFICATION
Unify (if possible) the following pairs of predicates and
give the resulting substitutions. B is a constant.
P(x, f(x), z) and ¬ P(g(y),f(g(B)),y)
P(f(a), f(x)) and ¬ P(y, y)
P(x, f(x)) and ¬ P(f(y), y)
P(x, f(z)) and ¬ P(f(y), y)
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.
For example, for unifying the following two clauses:
hate(x,y) and hate( marcus,z)
There can be number of substitutions such as
{ y/z, Marcus/x}
{z/y, Marcus/x}
{Ceaser/y,Ceaser/z, Marcus/x}
{Marcus/y,Marcus/z, Marcus/x}
RESOLUTION ALGORITHM
Algorithm to prove a proposition P from set of axioms F
(Knowledge Base).
Step 1: Convert all wff of F into clause form.
Step 2: Negate P and convert into clause form.
Step 3: Repeat steps a to d until either contradiction is found
or no progress is made:
(a) Select two parent clauses ( For first iteration, one of the
parent clause is negate P).
(b) Apply unification algorithm to find set of possible
substitutions to match the predicates.
(c) Resolve them together to find the resolvent. Resolvent is
disjunction of all the predicates of the parent clauses
except the predicate which is in positive form in one parent
clause and in negative form in second parent clause.
(d) If the resolvent is empty then contradiction is found,
otherwise add the resolvent to set of available clauses.
RESOLUTION EXAMPLE 1
Consider the knowledge base:
1. Steve only likes easy courses.
x: easy(x) -> likes(Steve,x)
2. Science courses are hard.
y: science(y) -> ~easy(y)
3. All the courses in the basketweaving department are
easy.
z: basketweaving(z)-> easy(z)
4. BK301 is a basketweaving course.
basketweaving(BK301)
Use resolution, to prove Steve likes BK301
P: likes(Steve,BK301)
RESOLUTION EXAMPLE 1
Set F in symbolic form:
1) x: easy(x) -> likes(Steve,x)
2) y: science(y) -> ~easy(y)
3) z: basketweaving(z)-> easy(z)
4) basketweaving(BK301)
P: likes(Steve,BK301)
Step 1: Reduce F in Clause form:
1) x: easy(x) -> likes(Steve,x)
(i) x: ⌐easy(x) ˅ likes(Steve,x)
(ii) ⌐easy(x) ˅ likes(Steve,x)
RESOLUTION EXAMPLE 1 CONTD…
2) y: science(y)-> ⌐easy(y)
(i) y: ⌐science(y) ˅ ⌐easy(y)
(ii) ⌐science(y) ˅ ⌐easy(y)
3) z: basketweaving(z) -> easy(z)
(i) z: ⌐basketweaving(z) ˅ easy(z)
(ii) ⌐basketweaving(z) ˅ easy(z)
4) basketweaving(BK301)
Step 2: Negate P: ⌐likes(Steve,BK301)
It is already in Clause Normal Form.
RESOLUTION EXAMPLE 1 CONTD…
⌐likes(Steve,BK301)
(3)
BK301/z
(1)
BK301/x
1. ⌐easy(x) ˅ likes(Steve,x)
⌐easy(BK301)2. ⌐science(y) ˅ ⌐easy(y)
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.
2.
3.
4.
5.
man(Marcus)
Pompeian(Marcus)
x: pompeian(x) roman(x)
(i) x: ⌐pompeian(x) ˅ roman(x)
(ii) ⌐pompeian(x) ˅ roman(x)
ruler(Caesar)
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))
7)
v: w: person(v) ruler(w) tryassassinate(v, w) loyalto(v, w).
(i) v: w: [man(v) ruler(w) tryassassinate(v,w)] ˅ loyalto(v, w)
(ii) v: w: [ man(v) ˅ ruler(w) ˅ tryassassinate (v,w)] ˅ loyalto(v,w)
(iii) [ man(v) ˅ ruler(w) ˅ tryassassinate (v,w)] ˅ loyalto(v,w)
(iv) man(v) ˅ ruler(w) ˅ tryassassinate (v,w) ˅ loyalto(v,w)
8)
tryassassinate(Marcus, Caesar).
Step 2: Negate P: hate(Marcus,Caeser)
It is already is Clause form.
RESOLUTION EXAMPLE 2 CONT…
Step 3:
⌐ hate(Marcus,Ceaser)
1.
man(Marcus)
2.
Pompeian(Marcus)
3.
⌐pompeian(x) ˅
roman(x)
(5)
4.
Ruler(Caesar)
Marcus/y
(3)
5.
⌐ roman(Marcus) ˅ loyalto(Marcus, Caesar)
Marcus/x
⌐pompeian(Marcus) ˅ loyalto(Marcus, Caesar)
(7)
loyalto(Marcus, Caesar)
Marcus/v
6. (2) loyalto(z, f(z))
7.
man(v) ˅ ruler(w) ˅
tryassassinate (v,w) ˅
loyalto(v,w)
8.
Ceaser/w
man(Marcus) ˅ ruler(Ceaser) ˅ tryassassinate (Marcus, Ceaser)
(4)
⌐ roman(y) ˅ loyalto(y,
Caesar) hate(y,
Caesar)
tryassassinate(Marcus,
Caesar).
(1)
ruler(Ceaser) ˅ tryassassinate (Marcus, Ceaser)
tryassassinate (Marcus, Ceaser)
contradiction
(8)
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.
Prove using resolution: If John does not study, then
Mary does not love John.
RESOLUTION EXAMPLE 4 CONTD…..
Step 1: Convert all axioms of knowledge base to Clausal
Normal Form
1. Anyone whom Mary loves is a football star.
x: loves(Mary,x) footballstar(x)
loves(Mary,x) footballstar(x)
2. Any student who does not pass does not play.
y: student(y) pass(y) play(y)
y: (student(y) pass(y)) play(y)
y: ( student(y) pass(y)) play(y)
( student(y) pass(y)) play(y)
student(y) pass(y) play(y)
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)
5. Anyone who does not play is not a football star.
z: play(z) footballstar(z)
z: play(z) footballstar(z)
play(z) footballstar(z)
RESOLUTION EXAMPLE 4 CONTD…..
Step 2: Negate Conclusion and convert it into Clausal
Normal Form
If John does not study, then Mary does not love John.
Conclusion: study(John) loves(Mary,John)
study(John) loves(Mary,John)
Negated Conclusion: (study(John) loves(Mary,John))
study(John)
loves(Mary,John))
6a. study(John) ,
6b. loves(Mary,John)
RESOLUTION EXAMPLE 4 CONTD…..
Step 3: Resolution
6a. loves(Mary,John)
John/x
1
footballstar(John)
5
John/z
play(football)
2
John/y
4
John/y
student(John) pass(John)
student(John) study(John)
student(John)
3
Contradiction
6b
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:
∀x¬(∃y rides(x,y) ∧isHarley(y))∨isRoughcharacter(x)
Reduce Scope of NOT to individual predicate:
∀x∀y¬(rides(x,y) ∧isHarley(y)) ∨isRoughcharacter(x)
∀x∀y(¬rides(x,y) ∨¬isHarley(y)) ∨isRoughcharacter(x)
Remove Universal Quantifier:
(¬rides(x,y) ∨¬isHarley(y)) ∨isRoughcharacter(x)
Clausal Normal Form:
¬rides(x,y) ∨¬isHarley(y) ∨ isRoughcharacter(x)
∀U: BIKER(U) → ∃V: RIDES(U,V) ∧ (ISHARLEY(V) ∨ ISBMW(V))
Remove Conditional Operator:
∀u: ¬biker(u) ∨ (∃v: rides(u,v) ∧ (isHarley(v) ∨ isBMW(v)))
Move all the quantifiers to the left of the expression
∀u∃v: ¬biker(u) ∨ (rides(u,v) ∧ (isHarley(v) ∨isBMW(v)))
Remove Existential Quantifier:
Put v=f(u)
∀u: ¬biker(u) ∨ (rides(u,f(u)) ∧ (isHarley(f(u)) ∨ isBMW(f(u))))
Remove universal quantifier:
¬biker(u) ∨ (rides(u,f(u)) ∧ (isHarley(f(u)) ∨ isBMW(f(u))))
Apply distributive law
(¬biker(u) ∨ rides(u,f(u)))∧ (¬biker(u)
∨isHarley(f(u))∨isBMW(f(u)))
Separate each conjunct: (Clausal Normal form: )
2a. ¬isbiker(u) ∨ rides(u,f(u))
2b. ¬isbiker(u) ∨isHarley(f(u)) ∨isBMW(f(u))
∀P∃Q: RIDES(P,Q) ∧ISBMW(Q) → ISYUPPIE(P)
Remove Conditional operator:
∀p¬(∃q rides(p,q) ∧isBMW(q))∨isYuppie(p)
Reduce Scope of NOT to individual predicate:
∀p∀q ¬(rides(p,q) ∧isBMW(q)) ∨ isYuppie(p)
∀p∀q (¬rides(p,q) ∨¬isBMW(q)) ∨isYuppie(p)
Remove universal quantifier
(¬rides(p,q) ∨¬isBMW(q)) ∨isYuppie(p)
Clausal Normal form:
¬rides(p,q) ∨¬isBMW(q) ∨isYuppie(p)
∀Z: ISYUPPIE(Z) → ISLAWYER(Z)
Remove Conditional Operator:
∀z: ¬isYuppie(z) ∨isLawyer(z)
Remove Universal Qunatifier:
¬isYuppie(z) ∨isLawyer(z)
Clausal Normal Form:
¬isYuppie(z) ∨isLawyer(z)
∀A∀B: ISNICEGIRL(A,) ∧
ISROUGHCHARACTER(B) → ¬DATES(A,B)
Remove Conditional Operator:
∀a∀b: ¬ (isNicegirl(a,) ∧isRoughcharacter(b)) ∨¬dates(a,b)
Reduce the scope of NOT operator to individual terms:
∀a∀b: (¬isNicegirl(a,) ∨¬isRoughcharacter(b)) ∨
¬dates(a,b)
Remove universal quantifier:
(¬isNicegirl(a,) ∨¬isRoughcharacter(b)) ∨¬dates(a,b)
Clausal Normal Form:
¬isNicegirl(a) ∨¬isRoughcharacter(b) ∨¬dates(a,b)
ISNICEGIRL(MARY) ∧ISBIKER(JOHN)
isNicegirl(Mary) ∧isBiker(John)
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
Anything anyone eats is called food
(2) John likes all kind of food
(3) Bread is a food
(4) Mango is a food
(5) Alka eats Pizza
(6) Alka eats everything John eats
Answer the following questions:
(a) Does John like pizza?
(b) What food Alka eats?
(1)
Solution:
1.
(Step 1):
“ Anything anyone eats is called food.”
x: y: eats(y,x) food(x)
Þ x: y: eats(y,x)) food(x)
Þ eats(y,x) food(x)
2.
---wff
(1)
“John likes all kind of food”
z: food(z) like(John , z)
Þ z: food(z) like( John,z)
Þ food(z) like(John,z)
(2)
3. “Bread is a food”
food(bread)
4. “Mango is a food”
food( mango)
(3)
(4)
5. “Alka eats Pizza”
eats( Alka, Pizza)
(5)
6. “Alka eats everything John eats”
u: eats(John , u) eats(Alka, u)
=> u: eats(John , u) eats(Alka, u)
=> eats(John,u) eats(Alka,u)
(6)
Question to be answered : 1. “Does john likes Pizza ?”
P: “John like Pizza”
P: like(John ,Pizza)
(7)
Ø
like(John, Pizza)
(2)
food(z) like( John , z)
Pizza/ z
(1)
eats(x,y) food(y)
(5)
eats( Alka, Pizza)
food(Pizza)
Pizza/ y
eats(x , Pizza)
Alka/ x
contradiction
Since like(john , pizza) is contradiction like(john , pizza) is true
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
conclusion(P) t: eats ( Alka, t)
=>
=>
P: [t: eats (Alka, t)]
T: eats (Alka ,t)
eats (Alka , t)
(8)
eats (Alka , t)
Pizza/ t
(8)
(5)
eats( Alka, Pizza)
contradiction
Alka eats something is true.
And t stores pizza
Therefore we conclude
:
eats ( alka, ??) answer is “pizza”
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )