Saturday, 29 September 2018

Forward chaining and backward chaining in AI

 Forward chaining and backward chaining

  • In a rule-based expert system, the domain knowledge is represented by a set of IF-THEN production rules and data is represented by a set of facts about the current situation.
  • The inference engine compares each rule stored in the knowledge base with facts contained in the database.
  • When the IF (condition) part of the rule matches a fact, the rule is fired and its THEN (action) part is executed.
  • The matching of the rule IF parts to the facts produces inference chains.
  • The inference chain indicates how an expert system applies the rules to reach a conclusion.

Inference engine cycles via a match -fire Procedure

  
An example of an inference chain

Rule 1:     IF         Y is true
                 AND    D is true 
                 THEN  Z is true

Rule 2:      IF        X is true
                 AND    B is true
                 AND    E is true
                 THEN  Y is true

Rule 3:      IF         A is true
                  THEN  X is true

Forward chaining
  • Forward chaining is one of the two main methods of reasoning when using inference rules.
  • Forward chaining is a popular implementation strategy for expert systems, business and production rule and systems..
  • Forward chaining starts with the available data and uses inference rules to extract more data until a goal is reached.
  • An inference engine using forward chaining searches the inference rules until it finds one where the If clause is known to be true.
  • When such a rule is found, the engine can conclude, the 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 croats
  • Fritz eats flies
  • Tweety eats flies
  • Tweety chirps
  • Tweety is yellow
  • 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 computers that Fritz is a frog.
  • Because the data determines which rules are selected and used, this method is called data-driven.
  • The forward chaining approach is often employed be 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.
Backward Chaining
  • Backward chaining (or backward reasoning) is an inference method that can be described as working backward from the goal(s).
  • It is used in automated theorem provers, proof assistants and other artificial Intelligence applications.
  • In game theory, its application to (simpler) subgames in order to find a solution to the game is called backward induction.
  • Backward chaining starts with a list of goals (or a hypothesis) and works backwards from the consequent to the antecedent to see if there is data available that will support any of these consequents.
  • An inference engine using backward chaining would search the inference rules until it finds one which has a consequent (Then clause) that matches a desired goal.
  • For example, suppose that the goal is to conclude whether Tweety or Fritz is a frog, given information about each of them, 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 backward 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 

How do we choose between forward and backward chaining?
  • If an expert first needs to gather some information and then tries to infer from it whatever can be inferred, choose the forward chaining inference engine.
  • However, if your expert begins with a hypothetical solution and then attempts to find facts to prove it, choose the backward chaining inference engine.

No comments:

Post a Comment

Popular Posts