0% found this document useful (0 votes)
27 views

Inference Engine

Uploaded by

Ram sampla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Inference Engine

Uploaded by

Ram sampla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Inference Engine

It is important to understand about inference engine before learning about forward and backward chaining. An
inference engine is a system which applies logical reasoning to draw conclusions and solve a problem based on
given facts.

It consists of algorithms that bring useful info from the knowledge base and use it to conclude new facts to the user's
issues. The inference engine uses two mechanisms, forward and backward chaining, in order to extract data from the
knowledge base.
Let us now discuss both of them one by one.

Forward Chaining
Forward chaining is a data-driven reasoning approach used by inference engines. It starts with given facts and
applies rules to derive new conclusions or facts from them. The engine keeps applying the rules until it reaches a
conclusion or cannot apply any more rules. It is based on logical prediction methodology. One of its examples is the
prediction of trends in the stock market.
Characteristics
 It is a bottom-up approach.

 It starts with the initial state and progresses toward the end state to reach a conclusion.

 It is a data-driven approach which utilises given data.

 It derives conclusions without any need for explicit guidance.


Example
Given below are some facts and some rules:
Facts:
1. Sohail is a coder.

2. Sohail studies computer science.

Rules:
1. If a person is a coder, it means he enrolled in a college.

2. If a person is enrolled in a college and studies computer science, it means he learned DSA.

Now, we will use forward chaining to derive a conclusion based on given facts and rules.
Step 1: If a person is a coder, it means he enrolled in a college.
 FOL: ∀x (coder(x) → Enrolled_IN(x, college))

 Applying rule 1 to the fact: Enrolled_IN(Sohail, college)

Step 2: If a person is enrolled in a college and studied computer science, it means he learned DSA.
 FOL: ∀x,y (Enrolled_In(x, college) ∧ studies(x, computer science) → Learned_DSA(x))

 Applying rule 2 to the fact: Learned_DSA(Sohail)

Final conclusion: Learned_DSA(Sohail)


In the above example, we used forward chaining to derive a conclusion based on given facts and rules. We
converted facts and rules into FOL and reached the final conclusion.
Note: The FOL (First Order Logic) representation helps the inference engine to reach a conclusion effectively.
Advantages
Below are a few pros of forward chaining in AI.
 It is a great way to reach a conclusion based on available data.

 Forward chaining can provide more information from limited data.

 It is suited for expert systems where an application needs more control and monitoring.

 It should be applied when there is a very few numbers of initial states available.
Disadvantages
Below are a few cons of forward chaining in AI.
 The inference engine generates information without knowing which data is more relevant and useful to reach
the final result.

 The inference engine may fire many unnecessary rules to reach the goal state.

 The user may need to enter a lot of information to reach the goal state.

 It can result in a high cost for the chaining process.


Backward Chaining
Backward chaining is also called backward reasoning. In this technique, the inference engine starts with the goal and
works backwards to find evidence that supports the goal. In simple words, it works from the goal state and reaches
the initial state.
Characteristics
 It is a top-down approach.

 It uses a depth-first search strategy.

 It is a goal-driven approach, as we start from the goal state and reach the initial state.

 It divides objectives into sub-goals to validate the facts.


Example
Given below are some facts and rules from which we would derive the conclusion.
Fact:
1. Sohail is a coder.

2. Sohail studies computer science.

Rules:
1. If a person is a coder, it means they enrolled in a college.

2. If a person is enrolled in a college and studies computer science, it means they learned DSA.

Goal: Did Sohail learn DSA or not?

Now, we will use backward chaining to check whether Sohail learns DSA or not.

Step 1: If a person is enrolled in a college and studies computer science, it means they learned DSA. (Rule 1)
 FOL: ∀x,y (Enrolled_In(x, college) ∧ studies(x, computer_science) → Learned(x, DSA))

Now, we need to check if Sohail is enrolled in a college and studies computer science.
Step 2: If a person is a coder, it means they enrolled in a college. (Rule 2)
 FOL: ∀x (coder(x) → Enrolled_In(x, college))

Step 3: We need to check if Sohail is a coder and studies computer science.


 Based on fact 1, Sohail is a coder.

 Based on fact 2, Sohail studies computer science.

From the above, we can conclude that Sohail is enrolled in a college (from Rule 1) and studies computer science.
Therefore, using the backward chaining, we can conclude that Sohail learned DSA.
Advantages
Below are a few pros of backward chaining in AI.
 In backward chaining, the process terminates once the fact is verified.

 It is a faster process as it only analyses and verifies facts.

 It only considers the relevant part of the data and eliminates unnecessary information.

 It is very effective in solving problems like debugging and diagnosing.


Disadvantages
Below are a few cons of backward chaining in AI.
 In backward chaining, the goal should be known before starting the process.

 Backward chaining is very difficult and complex to implement.

 It can only generate a limited number of outcomes.

 It only tests for the required rules and neglects the others.

Forward Chaining vs Backward Chaining

Forward Chaining Backward Chaining

In forward chaining, the decision is In backward chaining, the process starts from
taken based on given data. the goal state and reaches the initial state.

It is a data-driven technique. It is a goal-driven technique.

It is a bottom-up approach. It is a top-down approach.


Forward Chaining Backward Chaining

It uses a breadth-first search strategy. It uses a depth-first search strategy.

Its only goal is to reach a conclusion. Its goal is to validate the facts.

It is a slow process. It is a fast process.

It operates in the forward direction It operates in the backward direction (goal state
(initial state to goal state). to initial state).

It may include multiple ASK questions Backward chaining includes fewer ASK
from the information source. questions compared to forward chaining.

You might also like