21
ForwardChaining
BACKWARDCHAINING
Subscribe
Inference Engine
 The inference engine is the component of the intelligent system in artificial intelligence, which
applies logical rules to the knowledge base to infer new information from known facts.
 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.
 Modus Ponens:
 The Modus Ponens rule is one of the most important rules of inference, and it states that if P
and P → Q is true, then we can infer that Q will be true.
 if P implies Q, then P is called the antecedent and Q is called the consequent.
 Example:
 A It is raining
 AB if it is raining then i will carry an umbrella.
 B I will carry an umbrella (new knowledge)
Forward and Backward Chaining
 The Inference engine can take two basic approaches to search for an answer. These are:
Subscribe
• Start with atomic sentences in the
knowledge base and applies inference rules
(Modus Ponens) in the forward direction to
extract more data until a goal is reached.
Forward
Chaining
• Starts with the goal and works backward,
chaining through rules to find known facts
that support the goal.
Backward
Chaining
Example:
Forward Chaining
A He exercises regularly.
AB if he is exercising regularly, he is fit.
B He is fit
Backward Chaining
B He is fit
AB if he is exercising regularly, he is fit.
A He exercises regularly.
Subscribe
Forward Chaining Logic
 Forward chaining is also known as a forward deduction or forward reasoning method
when using an inference engine. The Forward-chaining algorithm starts from known
facts, triggers all rules whose premises are satisfied, and add their conclusion to the
known facts. This process repeats until the goal is reached.
 Properties of Forward-Chaining:
 It is a down-up approach, as it moves from bottom to top.
 It is a process of making a conclusion based on known facts or data, by starting from
the initial state and reaches the goal state.
 Forward-chaining approach is also called as data-driven as we reach to the goal using
available data.
 Forward -chaining approach is commonly used in the business, and production rule
systems.
Subscribe
Example of Forward Chaining
 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:
1. If X croaks and X eats flies - Then X is a frog
2. If X chirps and X sings - Then X is a canary
3. If X is a frog - Then X is green
4. If X is a canary - Then X is yellow
Facts:
 Fritz croaks
 Fritz eats flies
With forward reasoning, the inference engine can derive that Fritz is green in a
series of steps:
Subscribe
Example of Forward Chaining
1. If X croaks and X eats flies - Then X is a frog
2. If X chirps and X sings - Then X is a canary
3. If X is a frog - Then X is green
4. If X is a canary - Then X is yellow
1.Since the base facts indicate that "Fritz croaks" and "Fritz eats flies", the
antecedent of rule 1 is satisfied by substituting Fritz for X, and the inference engine
concludes:
Fritz is a frog.
2. The antecedent of rule 3 is then satisfied by substituting Fritz for X, and the
inference engine concludes:
Fritz is green
Subscribe
Backward Chaining Logic
 Backward-chaining is also known as a backward deduction or backward reasoning method
when using an inference engine. A backward chaining algorithm is a form of reasoning,
which starts with the goal and works backward, chaining through rules to find known facts
that support the goal.
 Properties of Forward-Chaining:
 It is known as a top-down approach.
 Backward-chaining is based on modus ponens inference rule.
 In backward chaining, the goal is broken into sub-goal or sub-goals to prove the facts true.
 It is called a goal-driven approach, as a list of goals decides which rules are selected and
used.
 Backward -chaining algorithm is used in game theory, automated theorem proving tools,
inference engines, proof assistants, and various AI applications.
 The backward-chaining method mostly used a depth-first search strategy for proof.
Subscribe
Example of Backward Chaining
For example, suppose a new pet, Fritz, is delivered in an opaque box along with two facts
about Fritz:
 Fritz croaks
 Fritz eats flies
The goal is to decide whether Fritz is green, based on a rule base containing the following
four rules:
1. If X croaks and X eats flies - Then X is a frog
2. If X chirps and X sings - Then X is a canary
3. If X is a frog - Then X is green
4. If X is a canary - Then X is yellow
With backward reasoning, an inference engine can determine whether Fritz is green in four
steps.
Subscribe
Example of Backward Chaining
1. If X croaks and X eats flies - Then X is a frog
2. If X chirps and X sings - Then X is a canary
3. If X is a frog - Then X is green
4. If X is a canary - Then X is yellow
To start, the query is phrased as a goal assertion that is to be proved: "Fritz is green".
1. Fritz is substituted for X in rule 3 to see if its consequent matches the goal, so rule 3 becomes:
If Fritz is a frog - Then Fritz is green
Since the consequent matches the goal ("Fritz is green"), the rules engine now needs to see if the antecedent
("Fritz is a frog") can be proved. The antecedent, therefore, becomes the new goal:
Fritz is a frog
Subscribe
Continue…
1. If X croaks and X eats flies - Then X is a frog
2. If X chirps and X sings - Then X is a canary
3. If X is a frog - Then X is green
4. If X is a canary - Then X is yellow
2. Again substituting Fritz for X, rule 1 becomes:
If Fritz croaks and Fritz eats flies - Then Fritz is a frog
Since the consequent matches the current goal ("Fritz is a frog"), the inference engine now needs to
see if the antecedent ("Fritz croaks and eats flies") can be proved. The antecedent, therefore, becomes
the new goal: Fritz croaks and Fritz eats flies
Subscribe
Continue…
Subscribe
 3. Since this goal is a conjunction of two statements, the inference engine breaks it
