Forward reasoning and backward reasoning examples

The demand for expert systems is increasing rapidly these days, with more and more people demanding systems that provide quick and accurate solutions. 

Artificial intelligence (AI) is easily accomplishing this feat with the help of a variety of technologies that assist AI applications in performing a variety of tasks such as planning, classification, reasoning, and so on.

Forward and backward chaining are two important reasoning techniques used by expert systems to mimic human-like intelligence. The importance of Forward and Backward Chaining in expert systems is enormous, making it critical for us to understand their fundamentals.

This article provides an overview of these techniques as well as an explanation of how they work. Readers will have learned real-world examples of how backward and forward chaining are used in AI by the end of the article.

Introduction to Expert System

A brief overview of an expert system can provide more information about the origins of backward and forward chaining in AI.

An expert system is a computer programme that uses rules, approaches, and facts to solve complex problems. MYCIN and DENDRAL are two examples of expert systems. To diagnose bacterial infections, MYCIN employs the backward chaining technique. DENDRAL uses forward chaining to create chemical structures.

An expert system is made up of three parts: a user interface, an inference engine, and a knowledge base. The user interface allows system users to interact with the expert system. The knowledge base contains high-quality, domain-specific knowledge.

The inference engine component is responsible for backward and forward chaining. This is a component that applies logical rules to the knowledge base in order to obtain new information or make a decision. 

The inference engine employs backward and forward chaining techniques as strategies for proposing solutions or deducing information in the expert system.

Also Read | Applications of Computer Vision in AI

What is Forward Chaining?

When using an inference engine, forward chaining is also known as forward deduction or forward reasoning. Forward chaining is a type of reasoning in which atomic sentences in a knowledge base are used to extract more data in the forward direction using inference rules (Modus Ponens).

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

Forward-Chaining Characteristics

  1. As it moves from bottom to top, it is a down-up approach.

  1. It is the process of reaching a conclusion based on known facts or data, beginning with the initial state and progressing to the goal state.

  1. The forward-chaining approach is also known as data-driven because we achieve our goal by utilizing available data.

  1. The forward-chaining approach is commonly used in expert systems such as CLIPS, business rule systems, and production rule systems.

The rule-based system, XCON, is an example of a Forward Chaining expert system used to configure large computer systems. It was one of the first clear commercial successes of expert systems, which were written in the general-purpose programming language OPS5.

Algorithm of Forward Chaining

To complete a task and reach a logical or accurate conclusion, the forward-chaining algorithm, also known as the forward chaining inference process, employs the following step-by-step procedure:

  1. The system receives information about the problem from the user.

  1. This data is then stored in the working memory.

  1. The inference engine searches the rules in a predefined sequence for the one that matches the contents of the working memory.

  1. To find new matches, the system re-evaluates the rules.

  1. Rules that were previously fired are ignored once the new cycle begins.

Also Read |  Conversational Intelligence: Concepts, Importance & Tools

Advantages and Disadvantages of Backward Chaining

Forward chaining has the following advantages:

  1. The right arrangements can be successfully inferred in this type of chaining if the inference engine meets pre-determined principles.

  1. Because the endpoint is accessible, it is a faster thinking strategy than forward chaining.

  1. The outcome is now known, making it simple to draw conclusions.

  1. This procedure is repeated until no more matches are found.

  1. This method is most evident when Forward Chaining is used in rule-based systems.

Forward chaining has the following drawbacks:

  1. It only infers the necessary information, making it less adaptable than forward chaining.

  1. It doesn't end with a slew of answers or solutions.

  1. If the endpoint is known, the path to reasoning can be taken.

What is Backward Chaining?

Backward Chaining, also known as backward reasoning, is an inference engine reasoning technique that begins with a hypothetical goal. Backtracking is used to find the most optimal way to resolve a conflict or reach a goal state, where the search begins at the conclusion and goes back to understand the conditions that led to the conclusion.

This inference engine reasoning technique is used by systems to find the conditions and rules that resulted in a logical result or conclusion.

Backward chaining has the following characteristics:

  1. It is referred to as a top-down approach.

  1. Backward chaining is based on the rule of modus ponens inference.

  1. Backward chaining divides the goal into sub-goals or sub-goals to demonstrate the truth of the facts.

  1. A goal-driven approach is used because a list of goals determines which rules are selected and used.

  1. Backward-chaining algorithms are used in game theory, automated theorem proving tools, inference engines, proof assistants, and a variety of AI applications. 

  1. For proof, the backward-chaining method mostly used a depth-first search strategy.

Example of Backward Chaining

MYCIN is an example of a Backward Chaining expert system that used AI to identify severe bacterial infections. MYCIN was created in the early 1970s at Stanford University and used a simple inference engine and knowledge base.

In human problem-solving, the Backward Chaining algorithm uses a process similar to hypothesis testing. However, in contrast to the latter, it focuses on the necessary rules. In a nutshell, this backward chaining procedure entails:

First, the system examines the knowledge base to determine whether or not the goal has been specified. If not, it searches the knowledge base for rules that contain the goal in their THEN part in the form of premises until it finds one.

Once the premises are identified, the system checks to see if they are in the knowledge base, which, if not, serves as the new goal. This new goal is known as a sub-goal to be demonstrated.

The system repeats the preceding steps until it encounters a premise that is not provided by any rule. This is known as a primitive premise.

Finally, when the system locates the primitive, it prompts the user for additional information, which is used to prove both the sub-goal and the original goal.

Advantages and Disadvantages of Backward Chaining

