You are on page 1of 20

MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

CHAPTER 2
KNOWLEDGE REPRESENTATION

INTRODUCTION__________________________________________ 1
SEMANTIC NETWORK_____________________________________ 3
DECISION TREE _________________________________________ 6
FRAME_________________________________________________ 7
PRODUCTION RULE ______________________________________ 9
FORWARD CHAINING __________________________________ 10
BACKWARD CHAINING _________________________________ 11
PRACTICE MAKES PERFECT ______________________________ 12

2:0
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

2 KNOWLEDGE REPRESENTATION

INTRODUCTION
Definition
Wisdom Using knowledge in a beneficial way
om
sd
Wi Meta- Knowledge about knowledge.
ta- e knowledge
Me ledg
ow
A collection of information that has been
kn organized and analyzed to make it
understandable and applicable to problem
ge Knowledge
ed
owl solving.
K n
Consists of symbols, relationship between
on them and rules or procedures for
ati
rm manipulating them.
I nfo
Rules about using information.
Data organized so that it is meaningful to
Information
ta the person receiving it.
Da

ise
No Potentially useful information.
Data Numeric/alphanumeric string that by
themselves do not have any meaning.

A pyramid of knowledge No apparent information.


Noise Unwanted elements in communication that
can influence the judgment.

Knowledge can be classified into procedural knowledge, declarative knowledge and tacit
knowledge.
Procedural knowledge is often referred as knowing how to do something. An example of
procedural knowledge is knowing how to boil a pot of water.
Declarative knowledge refers to knowing that something is true or false. Is it concerned
with knowledge expressed in the form of declarative statements such as “Do not put your
fingers in a pot of boiling water”.
Tacit knowledge is sometimes called Unconscious knowledge because it cannot be
expressed by language. An example is knowing how to move your hand. On a gross scale, you
might say that you move your hand by tightening or relaxing certain muscles and tendons. But
at the next lever, how do you know how to tighten or relax the muscles and tendons? Other
examples are walking or riding a bicycle.
Other types of knowledge are meta-knowledge that describes knowledge about knowledge,
heuristic knowledge that describes rules of thumb that guides the reasoning process while
structural knowledge that describes an expert overall mental model of the problem.
Knowledge representation (KR) is the way that knowledge is stored in a program. It implies
a systematic way to store the information and coded into the program. Three common
characteristics of KR schemes are:

2:1
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

i. Existing computer languages can be used and the knowledge is stored in memory.
ii. The stored knowledge and facts can be used in reasoning.
iii. The predominate knowledge representation schemes are frames and production
rules.

What to represent?
Explanation Example
Object Facts about objects in our world Guitars have single strings, trumpets
domain. are brass instruments.
Events Actions that occur in our world. Steve Vai played the guitar in Frank
Zappa’s Band.
Performance A behavior like playing the guitar Steve Vai played the guitar using his
involves knowledge about how to do left hand, Sally can type 50 words
things. per minute, etc.
Meta-knowledge Knowledge about what we know Steve Vai is a professional guitarist
because he was born in a guitarist
family, etc.

Properties of KR:
i. Adequate to express all of the necessary information.
ii. Support efficient execution of the resulting code.
iii. Provide a natural scheme for expressing the required knowledge.

KR scheme can be divided into four;


i. Network scheme – semantic network and decision tree.
ii. Structured – frames.
iii. Procedural – production system (rule-based systems).
iv. Logic – propositional calculus and predicate logic.

The functions of these are:


i. Capture the essential features of a problem domain and make that information
accessible to problem-solving procedures.
ii. Provide a natural framework for expressing problem-solving knowledge where it
should make that knowledge available to the computer and assist the programmer in
its organization.

2:2
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

SEMANTIC NETWORK
Semantic network or net were first developed for AI as a way to representing human
memory. It is a graphical representation that shows the hierarchical relationship between
objects that is composed of nodes and arcs used to represent propositional information; a
statement that is either true or false, such as “a triangle has three slides.” Nodes are sometimes
referred to as objects or descriptive knowledge (attribute) about the objects while arcs as links
or edges that express a relationship between nodes that provide the basic structure for
organizing knowledge. The link can show any relationship. Without relationships, knowledge is
simply a collection of unrelated facts. With relationships, knowledge is a cohesive structure
about which other knowledge can be inferred.

