Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

3.

1 Forward and Backward Inference

Q1. Use forward and backward chaining to prove the goal.

(A) Knowledge Base:

If [X croaks and eats flies] Then [X is a frog]

If [X chirps and sings] Then [X is a canary]

If [X is a frog] Then [X is colored green]

If [X is a canary] Then [X is colored yellow]

[Fritz croaks and eats flies]

Goal: [Fritz is colored Y]?

Solution: Forward Chaining :

If[X croaks and eat flies] [Fritz croaks and eats


Then[X is a frog] flies]

If[X is a Frog]
[Fritz is a frog]
Then[X is green in color

[Fritz is colored green] [Fritz is colored Y]?

Y= Green
Backward Chaining:

[Fritz is colored Y]

If[X is a frog] If[X is a Canary]


Then[X is colored green] Then[X is colored yellow]

[X is a frog] [X is a Canary]

If[X croaks and eat flies]


Then[X is a frog]

[X croaks and eat flies] [Fritz croaks and eat flies]

X =Fritz , Y = Green
(B) Knowledge Base:

Ravi enjoys a wide variety of foods.

Banana is a food.

Pizza is a food.

A food is anything that anyone consumes and isn’t harmed by it.

Sam eats idli and is still alive.

Bill eats everything that Sam eats.

Goal: Ravi Like Idli : Forward Chaining:

Banana is a food

Pizza is a food

A food is anything that anyone consumes and isn’t harmed by it

Sam eats idli and is still alive

Bill eats everything that Sam eats

Ravi likes idli


Backward Chaining:

Goal: Ravi Likes Idli

Ravi directly likes idli or someone he eats everything that they eat likes idli

Bill eats everything that Sam eats and Sam eats idli

Sam eats idli and is still alive

Idli is a food and is not harmful

A food is anything that anyone consumes and isn’t harmed by it

Banana is a food and is not harmful

Pizza is a food and is not harmful


Q2. Consider the following story of the "lucky student": "Anyone passing his history exams and
winning the lottery is happy. But anyone who studies or is lucky can pass all his exams. John did not
study but he is lucky. Anyone who is lucky wins the lottery. Is John happy? Use forward and
backward chaining to get the conclusion.

Forward Chaining:

John is lucky and does not study

Anyone who is lucky wins the lottery

John wins the lottery

Anyone passing history exams and winning the lottery is happy

John is happy

Backward Chaining:
Is John happy?

John wins the lottery and passes history exams

John is lucky and does not study

Anyone who is lucky wins the lottery

Anyone passing history exams and winning the lottery is happy


Q3. Based on the following sets of rules, determine whether you should invest long term in India
using backward chaining.
Observed: Economic situation in India is stable.
Rule 1: If gross capita per income increases then long-term investment is viable.
Rule 2: If employment rate is high then gross capita per income increases.
Rule 3: If employment rate is low then gross capita per income decreases.
Rule 4: If economic situation is stable then employment rate is high
Rule 5: If economic situation is unstable then employment rate is low.
Also show the inferencing using forward-chaining.
Forward Chaining:
Economic situation in India is stable

If economic situation is stable then employment rate is high

If employment rate is high then gross capita per income increases

If gross capita per income increases then long-term investment is viable


Backward Chaining:
Should you invest long term in India?

Economic situation in India is stable

If economic situation is stable then employment rate is high

If employment rate is high then gross capita per income increases

If gross capita per income increases then long-term investment is viable

You might also like