Mod2 PDF
Mod2 PDF
Knowledge Representation
Module -II
Index
• Introduction to Knowledge Representation
• Types of Knowledge
• Issues in Knowledge Representation
Learning Objective
To gain the insight about a knowledge representation techniques
in the area of AI
3
Knowledge
4
Knowledge Representation
• A knowledge representation is a study of ways of how knowledge is actually
represented and how effectively it resembles the representation of knowledge
inhuman brain.
• A knowledge representation system should provide ways of representing complex
knowledge.
• How to represent the knowledge in a machine?
• The Language is needed to represent the knowledge . There must be a method to
use this knowledge.
• Syntax and semantic must be well defined in order to represent the language.
5
Knowledge Representation
• To solve problems in artificial intelligence requires large amount of knowledge and some
mechanism that knowledge to create solutions to new problem. A variety of knowledge
facts have been exploited in AI programs. Hence we are dealing with two different kinds
of entities such as:
• Facts: - It is truth in some relevant world. These are the things we want to represent.
• Representations of facts in some chosen formalism: - These are the things we will
actually be able to manipulate.
Presentation of Knowledge
So that one way to think of structuring these entities is as two levels:-
The knowledge level: - In this facts are described.
The symbol level: - In this we can give representations of object at the knowledge level
are defined in terms of symbol that can be manipulated by programs.
Fig: Mapping between Facts and Representations
Presentation of Knowledge
• Consider the English sentence: Luka is a dog.
• The fact represented by that English sentence can be represented in logic as: dog (Luka)
• We also have logical representations of fact that: All dogs have tails
• V x: dog (x) has tail (x)
• Hence we can deduce this representation: has tail (Luka)
9
Characteristics of Knowledge Representation
• The knowledge representation scheme should have a good expressive
capacity. It will catalyze the inference mechanism in its reasoning
process.
• From the computer system point of view, the representation must be
efficient.
10
11
Types of Knowledge
12
Types of Knowledge
13
Types of Knowledge
14
Types of Knowledge
15
Issues in Knowledge Representation
• The fundamental goal of Knowledge Representation is to facilitate
inferencing (conclusions) from knowledge.
• The issues that arise while using KR techniques are many. Some of
these are below:
• Important Attributes
• Relationship among attributes
• Choosing Granularity
• Set of objects
• Finding Right structure
16
Issues in Knowledge Representation
Important Attributes :
• Any attribute of objects so basic that they occur in almost every problem domain ?
Relationship among attributes:
• Any important relationship that exists among object attributes ?
Choosing Granularity :
• At what level of detail should the knowledge be represented ?
Set of objects :
• How sets of objects be represented ?
Finding Right structure :
• Given a large amount of knowledge stored, how can relevant parts be accessed ?
17
Fig: Inheritable Knowledge representation [1]
18
Important Attributed
• Any attribute of objects so basic that they occur in almost every
problem domain?
• There are two attributed “instance” and “isa”, that are general
significance. These attributes are important because they support
property inheritance.
19
Relationship among Attributes
• The attributes to describe objects are themselves entities they
represent.
• The relationship between the attributes of an object, independent of
specific knowledge they encode, may hold properties like:
20
Relationship among Attributes
Inverses :
This is about consistency check, while a value is added to one attribute.
The entities are related to each other in many different ways.
Existence in an "isa" hierarchy :
This is about generalization-specialization, like, classes of objects and
specialized subsets of those classes.
21
Relationship among Attributes
Techniques for reasoning about values :
Single valued attributes :
• This is about a specific attribute that is guaranteed to take a unique value.
• Example : A baseball player can at time have only a single height and be a
member of only one team.
22
Choosing Granularity
While deciding the granularity of representation, it is necessary to
know the following:
• i. What are the primitives and at what level should the knowledge be
represented?
• ii. What should be the number (small or large) of low-level primitives
or high-level facts?
High-level facts may be insufficient to draw the conclusion while Low-
level primitives may require a lot of storage.
23
Choosing Granularity
For example: Suppose that we are interested in following facts:
Ram spotted Shyam.
Now, this could be represented as "Spotted (agent(Ram), object
(Shyam))“
Such a representation can make it easy to answer questions such as:
Who spotted Shyam?
Suppose we want to know : "Did Ram see Sukhvinder?"
Given only one fact, user cannot discover that answer.
Hence, the user can add other facts, such as "Spotted (x, y) → saw (x,
y)"
24
Set of objects
The reason to represent sets of objects is :
• If a property is true for all or most elements of a set, then it is more
efficient to associate it once with the set
• rather than to associate it explicitly with every elements of the set .
Example: assert large (elephant);
• Remember to make clear distinction between, whether we are
asserting some property of the set itself,
• means, the set of elephants is large, or
• asserting some property that holds for individual elements of the set
, means, any thing that is an elephant is large. 25
Finding Right Structure
• Given a large amount of knowledge stored in a database, how can
relevant parts are accessed when they are needed?
• This is about access to right structure for describing a particular
situation.
While doing so, it is necessary to solve following problems:
• How to perform an initial selection of the most appropriate structure.
• How to fill in appropriate details from the current situations.
• How to find a better structure if the one chosen initially turns out not
to be appropriate.
• What to do if none of the available structures is appropriate.
• When to create and remember a new structure.
26
Reference
[1] https://www.tutorialride.com
27
Bibliography
[1] Artificial Intelligence (2nd ed) by Elaine Rich and Kevin
Knight, McGraw Hill (1991). ISBN 0-07-100894-2
[2] Dan W. Patterson, Introduction to Artificial Intelligence and
Expert Systems- Prentice Hall of India.
28
Thank You
29
Amity School of Engineering and
Technology
Knowledge Representation
(PL and FOPL)
Module -II
Programme: B. Tech-CSE,
Semester: VIIth
Course: Artificial Intelligence (CSE401)
Faculty: Dr. S. K. Dubey
Index
• Propositional Logic
• First Order Predicate Logic
Learning Objective
To gain the insight about Propositional Logic
And its importance in the area of AI
32
Propositional Logic
• Propositional Logic is one of the representation
schemes.
• It is the combination of Proposition + Logic
33
Proposition
• Propositions are elementary atomic sentences.
• Propositions may be either true or false but may take on other
value.
• There are two kinds of proposition
– Simple
– Compound
• Some examples of simple propositions are
– John has two children.
– It is raining.
– People live on earth.
– mango is yellow.
34
Proposition (cont.…)
• For example, the following are compound formulas.
– It is raining and the wind is blowing.
– The moon is made of green cheese or it is not.
– If you study hard you will be rewarded.
– The sum of 10 and 20 is not 50.
35
Logic
• One of the prime activities of the human intelligence is
reasoning.
• The activity of reasoning involves construction, organization
and manipulation of statements to arrive at new conclusions.
• Thus logic can be defined as a scientific study of the process
of reasoning.
• Logic is a formal language.
• Logic is basically classified in two main categories
– Propositional logic
– Predicate logic
36
Propositional Logic
• One of the main concerns of propositional logic is the
study of rules by which new logic variables can be
produced as functions of some given logic variables.
37
Propositional Logic Syntax
• Logic constants: TRUE, FALSE
38
Propositional Logic Connectives
39
Well-formed formulas (wff)
• WFF consist of atomic symbols joined with connectives.
• For example: A, A Ʌ B, A V ¬B, A → B
40
Canonical or Normal Forms
• All wffs can be expressed in the following two normal forms:
– CNF (Conjunctive Normal Form)
e.g. (P V ¬Q) Ʌ ( Q V ¬S V ¬R)
clause 1 clause 2
– DNF (Disjunctive Normal Form
e.g. (P Ʌ ¬Q) V ( Q Ʌ ¬S Ʌ ¬R)
clause 1 clause 2
41
Understanding Semantics of
Propositional logic
The semantics or meaning of a sentence is just the value true or
false. The terms used for semantics of a language are given
below.
Table 1: Semantics of Propositional Logic
Semantics Descriptions
Valid A sentence is a valid if it is true for all interpretations.
Valid sentences are also called tautologies.
Model An interpretation of a formula or sentence under which
the formula is true is called a model of that formula.
Unsatisfiable It is said to be unsatisfiable if it is false for every
(contradiction) interpretation.
Satisfiable It is said to be satisfiable if it is true for some
interpretation.
Equivalence Two sentences are equivalent if they have the same
truth value under every interpretation. 42
Example of Propositional logic
Write the syntax for propositional logic:
If the fruit is sweet, then the taste is better.
• The propositions are:
– A : The fruit is sweet.
– B: The taste is better
• The sentence is represented as A→B
43
Truth Table of Logical Connectives
44
Task for you
• Proof the following propositional logic using Truth Table:
A→B is equivalent to ¬A V B
A↔B is equivalent to (A→B)Ʌ(B→A)
45
Truth Table of Equivalence sentences
(A→B)Ʌ
A B ¬A ¬AVB A→B B→A (B→A)
Practice Problem: Show that A→B is equivalent to ¬AV(AɅB)
46
Some Laws in Propositional Logic
Idempotency A V A = A
A Ʌ A = A
Associativity (A V B) V C = A V (B V C)
(A Ʌ B) Ʌ C = A Ʌ (B Ʌ C)
Commutativity A V B = B V A
A Ʌ B = B Ʌ A
A↔B = B↔A
Distributivity A Ʌ (B V C) = (A Ʌ B) V (A Ʌ C)
A V (B Ʌ C) = (A V B) Ʌ (A V C)
De Morgan’s laws ¬(A Ʌ B) = ¬A V ¬B
¬(A V B) = ¬A Ʌ ¬B
Conditional elimination A→B = ¬A V B
Bi-conditional elimination A↔B =(A→B)Ʌ(B→A)
47
Practice Problems
48
Solution of P1
P1: (A Ʌ B) V ¬(A V B)
Table 5: Solution of P1
P1 is said to be satisfiable because it is true for some interpretation.
49
Solution of P2
P2: (A V B) → (A Ʌ B)
Table 6: Solution of P2
A B AVB AɅB (A V B) → (A Ʌ B)
P2 is said to be satisfiable because it is true for some interpretation.
50
Solution of P3
P3: (A Ʌ B) → (A V ¬B)
Table 7: Solution of P3
A B ¬B A Ʌ B A V ¬B (A Ʌ B) → (A V ¬B)
P3 is said to be valid because it is true for all interpretation.
51
Inference rules of Propositional Logic
• Rules are
– Modus ponens
– Modus tollens
– Chain rule
– Substitution
– Simplification
– Conjunction
– Transposition
52
• Modus ponens
From A and A → B infer B. This is sometime written
as :
A
A → B
B___
For example:
given : (ram is a father)
and : (ram is a father) → (ram has a child)
conclude : (ram has a child)
53
• Modus tollens
From A → B and ¬B infer ¬A. This is sometime written
as :
A → B
¬B__
¬A __
For example:
given: (The machine is defective) → (The production is less)
and : (The production is not less)
conclude : (The machine is not defective)
54
• Chain rule
From A → B and B → C infer A → C. This is sometime written as :
A → B
B → C
A → C
For example:
Given : (programmer like python) → (programmer hates COBOL)
And : (programmer hates COBOL) → (programmer likes recursion)
conclude: (programmer like python) → (programmer likes recursion)
55
• Substitution: If s is a valid sentence, s` derived from s by
consistent substitution of proposition in s, is also valid. For
example, the sentence A V ¬A is valid; therefore B V ¬B is also
valid by the substitution rule.
• Simplification: From A Ʌ B infer A.
• Conjunction: From A and from B, infer A Ʌ B
• Transposition: From A → B, infer ¬B → ¬A
56
First Order Predicate Logic (FOPL)
57
Syntax of FOPL
• Connectives
• Quantifiers
• Constants
• Variables
• Predicates
• Functions
58
Syntax of FOPL (cont.…)
• Connectives: There are five connective symbols
¬ : not or negation
Ʌ : and or conjunction
V : or or inclusive disjunction
→ : implication
↔ : equivalence or if and only if
• Quantifiers: There are two quantifier symbols are
Ǝ : existential quantification
Example: Ǝ x means there exist x
∀ : universal quantification
Example: ∀x means for all x
59
Syntax of FOPL (cont.…)
• Variables: variables are terms that can assume different values
over a given domain.
60
Syntax of FOPL (cont.…)
• Functions: it is also possible to have a function as an
argument, e.g. “Ajay’s father is Vijay’s father” is represented as:
– FATHER(father(Ajay), Vijay)
– Here FATHER is a predicate and father(Ajay) is a function to
indicate Ajay’s father.
61
Syntax of FOPL (cont.…)
• Constants, variables, and functions are referred to as terms.
• When we want to refer to an atom or its negation, we often use
the word literal.
62
Few examples on Translating English to FOPL
i. Alice likes helicopters.
ii. Ajay’s father is Vijay’s father.
iii. Sachin is a man
iv. Shyam likes apple.
v. Rima is a girl.
vi. Lotus is white.
vii. Paul owns diamond.
viii. Shyam is taller than Ram
ix. My name is Vijay
x. Mango is fruit.
63
Few examples on Translating English to
FOPL
Solution:
i.Alice likes helicopters. Likes (Alice, helicopters)
ii.Ajay’s father is Vijay’s father. Father(father(ajay),vijay))
iii.Sachin is a man Man(sachin)
iv.Shyam likes apple. Likes(shyam,apple)
v.Rima is a girl. Girl(Rima)
vi.Lotus is white. White(Lotus)
vii.Paul owns diamond. Owns(Paul, diamond)
viii.Shyam is taller than Ram Taller(shyam, ram)
ix.My name is Vijay Name(Vijay)
x.Mango is fruit. Fruit(mango)
64
More examples on Translating English
to FOPL
xi. Ram is male.
xii. Tuna is fish.
xiii. Dashrath is ram‟s father.
xiv. Kush is son of ram.
xv. Kaushaliya is wife of Dashrath.
xvi. Clinton is tall.
xvii.There is a white alligator.
xviii.All kings are person.
xix. Nobody loves john.
xx. Every one has a father.
65
More examples on Translating English
to FOPL
Solution:
xi.Ram is male. Male(ram)
xii.Tuna is fish. Fish(tuna)
xiii.Dashrath is ram‟s father. Father(dashrath,ram)
xiv.Kush is son of ram. Son(kush,ram)
xv.Kaushaliya is wife of Dashrath. Wife(kaushaliya,dashrath)
xvi.Clinton is tall. Tall(Clinton)
xvii.There is a white alligator. White(Alligator)
xviii.All kings are person. ∀x: Kings(x) → Person(x)
xix.Nobody loves john. ∀x: ¬Loves(x,john)
xx.Every one has a father. ∀x,Ǝy: Father(y,x)
66
Translating into Predicate Logic
i. Marcus was a man.
ii. Marcus was a Pompeian.
iii. All Pompeians were Romans.
iv. Caesar was a ruler.
v. All Romans were either loyal to Caesar or hated him.
vi. Everyone is loyal to someone.
vii. People only try to assassinate rulers they aren't loyal to.
viii. Marcus tried to assassinate Caesar.
ix. All men are people.
67
Translating into Predicate Logic
(Solution)
i. Marcus was a man. Man(marcus)
ii. Marcus was a Pompeian. Pompeian(marcus)
iii. All Pompeians were Romans. ∀x: Pompeian (x) → Roman(x)
iv. Caesar was a ruler. Ruler(caesar)
v. All Romans were either loyal to Caesar or hated him.
∀x: Roman(x) → LoyalTo(x,Caesar) V Hate(x,Caesar)
vi. Everyone is loyal to someone. ∀x,Ǝy: LoyalTo(x,y)
vii. People only try to assassinate rulers they aren't loyal to.
∀x, ∀y: Person(x) ɅRuler(y) ɅTryAssassinate(x,y) →¬LoyalTo(x,y)
viii. Marcus tried to assassinate Caesar.
TryAssassinate(Marcus, Caesar)
ix. All men are people. ∀x: Men(x) → People(x) 68
More examples on Translating into
Predicate Logic
i. Hari likes all kind of food.
ii. Bananas are food.
iii. Apples are food.
iv. Anything anyone eats and isn’t killed by food.
v. Hari eats everything ram eats.
69
More examples on Translating into
Predicate Logic
Solution:
i.Hari likes all kind of food.
∀x: Food(x) → Likes(hari, x)
ii.Bananas are food. Food(bananas)
iii.Apples are food. Food(apples)
iv.Anything anyone eats and isn’t killed by food.
∀x:Ǝy: Eats(y,x) Ʌ ¬Killedby(y,x) → Food(x)
v.Hari eats everything ram eats.
∀x: eats(ram, x) → eats(hari, x)
70
More examples on Translating into
Predicate Logic
i. Every gardener likes the sun.
ii. Not Every gardener likes the sun.
iii. You can fool some of the people all of the time.
iv. You can fool all of the people some of the time.
v. You can fool all of the people at same time.
vi. You can not fool all of the people all of the time.
vii. Everyone is younger than his father.
71
More examples on Translating into Predicate Logic
Solution:
i.Every gardener likes the sun. ∀x: gardener(x) → likes(x, Sun)
ii.Not Every gardener likes the sun. ¬(∀x: gardener(x) → likes(x, Sun))
iii.You can fool some of the people all of the time.
Ǝx:∀t: person(x) Ʌ time(t) → canBeFooled(x, t)
iv.You can fool all of the people some of the time.
∀x:Ǝt: person(x) Ʌ time(t) → canBeFooled(x, t)
v. You can not fool all of the people all of the time.
¬(∀x:∀t: person(x) Ʌ time(t) → canBeFooled(x, t))
vi. Everyone is younger than his father.
∀x: person(x) → younger(x, father(x))
72
Skolemization
73
Example
Example
• Everybody respect somebody.
∀x:Ǝy:(Person(x) ^ Person(y)) → respect(x,y)
Converted to
∀x: (Person(x) ^ Person f(x)) → respect(x,f(x))
where f(x) specifies the person that x respect
74
Clausal Form
• A formula is said to be in clausal form if it is of the form:
∀x1 ∀x2 … ∀xn [C1 ∧ C2 ∧ … ∧ Ck].
• All first-order logic formulas can be converted to clausal form.
75
Equivalent Logical Expressions
i. ¬(¬F) = F (Double Negation)
ii. F Ʌ G = G Ʌ F, F V G = G V F (Commutativity)
iii. (F Ʌ G) Ʌ H = F Ʌ (G Ʌ H), (F V G) V H = F V (G V H)
(Associativity)
iv. F V (G Ʌ H) = (F V G) & (F V H), F & (G V H) = (F & G) V (F &
H) (Distributivity)
v. ¬(F Ʌ G) = ¬F V ¬G, ¬(F V G) = ¬F Ʌ ¬G (De Morgan)
vi. F → G = ~F V G
vii. F ↔ G = (~F V G) Ʌ (~G V F)
viii. ∀ x F[x] V G = ∀ x (F[x] V G )
ix. Ǝx F[x] V G = Ǝx (F[x] V G )
76
Equivalent Logical Expressions (cont...)
x. ∀x F[x] Ʌ G = ∀x (F[x] Ʌ G )
xi. Ǝx F[x] Ʌ G = Ǝx (F[x] Ʌ G )
xii. ¬(∀x) F[x] = Ǝx (~F[x])
xiii. ~(Ǝx) F[x] = ∀x (~F[x])
xiv. ∀x F[x] Ʌ ∀x G[x] = ∀x (F[x] Ʌ G[x])
xv. Ǝ x F[x] Ʌ Ǝ x G[x] = Ǝx (F[x] Ʌ G[x])
77
Horn Clause
• It is a clause with at most one positive literal. Example
P ,
¬P V Q
¬ P V ¬ Q V R
• Clauses of this type were first investigated by the logician Alfred Horn.
There are three types of Horn clauses
i. A single atom: often called a “fact”.
ii. An implication: often called a “rule”- whose antecedent consists of a
conjunction of positive literals and whose consequent consists of a single
positive literal.
iii. A set of negative literals: written in implication form with an antecedent
consisting of a conjunction of positive literals and an empty consequent.
This form is obtained, for example, when one negats a wff to be proved
consisting of a conjunction of positive literals. Such a clause is therefore
often called a “goal”.
78
Horn Clause (Cont.…)
• In a horn clause, generally one condition is followed by zero, or more
conditions. It is represented as
Conclusion…
Condition-1,
Condition-2,
Condition-3,
………
Condition-n,
• The conclusion is true if and only if condition-1, condition-2……and so on
until condition–n is true.
i. Marcus was a man. Man(marcus)
ii. Marcus was a Pompeian. Pompeian(marcus)
iii. All Pompeians were Romans. ∀ x: Pompeian (x) → Roman(x)
iv. Caesar was a ruler. Ruler(caesar)
v. All Romans were either loyal to Caesar or hated him.
∀ x: Roman(x) → LoyalTo(x,Caesar) V Hate(x,Caesar)
vi. Everyone is loyal to someone. ∀ x,Ǝy: LoyalTo(x,y)
vii. People only try to assassinate rulers they aren't loyal to.
∀ x, ∀ y: Person(x) ɅRuler(y) ɅTryAssassinate(x,y) →¬LoyalTo(x,y)
viii. Marcus tried to assassinate Caesar.
TryAssassinate(Marcus, Caesar)
ix. All men are people. ∀ x: Men(x) → People(x)
80
Prove this
• Given the above sentences, can
we make a conclusion as
follows:
“Marcus was not loyal to Caesar
?”
or:
¬loyalto(Marcus,Caesar)
Solution:
• In order to prove the goal, we
need to use the rules of
inference to transform it into
another goal that can in turn be
transformed, and so on, until
there are no unsatisfied goals
remaining. 81
Resolution Principle
• Given two clauses C1 and C2 with no variables in common, if there
is a literal l1, in C1 and which is a complement of a literal l2 in C2 ,
both l1 and l2 are deleted and a disjuncted C is formed the
remaining reduced clauses. The new clauses C is called the
resolve of C1 and C2.
• Resolution is the process of generating these resolvents from the
set of clauses.
• Example: (¬AVB) and (AVC)
We can write
BVC 82
Refutation
• In other words, to prove a statement, resolution attempts to show
that the negation of the statement produces a contradiction
with the known statements.
83
Example of Resolution
• Consider the following clauses:-
P : A V B V D
Q: ¬A V B V D
R: ¬B V D
Solution
P : A V B V D (Given in the problem)
Q : ~A V B V D (Given in the problem)
S : B V D (Resolvent of P and Q)
R : ~B V D (Given in the problem)
T : D (Resolvent of R and S)
84
Example of Resolution
Sno Clauses
1 Man(Marcus)
2 Pompiean(Marcus)
3 ¬Pompiean(X1) V Roman(X1)
4 Ruler(Caesar)
5 ¬Roman(X2) V loyalto(X2,Caesar) V hate(X2,Caesar)
6 loyalto(X3,f1(X3))
7 ¬man(X4) V ¬man(Y1) V ¬tryassassinate(X4, Y1) V loyalto(X4, Y1)
8 tryassassinate(Marcus, Caesar)
85
Solution
86
Solution
87
Another Example of Resolution
Assume the following facts:
i. Raman only likes easy courses.
ii. Computer Science courses are hard.
iii. All the courses in Arts Department are easy.
iv. ART101 is a course in Arts”.
Convert the above statements into appropriate wffs so that the
resolution can be performed to answer the question:
88
Solution
First we will convert it into FOPL (First order predicate logic)
i. Raman only likes easy courses.
∀ x: easy(x) → likes(raman,x)
ii. Computer Science courses are hard.
∀ x: computer science(x) → ¬easy(x)
iii. All the courses in Arts Department are easy.
∀ x: arts(x) → easy(x)
iv. ART101 is a course in Arts”.
arts(ART101)
The conclusion is encoded as likes(raman , x).
89
Solution (cont.…)
First we put our premises in the clause form and the negation of
conclusion to our set of clauses (we use numbers in parentheses to
number the clauses):
i. ¬easy(x) V likes(raman,x)
ii. ¬computer science(x) V ¬easy(x)
iii. ¬arts(x) V easy(x)
iv. arts(AR101)
v. ¬likes(raman, x)
90
Solution (cont.…)
Sno Clauses Note
1 ¬easy(x) V likes(raman,x) P
2 ¬computer science(x) V ¬easy(x) P
3 ¬arts(x) V easy(x) P
4 arts(AR101) P
5 ¬ likes(raman, x) P
6 ¬easy(x) 1, 5
7 ¬arts(x) 3, 6
8 NIL 4, 7;
x=ART101
91
Solution (cont.…)
• A resolution proof may be obtained by the following sequence of
resolutions
• (6) 1&5 yields resolvent ¬easy(x).
• (7) 3&6 yields resolvent ¬humanities (x).
• (8) 4&7 yields empty clause;
92
Thank You
93
Amity School of Engineering and
Technology
Module -II
Programme: B. Tech-CSE,
Semester: VIIth
Course: Artificial Intelligence (CSE401)
Faculty: Dr. S. K. Dubey
Index
• Semantic Network
• Frames
Learning Objective
To gain the insight about semantic networks and
frames and its importance in the area of AI
96
Semantic Networks
• Semantic network is simple representation scheme
which uses a graph of labeled nodes and labeled
directed arcs to encode knowledge
– Nodes – objects, concepts, events
– Arcs – relationships between nodes
• Graphical depiction associated with semantic networks
is a big reason for their popularity
Semantic Networks
• Definition
– Represent knowledge as a graph
– Nodes correspond to facts or concepts
– Arcs correspond to relations or associations between
concepts
– Nodes and arcs are labeled
• Properties
– Labeled arcs and links
– Inference is to find a path between nodes
– Implement inheritance
– Variations – conceptual graphs 98
Nodes and Arcs
• Arcs define binary relations which hold between objects
denoted by the nodes.
mother age
Y X 7
wi mother (X, Y)
fe age (X, 7)
hu father
age sb wife (Y, Z)
an
d age (Z, 32)
32 Z
Example
Let us make a semantic net with the following piece of information
“Tweety is a blue bird having wings to fly.”
Fact 1 : Tweety is a bird.
Fact 2 : Birds can fly.
Fact 3 : Tweety is blue in color.
CAN fly
tweety COLOR
bird A-KIND-OF
Blue
HAS-PARTS wings
Example
My car is red and Mohan’s car is green
I
owner
color
car1 red
is-a
car
is-a color
car2 green
owner
Mohan
Semantic nets
• Certain arcs - particularly isa arcs - allow inheritance of
properties.
• This permits the system to "know" that a Innova has four
wheels because it is a type of car, and cars have four
wheels.
Inference in a Semantic Net
Inheritance
– the is-a and instance-of representation provide a
mechanism to implement this.
– Inheritance also provides a means of dealing with
default reasoning
I
I
owner
owner color
color car1 what?
car1 red
is-a is-a
is-a
color
car2 green
owner
What color is the car1?
john
Example
• Tom is a cat.
• Tom caught a bird.
• Tom is owned by John.
• Tom is ginger in colour.
• Cats like cream.
• The cat sat on the mat.
• A cat is a mammal.
• A bird is an animal.
• All mammals are animals.
• Mammals have fur.
Example
• Scooter is a two wheeler.
• Motor-bike is a two wheeler.
• Motor-bike is a moving-vehicle.
• Moving –vehicle has engine.
• Moving-vehicle has electrical system.
• Moving-vehicle has fuel system.
Example
Is_a Is_a
Scooter Two-wheeler Motor-bike
has has
Brakes Moving-Vehicle Engine
has has
Electrical-system Fuel-system
Hierarchical Structure
vehicle
Is_a Is_a Is_a
Is_a Is_a
Beak
Red Color
Kinds of Semantic Nets
Assertional Networks
• Designed to assert
propositions.
Fig source: Wikipedia.org
Kinds of Semantic Nets
Implicational
Networks
•Uses implication as
the primary relation
for connecting nodes.
Kinds of Semantic Nets
Executable
Networks
•Contain
mechanisms that can
cause some change
to the network itself.
Kinds of Semantic Nets
Learning Networks
•Networks that build
or extend their
representations by
acquiring knowledge
from examples.
Kinds of Semantic Nets
Hybrid Networks
•Networks that
combine two or more
of the previous
techniques, either in a
single network or in
separate, but closely
interacting networks.
Advantages of Semantic nets
• Easy to visualize
• Related knowledge is easily clustered.
• Natural
• Modular
• Efficient
• Convey meaning in a transparent manner
• Simple
• Understandable
Disadvantages
• There is no standard definition of link names
• Facts placed inappropriately cause problems.
• No standards about node and arc values
• Semantic Nets are not intelligent, dependent on
creator
• Links on objects represent only binary relations.
• Negation, disjunction and general non-taxonomic
knowledge are not easily expressed.
Exercises
• Try to represent the following two sentences into the
appropriate semantic network diagram:
– isa(person, mammal)
– instance(Xl, person) all in one graph
– team(Xl, Y)
– John gave Mary the book
Solution 1
• isa(person, mammal), instance(X, person), team(X, Y)
mammal
is_a
is_a
X team Y
Solution 3
X gave Y the pen
Gave pen
Action Instance
Predicate
Y
Partitioned Semantic Networks
•The central idea of partitioning is to allow groups, nodes and
arcs to be bundled together into units called spaces –
fundamental entities in partitioned networks, on the same level
as nodes and arcs (Hendrix).
• Hendrix’s Partitioned network would express this
statement as an ordinary semantic network:
S1
SA
General
Statement dog bite postman
is_a S1
is_a is_a is_a
form
G D agent
B
patient
P
Partitioned Semantic Networks
SA
General
Statement dog bite postman
is_a S1
is_a is_a is_a
form
G agent patient
D B P
Partitioned Semantic Networks
• Suppose that we now want to look at the
statement:
– "Every dog in town has bitten the postman"
SA
dog
General
Statement town dog bite postman
is_a S1
is_a is_a is_a
form
G agent patient
D B P
Frame
• Frames – semantic net with properties
• Frame: a knowledge representation technique which
attempts to organize concepts into a form which exploits
interrelationships and common beliefs
• A frame is similar to a record data structure or database
record:
• Frame has slot names and slot fillers, and usually
arranged in a hierarchy
Frames
• A frame represents an entity as a set of slots (attributes)
and associated values
• A frame can represent a specific entry, or a general
concept
• Frames are implicitly associated with one another
because the value of a slot can be another frame
Structure of frame
Three components of a frame
•frame name
•attributes (slots)
•values (fillers: list of values, range,
string, etc.)
Frame Representation
Book Frame
Slot Filler
Bird Frame
(SPECIES (VALUE bird))
(COLOR (VALUE Blue))
• More natural support of values then semantic nets (each
slots has constraints describing legal values that a slot
can take)
• Can be easily implemented using object-oriented
programming techniques
• Inheritance is easily controlled
Class and instance frames
• (frame) instance: representing” lowest-level” object; a
single object or entity
• (frame) class: describes different frames (either
instances or classes)
• every instance has an “is-a” link, pointing to its class
– possibly more than one “is-a”
Example of frames
Frame Name: Bird
Class frame
Properties: Colour Unknown
Wings 2
Flies True
• Similar to Object-Oriented programming paradigm
Hotel Chair
•what chair
Hotel Room •height 20-40cm Hotel Phone
•what room •legs 4
•what phone
•where hotel
•billing guest
•contains
–hotel chair
Hotel Bed
–hotel phone
–hotel bed •what bed
•size king
Mattress
•part mattress
•price 100$
Advantages of Frames
• Makes programming easier by grouping related
knowledge
• Easily understood by non-developers
• Expressive power
• Easy to set up slots for new properties and relations
• Easy to include default information and detect missing
values
Disadvantages of Frames
• No standards (slot-filler values)
• More of a general methodology than a specific
representation:
– Frame for a class-room will be different for a professor and for a
maintenance worker
• No associated reasoning/inference mechanisms
References
[1] Artificial Intelligence (2nd ed) by Elaine Rich and Kevin
Knight, McGraw Hill (1991). ISBN 0-07-100894-2
[2] Dan W. Patterson, Introduction to Artificial Intelligence
and Expert Systems- Prentice Hall of India.
138
Thank You
139
Conversion to Clausal form or CNF
1. Eliminate logical implications, →, using the fact that A → B is
equivalent to ¬A ∨ B.
2. Reduce the scope of each negation to a single term, using the
following facts:
¬(¬P) = P
¬(A ∨ B) = ¬A ∧ ¬B
¬(A ∧ B) = ¬A V ¬B
¬∀x: P(x) = ∃x: ¬P(x)
¬∃x: P(x) = ∀x: ¬P(x)
3. Standardize variables so that each quantifier binds a unique variable.
4. Move all quantifiers to the left, maintaining their order.
140
Conversion to Clausal form or CNF
5. Eliminate existential quantifiers, using Skolem functions (functions of
the preceding universally quantified variables).
6. Drop the prefix; assume universal quantification.
7. Convert the matrix into a conjunction of disjunctions.
[(a Ʌ b) V c = (a V c) Ʌ (b V c)]
8. Create a separate clause corresponding to each conjunction.
9. Standardize apart the variables in the clauses.
141
Example of Clausal Conversion
Ǝx Ɐy (Ɐz P(f(x), y, z) → (Ǝu Q(x, u) Ʌ Ǝv R(y, v)))
Step 1: Eliminate logical implications
Ǝx Ɐy (¬(Ɐz ) P(f(x), y, z) V (Ǝu Q(x, u) Ʌ (Ǝv) R(y, v)))
Step 2: Reduce the scope of each negation to a single term
Ǝx Ɐy (Ǝz ¬P(f(x), y, z) V (Ǝu Q(x, u) Ʌ (Ǝv) R(y, v)))
Step 3: It is not require here because quantifiers have different variable assignments.
Step 4: Move all quantifiers to the left
Ǝx Ɐy Ǝz Ǝu Ǝv (¬ P(f(x), y, z) V (Q(x, u) Ʌ R(y, v)))
Step 5: Skolem functions
Ɐy(~P f(x) , y, g(y)) V Q(a, h(y)) Ʌ R(y, l(y))
142
Example of Clausal Conversion (cont...)
Step 6: Drop the prefix
(¬P f(x) , y, g(y)) V Q(a, h(y)) Ʌ R(y, l(y))
Step 7: Convert the matrix into a conjunction of disjunctions
((~P f(x) , y, g(y)) V Q(a, h(y)) Ʌ ( ~P f(x) , y, g(y)) V R(y, l(y)))
Step 8:
(~P f(x) , y, g(y)) V Q(a, h(y))
( ~P f(x) , y, g(y)) V R(y, l(y)))
Step 9: Standardize apart the variables in the clauses
143
Unification
• Any substitution that makes two or more expression equal is called a
unifier for the expression.
• Two formulas unify if they can be made identical.
• A unification is a function that assigns bindings to variables.
• A binding is either a constant, a functional expression or another variable.
144
Unification Process
• The basic idea of unification is very simple.
• To attempt to unify two literals, we first check if their initial
predicate symbols are the same. If so, we can proceed.
• Otherwise, there is no way they can be unified, regardless of their
arguments. For example, the two literals
tryassassinate (Marcus, Caesar)
hate(Marcus, Caesar)
cannot be unified.
• If the predicate symbols match, then we must check the arguments,
one pair at a time. If the first matches, we can continue with the
second, and so on.
145
Example
P(x, x) P(A,A) {x/A}
P(x, x) P(A,B) fail
P(x, y) P(A,B) {x/A, y/B}
P(x, y) P(A,A) fail
P(x, y) P(A, z) {x/A, y/z}
P(f(x),y) P(f(A),B) {x/A, y/B}
P(x, y) P(f(x),B) fail
P(x, y) P(z, f(z)) {x/z, y/f(z)}
146
Unification algorithm
• Unify(L1, L2) returns a list representing the composition of the
substitutions that were performed during the match.
• The empty list, NIL, indicates that a match was found without any
substitutions.
• The list consisting of the single value FAIL indicates that the unification
procedure failed.
• The final substitution produced by the unification process will be used by
the resolution procedure.
147
Unification algorithm
Algorithm: Unify(L1, L2)
1. If L1 or L2 are both variables or constants, then:
(a)If L1 and L2 are identical, then return NIL.
(b)Else if L1 is a variable, then if L1 occurs in L2 then return {FAIL}, else return(L2/L1).
(c)Else if L2 is a variable, then if L2 occurs in L1 then return {FAIL} , else return(L1/L2).
(d)Else return {FAIL}.
2.If the initial predicate symbols in L1 and L2 are not identical, then return {FAIL}.
3.If LI and L2 have a different number of arguments, then return {FAIL}.
4.Set SUBST to NIL. (At the end of this procedure, SUBST will contain all the substitutions used to
unify L1 and L2.)
5.For i ← 1 to number of arguments in L1 :
(a)Call Unify with the ith argument of L1 and the ith argument of L2, putting result in S.
(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).
6.Return SUBST
148
Example
• (Unification) For each pair of atomic sentences, give the most general
unifier if it exists, otherwise say “fail”:
a. R(A, x), R(y, z)
b. P(A, B, B), P(x, y, z)
c. Q(y, G(A, B)), Q(G(x,x), y)
d. Older(Father(y), y), Older(Father(x), John)
e. Knows(Father(y),y), Knows(x,x)
149
Solution
• (Unification) For each pair of atomic sentences, give the most general
unifier if it exists, otherwise say “fail”:
a. R(A, x), R(y, z) y/A, x/z
b.P(A, B, B), P(x, y, z) x/A, y/B, z/B
c. Q(y, G(A, B)), Q(G(x,x), y) fail
d. Older(Father(y), y), Older(Father(x), John) x/y, y/John
e. Knows(Father(y),y), Knows(x,x) fail
150
Amity School of Engineering and
Technology
Knowledge Representation
Module -II
Programme: B. Tech-CSE,
Semester: VIIth
Course: Artificial Intelligence (CSE401)
Faculty: Dr. S. K. Dubey
Index
• Procedural vs. Declarative Knowledge
• Forward vs. backward reasoning
Learning Objective
To gain the detail insight about knowledge and
reasoning and its importance in the area of AI
153
154
Knowledge
Declarative Procedural
• Declarative knowledge deals with factoid questions
(what is the capital of India?.)
• Procedural knowledge deals with “How”
• Procedural knowledge can be embedded in declarative
knowledge
Example: Employee knowledge base
Employee record
Emp id : 1124
Age : 27
Salary : 10L / annum
Tax : Procedure to calculate tax from basic salary,
Loans, medical factors, and # of children
Procedural Knowledge
• It lays down the steps to perform.
• It is not so popular because it is generally not used.
• A key feature of procedural knowledge is that it is hard to
explain verbally
158
Procedural knowledge
159
Procedural knowledge
160
Declarative Knowledge
• Declarative knowledge can be thought of as 'knowledge about'
or answers to 'WH- questions.‘
• Categories of declarative knowledge are facts, world or personal
history, and rules for mathematics operations.
• A key feature of declarative knowledge is that it is easy to
express declarative knowledge in the form of words or symbols.
• You are consciously aware of your understanding of declarative
information
161
Declarative Knowledge
• Declarative representation
• –Knowledge is specified but the use is not given.
• –Need a program that specifies what is to be done to the
knowledge and how.
• –Example:
• Logical assertions and Resolution theorem prover
162
Declarative Knowledge
• Declarative or functional knowledge clarifies what to do to
perform a certain task. It lays down the function to perform.
• Declarative Knowledge also known as Descriptive knowledge,
is the type of knowledge which tells the basic knowledge
about something
• It is more popular than Procedural Knowledge.
• It emphasize what to do something to solve a given problem.
163
Procedural Declarative
knowledge knowledge
– Focuses on tasks that must – Refers to representations
be performed to reach a of objects and events;
particular objective or goal. knowledge about facts and
relationships;
– Examples : procedures,
rules, strategies, agendas, – Example : concepts,
models. objects, facts,
propositions, assertions,
semantic nets, logic and
–
descriptive models. Slide 4
PROCEDURAL KNOWLEDGE DECLARATIVE KNOWLEDGE
167
• Forward: from the start states.
• Backward: from the goal states
168
Forward Reasoning
• Forward reasoning starts from the initial states
• Begin building a tree of move sequences that might be
solutions by starting with the initial configurations at the
root of the tree.
• Generate the next level of the tree by finding all the rules
whose left sides match the root node and using their right
sides to create the new configurations.
• Continue until a configuration that matches the goal state
is generated.
169
Backward Reasoning
• Backward reasoning stats from the goal states
• Begin building a tree of move sequences that might be
solutions by starting with the goal configurations at the
root of the tree.
• Generate the next level of the tree by finding all the rules
whose right side match the root node.
170
Forward vs. Backward Reasoning
Four factors influence forward or Backward?
–Move from the smaller set of states to the larger set of
states
–Proceed in the direction with the lower branching factor
–Proceed in the direction that corresponds more closely
with the way the user will think
–Proceed in the direction that corresponds more closely
with the way the problem-solving episodes will be
triggered
Slide 171
Forward vs. Backward Reasoning
To encode the knowledge for reasoning, we need 2 kinds of
rules:
– Forward rules: to encode knowledge about how to respond
to certain input.
– Backward rules: to encode knowledge about how to
achieve particular goals.
Forward vs. Backward Reasoning
• Whether you use forward or backwards reasoning to
solve a problem depends on the properties of your rule
set and initial facts.
Forward chaining may be better if you have lots of things
you want to prove (or if you just want to find out in general
what new facts are true); when you have a small set of
initial facts;
Backward chaining may be better if you are trying to prove
a single fact, given a large set of initial facts, and where, if
you used forward chaining, lots of rules would be eligible to
fire in any cycle.
174
EXAMPLE
175
Backward reasoning: Example
For example, suppose a new pet, Fritz, is delivered in an opaque box
along with two facts about Fritz [1] :
• Fritz croaks
• Fritz eats flies
The goal is to decide whether Fritz is green, based on a rule
base containing the following four rules:
An Example of Backward Chaining.
• If X croaks and X eats flies – Then X is a frog
• If X chirps and X sings – Then X is a canary
• If X is a frog – Then X is green
• If X is a canary – Then X is yellow
With backward reasoning, an inference engine can determine whether
Fritz is green 176
Backward reasoning: Example
Fritz is substituted for X in rule #3 to see if its consequent matches the goal,
so rule #3 becomes:
• If Fritz is a frog – Then Fritz is green
Since the consequent matches the goal ("Fritz is green"), so
The antecedent therefore becomes the new goal:
Fritz is a frog
• If Fritz croaks and Fritz eats flies – Then Fritz is a frog, so new goal :
• Fritz croaks and Fritz eats flies
Since this goal is a conjunction of two statements, , So:Fritz croaks. Fritz
eats flie
• So by rule 1 : Fritz is a frog
• And then by rule 3, Fritz is green
177
Forward reasoning: Example
Let us illustrate forward chaining by following the pattern of a computer
as it evaluates the rules. Assume the following facts:
• Fritz croaks
• Fritz eats flies
• With forward reasoning, the inference engine can derive that Fritz is
green
1. Since the base facts indicate that "Fritz croaks" and "Fritz eats flies",
the antecedent of rule #1 is satisfied by substituting Fritz for X, and the
inference engine concludes:
• Fritz is a frog
2. The antecedent of rule #3 is then satisfied by substituting Fritz for X,
and the inference engine concludes:
• Fritz is green
178
Question for you
• If D barks and D eats bone, then D is a dog.
• If V is cold and V is sweet, then V is ice-cream.
• If D is a dog, then D is black.
• If V is ice-cream, then it is Vanilla.
• Tomy barks.
• Tomy eats bone.
179
References
[1] https://en.wikipedia.org/
180
Thank You
181