We have created Artificial Intelligence as a way to amplify human intelligence and promote growth like never before. AI can help us solve numerous problems of varying complexities.

One such type of problem is the case where one has to predict outcomes using the given pool of knowledge.  Here, the knowledge base is given and using logical rules and reasoning, one has to predict the outcome.

These problems are usually solved using Inference Engines, which utilize their two special modes: Backward Chaining and Forward Chaining.

As we progress, let’s have a detailed look at both the chaining processes used in Artificial Intelligence.

## What is an Inference Engine?

An Inference Engine is a tool of Artificial Intelligence that is used as a component of the system to deduce new information from a knowledge base using logical rules and reasoning. The first-ever Inference Engines were a part of expert systems in AI. As previously stated, Inference Engines predict outcomes with the already existing pool of data, comprehensively analyzing it and using logical reasoning to predict the outcomes.

Learn about AI algorithms like A* Search algorithm.

This same process would be repeated as new facts would be discovered and this would make the inference engine trigger additional rules for its findings. After some runs of the inference engine, it was noticed that Inference Engines works in one of the two ways, either based on goals or based on facts, which later came to be known as forwarding chaining and backward chaining.

Forward chaining comes with known facts and iterates the process to find new facts while backward chaining starts with goals and works backwards to determine what conditions would be required to achieve the given goals.

## Examples regarding Inference Rules

Let’s take a look at some simple examples to help you differentiate between both sets of inference rules.

Inference Rules

• Deductive inference rule:

Forward Chaining: Conclude from “A” and “A implies B” to “B”.

A

A -> B

B

Example:

It is raining.

If it is raining, the street is wet.

The street is wet.

•  Abductive inference rule:

Backward Chaining: Conclude from “B” and “A implies B” to “A”.

B

A -> B

A

Example:

The street is wet.

If it is raining, the street is wet.

It is raining.

## Forward Chaining

Forward Chaining is one of the two main methods of inference engine which uses the logical process of inferring unknown truths to find a solution from the known set of data by using determined conditions and rules.

You can say that generally complex tasks can be reduced into multiple simpler tasks that are performed either simultaneously or sequentially, just like a chain or chaining is an effective method of teaching complex skills and processes using multiple steps.

As a data-driven as well as bottom-up logic approach, forward chaining starts from known facts and conditions, then progresses towards logical conclusion using if-then statements. Then these conditions and rules are applied to the problem until no further applicable situations are left or the limit has been reached. Forward Chaining searches for any solutions and can come up with an infinite number of possible conclusions.

Learn about expert systems in AI

## Forward Chaining in AI

The Forward-thinking approach is used in AI to help an AI agent solve logical problems by inspecting the data from the previous learnings and then coming to a conclusion full of solutions. That’s not all, Forward Chaining might as well be used to explore the available information or answer a question or solve a problem. Forward chaining is extensively used to break down a long and complex logical approach by attaching each step once the previous one is completed. This way, it goes from beginning to the end with relative ease.

### Steps for working of Forwarding Chaining

1. Step 1: We start from the already stated facts, and then, we’ll subsequently choose the facts that do not have any implications at all.
2. Step 2: Now, we will state those facts that can be inferred from available facts with satisfied premises.
3. Step 3: In step 3 we can check the given statement that needs to be checked and check whether it is satisfied with the substitution which infers all the previously stated facts. Thus we reach our goal.

Let’s take an example to make it more understandable to you.

As per the law, it is a crime for an American to sell weapons to hostile nations. Country A, an enemy of America, has some missiles, and all the missiles were sold to it by Robert, who is an American citizen.

Prove that “Robert is a criminal.”

Step 1: Here all the stated facts are stated which don’t have any implications at all.

Step 2: We choose the facts that can be inferred from available facts with satisfied premises.

Step 3: In step 3 we can check the given statement that needs to be checked and check whether it is satisfied with the substitution which infers all the previously stated facts. Thus we reach our goal.

Hence it can be proved that Robert was the criminal.

## Backward Chaining

Backward Chaining is a logical process of determining unknown facts from known solutions by moving backwards from known solutions to determine the initial conditions and rules.

This means that Backward Chaining is a top-down reasoning approach that starts from conclusions and then goes back towards the conditions it was inferred from using the depth-first approach. In short, this means that Backward Chaining traces back through the code and applies logic to determine which of the following actions would have caused the result.

### Backward Chaining in AI

The Backward Chaining approach is used in AI to find the conditions and rules because of which a particular logical result or conclusion was reached. Real-life applications of Backward Chaining include use to find information regarding conclusions and solutions in reverse engineering practices as well as game theory applications.

Some other applications of Backward Chaining include automated theorem proving tools, inference engines, proof assistants and other artificial intelligence applications.

### Steps of working for Backward Chaining

1. Step 1. In the first step, we’ll take the Goal Fact and from the goal fact, we’ll derive other facts that we’ll prove true.
2. Step 2: We’ll derive other facts from goal facts that satisfy the rules
3. Step 3: At step-3, we will extract further fact which infers from facts inferred in step 2.
4. Step 4: We’ll repeat the same until we get to a certain fact that satisfies the conditions.

Let’s take the same example as taken in Forward Chaining, to prove this time that Robert is the criminal.

Step 1:

In the first step, we’ll take the Goal Fact and from the goal fact, we’ll derive other facts that we’ll prove true.

Step 2:

In second step, we’ll derive other facts from goal facts that satisfy the rules

Step 3:  At step-3, we will extract further facts which infers from facts inferred in step 2.

Step 4: We’ll repeat the same until we get to a certain fact that satisfies the conditions.

Step 5:

Once all the facts and conditions have been derived, the iteration process stops.

## Difference between Forward Chaining and Backward Chaining

Now that you know the Interface Engines’ functioning and the exact roles of Forward and Backward Chaining, you can indulge yourselves into some problem solving and get a better grasp on the “abouts and roles” of AI!
Great Learning‘s exclusive courses on Artificial Intelligence and Machine Learning can definitely help you do that.

3
Previous articleLinear Discriminant Analysis or LDA in Python
Great Learning's Blog covers the latest developments and innovations in technology that can be leveraged to build rewarding careers. You'll find career guides, tech tutorials and industry news to keep yourself updated with the fast-changing world of tech and business.