Sunteți pe pagina 1din 5

Forward and Backward Chaining in AI

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.

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 humans.
Difference:-

Forward chaining.

1. It is also known as data driven inference technique.


2. Forward chaining matches the set of conditions and infer results from these
conditions. Basically, forward chaining starts from a new data and aims for
any conclusion.(data->goal)
3. It is bottom up reasoning.
4. It is a breadth first search.
5. It continues until no more rules can be applied or some cycle limit is met.
6. For example: If it is cold then I will wear a sweater. Here “it is cold is the
data” and “I will wear a sweater”is a decision. It was already known that it is
cold that is why it was decided to wear a sweater, This process is forward
chaining.
7. It is mostly used in commercial applications i.e event driven systems are
common example of forward chaining.
8. It can create an infinite number of possible conclusions.

Backward chaining.

1. It is also called as goal driven inference technique.


2. It is a backward search from goal to the conditions used to get the goal.
Basically it starts from possible conclusion or goal and aims for necessary
data.(goal->data)
3. It is top down reasoning.
4. It is a depth first search.
5. It process operations in a backward direction from end to start, it will stop
when the matching initial condition is met.
6. For example: If it is cold then I will wear a sweater. Here we have our
possible conclusion “I will wear a sweater”. If I am wearing a sweater then it
can be stated that it is cold that is why I am wearing a sweater. Hence it was
derived in a backward direction so it is the process of backward chaining.
7. It is used in interrogative commercial applications i.e finding items that
fulfill possible goals.
8. Number of possible final answers is reasonable.
Forward chaining example:-

“Weather forecasting system”


Suppose we have developed the following rules for our weather forecasting system,

Rule I

If we suspect temperature is less than 20◦


AND there is humidity in the air
Then there are chances of rain.
Rule II
If Sun is behind the clouds
AND air is very cool.
Then we suspect temperature is less than 20◦

Rule III
If air is very heavy
Then there is humidity in the air.

Now, Suppose we have been given the following facts,


a)Sun is behind the clouds
b)Air is very heavy and cool

Problem:- Using forward chaining try to conclude that


“there are chances of rain”.

As we know that forward chaining is a data driven method so we will start from
our given data(facts). we can brake our second fact into two facts because it is
connecting by AND. So we have three facts-
a) Sun is behind the clouds
b) Air is very heavy.
c) Air is very cool.
Now, in forward chaining system we will rich goal from the given facts. For this
we match with the ‘IF..AND’ part of the rule base and create new fact which
one is present in the ‘Then’ part. In other words if we ask question “Why this
happened?” to the given facts then we will get our answer from the set of
rules which are present in the knowledge base.

a)Sun is behind the clouds and c) Air is very cool this two facts are present in
the IF..AND part of Rule II. Thus we get our new fact “we suspect temperature
is less than 20◦”
Now we have the following facts present:

b) “Air is very heavy”


d) “we suspect temperature is less than 20◦”

So now, our fact b) has matched with the ‘IF’ part of the Rule III. Thus
our new fact will become

e) “there is humidity in the air”


d) “we suspect temperature is less than 20◦”

Now, this both new fact e and d are matched with the ‘If...AND’ part
of Rule I. Thus our new fact will be
f)“there are chances of rain” Which is nothing but our goal state.
Backward chaining example:-

We will use same example


“Weather forecasting system”

As we know that backward chaining is a goal driven method so we will start


from our goal statement and we will rich facts from the goal state. we can
brake our second fact into two facts because it is connecting by AND. So we
have three facts-
a) Sun is behind the clouds
b) Air is very heavy.
c) Air is very cool.

So we have our goal statement “there are chances of rain”. if we ask question
“Why this happened?” then we will get our answer in the “Then” part
of given Rules.

So the statement “there are chances of rain” is present in the ‘Then’


part of Rule I. Thus we get our two sub goals
1. “we suspect temperature is less than 20◦”
2. “there is humidity in the air”

Now sub goal number 1 is present in the ‘Then’ part of Rule II. Thus we get our
another two sub goals
3.”Sun is behind the clouds”
4. “air is very cool”. Which is nothing but our first and third fact.(a and c)

And sub goal number 2 is present in the ‘Then’ part of Rule III. Thus we get our
another sub goal
5. “Air is very heavy.” Which is nothing but our second fact(b).

Hence we conclude that “there are chances of rain” because we rich all
facts(data).

S-ar putea să vă placă și