Chaining is a method in which we apply logical rules in a sequential manner to our data to derive meaningful conclusions.
Input facts are the initial facts provided to the system.
The logical base contains rules that the system uses for reasoning.
The inference engine performs logical reasoning and makes inferences based on input facts and rules.
Derived conclusions are the conclusions that we infer in the inference engine.
The final result is the ultimate result obtained from the whole process.
In artificial intelligence, we derive conclusions by applying a set of predefined rules on data. It is used in expert systems, knowledge-based systems, and inference engines to automate decision-making processes. It enables the system to process and analyze data, apply relevant rules, and derive new information or conclusions.
There are two types of chaining: forward and backward. In this Answer, we will discuss these types in detail.
Forward chaining is a bottom-up approach in which we move in a forward direction from collecting facts to finding our final result.
In this approach, we adhere to the following steps:
We first collect the facts used for our task.
We identify the rules and logic that match our data.
We apply the logical rules to our data.
We collect the conclusion and inferences derived from our data.
We deduce a final result of our process.
Let's suppose we have to use forward chaining in a medical center. In this specific case, we have the following predefined rules in our inference engine:
Rule 1: If a patient has a fever, they have a viral infection.
Rule 2: If a patient has a cough, they have a respiratory infection.
We adhere to the following steps:
We identify two facts: The patient has a fever and a cough.
We match the patient facts with the rules present in our logical base.
Our rules match the patient's facts. They have a fever, so we infer it is a viral infection. Secondly, they have a cough, so we infer it is a respiratory infection.
We add our conclusions (viral infection) and (respiratory infection) to the derived conclusions.
Our final outcome is that our patient has a viral and respiratory infection.
Backward chaining is a top-down approach in which we first decide the final outcome we want to achieve and then work in a backward direction to fulfill it.
In this approach, we adhere to the following steps:
We first specify our end goal.
We check if selected rules can be satisfied based on the facts available.
We select the rules that align with conclusions to achieve our goal.
We evaluate the goal based on the available facts and supported premises.
We obtain the facts that help us achieve our end goal.
Let's suppose we use backward chaining in a medical center. In this specific case, we have the following predefined rules in our inference engine:
Rule 1: If a patient has a fever, they have a viral infection.
Rule 2: If a patient has a cough, they have a respiratory infection.
We adhere to the following steps:
We start with the final result, which is to diagnose the patient's condition.
We look for rules whose conclusions match the goal: the patient has a viral and respiratory infection.
Rule 1 matches the goal, which is the viral infection, and Rule 2 matches the goal, which is the respiratory infection. Therefore, we must examine its premises (fever and sore throat).
We check if the premises can be satisfied based on the available facts. In this case, the patient has a high fever and cough, so the premises are satisfied.
We conclude the premises are satisfied, and we find the facts that the patient has a fever and cough.
Forward chaining | Backward chaining |
Forward direction | Backward direction |
Data driven approach | Goal driven approach |
Bottom-up approach | Top-down approach |
Uses breadth for search | Uses depth for search |
Starting point is the fact | Starting point is the goal |
Ending point is the goal | Ending point is the fact |