Two types of commonly used links are IS_A and A_KIND_OF (AKO). IS_A means “is an
instance of” and refers to a specific member of a class. The link AKO is used to relate one class
to another. It is not used to relate a specific individual because that is the function of IS_A. The
more general class that an AKO arrow points to is called a superclass. If a superclass has an
AKO pointing to another node, then it is also a class the AKO points to. Another way of
expressing this is that an AKO points from a subclass to a class.

Another common link is HAS_A, which relates a class to a subclass. The HAS_A points
opposite to the AKO and is often used to relate an object to a part of the object. More
specifically, the IS_A relates a value to an attribute while a HAS_A relates an object to an
attribute.

EXERCISE & SOLUTION

Construct a semantic network for the following situation:

Ex1 Bird is an animal. It can fly and has two wings. Penguin and canary are a kind of
bird. However, a penguin can only walk. Tweety is a canary.

Solution Animal

Fly IS_A

CAN

Bird AKO Penguin


HAS
Wings

AKO CAN

Canary Walk
IS_A
Tweety

2:3
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

Ex2 Ann is a wife of Bill. Ann is the mother of Susan. Ann is the sister of Carol. Bill is
the father of Susan. Tom is the husband of Susan. Susan is the mother of John.
Tom is the father of John. David is the husband of Carol. Carol is the mother of
Tom. David is the father of Tom.

Solution

An object-attribute-value triplet (OAV) triplet can be used to characterize all the


knowledge in semantic net. The OAV triplet representation is convenient for listing knowledge in
the form of a table and thus translating the table into computer code by rule induction.

The following table presents some OAV triplet:


Object Attributes Values
House Bedrooms 2,3,4 etc
House Colors Blue, yellow, green
Admission to university GPA 3.0, 3.5
Inventory control Level of inventory 15, 20, 30
Bedroom Size 9’ * 10’, 6’ * 12’

Another example, if we have a fact – “The chair’s color is red and priced at RM35”.

Red
color

Chair

price
RM35

Object Attribute Value

2:4
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

Mammal legs 4
The objects in a class have one or more attributes in common.
Each attribute has a value. The combination of attribute and
subset
value is a property. Inheritance is important feature of a semantic
network that eliminates the need to repeat common
characteristics. Hence, it eases the task of encoding the Cat

knowledge. The subset relation is often used to link a class and


its superclass. Some links are inherited along subset paths. member

Bill

The example of semantic net - inheritance

However, inheritance can cause problem. Wing


Consider the following fact:
HAS
“Parrot is a bird. Typically, bird has wings and Animal BREATHE Air
IS_A
travel by flying. Bird category falls under Parrot IS_A Bird

animal kingdom. All animal requires air to


breathe. Ostrich is a bird but travels by IS_A TRAVEL
walking.”
Ostrich
Fly
Base on this fact we know that all birds can fly
and ostrich is a bird. But can ostrich fly? To TRAVEL
correct this error, we use exception handling.
When node inherits wrong information, link a Walk

new node to it with the correct information.

Inheritance can be a multiple inheritance when a node has a


Person Skin_color Fair
number of super classes. It enables node to inherit properties
from multiple parent nodes and their ancestors in the network.
However, multiple inheritances can cause conflicting
inheritance.
subclass subclass

Ali Raju

What happen if Raju’s skin is dark?

2:5
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

Problem with semantic net:


i. Problematic statements.
a. Negation – “Sherry loves to eat Cadbury roast almond chocolate, but not their
almond.”
b. Disjunction – “Opus eats oranges or apples.”
ii. Quantified statements.
a. “Every dog has bitten a postman.”
b. “Every dog has bitten every postman.”

Advantages of semantic network:


i. Easy to visualize.
ii. Relationships can be defined by the knowledge engineer.
iii. Related knowledge is easily clustered.
iv. Efficient in space requirements.
v. Objects represented only once.

