Unit 4 - AI
Unit 4 - AI
Unit 4 - AI
Knowledge Representation
KNOWLEDGE REPRESENTATION
First order logic – representation revisited – Syntax and
semantics for first order logic – Using first order logic –
Knowledge engineering in first order logic - Inference in
First order logic – propositional versus first order logic –
unification and lifting – forward chaining – backward
chaining - Resolution - Knowledge representation -
Ontological Engineering - Categories and objects.
Knowledge Base
Knowledge Base
Logic
Example:
● 5 is a prime number
● 3+4= 8 Excellence and Service
CHRIST
Deemed to be University
Propositional Logic - Syntax
Atomic Sentences:
● Atomic propositions are the simple propositions.
● It consists of a single proposition symbol.
Example: 2+2 = 4 - True
The sun is cold - False
Compound Sentences:
● Constructed by combining simpler or atomic
propositions, using parentheses and logical
connectives.
● Example - "It is raining today, and street is wet."
"Ankit is a doctor, and his clinic is in
Mumbai."
Compound Sentences:
There are five connectives
○ Negation (~) - NOT
○ Conjunction (∧) - AND
○ Disjunction (V) - OR
○ Implication (🡪) - IMPLIES
○ Biconditional (⬄) - IF AND ONLY IF
Quantifiers in FOL
∀ x Likes(x, IceCream)
¬∃ x ¬Likes(x, IceCream)
Example:
28
Excellence and Service
CHRIST
Deemed to be University
Syntax of FOL
∀x bird(x) →
fly(x)
∀x man(x) → respects(x,
Parent)
∀x Gardener(x) → likes(x,
Sun)
~tall(Denny)
∀x Pompeians(x) →
Romans(x)
Painter(Picasso)
∀x Elephant(x) → Grey(x)
Fenny is a Professor
Professor(Fenny)
Criticize(Lucy,John)
Lipton is a Tea
Tea (Lipton)
∀x man(x) → mortal(x)
∀x girls(x) → beautiful(x)
∀x glitters(x) → ~gold(x)
∃x boys(x) Ʌ obedient(x)
∀x ∀y Brothers(x, y) → Siblings(x, y)
∀x ∃y Loves(x, y)
∃y ∀x Loves(x, y)
Examples Of FOL
Examples Of FOL
KNOWLEDGE REPRESENTATION
First order logic – representation revisited – Syntax and
semantics for first order logic – Using first order logic –
Knowledge engineering in first order logic - Inference in
First order logic – propositional versus first order logic –
unification and lifting – forward chaining – backward
chaining - Resolution - Knowledge representation -
Ontological Engineering - Categories and objects
Inferences in FOL
Inferences in FOL
Universal Instantiation:
● Any sentence can be inferred by substituting a
ground term for the variable
● Ground Term - Term without variable
● Rule - Let denote
the result of applying the substitutions θ to
sentence α
Inferences in FOL
{x/John}
Inferences in FOL
Existential Instantiation:
● Variable is replaced by a single new constant
symbol
● Rule - For any sentence α, variable v and constant
symbol k (that does not appear elsewhere in the
knowledge base)
Inferences in FOL
Inferences in FOL
Inferences in FOL
Example:
p1' is king(John) p1 is king(x)
p2' is Greedy(y) p2 is Greedy(x)
θ is {x/John, y/John} q is evil(x)
SUBST(θ,q) is Evil(John)Excellence and Service
CHRIST
Deemed to be University
Syllabus
KNOWLEDGE REPRESENTATION
First order logic – representation revisited – Syntax and
semantics for first order logic – Using first order logic –
Knowledge engineering in first order logic - Inference in
First order logic – propositional versus first order logic –
unification and lifting – forward chaining – backward
chaining - Resolution - Knowledge representation -
Ontological Engineering - Categories and objects
Unification
Example: {x/John}
Unification
Example:
p = knows(John, x) q = knows(John,ΘJane)
=
p = knows(John, x) {x/Jane}
Θ = {x/Mary,
q = knows(y, Mary)
p = knows(John, x) y/John}
q = knows(y,ΘMother(y))
= {y/John,
p = knows(John, x) q = knows(x, Mary)
x/Mother(John)}
fail
● This problem can be avoided by standardizing apart
one of the two sentences being unified (i.e renaming
its variables to avoid name clashes)
p=knows(John,x) q= knows(x17, Mary)
Unification
KNOWLEDGE REPRESENTATION
First order logic – representation revisited – Syntax and
semantics for first order logic – Using first order logic –
Knowledge engineering in first order logic - Inference in
First order logic – propositional versus first order logic –
unification and lifting – forward chaining – backward
chaining - Resolution - Knowledge representation -
Ontological Engineering - Categories and objects
Forward Chaining
● It is a simple algorithm.
● It starts from the known facts, it triggers all the
rules whose premises are satisfied adding their
conclusions to the known facts.
● The process repeats until the query is answered or
new facts are added.
Known facts → Goal
Definite Clauses
● A definite clause is either atomic or is an implication
whose antecedent is a conjunction of positive literals
and whose consequent is a single positive literal.
● Literal is any predicate applied to a set of terms.
● First order literals can include variables and they are
assumed to be universally quantified.
Example:
King(John)
Greedy(y)
King(x) ∧ Greedy (x) → Evil (x)
Excellence and Service
CHRIST
Deemed to be University
Example
Example
Example
Example
Example
Example
Example
Example
Example
KNOWLEDGE REPRESENTATION
First order logic – representation revisited – Syntax and
semantics for first order logic – Using first order logic –
Knowledge engineering in first order logic - Inference in
First order logic – propositional versus first order logic –
unification and lifting – forward chaining – backward
chaining - Resolution - Knowledge representation -
Ontological Engineering - Categories and objects
Backward Chaining
Criminal(Robert)
97
Excellence and Service
CHRIST
Deemed to be University
1. American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p)
2. Owns(A, T1)
3. Missile(T1)
4. Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A)
5. Missile(p) → Weapons (p)
6. Enemy(p, America) →Hostile(p)
7. Enemy (A, America)
8. American(Robert).
Criminal(Robert)
1: { p / Robert }
{ }
98
Excellence and Service
CHRIST
Deemed to be University
1. American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p)
2. Owns(A, T1)
3. Missile(T1)
4. Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A)
5. Missile(p) → Weapons (p)
6. Enemy(p, America) →Hostile(p)
7. Enemy (A, America)
8. American(Robert).
Criminal(Robert)
1: { p / Robert }
8: { }
99
Excellence and Service
CHRIST
Deemed to be University
1. American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p)
2. Owns(A, T1)
3. Missile(T1)
4. Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A)
5. Missile(p) → Weapons (p)
6. Enemy(p, America) →Hostile(p)
7. Enemy (A, America)
8. American(Robert).
Criminal(Robert)
Criminal(West)
1: { p / Robert }
American(Robert)
American(West) Weapon(q)
Weapon(y) Sells(Robert,q,r)
Sells(West,y,z) Hostile(z)
Hostile(r)
8: { }
5:{p/q}
Missile(q)
100
Excellence and Service
CHRIST
Deemed to be University
1. American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p)
2. Owns(A, T1)
3. Missile(T1)
4. Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A)
5. Missile(p) → Weapons (p)
6. Enemy(p, America) →Hostile(p)
7. Enemy (A, America)
8. American(Robert).
Criminal(Robert)
Criminal(West)
1: { p / Robert }
American(Robert)
American(West) Weapon(T1)
Weapon(y) Sells(Robert,T1,r)
Sells(West,M1,z)
Sells(West,y,z) Hostile(z)
Hostile(r)
8: { }
5:{p/q}
Missile(M1)
Missile(T1)
3: { q / T1 }
101
Excellence and Service
CHRIST
Deemed to be University
1. American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p)
2. Owns(A, T1)
3. Missile(T1)
4. Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A)
5. Missile(p) → Weapons (p)
6. Enemy(p, America) →Hostile(p)
7. Enemy (A, America)
8. American(Robert).
Criminal(Robert)
Criminal(West)
1: { p / Robert }
American(Robert)
American(West) Weapon(T1)
Weapon(y) Sells(Robert,T1,A)
Sells(West,M1,z)
Sells(West,y,z) Hostile(A)
Hostile(z)
8: { }
5:{p/q}
Missile(M1)
Missile(T1) 4 : { p / T1}
{r/A}
3: { q / T1 }
Missile(T1) Owns(A,T1)
102
Excellence and Service
CHRIST
Deemed to be University
1. American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p)
2. Owns(A, T1)
3. Missile(T1)
4. Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A)
5. Missile(p) → Weapons (p)
6. Enemy(p, America) →Hostile(p)
7. Enemy (A, America)
8. American(Robert).
Criminal(Robert)
Criminal(West)
1: { p / Robert }
American(Robert)
American(West) Weapon(q)
Weapon(y) Sells(Robert,T1,A)
Sells(West,M1,z)
Sells(West,y,z) Hostile(Nono)
Hostile(A)
Hostile(z)
8: { }
5:{p/q}
4 : { p / T1}
Missile(M1)
Missile(T1)
{r/A}
3: { q / T1 }
Missile(M1)
Missile(T1) Owns(Nano,M1)
Owns(A,T1)
3: { } 2: { }
103
Excellence and Service
CHRIST
Deemed to be University
1. American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p)
2. Owns(A, T1)
3. Missile(T1)
4. Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A)
5. Missile(p) → Weapons (p)
6. Enemy(p, America) →Hostile(p)
7. Enemy (A, America)
8. American(Robert).
Criminal(Robert)
Criminal(West)
1: { p / Robert }
American(Robert)
American(West) Weapon(q)
Weapon(y) Sells(Robert,T1,A)
Sells(West,M1,z)
Sells(West,y,z) Hostile(Nono)
Hostile(A)
Hostile(z)
8: { } 5:{p/q} 6 : { p / A}
Missile(M1)
Missile(T1)
4 : { p / T1}
Enemy(A, America)
3: { q / T1 } {r/A}
Missile(M1)
Missile(T1) Owns(Nano,M1)
Owns(A,T1)
3: { } 2: { }
104
Excellence and Service
CHRIST
Deemed to be University
1. American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p)
2. Owns(A, T1)
3. Missile(T1)
4. Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A)
5. Missile(p) → Weapons (p)
6. Enemy(p, America) →Hostile(p)
7. Enemy (A, America)
8. American(Robert).
Criminal(Robert)
Criminal(West)
1: { p / Robert }
American(Robert)
American(West) Weapon(q)
Weapon(y) Sells(Robert,T1,A)
Sells(West,M1,z)
Sells(West,y,z) Hostile(Nono)
Hostile(A)
Hostile(z)
8: { } 5:{p/q} 6 : { p / A}
Missile(M1)
Missile(T1)
4 : { p / T1}
Enemy(A, America)
3: { q / T1 } {r/A}
7: { }
Missile(M1)
Missile(T1) Owns(Nano,M1)
Owns(A,T1)
3: { } 2: { }
105
Excellence and Service
CHRIST
Deemed to be University
Resolution
● It proves by Contradiction
● The sentences must be Conjunctive Normal Form
● It is a single inference rule, that yields a complete
inference algorithm.
● Resolution can resolve two clauses if they contain
complementary literals, which are assumed to be
standardized apart so that they share no variables.
Resolution - Example
Resolution - Example
2. Owns(A, T1)
3. Missile(T1) Excellence and Service
CHRIST
Deemed to be University
Resolution - Example
Resolution - Example
Resolution - Example
¬Criminal (Robert)
Resolution - Example
3: Θ = { }
Owns(A, T1)
¬ Owns (A, T1) ∨ ¬hostile(A)
2: Θ = { }
¬Enemy(p, America) ∨
Hostile(p) ¬hostile(A)
6: Θ = {p/A }
Enemy(A, America) ¬Enemy(A, America)
7: Θ = { }
KNOWLEDGE REPRESENTATION
First order logic – representation revisited – Syntax and
semantics for first order logic – Using first order logic –
Knowledge engineering in first order logic - Inference in
First order logic – propositional versus first order logic –
unification and lifting – forward chaining – backward
chaining - Resolution - Knowledge representation -
Ontological Engineering - Categories and objects
Dogs ∈ Domesticatedspecies
● Disjoint Relation: Two or more categories are disjoint if
they have no members in Common.
Disjoint({Animals, Vegetables})