14
RULED-BASED EXPERT SYSTEM (FORWARD CHAINING AND BACKWARD CHAINING) -Amit Singh Dahal -g5638545

Ruled based expert system

Embed Size (px)

DESCRIPTION

Using Forward and Backward Chaining

Citation preview

Page 1: Ruled based expert system

RULED-BASED EXPERT SYSTEM

(FORWARD CHAINING AND BACKWARD CHAINING)

-Amit Singh Dahal

-g5638545

Page 2: Ruled based expert system

FIRST STEP: WRITE THE RULES BASED ON DIAGRAMS:

R1: IF the animal has hairTHEN it is a mammal

R2: IF the animal gives milkTHEN it is a mammal

R3: IF the animal has feathersTHEN it is a bird

R4: IF the animal fliesthe animal lays eggs

THEN it is a bird R5: IF the animal is a mammal

the animal eats meatTHEN it is a carnivore

Page 3: Ruled based expert system

CONTD…

R6: IF the animal is a mammalthe animal has pointed

teeththe animal has clawsthe animal's eyes point

forwardTHEN it is a carnivore

R7: IF the animal is a mammalthe animal has hooves

THEN it is an ungulate R8: IF the animal is a mammal

the animal chews cudTHEN it is an ungulate AND

it is even-toed

Page 4: Ruled based expert system

CONTD… R9: IF the animal is a carnivore

the animal has a tawny colourthe animal has dark spotsTHEN it is a cheetah

  R10: IF the animal is a carnivore

the animal has a tawny colourthe animal has black stripesTHEN it is a tiger

R11: IF the animal is an ungulatethe animal has long legsthe animal has a long neckthe animal has dark spotTHEN it is a giraffe

R12: IF the animal is an ungulatethe animal has a white colourthe animal has black stripesTHEN it is a zebra

Page 5: Ruled based expert system

CONTD…

R13 :IF the animal is a birdthe animal does not flythe animal has long legsthe animal has a long neckthe animal is black and white

THEN it is an ostrich R14 :IF the animal is a bird

the animal does not flythe animal swimsthe animal is black and white

THEN it is a penguin R15 :IF the animal is a bird

the animal is a good flierTHEN it is an albatross

Page 6: Ruled based expert system

FORWARD CHAINING Facts in the working memory:

-the animal gives milk-the animal chew cuds-the animal has long legs-the animal has a long neck-the animal has a dark spot

Assume GOAL:

the animal is Giraffe

Page 7: Ruled based expert system

Round 1:R2: IF the animal gives milk

THEN it is a mammal fires mammal Round 2:

R8: IF the animal is mammal the animal chews cudTHEN it is an ungulate fires ungulate

Round 3:R11: IF the animal is an ungulate

the animal has long legs the animal has a long neck the animal has dark spot THEN it is a GIRAFFE

Hence, goal reached. The used rules are: R2, R8 and R11.

Page 8: Ruled based expert system

BACKWARD CHAINING Facts in the working memory:

-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

Assume GOAL:

the animal is Cheetah

Page 9: Ruled based expert system

Pass 1:

Based on R10:

?the animal is carnivore the animal has a tawny color the animal has dark spot

Stack:

Cheetah

R1

R1

AND

Page 10: Ruled based expert system

Pass 2:

Based on R5 and R6:

?the animal is a mammal?the animal can eat meat

?the animal is a mammalthe animal has pointed teeththe animal has clawsthe animal eyes point forward

Stack:

AND

AND

ORR2

Carnivore

R1

R2

Page 11: Ruled based expert system

Pass 3:

Based on R1 and R2:

the animal has hair

the animal gives milk

Stack:

OR Mammal

R1

R2

Page 12: Ruled based expert system

Pass 4:

Based on R5 and R6:

the animal is a mammal? the animal can eat meat

the animal is a mammal the animal has pointed teeth the animal has claws the animal eyes point forward

Stack:

AND

OR

AND

Carnivore

R1

Page 13: Ruled based expert system

Pass 5:

the animal is carnivore the animal has a tawny color the animal has dark spot

Stack: Clear

Hence, goal is correct using backward chaining provided the information and the rules used are:R10, R5, R6, R1, R2.

AND Cheetah

Page 14: Ruled based expert system

THE ENDAny Questions??