Forward Chaining Backward Chaining
Forward Chaining Backward Chaining
Rule-Based Systems
• Instead of representing knowledge in a relatively
declarative, static way (as a bunch of things that are
true), rule-based system represent knowledge in
terms of a bunch of rules that tell you what you
should do or what you could conclude in different
situations.
• A rule-based system consists of a bunch of IF-THEN
rules, a bunch of facts, and some interpreter
controlling the application of the rules, given the
facts.
Two broad kinds of rule system
Forward chaining systems and
Backward chaining systems.
Forward chaining
is a data driven method of deriving a particular goal
from a given knowledge base and set of inference
rules.
Inference rules are applied by matching facts to the
antecedents of consequence relations in the
knowledge base
Cont’d…
• In a forward chaining system you start
with the initial facts, and keep using the
rules to draw new conclusions (or take
certain actions) given those facts.
• Forward chaining systems are primarily
data-driven
• Inference rules are successively applied to
elements of the knowledge base until the
goal is reached
Cont’d…
• A search control method is needed to
select which element(s) of the knowledge
base to apply the inference rule to at any
point in the deduction.
• facts in the system are represented in a
working memory which is continually
updated.
Cont’d…
If [X is a frog]
Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goal
[Fritz is colored Y]?
If [X is a frog]
Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goal
[Fritz is colored Y]?
If [X is a canary]
Then [X is colored yellow]
[Fritz is a frog]
Goal
[Fritz is colored Y]?
If [X is a canary]
Then [X is colored yellow]
[Fritz is a frog]
[Fritz croaks and eats flies]
[Fritz is a frog]
Goal
[Fritz is colored Y]?
If [X is a frog]
Then [X is colored green]
If [X is a canary]
[Fritz is a frog] Then [X is colored yellow]
[Fritz is a frog]
Goal
[Fritz is colored Y]?
?
If [X is a frog]
Then [X is colored green]
[Fritz is a frog]
If [X is a canary]
Then [X is colored yellow]
[Fritz is a frog]
Goal
[Fritz is colored Y]?
If [X is a frog] If [X is a frog]
Then [X is colored green]
[Fritz is a frog] Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
[Fritz is a frog]
[Fritz is colored green]
Goal
[Fritz is colored Y]?
If [X is a frog] If [X is a frog]
Then [X is colored green]
[Fritz is a frog] Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goal
[Fritz is colored Y]?
If [X is a frog] If [X is a frog]
Then [X is colored green]
[Fritz is a frog] Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goal
[Fritz is colored Y]?
?
If [X is a frog] If [X is a frog]
[Fritz is a frog] Then [X is colored green]
Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goal
[Fritz is colored Y]?
If [X is a frog] If [X is a frog]
Then [X is colored green]
[Fritz is a frog] Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goal
[Fritz is colored Y]?
Y = green
Data-drive Goal-drive
n n
Combining forward- and
backward-chaining
• Begin with data and search forward until
the number of states becomes
unmanageably large.
• Switch to goal-directed search to use sub
goals to guide state selection.
Strategies
• These strategies may help in getting reasonable
behavior from a forward chaining system,
• but the most important thing is how we write the
rules.
• They should be carefully constructed, with the
preconditions specifying as precisely as possible
when different rules should fire.
• Otherwise we will have little idea or control of what
will happen
Conclusion
• Goal-driven, backward chaining
• Data-driven, forward chaining
⬥ conditions first, then actions
⬥ working memory contains true statements
describing the current environment
⬥ actions first, then conditions (sub goals)
⬥ working memory contains sub goals to be
shown as true
Forwards vs. Backwards Reasoning