You are on page 1of 28

Knowledge Representation Rule

in
Artificial Intelligence
KR Using rules
IF . . THEN
ECA (Event Condition Action)
RULES
. APLLICATIONS
EXAMPLES
1. If flammable liquid was spilled, call the fire
department.
2. If the pH of the spill is less than 6, the spill
material is an acid.
3. If the spill material is an acid, and the spill smells
like vinegar, the spill material is acetic acid.
( are used to represent rules)
FACTS

[][][]

MATCH EXECUTE

[][][]

Fig. 1 the rule Interpreted cycles through a


Match- Execute sequence
• The rule-based method of knowledge representation uses IF-THEN rules
(sometimes called condition action rules) to specify the knowledge
• List of rules in the rules-base;
• List of known facts in the facts-base; and an inferencing system, which
processes the rules to derive new facts via some form of reasoning.
• A rule consists of an IF part which is a set of conditions (called
the antecedents) that must be met before the rule is said to ‘fire’ so that
the set of actions in the THEN part (called the consequents) are executed.
• For example, for Rule R1 in Table, if the condition ‘animal has hair’ is met–
 
that is, there is a known fact in the knowledge base that the animal being
classified has hair, then the rule is fired, and the action is to add a further
fact ‘species is mammal’ to the knowledge-base.
• 4 Condition to meet before it Fires – Separated by AND or OR.
FACTS

A flammable Spill smells The spill


The pH of the
liquid was like vinegar material is
spill is < 6
spilled an acid

EXECUTE
MATCH
New fact added to the KB
RULES

If the pH of the spill is less than 6,the spill


material is acid

Fig.2 Rules execution can modify the facts


in the knowledge base
FACTS

A flammable The pH of the Spill smells The spill ACETIC


liquid was spill is < 6 like vinegar material is ACID
spilled an acid

MATCH

If the spill material is an acid and the spill


smells like vinegar, the spill material is
acetic acid EXECUTE

RULES

Fig.3 Facts added by rules can match rules


FACTS

A flammable The pH of the Spill smells


liquid was spill is < 6 like vinegar
spilled

EXECUTE Fire
MATCH dept
is
called

If a flammable liquid was spilled, call the


fire department

RULES
Fig.4 Rule execution can affect the real world
The spill
The pH of
material is
the spill is < 6
an acid

The spill
material is
an acetic
acid

Spill smells
like vinegar

Fig.5 Inference chain for inferring the spill material


Knowledge based rule - Video Surveillance
Face Recognition using DNA
Forward Chaining
It is a strategy of an expert system to answer the question, “What
can happen next?”.
Here, the Inference Engine follows the chain of conditions and
derivations and finally deduces the outcome.
It considers all the facts and rules, and sorts them before concluding
to a solution.
This strategy is followed for working on conclusion, result, or effect.
For example, prediction of share market status as an effect of
changes in interest rates.
Fig. 6 An example of forward chaining
A D
F
C Z
B
Fig. 7 Inference chain produced by Fig. 6
Backward Chaining
With this strategy, an expert system finds out the answer to the
question, “Why this happened?”
On the basis of what has already happened, the Inference Engine
tries to find out which conditions could have happened in the past
for this result. This strategy is followed for finding out cause or
reason. For example, diagnosis of blood cancer in human
Fig. 8 An example of Backward Chaining
A practical example for Forward Chaining; A practical example of backward chaining
Tom is running (A) will go as follows:
If a person is running, he will sweat (A- Tom is sweating (B).
>B) If a person is running, he will sweat (A->B).
Therefore, Tom is sweating. (B) Tom is running (A).
Difference Between Forward and Backward Chaining
Figure 1 ANTECEDENTS CONSEQUENTS

…… ……
……
…… ……
Rn If if1
if2
:
then then1
then2
:
Z1 If ?x has hair
then ?x is a mammal
Z2 If ?x gives milk
then ?x is a mammal
Z3 If ?x has feathers
then ?x is a bird
Z4 If ?x flies
?x lays eggs
then ?x is a bird
Matching
Z5 If ?x is a mammal
?x eats meat
then ?x is carnivore

Z6 If ?x is a mammal
?x has pointed teeth
?x has claws
?x has forward-pointing eyes
then ?x is carnivore

Z7 If ?x is a mammal
?x has hoops
then ?x is an ungulate

Z8 If ?x is a mammal
?x chews cud
then ?x is an ungulate
Z9 If ?x is a carnivore
?x has tawny color
?x has dark spots
then ?x is a cheetah

Z10 If ?x is a carnivore
?x has tawny color
?x has dark spots
then ?x is a tiger

Z11 If ?x is an ungulate
?x has long legs
?x has long neck
?x has tawny color
?x has dark spots
then ?x is a giraffe
Z12 If ?x is a ungulate
?x has white color
?x has black strips
then ?x is a zebra

Z13 If ?x is a bird
?x does not fly
?x has long legs
?x has long neck
?x is black and white
then ?x is a ostrich

Z14 If ?x is a bird
?x does not fly
?x has swim
?x is black and white
Z15 If ?x is a bird
?x is a good flyer
then ?x is an albatross

Stretch has hair.


Stretch chews cud.
Stretch has long legs.
Stretch has long neck.
Stretch has tawny color .
Stretch has dark spots.
Fired first
Has
hair is a mammal
Z1

Fired second
Chews cud is an ungulate
Z8

Fired third
Has long legs
is a
Has long neck Z11
giraffe
Has tawny color

Has dark sports

FIGURE: 2
Has forward-pointing eyes Fourth rule used

Has claws
Has pointed teeth
Z6 is a carnivore

Third rule used


Has
hair is a mammal
Z1

Second rule used

Eats meat is a carnivore


Z5 First rule used

Has tawny color


Z9
Has dark sports
is a cheetah
FIGURE: 3

You might also like