Unit 3: - Knowledge Representation
Unit 3: - Knowledge Representation
• KNOWLEDGE REPRESENTATION
KB
Knowledge base
Inference Mechanism
1. Knowledge base (KB):-
• Contains knowledge abt the domain or world
• A set of sentences
• Each sentence describe facts about the world
• Each sentence is rep by knowledge representation
Language
2.Inference Mechanism:-
• provides a way to use the knowledge base or
deriving a new sentence from KB
• Propositional logic
• First-order logic or Predicate logic(FOL)
• Temporal logic
• Numerical constraints logic
• Map-coloring logic logic
Example:
P means "It is hot“
Q means "It is humid"
R means "It is rain
"It is hot“ and "It is humid" is rep by P and Q
Ex: red, round, prime, brother of, bigger than, part of, comes
between
22
04/22/22 A .Jeyanthi MNMJEC
Existential quantifier
Existential quantifier means “there exists” or “at
least one”
The notation x P
where P is exprn
x is variable
The expression P is true for at least one value of
the variable
Example: “Someone likes McDonalds” is
x likes(x, McDonalds)
Typically use with
04/22/22 A .Jeyanthi MNMJEC 23
Quantifiers contd…
• Universal quantifiers are often used with “implies” to form
“rules”:
x student(x) smart(x) means “All students are smart”
• Existential quantifiers are usually used with “” to specify a list of
properties about an individual:
x student(x) smart(x) means “There is a student who is
smart”
24
04/22/22 A .Jeyanthi MNMJEC
NESTING QUANTIFIERS
More complex sentence can be exist using multiple
quantifiers
Everyone likes someone: (x)(y) likes(x,y)
“Somebody likes everybody.” : ∃ x ∀ y Likes(x, y)
Everyone likes some kind of food
x y food(y) likes(x, y)
There is a kind of food that everyone likes
x y, food(x) likes(y, x)
Someone likes all kinds of food
x y, food(y) likes(x, y)
Every food has someone who likes it
x y, food(x) likes(y, x)
04/22/22 A .Jeyanthi MNMJEC 25
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
Everyone likes someone: (x)(y) likes(x,y)
“Somebody likes everybody.” : ∃ x ∀ y Likes(x, y)
32
04/22/22 A .Jeyanthi MNMJEC
IMPLICATION()
P Q (P is Premise, Q is Conclusion)
If P is true then Q will certainly be true (but not the other
way)
Example:-
“ if it rains then the roads are wet”
Note:
So if it rains is true then the roads are wet is true.
But when the roads are wet then it may be due to
other reasons also(sprinkler to clear the road)
So P Q ↔ ¬P Q
04/22/22 A .Jeyanthi MNMJEC 33
IMPLICATION contd..
So P Q ↔ ¬P Q
1.Modus Ponens α, α ⇒ β β
2. And Introduction α, β αβ
3.And Elimination α β α
4.OR Introduction α αβ
5.Double Negation α α
6.Unit Resolution α β, β α
7.Resolution α β, β C α C
8.Universal Instantiation
9.Existential Instantiation
Note: Resolution is both sound and complete
04/22/22
40 A .Jeyanthi MNMJEC
SUBSTITUTION
Substituting variables by constant or ground terms in any sentence
for any sentence P, variable v, and constant g
SUBST({v/g},P)
Example:
1. Result of SUBST({x/Harry, y/Sally}, Likes(x , y)) is
Likes(Harry, Sally)
2. Result of SUBST({x/John}, King(x) Greedy(x) Evil(x)) is
King(John) Greedy(John) Evil(John)
Note: ground terms is a term with no variable
colour(sky) is ground term
sqrt(x) is not a ground term
Crown(C1) OnHead(C1,John)
provided C1 is a new constant symbol, called a
Skolem constant
p q θ
STEP IX Enemy(Nono,America)
Apply Modes Ponen to 7 and (I)
Hostile(Nono) ------(J)
STEP X Apply AND introduction to 6,E,G,J
American(west) Weapon(M1) Sells(west,M1,nono) Hostile(Nono) ----(K)
04/22/22
(7) Enemy(Nono,America) A .Jeyanthi MNMJEC
----------->(H) 57
Criminal(west) proof using GMP
• STEP I Apply GMP to C,E
• Weapon(M1) is inferred
• STEP II Apply GMP to F,H
• Hostile(Nono) is inferred
• STEP III Apply GMP to B,C,D
• Sells(west,M1,Nono)
• STEP IV Apply GMP to step I,II,III and A,G
• Criminal(west) is proved
04/22/22 A .Jeyanthi MNMJEC 58
Forward chaining
• Iteration 2:
• i)In sentence (A) all premises are unified with known facts
• Criminal(west) is added to KB and is proved
American(West) Missile(M1)
Owns(Nono,M1) Enemy(Nono,America)
2.Deducing weapon(y)
Weapon(y) unifies Missile(x) Weapon(x)
•
∴ Weapon(y) is deduced to Missile(y)
Missile(y) unifies with Missile (M1) with
SUBST{y/M1} ∴ we get Missile(M1)
∴ weapon(y) is deduced
04/22/22 A .Jeyanthi MNMJEC 69
BACKWARD CHAINING EXAMPLE
3. Deducing Sells(West,M1,z)
Sells(West,M1,z) unifies with
Missile(x) Owns(Nono,x) Sells(West,x,Nono)
SUBST{x/ M1 , z/Nono }
∴ we get Missile(M1) , owns(Nono , M1)
4.Deducing Hostile(Nono)
Example:
unhappy(me) with
SUBST{x/me)
C
3.Inference continues until empty clause is derived.
{Y/john}
5. happy (john)
3. graduating (john)
7. []
04/22/22 A .Jeyanthi MNMJEC 86
Example 2: Resolution
Criminal (West) Proof Using Resolution
2. Move ¬ inwards:
Recall: ¬∀x p ≡ ∃x ¬p, ¬ ∃x p ≡ ∀x ¬p
∀x [∃y Animal(y) ∧ ¬Loves(x,y)] ∨ [∃y Loves(y,x)]
6. Distribute ∨ over ∧ :
[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]
1
04/22/22 A .Jeyanthi MNMJEC 95
Step 2: Convert to Definite Clause
Ignore and Eliminate
1.
John likes all kinds of food.
food(x) likes(john, x)
2. Apples are food.
food(apple)
3. Chicken is food.
food(chicken)
4. Anything anyone eats and isn't killed by is food.
eats(x, y) killed(x) food(y)
5. Bill eats peanuts and is still alive.
eats(Bill, peanuts)
6. killed (Bill)
7. eats(Bill, x) eats(Sue, x)
1
x1/ peanuts/
y4/ peanuts
eats(x4,peanuts) killed( x4) eats(Bill.peanuts)
Bill/x4
killed(Bill) killed(Bill)
{X ,Peanut}
Food((Peanut)
{Y/Peanut}
X/BILL
X/BILL
EAT(BILL ,Peanut)
NOTKILLED(BILL)
{Y/john}
5. easy (x)
6. basketweaving (X)
basketweaving (BK301))
7. []
Steve like BK301
04/22/22 A .Jeyanthi MNMJEC 104