Forward chaining and backward chaining are two strategies used in designing expert systems for artificial intelligence. Forward chaining is a form of reasoning that starts with simple facts in the knowledge base and applies inference rules in the forward direction to extract more data until a goal is reached. Backward chaining starts with the goal and works backward, chaining through rules to find known facts that support the goal.

They influence the type of expert system you’ll build for your AI. An expert system is a computer application that uses rules, approaches and facts to provide solutions to complex problems. 

Forward Chaining vs. Backward Chaining Defined

  • Forward chaining: Forward chaining is a form of reasoning for an AI expert system that starts with simple facts and applies inference rules to extract more data until the goal is reached.
  • Backward chaining: Backward chaining is another strategy used to shape an AI expert system that starts with the end goal and works backward through the AI’s rules to find facts that support the goal.

An expert system contains two primary components: 

  1. Knowledge base: This is a structured collection of facts about the system’s domain.
  2. Inference engine: This is a component of the expert system that applies logical rules to the knowledge base to deduce new information. It interprets and evaluates the facts in the knowledge base in order to provide an answer.

Let’s dive deeper into each strategy and how they influence the expert system in AI.

 

What Is Forward Chaining?

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 adds their conclusion to the known facts. This process repeats until the problem is solved. 

In this type of chaining, the inference engine starts by evaluating existing facts, derivations, and conditions before deducing new information. An endpoint, or goal, is achieved through the manipulation of knowledge that exists in the knowledge base.

flow chart for forward chaining process
Forward chaining flow chart illustrating how it works. | Image: Parag Radke

More on AIMarkov Chain Explained

 

Forward Chaining Properties

  • Forward chaining follows a down-up strategy, going from bottom to top.
  • It uses known facts to start from the initial state (facts) and works toward the goal state, or conclusion.
  • The forward chaining method is also known as data-driven because we achieve our objective by employing available data.
  • The forward chaining method is widely used in expert systems such as CLIPS, business rule systems and manufacturing rule systems.
  • It uses a breadth-first search as it has to go through all the facts first.
  • It can be used to draw multiple conclusions.

 

Examples of Forward Chaining

Let’s say we want to determine the max loan eligibility for a user and cost of borrowing based on a user’s profile and a set of rules, both of which constitute the knowledge base. This inquiry would form the foundation for our problem statement.

 

Knowledge Base

Our knowledge base contains the combination of rules and facts about the user profile.

  1. John’s credit score is 780.
  2. A person with a credit score greater than 700 has never defaulted on their loan.
  3. John has an annual income of $100,000.
  4. A person with a credit score greater than 750 is a low-risk borrower.
  5. A person with a credit score between 600 to 750 is a medium-risk borrower.
  6. A person with a credit score less than 600 is a high-risk borrower.
  7. A low-risk borrower can be given a loan amount up to 4X of his annual income at a 10 percent interest rate.
  8. A medium-risk borrower can be given a loan amount of up to 3X of his annual income at a 12 percent interest rate.
  9. A high-risk borrower can be given a loan amount of up to 1X of his annual income at a 16 percent interest rate.

Based on that knowledge base, let’s look at the questions we will want to resolve using forward chaining.

 

Question

Next, we’ll seek to find answers to two questions:

  1. What max loan amount can be sanctioned for John?
  2. What will the interest rate be?

 

Results

To deduce the conclusion, we apply forward chaining on the knowledge base. We start from the facts which are given in the knowledge base and go through each one of them to deduce intermediate conclusions until we are able to reach the final conclusion or have sufficient evidence to negate the same.

John’ CS = 780   AND  CS > 750 are Low Risk Borrower → John is a Low Risk Borrower

Loan Amount for Low Risk Borrower is 4X annual income AND John’s annual income is $100k 

→ Max loan amount that can be sanctioned is $400k at a 10% interest rate.

 

What Is Backward Chaining

Backward chaining is also known as a backward deduction or backward reasoning method when using an inference engine. In this, the inference engine knows the final decision or goal. The system starts from the goal and works backward to determine what facts must be asserted so that the goal can be achieved.

For example, it starts directly with the conclusion (hypothesis) and validates it by backtracking through a sequence of facts. Backward chaining can be used in debugging, diagnostics and prescription applications.

Backward chaining flow chart illustrating how it works.
Backward chaining flow chart illustrating how it works. | Image: Parag Radke

 

Properties of Backward Chaining

  • Backward chaining uses an up-down strategy going from top to bottom.
  • The modus ponens inference rule is used as the basis for the backward chaining process. This rule states that if both the conditional statement (p->q) and the antecedent (p) are true, then we can infer the subsequent (q).
  • In backward chaining, the goal is broken into sub-goals to prove the facts are true.
  • It is called a goal-driven approach, as a list of goals decides which rules are selected and used.
  • The 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.
A tutorial on forward chaining and backward chaining. | Video: Francisco Iacobelli

More on AIMonte Carlo Tree Search: A Guide

 

Examples of Backward Chaining

In this example, let’s say we want to prove that John is the tallest boy in his class. This forms our problem statement.

 

Knowledge Base

We have few facts and rules that constitute our knowledge base:

  • John is taller than Kim
  • John is a boy
  • Kim is a girl
  • John and Kim study in the same class
  • Everyone else other than John in the class is shorter than Kim

 

Question

We’ll seek to answer the question:

  • Is John the tallest boy in class?

 

Results

Now, to apply backward chaining, we start from the goal and assume that John is the tallest boy in class. From there, we go backward through the knowledge base comparing that assumption to each known fact to determine whether it is true that John is the tallest boy in class or not.

Our goal:

  • John is the tallest boy in the class

Which means:

Height (John) > Height (anyone in the class)

AND

John and Kim both are in the same class

AND

Height (Kim) > Height (anyone in the class except John)

AND

John is boy

SO

Height (John) > Hight(Kim) 

Which aligns with the knowledge base fact. Hence the goal is proved true.
Expert Contributors

Built In’s expert contributor network publishes thoughtful, solutions-oriented stories written by innovative tech professionals. It is the tech industry’s definitive destination for sharing compelling, first-person accounts of problem-solving on the road to innovation.

Learn More

Great Companies Need Great People. That's Where We Come In.

Recruit With Us