Disadvantages of semantic network:


i. Inheritance (multiple inheritance) can cause problems.
ii. Facts that are placed inappropriately can cause problems.
iii. No standards about node and arc values.

DECISION TREE
Decision tree is a tree in which each branch node represents a choice between number
of alternatives and each leaf node represents a decision. It is commonly used for gaining
information for the purpose of decision making. The nodes should be split recursively and the
final result is a decision tree in which each branch represents a possible scenario of decisions
and its outcome. Decision tree can simplify knowledge acquisition and are fairly easy to
translate into rules.

yes Car starts? no

So what is
your yes Starter motor turns?
problem?

no
Is there fuel? no

yes

So what is
your
problem?

The example of decision tree – car problem

2:6
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

FRAME
One type of schema that has been used in many AI applications is the frame. Frames
provide a convenient structure for representing objects that are typical to a given situation such
as stereotypes knowledge (common concepts and situations). Like semantic net, frames can be
organized in a hierarchy with general concepts near the top and specific concepts placed at the
lower levels. Unlike semantic nets, each frame or node in this hierarchy can be very rich in
supplementary information, thus eliminating many of the nodes that are required in a semantic
net. A frame would be a good choice for describing a mechanical device, for example a car.
Values that describe one object are group together into single unit.
Basic frame design:
i. Name.
ii. Slots (attributes) which have values:
a. A specific value.
b. A default value.
c. An inherited value.
d. A pointer to another frame.
e. A procedure that gives the value.
iii. Each slot describes:
a. Declarative knowledge – ex. Color of the car (fixed).
b. Procedural knowledge – activate a certain rule if the value exceeds certain value.
iv. Each slot contains one or more facets.
v. Facet describes some knowledge or procedures about the attribute in the slot.
Class frame:
i. Represent the general characteristics of some of common objects.
ii. Define those properties that are common to the entire object within the class, and
possibly default property values.
iii. 2 types of properties: -
a. Static
b. Dynamic
Instance Frame:
i. Use to describe a specific instance (sub-class) of a class frame.
ii. The frame inherits both property values from the class and can be changed to tailor
the object represented in instance frame.
iii. Can create as many instances of the class and immediately inherits the class
information

Types of facet Description


Constraint value Describe the attributes for the slot
Default value Default value for a particular attribute
Range Indicates the type of information that can appear in the slot
If-added procedure Execute when new information is placed in the slots
If-removed procedure Executes when information is deleted from the slot
If-needed procedure Executes when new information is needed from the slot (but the slot is
empty)
If-changed procedure Executes when information changes

2:7
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

Frame Name Tweety

Frame Name Bird Bird


Class

Properties Color Unknown Color Yellow


Properties
Eat Worm Eat Worm
No_wing 2 No_wing 2
Flies True Flies False
Hungry Unknown
Hungry Unknown
Activity Unknown
Activity Unknown
Lives Cage

Example of Class frame for Bird Example of Instance frame for Tweety

Like a semantic net, frame also has inheritance issue. From example, Tweety is an instance of
bird class. Like most bird, Tweety eat worms but cannot fly. Therefore, frame allows an instance
to accept the class default values or provide value unique to the instance. It can also provide
unique properties, e.g. if Tweety live in a cage.

With this scheme, we can also create a complex


Birds
frame structure. For example, consider the world
of birds arrange hierarchical structure.

Robins Canaries Sparrows

Bird 1 Bird 2 Bird 3 Bird 4 Bird 5 Bird 6

Frame world of birds

Frame advantages:
i. Fairly intuitive for many applications.
a. Similar to human knowledge organization.
b. Suitable for causal knowledge.
c. Easy to include default information and detect missing values.
d. Easier to understand than logic or rules.
ii. Very flexible.

Frame disadvantages:
i. No standards.
ii. Frame for sub-class will be different for a superclass.

2:8
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

PRODUCTION RULE
Production rule represent knowledge in the form of condition-action pairs. Each rule implements
as autonomous chunk of expertise that can be developed and modified independently of other
rules. It can be viewed as a simulation of the expert’s cognitive behavior. Basic format for
production rule: -