into two sub-goals, both of which must be proved:
Fritz croaks and Fritz eats flies
 4.To prove both sub-goals, the inference engine sees that both sub-goals were given
as initial facts. Therefore, the conjunction is true:
Fritz croaks and Fritz eats flies
therefore, the antecedent of rule 1 is true and the consequent must be true:
 Fritz is a frog.
 therefore, the antecedent of rule 3 is true and the consequent must be true:
 Fritz is green.
Rule 1: If X croaks and X eats flies - Then X is a frog
Rule 3: If X is a frog - Then X is green.
SUMMARY
Subscribe
Comparison
Forward Chaining
 Forward chaining starts from known facts and
applies inference rule to extract more data unit it
reaches to the goal.
 Forward chaining is known as data-driven
inference technique as we reach to the goal using
the available data.
 It is a bottom-up approach.
 Forward chaining reasoning applies a breadth-
first search strategy.
 Forward chaining is suitable for the planning,
monitoring, control, and interpretation application.
 Forward chaining can generate an infinite number
of possible conclusions.
 Forward chaining is aimed for any conclusion.
Backward Chaining
 Backward chaining starts from the goal and works
backward through inference rules to find the required
facts that support the goal.
 Backward chaining is known as goal-driven
technique as we start from the goal and divide into
sub-goal to extract the facts.
 It is a top-down approach.
 Backward chaining reasoning applies a depth-first
search strategy.
 Backward chaining is suitable for diagnostic,
prescription, and debugging application.
 Backward chaining generates a finite number of
possible conclusions.
 Backward chaining is only aimed for the required
data.
Subscribe
Thanks For
Watching
Reference:
Artificial Intelligence
A Modern Approach Third Edition
Peter Norvig and Stuart J. Russell
Subscribe
Like
Share
OMega TechEd
About the Channel
This channel helps you to prepare for BSc IT and BSc computer science subjects.
In this channel we will learn Business Intelligence ,Artificial Intelligence, Digital Electronics,
Internet OF Things Python programming , Data-Structure etc.
Which is useful for upcoming university exams.
Gmail: omega.teched@gmail.com
Social Media Handles:
omega.teched
megha_with
Subscribe

