You are on page 1of 6

Artificial Intelligence: Expert Systems

Exercise 1: Consider the following animal knowledge base:


R1

IF
THEN

the animal has hair


it is a mammal

R2

IF
THEN

the animal gives milk


it is a mammal

R3

IF
THEN

the animal has feathers


it is a bird

R4

IF

the animal flies


the animal lays eggs
it is a bird

THEN
R5

IF
THEN

R6

IF

THEN
R7

IF
THEN

R8

IF
THEN

R9

IF
THEN

R10

IF
THEN

the animal is a mammal


the animal eats meat
it is a carnivore
the animal is a mammal
the animal has pointed teeth
the animal has claws
the animal's eyes point forward
it is a carnivore
the animal is a mammal
the animal has hooves
it is an ungulate
the animal is a mammal
the animal chews cud
it is an ungulate AND
it is even-toed
the animal is a carnivore
the animal has a tawny color
the animal has dark spots
it is a cheetah
the animal is a carnivore
the animal has a tawny color
the animal has black stripes
it is a tiger

R11

IF
THEN

R12

IF
THEN

R13

IF

THEN
R14

IF

THEN
R15

IF
THEN

the animal is an ungulate


the animal has long legs
the animal has a long neck
it is a giraffe
the animal is an ungulate
the animal has a white color
the animal has black stripes
it is a zebra
the animal is a bird
the animal does not fly
the animal has long legs
the animal has a long neck
the animal is black and white
it is an ostrich
the animal is a bird
the animal does not fly
the animal swims
the animal is black and white
it is a penguin
the animal is a bird
the animal is a good flier
it is an albatross

Question 1. Given these facts in working memory initially:


the animal gives milk
the animal chews its cud
the animal has long legs
the animal has a long neck
Give the different facts deduced by the inference engine when using forward
chaining (data driven reasoning). For conflict resolution, use rule order as
implied priority (if there is a conflict, choose the rule with smallest number).
Stop when discovering an animal.
Question 2. Given the facts in working memory initially:
the animal has hair
the animal has claws
the animal has pointed teeth
the animal's eyes point forward
the animal has a tawny color
the animal has dark spots
Is the animal a cheetah? Justify using backward chaining (Goal driven
reasoning)

Solution (Q1).
Working Memory:
the animal gives milk
the animal chews its cud
the animal has long legs
the animal has a long neck
Inference engine:
Cycle 1: R2 add: it is a mammal to Working Memory (WM)
Cycle 2: R2, R8 add: it is an ungulate, it is even-toed to WM
Cycle 3: R2, R8, R11 add: it is a Giraffe to WM
Stop and display: It is a Giraffe
Final state of Working Memory:
the animal gives milk
the animal chews its cud
the animal has long legs
the animal has a long neck
it is a mammal
it is an ungulate
it is even-toed
it is a Giraffe

Solution (Q2).
Given the facts in working memory initially:
the animal has hair
the animal has claws
the animal has pointed teeth
the animal's eyes point forward
the animal has a tawny color
the animal has dark spots
Is the animal a cheetah? Justify using backward chaining (Goal driven
reasoning)
To prove that the animal is a cheetah, we have to prove that (using Rule 9):
the animal is a carnivore and the animal has a tawny color and the animal has
dark spots
To prove that the animal is carnivore, we have to prove either:
the animal is a mammal and the animal eats meat (Rule 5)
or
the animal is a mammal and the animal has pointed teeth and the animal has
claws and the animal's eyes point forward (Rule 6)
The animal is mammal can be proved using Rule 1 (as the animal has hair is
present in WM). However, the animal eats meat is not present in WM and
cannot be proved using any rule. So, we cannot prove that the animal is
carnivore by using Rule 5. Now, let us try Rule 6. The animal is mammal can
be proved using Rule 1.the facts the animal has pointed teeth and the animal
has claws and the animal's eyes point forward are present in WM so they are
true. Therefore, the animal is a carnivore is true.
the animal is a carnivore has been proved. Let us prove the remaining facts.
the animal has a tawny color and the animal has dark spots are true because
they are present in WM. Therefore, we can conclude that:
The animal is cheetah

Exercise 2. Consider the following Knowledge Base:


Rule 1: If A and B Then C
Rule 2: If A and not(B) Then D
Rule 3: If C and D Then E
Rule 4: If B and E and F then G
Rule 5: If A and E Then H
Rule 6: If D and E and H Then I
Rule 7: If not(C) Then E
Rule 8: If A and E and I Then G
Rule 9: If H and G Then K
Questions:
Q1. Given these facts in working memory initially: A and F
List the different facts deduced by the inference engine when using forward
chaining (data driven reasoning). For conflict resolution, use rule order as
implied priority (if there is a conflict, choose the rule with smallest number).
For the case of fact with negation, use closed world assumption: if the fact is
present in WM (working Memory) then it is true (its negation is false)
otherwise it is false (its negation is true).
Q2. Given the facts in working memory initially: A
Is the goal I true of false? Justify using backward chaining (Goal driven
reasoning). For conflict resolution, use rule order as implied priority (if there is
a conflict, choose the rule with smallest number).

Solution (Q1).
working memory (initially): A and F
List the different facts deduced by the inference engine when using forward
chaining (data driven reasoning). For conflict resolution, use rule order as
implied priority (if there is a conflict, choose the rule with smallest number).
For the case of fact with negation, use closed world assumption: if the fact is
present in WM (working Memory) then it is true (its negation is false)
otherwise it is false (its negation is true).
Closed world assumption: if a fact is present in WM, it is true otherwise it is
false (its negation is true).
Inference Engine:
Cycle 1: R2, R7 select R2 and add: D to Working Memory (WM)
Cycle 2: R2, R7 add: E to WM
Cycle 3: R2, R5, R7 add: H to WM
Cycle 4: R2, R5, R6, R7 add: I to WM
Cycle 5: R2, R5, R6, R7, R8 add: G to WM
Cycle 6: R2, R5, R6, R7, R8, R9 add: K to WM
Cycle 7: R2, R5, R6, R7, R8, R9 STOP there is no applicable rules
Solution (Q2)
Is the goal I true of false? Justify using backward chaining (Goal driven
reasoning). For conflict resolution, use rule order as implied priority (if there is
a conflict, choose the rule with smallest number).
By exploring AND/OR Graph, we can easily prove that I is true

You might also like