IF <condition occur>
THEN <action will occur>

E.g.1 IF person has fever E.g.2 IF person has fever


THEN take aspirin AND fever is greater than 102
THEN see doctor

Other potential rule formats: -

Conclusion, IF premise. Inclusion of ELSE.


E.g. Replace the battery, IF battery is bad E.g. IF the battery is dead
OR out of gas
THEN the car will stop
OR ELSE you can get to the destination

There are two types of rule:


i. Knowledge rule (Declarative rule) - state all the facts and relationships about
problem. E.g.
IF an international conflict begins
THEN the gold price goes up
ii. Procedural rule (Inference rule) - provide advice on how to solve the problem given
certain facts. E.g.
IF the data needed is not available in the system
THEN request the data from the user

Production rule advantages:


i. Easy to understand.
ii. Inference and explanation can be derived easily.
iii. Required modifications and maintenance is easy.
iv. Uncertainty can be easily combined with rules.
v. Each rule is often independent of all other rules.

Production rule disadvantages:


i. For complex knowledge, there will be a thousand of rules, thus it will cause a
difficulty to use and maintain it.
ii. Systems with too many rules may have a search limitation in the control program
such as may not search all rules or searching may be slow.

2:9
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

Production rule involve control strategies known as pattern matching. Pattern matching is the
matching of facts in working memory and knowledge base. It can be done in two ways; forward
chaining and backward chaining.

FORWARD CHAINING

Forward chaining is an inference strategy that begins with a set of known facts using rules
whose premises match the known facts, continues until goal reached or no more rules matches.
E.g. assume the following rules:

Rule 1 :
IF patience has sore throat
AND suspect bacterial infection
THEN believe patient has strep throat

Rule 2 :
IF patience temperature > 100
THEN patient has fever

Rule 3 :
IF patience sick for over a month
AND patient has fever
THEN suspect a bacterial infection

Assert the following facts (from user):


F1: Patient temperature > 102
F2: Patient has been sick for 12 months known fact
F3: Patient has sore throat

F4: Patient has fever


F5: Suspect a bacterial infections new facts generated by known fact
F6: Believe patient has strep throat

Advantages of forward chaining:


i. Works well when the problem naturally begins by gathering information.
ii. Provide considerable amount of information from only a small amount of data.
iii. Excellent for planning, monitoring, control and interpretation types of problem.

Disadvantages of forward chaining:


i. No means of recognizing that some evidence might be more important that the
others. Ask all possible questions.
ii. May ask unrelated question.

2:10
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

BACKWARD CHAINING
Backward chaining is an inference strategy that attempts to prove a hypothesis by gathering
supporting information. E.g. A patient visit a doctor. After listening and examining the patient,
the doctor believes patient has strep throat. Thus, the doctor has to prove his assumption.

Rule 1 :
IF there are sign of throat infection
AND there is evidence that organism
is Streptococcus
THEN patient has strep throat

Rule 2 :
IF patience throat is red
THEN there are sign of throat infections

Rule 3 :
IF stains of organisms is Grampos
AND morphology of the organism is Cossus
AND growth of the organism is chains
THEN there is evidence that the organism is Streptococcus

Result from examination:


F1: The throat is red
F2: Grampos is the type of stains of organisms
F3: The morphology is Cossus
F4: The growth is chains

Objective: To prove that ‘The patient has strep throat’

Advantages of backward chaining:


i. Works well when the problem naturally begins by forming a hypothesis.
ii. Remains focus on a given goals.
iii. Search only a relevant knowledge.
iv. Excellent for diagnosis, prescription and debugging types of problem.

Disadvantage of backward chaining:


i. It will continue to follow a given line of reasoning even if it should drop it and switch
to a different one.

2:11
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

PRACTICE MAKES PERFECT

Given the following knowledge, draw semantic net and/or frame.

1. Rita likes ice-cream. She likes strawberry and chocolate flavors. Ice-creams are not good
for teeth. Rita has a lot of cavities. Draw: semantic net.