We’ve listed some advantages of Backward chaining :

  1. The right arrangements can be successfully inferred in this type of chaining if the inference engine meets pre-determined principles.

  1. Because the endpoint is accessible, it is a faster thinking strategy than forward chaining.

  1. The outcome is now known, making it simple to draw conclusions.

Here are some disadvantages of Backward chaining :

  1. It only infers the necessary information, making it less adaptable than forward chaining.

  1. It doesn't end with a slew of answers or solutions.

  1. If the endpoint is known, the path to reasoning can be taken.

Difference between Forward and Backward Chaining

The following is the distinction between forward and backward chaining:

  1. 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.

  1. Backward chaining is referred to as a goal-driven inference technique, whereas forward chaining is referred to as a data-driven inference technique.

  1. Forward chaining is referred to as the down-up approach, whereas backward chaining is referred to as the top-down approach.

  1. Backward chaining employs a depth-first search strategy, whereas forward chaining employs a breadth-first search strategy.

  1. Both forward and backward chaining use the Modus ponens inference rule.

  1. Forward chaining is useful for tasks like planning, design process monitoring, diagnosis, and classification, whereas backward chaining is useful for tasks like classification and diagnosis.

  1. Backward chaining is similar to an exhaustive search, whereas forward chaining attempts to avoid the unnecessary path of reasoning.

  1. Forward-chaining can include a variety of ASK questions from the knowledge base, whereas backward chaining can include fewer ASK questions.

  1. Forward chaining is slow because it checks all of the rules, whereas backward chaining is fast because it only checks the rules that are required.

Also Read | AI Examples

Working of Forward and Backward Chaining with Example

Working of Forward Chaining

The following sequence explains a simple example of forward chaining.

A

A->B

B

A represents the starting point. A->B denotes a fact. This fact is employed in order to reach decision B.

As an example, consider the following:

Tom is on the move (A)

When a person runs, he will sweat (A->B).

As a result, Tom is perspiring. (B)

A DENDRAL expert system is an excellent example of forward chaining in artificial intelligence. DENDRAL is a programme that predicts the molecular structure of substances.

Deducing the chemical structure begins with determining the number of atoms in each molecule. The sample's mass spectrum is then used to determine the atomic arrangement. These steps can be summarized as follows.

  1. The chemical formula is established ( the number of atoms in every molecule).

  1. The spectrum machine is used to generate sample mass spectra.

  1. The chemical's isomer and structure are identified.

The identification of the chemical structure is the endpoint in this example. A generate and test technique is used in the DENDRAL expert system.

The generator contains two components: a synthesizer and a structural enumerator. The synthesizer is in charge of creating the mass spectrum. The structural enumerator identifies the structure of substances and keeps the generator from becoming redundant.

Working of Backward Chaining

The previous example's information (forward chaining) can be used to provide a simple explanation of backward chaining. Backward chaining is explained in the following order.

B

A->B

A

B represents the goal or endpoint that serves as the starting point for backward tracking. The initial state is denoted by the letter A. A->B is a fact that must be established in order to reach the endpoint B.

As an example of backward chaining, consider the following:

Tom is perspiring (B).

When a person runs, he will sweat (A->B).

Tom is on the move (A).

The MYCIN expert system exemplifies how backward chaining works in practice. This is a system that is used to diagnose bacterial infections. It also suggests treatments for these types of infections.

A MYCIN's knowledge base contains many antecedent-consequent rules that allow the system to recognise various causes of (bacterial) infections. This system is appropriate for patients who have a bacterial infection but do not know what it is. The system will collect data on the patient's symptoms and medical history. It will then analyze this data to determine the bacterial infection.

The following is an example of a suitable sequence:

The patient is suffering from a bacterial infection. The patient is throwing up.

He or she is also suffering from diarrhea and severe stomach upset. As a result, the patient has typhoid (salmonella bacterial infection)

The MYCIN expert system recommends appropriate treatment based on the information gathered from the patient. The recommended treatment is in accordance with the identified bacterial infection. In the preceding example, the system may advise the use of ciprofloxacin.

Also Read | Understanding Goods and Bads of AI

Forward Chaining and Backward Chaining, two building blocks of Expert Systems, aid in the creation of systems that solve both simple and complex problems by imitating human-like thinking. 

Furthermore, these have been improved to create a hybrid chaining inference technique that combines the benefits of both forward and backward chaining. In short, these techniques are at the heart of various modern machines, allowing them to perform previously unthinkable tasks.

AI or artificial intelligence relies heavily on forward and backward reasoning. These concepts differ primarily in terms of operational direction, speed, technique, strategy, and approach. Forward and backward chaining are analogous to an exhaustive search and an unnecessary path of reasoning.

What do you mean by forward and backward reasoning with example?

The forward and backward reasoning are differentiated on the basis of their purpose and process, in which forward reasoning is directed by the initial data and intended to find the goal while the backward reasoning is governed by goal instead of the data and aims to discover the basic data and facts.

What is an example of forward chaining?

Using Forward Chaining With Task Analysis An example that is often cited is brushing their teeth. The child may learn each step of taking the toothpaste out of the cabinet, putting it on a wet toothbrush, and scrubbing for a certain amount of time.

How does the backward reasoning differ from the forward reasoning?

1. Forward chaining starts from known facts and applies inference rule to extract more data unit it reaches to the goal. Backward chaining starts from the goal and works backward through inference rules to find the required facts that support the goal. 2.

What is an example of backward chaining?

Use backward chaining (i.e., breaking a skill down into smaller steps, then teaching and reinforcing the last step in the sequence first, then the second to the last step, and so on). For example, have the child wash his/her hands in the sink near the toilet.