Forward and Backward chaining in AI

  • 1.
  • 2.
    Subscribe Inference Engine  Theinference engine is the component of the intelligent system in artificial intelligence, which applies logical rules to the knowledge base to infer new information from known facts.  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.  Modus Ponens:  The Modus Ponens rule is one of the most important rules of inference, and it states that if P and P → Q is true, then we can infer that Q will be true.  if P implies Q, then P is called the antecedent and Q is called the consequent.  Example:  A It is raining  AB if it is raining then i will carry an umbrella.  B I will carry an umbrella (new knowledge)
  • 3.
    Forward and BackwardChaining  The Inference engine can take two basic approaches to search for an answer. These are: Subscribe • Start with atomic sentences in the knowledge base and applies inference rules (Modus Ponens) in the forward direction to extract more data until a goal is reached. Forward Chaining • Starts with the goal and works backward, chaining through rules to find known facts that support the goal. Backward Chaining
  • 4.
    Example: Forward Chaining A Heexercises regularly. AB if he is exercising regularly, he is fit. B He is fit Backward Chaining B He is fit AB if he is exercising regularly, he is fit. A He exercises regularly. Subscribe
  • 5.
    Forward Chaining Logic Forward chaining is also known as a forward deduction or forward reasoning method when using an inference engine. The Forward-chaining algorithm starts from known facts, triggers all rules whose premises are satisfied, and add their conclusion to the known facts. This process repeats until the goal is reached.  Properties of Forward-Chaining:  It is a down-up approach, as it moves from bottom to top.  It is a process of making a conclusion based on known facts or data, by starting from the initial state and reaches the goal state.  Forward-chaining approach is also called as data-driven as we reach to the goal using available data.  Forward -chaining approach is commonly used in the business, and production rule systems. Subscribe
  • 6.
    Example of ForwardChaining  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: 1. If X croaks and X eats flies - Then X is a frog 2. If X chirps and X sings - Then X is a canary 3. If X is a frog - Then X is green 4. If X is a canary - Then X is yellow Facts:  Fritz croaks  Fritz eats flies With forward reasoning, the inference engine can derive that Fritz is green in a series of steps: Subscribe
  • 7.
    Example of ForwardChaining 1. If X croaks and X eats flies - Then X is a frog 2. If X chirps and X sings - Then X is a canary 3. If X is a frog - Then X is green 4. If X is a canary - Then X is yellow 1.Since the base facts indicate that "Fritz croaks" and "Fritz eats flies", the antecedent of rule 1 is satisfied by substituting Fritz for X, and the inference engine concludes: Fritz is a frog. 2. The antecedent of rule 3 is then satisfied by substituting Fritz for X, and the inference engine concludes: Fritz is green Subscribe
  • 8.
    Backward Chaining Logic Backward-chaining is also known as a backward deduction or backward reasoning method when using an inference engine. A backward chaining algorithm is a form of reasoning, which starts with the goal and works backward, chaining through rules to find known facts that support the goal.  Properties of Forward-Chaining:  It is known as a top-down approach.  Backward-chaining is based on modus ponens inference rule.  In backward chaining, the goal is broken into sub-goal or sub-goals to prove the facts true.  It is called a goal-driven approach, as a list of goals decides which rules are selected and used.  Backward -chaining algorithm is used in game theory, automated theorem proving tools, inference engines, proof assistants, and various AI applications.  The backward-chaining method mostly used a depth-first search strategy for proof. Subscribe
  • 9.
    Example of BackwardChaining For example, suppose a new pet, Fritz, is delivered in an opaque box along with two facts about Fritz:  Fritz croaks  Fritz eats flies The goal is to decide whether Fritz is green, based on a rule base containing the following four rules: 1. If X croaks and X eats flies - Then X is a frog 2. If X chirps and X sings - Then X is a canary 3. If X is a frog - Then X is green 4. If X is a canary - Then X is yellow With backward reasoning, an inference engine can determine whether Fritz is green in four steps. Subscribe
  • 10.
    Example of BackwardChaining 1. If X croaks and X eats flies - Then X is a frog 2. If X chirps and X sings - Then X is a canary 3. If X is a frog - Then X is green 4. If X is a canary - Then X is yellow To start, the query is phrased as a goal assertion that is to be proved: "Fritz is green". 1. Fritz is substituted for X in rule 3 to see if its consequent matches the goal, so rule 3 becomes: If Fritz is a frog - Then Fritz is green Since the consequent matches the goal ("Fritz is green"), the rules engine now needs to see if the antecedent ("Fritz is a frog") can be proved. The antecedent, therefore, becomes the new goal: Fritz is a frog Subscribe
  • 11.
    Continue… 1. If Xcroaks and X eats flies - Then X is a frog 2. If X chirps and X sings - Then X is a canary 3. If X is a frog - Then X is green 4. If X is a canary - Then X is yellow 2. Again substituting Fritz for X, rule 1 becomes: If Fritz croaks and Fritz eats flies - Then Fritz is a frog Since the consequent matches the current goal ("Fritz is a frog"), the inference engine now needs to see if the antecedent ("Fritz croaks and eats flies") can be proved. The antecedent, therefore, becomes the new goal: Fritz croaks and Fritz eats flies Subscribe
  • 12.
    Continue… Subscribe  3. Sincethis goal is a conjunction of two statements, the inference engine breaks it into two sub-goals, both of which must be proved: Fritz croaks and Fritz eats flies  4.To prove both sub-goals, the inference engine sees that both sub-goals were given as initial facts. Therefore, the conjunction is true: Fritz croaks and Fritz eats flies therefore, the antecedent of rule 1 is true and the consequent must be true:  Fritz is a frog.  therefore, the antecedent of rule 3 is true and the consequent must be true:  Fritz is green. Rule 1: If X croaks and X eats flies - Then X is a frog Rule 3: If X is a frog - Then X is green.
  • 13.
  • 14.
    Comparison Forward Chaining  Forwardchaining starts from known facts and applies inference rule to extract more data unit it reaches to the goal.  Forward chaining is known as data-driven inference technique as we reach to the goal using the available data.  It is a bottom-up approach.  Forward chaining reasoning applies a breadth- first search strategy.  Forward chaining is suitable for the planning, monitoring, control, and interpretation application.  Forward chaining can generate an infinite number of possible conclusions.  Forward chaining is aimed for any conclusion. Backward Chaining  Backward chaining starts from the goal and works backward through inference rules to find the required facts that support the goal.  Backward chaining is known as goal-driven technique as we start from the goal and divide into sub-goal to extract the facts.  It is a top-down approach.  Backward chaining reasoning applies a depth-first search strategy.  Backward chaining is suitable for diagnostic, prescription, and debugging application.  Backward chaining generates a finite number of possible conclusions.  Backward chaining is only aimed for the required data. Subscribe
  • 15.
    Thanks For Watching Reference: Artificial Intelligence AModern Approach Third Edition Peter Norvig and Stuart J. Russell Subscribe Like Share
  • 16.
    OMega TechEd About theChannel This channel helps you to prepare for BSc IT and BSc computer science subjects. In this channel we will learn Business Intelligence ,Artificial Intelligence, Digital Electronics, Internet OF Things Python programming , Data-Structure etc. Which is useful for upcoming university exams. Gmail: omega.teched@gmail.com Social Media Handles: omega.teched megha_with Subscribe