2. ABC hotel consists of two types of rooms, that are, standard and superior rooms. A
standard room is equipped with a king bed while a superior room is equipped with two
queen beds. All rooms have a telephone, television and hot kettle. Draw: semantic &
frame.

2:12
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

3. There are three types of birds, that are, flightless, songbird and scavenger. Penguin is a
flightless bird that lives in the south pole. Canary is a songbird that lives in the tropical.
Eagle is a scavenger that lives in North America. Tweety is a canary cartoon character
while Opus is a penguin cartoon character. Draw: semantic net.

Add the following new knowledge:


i. Ostrich is also a flightless bird.
ii. All birds have wings with two legs

4. The aorta is a particular kind of artery which has a diameter of 2.5 cm. An artery is a kind
of blood vessel. An artery always has a muscular wall, and generally has a diameter of
0.4cm. A vein is a kind of blood vessel but has a fibrous wall. Blood vessels all have
tubular form and contain blood. Draw: semantic net.

2:13
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

5. Mini is a robin; it lives in a nest, which is on a pine tree in Mr. Ali’s backyard. Robins are
birds; they can fly and have wings. They are endangered species, and they are protected
by government regulations. Draw: semantic & frame.

2:14
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

6. You are given a set of rules for this question: Should we buy a house or not?

R1: IF inflation is low,


THEN interest rates are low,
ELSE interest rates are high.

R2: IF interest rates are high,


THEN housing prices are high,
ELSE housing prices are low.

R3: IF housing prices are high,


THEN do not buy a house,
ELSE buy a house.

a. Run forward chaining with a low inflation rate as given.

b. Run backward chaining with a high inflation rate as given and the hypothesis of do
not buy a house.

2:15
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

7. You are given an ES with the following rules:

R1: IF interest rates fall,


THEN bond prices will increase.

R2: IF interest rates increase,


THEN bond prices will decline.

R3: IF interest rates are unchanged,


THEN bond prices will remain unchanged.

R4: IF the dollar rises (against other currencies),


THEN interest rates will decline.

R5: IF the dollar falls,


THEN interest rates will increase.

R6: IF bond prices decline,


THEN buy bonds.

A client has just observed that the dollar exchange rate is falling. He wants to know whether
to buy bonds. Run a forward and a backward chaining and submit a report to him.
Hypothesis: buy bonds.

2:16
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

8. You are given a set of rules:

R1: IF a person has $10,000 to invest and she has a college degree
THEN she should invest in securities.

R2: IF a person’s annual income at least $40000 AND she has a college degree
THEN she should invest in growth stocks.

R3: IF a person is younger than 30 AND she is investing in securities


THEN she should invest in growth stocks.

R4: IF a person is a younger than 30 and older than 22


THEN She has a college degree.

R5: IF a person wants to invest in a growth stock


THEN the stock should be IBM.

The facts: We assume that an investor has $10,000 and that she is 25 years old. She
would like advice on investing in IBM stock. Run forward and backward chaining.
Hypothesis: he should invest in IBM stock.

2:17
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

9. The Animals Rule Base


R1: IF animal has hair R6: IF animal is ungulate
THEN animal is a mammal AND animal has black
stripes
R2: IF animal gives milk THEN animal is zebra
THEN animal is mammal
R7: IF animal is bird
R3: IF animal has a feather AND animal does not fly
THEN animal is bird AND animal can swim
AND animal is black and
R4: IF animal can fly white
AND animal lays eggs THEN animal is penguin
THEN animal is bird
R8: IF animal is bird
R5: IF animal is mammal AND animal is good flyer
AND animal chews cud THEN animal is albatross
THEN animal is ungulate

a. Given the following knowledge base:


F1: animal gives milk
F2: animal chews cud
F3: animal has black stripes
Use forward chaining to find out what animal is implied.

2:18
MODULE – LECTURE NOTES ISP542/ITS462 KNOWLEDGE REPRESENTATION

b. Given the following knowledge base:


F1: animal can fly
F2: animal lays eggs
F3: animal is good flyer
Use forward chaining to find out what animal is implied.

c. Use backward chaining to find out what sets of fact would suffice to establish that an
animal was a penguin?

2:19

You might also like