Forward chaining is one of the two main methods of reasoning when using an inference engine and can be described logically as repeated application of modus ponens. Forward chaining is a popular implementation strategy for expert systems, business and production rule systems. The opposite of forward chaining is backward chaining.
Forward chaining starts with the available data and uses inference rules to extract more data (from an end user, for example) until a goal is reached. An inference engine using forward chaining searches the inference rules until it finds one where the antecedent (If clause) is known to be true. When such a rule is found, the engine can conclude, or infer, the consequent (Then clause), resulting in the addition of new information to its data.
Inference engines will iterate through this process until a goal is reached.
For example, suppose that the goal is to conclude the color of a pet named Fritz, given that he croaks and eats flies, and that the rule base contains the following four rules:
- 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 green
- If X is a canary - Then X is yellow
Let us illustrate forward chaining by following the pattern of a computer as it evaluates the rules. Assume the following facts:
- Fritz croaks
- Fritz eats flies
- Tweety eats flies
- Tweety chirps
- Tweety is yellow
With forward reasoning, the computer can derive that Fritz is green in four steps:
1. Fritz croaks and Fritz eats flies
Based on logic, the computer can derive:
2. Fritz croaks and eats flies
Based on rule 1, the computer can derive:
3. Fritz is a frog
Based on rule 3, the computer can derive:
4. Fritz is green.
The name "forward chaining" comes from the fact that the computer starts with the data and reasons its way to the answer, as opposed to backward chaining, which works the other way around. In the derivation, the rules are used in the reverse order as compared to backward chaining. Note that the computer does not use any knowledge about Tweety, when it computes that Fritz is a frog.
Because the data determines which rules are selected and used, this method is called data-driven, in contrast to goal-driven backward chaining inference. The forward chaining approach is often employed by expert systems, such as CLIPS.
One of the advantages of forward-chaining over backward-chaining is that the reception of new data can trigger new inferences, which makes the engine better suited to dynamic situations in which conditions are likely to change.
- Feigenbaum, Edward (1988). The Rise of the Expert Company. Times Books. p. 318. ISBN 0-8129-1731-6.
- Hayes-Roth, Frederick; Donald Waterman, Douglas Lenat (1983). Building Expert Systems. Addison-Wesley. ISBN 0-201-10686-8.
- Kaczor, Krzystof; Szymon Bobek, Grzegorz J. Nalepa (12.05.2010). "Overview of Expert System Shells". http://geist.agh.edu.pl/. Krakow, Poland: Institute of Automatics: AGH University of Science and Technology, Poland. Retrieved 5 December 2013.