# What are forward and backward reasoning explain their chaining rules?

Forward chaining (or forward reasoning) 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.[1]

Inference engines will iterate through this process until a goal is reached.

## 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:

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 blue

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

With forward reasoning, the inference engine can derive that Fritz is green in a series of steps:

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
```

The name "forward chaining" comes from the fact that the inference engine 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 opposite order as compared to backward chaining. In this example, rules #2 and #4 were not used in determining that Fritz is green.

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.[2][3]

In this page we will learn about What is Forward Chaining and backward chaining in AI?, What is Inference engine?, Forward Chaining, Properties of Forward-Chaining, Facts Conversion into FOL,

## What is Forward Chaining and backward chaining in AI?

Forward and backward chaining is an essential topic in artificial intelligence, but before we go into forward and backward chaining, let's look at where these two phrases come from.

## What is Inference engine?

In artificial intelligence, the inference engine is a component of the intelligent system that applies logical rules to the knowledge base to infer new information from known facts. The expert system included the first inference engine. Inference engines often operate in one of two modes:
a) Forward chaining
b) Backward chaining

### Horn Clause and Definite clause:

Horn clause and definite clause are sentence types that allow the knowledge base to apply a more limited and efficient inference algorithm. Forward and backward chaining techniques are used in logical inference algorithms, and they both need KB in the form of a first-order definite sentence.
Definite clause: sometimes known as a strict horn clause, is a clause that is a disjunction of literals with exactly one affirmative literal.
Horn clause: A horn clause is a clause that is a disjunction of literals with at most one affirmative literal. As a result, all of the definite clauses are horn clauses.
Example: (¬ p V ¬ q V k). It has only one positive literal k.
It is equivalent to p ∧ q → k.

### A. Forward Chaining

When employing an inference engine, forward chaining is also known as forward deduction or forward reasoning. Forward chaining is a type of reasoning that starts with atomic sentences in a knowledge base and uses inference rules (Modus Ponens) to extract more data in the forward direction until a goal is attained.

The Forward-chaining algorithm begins with known facts, then activates all rules with satisfied premises and adds their conclusion to the known facts. This process continues until the issue is resolved.

Properties of Forward-Chaining:

• As it moves from bottom to top, it is a down-up method.
• It is a method of arriving at a conclusion based on known facts or data by starting at the beginning and working one's way to the end.
• Forward-chaining is also known as data-driven since it allows us to achieve our goal by utilizing existing data.
• Expert systems, such as CLIPS, business, and production rule systems, frequently employ the forward-chaining approach.
Consider the following well-known example, which we'll apply to both ways.
Example:

"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 criminal."
To answer the problem, we'll turn all of the facts above into first-order definite clauses, then utilize a forward-chaining procedure to get to the goal.

### Facts Conversion into FOL:

• Selling weapons to unfriendly or hostile countries is illegal in the United States. (Let's say p, q, and r are variables)
American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p) ...(1)
• It is a method of arriving at a conclusion based on known facts or data by starting at the beginning and working one's way to the end.
• Forward-chaining is also known as data-driven since it allows us to achieve our goal by utilizing existing data.
• Expert systems, such as CLIPS, business, and production rule systems, frequently employ the forward-chaining approach.

## Difference between backward chaining and forward chaining

Following is the difference between the forward chaining and backward chaining:
• Forward chaining begins with known facts and moves forward by applying inference rules to extract more data until it reaches the goal, whereas backward chaining begins with the goal and moves backward by applying inference rules to determine the facts that satisfy the goal.
• The down-up strategy is known as forward chaining, and the top-down approach is known as backward chaining.
• Forward chaining employs a breadth-first search approach, whereas reverse chaining employs a depth-first search approach.
• The Modus ponens inference rule is used in both forward and backward chaining.
• Forward chaining is useful for jobs like planning, design process monitoring, diagnosis, and classification, whereas backward chaining is useful for tasks like categorization and diagnosis.
• Backward chaining aims to avoid the needless path of reasoning, whereas forward chaining can be like an exhaustive search.
• There may be a variety of ASK questions from the knowledge base in forward-chaining, whereas there may be fewer ASK questions in backward-chaining.
• Forward chaining is sluggish because it tests all of the rules, whereas backward chaining is quick since it simply checks the rules that are required.

Forward chainingBackward chaining1.Forward chaining begins with known facts and uses inference rules to extract more data units until it gets the desired outcome.Backward chaining starts with the objective and works backwards using inference rules to locate the necessary facts to support it.2.It is a bottom-up approach.It is a top-down approach.3.Forward chaining is also regarded as a data-driven inference strategy because it allows us to attain our goal using the data we already have.Backward chaining is a goal-driven strategy since it begins with the objective and divides it into sub-goals in order to extract the facts.4.Forward chaining is also regarded as a data-driven inference strategy because it allows us to attain our goal using the data we already have.Backward chaining is a goal-driven strategy since it begins with the objective and divides it into sub-goals in order to extract the facts.5.All of the available rules are subjected to forward chaining testing.Only a few required rules are tested via backward chaining.6.Forward chaining is appropriate for applications such as planning, monitoring, control, and interpretation.Backward chaining is a useful technique for diagnosing, prescribing, and debugging.7.Forward chaining can lead to an unlimited number of different outcomes.The number of possible conclusions generated by backward chaining is finite.8.It works in the forward direction.It works in the backward direction.9.The goal of forward chaining is to reach any conclusion.Backward chaining is only for the data that is required.

### What is forward and backward reasoning?

The forward reasoning is data-driven approach while backward reasoning is a goal driven. The process starts with new data and facts in the forward reasoning. Conversely, backward reasoning begins with the results. Forward reasoning aims to determine the result followed by some sequences.

### When to use forward chaining and backward chaining explain with an example?

Forward chaining can be used for tasks such as planning, design process monitoring, diagnosis, and classification, whereas backward chaining can be used for classification and diagnosis tasks. Forward chaining can be like an exhaustive search, whereas backward chaining tries to avoid the unnecessary path of reasoning.

### What is the difference between backward and forward chaining?

As the name implies, forward chaining begins with known facts and moves forward by applying inference rules to extract more data, and it continues until it reaches the goal, whereas backward chaining begins with the goal and moves backward by applying inference rules to determine the facts that satisfy the goal.

### What is forward reasoning in AI?

Forward Reasoning It is a data-driven task. It begins with new data. The object is to find a conclusion that would follow. It uses an opportunistic type of approach. It flows from incipient to the consequence.