×

Forward Chaining in AI : Artificial Intelligence

Forward Chaining is the process which works on the basis of available data to make certain decisions. Forward chaining is the process of chaining data in the forward direction. In forward chaining, we start with the available data and use inference rules to extract data until the goal is not reached. Forward chaining is the concept of data and decision. From the available data, expand until a decision is not made.  

In artificial intelligence, we have two different methods to use forward chaining.

  • Forward Chaining in Propositional Logic
  • Forward Chaining in Predicate Logic/(FOPL)

We will discuss both one by one

Forward Chaining in Propositional Logic

In propositional logic, forward chaining starts its journey from the given knowledge base. If all the premises of the implication are known, then its conclusion will be added to the set of known facts.

We use the below forward chaining algorithm to perform the forward chaining.

 function PL-FC-ENTAILS?(KB, q) returns true or false
 inputs: KB, the knowledge base, a set of propositional definite clauses
 q, the query, a proposition symbol
 count ?a table, where count [c] is the number of symbols in c’s premise
 inferred ?a table,where inferred[s] is initially false for all symbols
 agenda ?a queue of symbols, initially symbols known to be true in KB
 while agenda is not empty do
 p?POP(agenda)
 if p = q then return true
 if inferred[p] = false then
 inferred[p]?true
 for each clause c in KB where p is in c.PREMISE do
 decrement count [c]
 if count [c] = 0 then add c.CONCLUSION to agenda
 return false 

Conclusions drawn from the above algorithm:

  • Forward Chaining is sound as every inference is necessarily an application of Modus Ponen.
  • Forward Chaining is complete as all atomic sentences will be derived from it.

Let’s see an example:

  1. If D barks and D eats bone, then D is a dog.
  2. If V is cold and V is sweet, then V is ice-cream.
  3. If D is a dog, then D is black.
  4. If V is ice-cream, then it is Vanilla.

Derive forward chaining using the given known facts to prove Tomy is black.

  • Tomy barks.
  • Tomy eats bone.

Solution: Given Tomy barks.

 From (1), it is clear:

If Tomy barks and Tomy eats bone, then Tomy is a dog.

From (3), it is clear:

If Tomy is a dog, then Tomy is black.

Hence, it is proved that Tomy is black.

Note: There is an advantage of forward chaining that is, we can draw new inference from the given facts.

Forward Chaining in Predicate Logic/ FOPL

Forward Chaining in Predicate Logic is different from forward chaining in Propositional Logic. In FOPL, forward chaining is efficiently implemented on first-order clauses. First-order clauses are the disjunction of literals of which exactly one is positive.

For example, Crow(x) ? Thrust(x)?Water(x).

Crow(x).

Thrust(x).

Therefore, a definite clause is either atomic or an implication whose predecessor is a conjunction of positive literals. As a result, it results in a single positive literal.

The forward chaining algorithm used in FOPL is:

 function FOL-FC-ASK(KB,?) returns a substitution or false
 inputs: KB, the knowledge base, a set of first-order definite clauses
 ?, the query, an atomic sentence
 local variables: new, the new sentences inferred on each iteration
 repeat until new is empty
 new ?{}
 for each rule in KB do
 (p1 ? . . . ? pn ? q)?STANDARDIZE-VARIABLES(rule)
 for each ? such that SUBST(?, p1 ? . . . ? pn) = SUBST(?, p_
 1 ? . . . ? p_
 n)
 for some p_
 1 , . . . , p_
 n in KB
 q_?SUBST(?, q)
 if q_ does not unify with some sentence already in KB or new then
 add q_ to new
 ??UNIFY(q_,?)
 if ? is not fail then return ?
 add new to KB
 return false 

Conclusions drawn:

  • Forward Chaining in FOPL is sound as each inference is an application of Generalized Modus Ponen.
  • It is complete as it answers each query.

Let’s see an example of Forward Chaining in FOPL

Consider the below axioms:

  1. Gita loves all types of clothes.
  2. Suits are clothes.
  3. Jackets are clothes.
  4. Anything any wear and isn’t bad is clothes.
  5. Sita wears skirt and is good.
  6. Renu wears anything Sita wears.

Apply backward chaining and prove that Gita loves Kurtis.

Solution: Convert the given axioms into FOPL as:

  1. x: clothes(x)?loves(Gita, x).
  2. Suits(x)?Clothes(x).
  3. Jackets(x)?Clothes(x).
  4. wears(x,y)? ¬bad(y)?Clothes(x)
  5. wears(Sita,skirt) ? ¬good(Sita)
  6. wears(Sita,x)?wears(Renu,x)

To prove: Gita loves Kurtis.

FOPL: loves(Gita, Kurtis).

On applying forward chaining in the below graph:  

Thus, it is proved that Gita loves Kurtis.


Related Topics

Reinforcement Learning in AI

Reinforcement Learning in AI Reinforcement LearningMarkov’s Decision ProcessQ leaningGreedy Decision MakingNIM GameNIM Game Implementation with Python Reinforcement Learning Reinforcement Learning is about learning from experience, where agents are given a set of rewards...

15 minutes read.

Cryptarithmetic Problem in AI

Cryptarithmetic Problem Cryptarithmetic Problem is a type of constraint satisfaction problem where the game is about digits and its unique replacement either with alphabets or other symbols. In cryptarithmetic problem, the...

3 minutes read.

Adversarial Search in Artificial Intelligence

AI Adversarial search: Adversarial search is a game-playing technique where the agents are surrounded by a competitive environment. A conflicting goal is given to the agents (multiagent). These agents compete...

3 minutes read.

Top 7 Artificial Intelligence and Machine Learning trends for 2024

Artificial Intelligence is the ability of machines to perform the same function as human beings, like problem-solving, learning, reasoning and recognizing. Machine Learning is another branch of Computer Science and...

6 minutes read.

Unsupervised Learning in AI

Unsupervised Learning in AI Unsupervised LearningIntroductionClusteringComparison between Supervised, Unsupervised, and Reinforcement Learning. Unsupervised Learning This is the third major category of Machine Learning. Unsupervised learning happens when we have data without additional feedback,...

2 minutes read.

Problem-solving in Artificial Intelligence

The reflex agents are known as the simplest agents because they directly map states into actions. Unfortunately, these agents fail to operate in an environment where the mapping is too large to...

7 minutes read.

The Wumpus World

The Wumpus world is a game playing which provides an environment to the knowledge-based agent to showcase its stored knowledge. It was developed by Gregory Yob in 1973. About the game:  It...

3 minutes read.

Propositional Logic

It is a branch of logic which is also known as statement logic, sentential logic, zeroth-order logic, and many more. It works with the propositions and its logical connectivities. It deals with the...

5 minutes read.

Resolution Method in AI

Resolution Method in AI Resolution method is an inference rule which is used in both Propositional as well as First-order Predicate Logic in different ways. This method is basically used for proving the...

5 minutes read.

Quantifying Uncertainty

The concept of quantifying uncertainty relies on how an agent can keep away uncertainty with a degree of belief. The term uncertainty refers to that situation or information which is either unknown or...

5 minutes read.

Top 10 Artificial Intelligence Technologies in 2024

Artificial Intelligence Technologies in 2020 1. Augmented Reality This is one of the most fascinating technology nowadays. Augmented Reality is the use of text, graphics, audio, etc. in real time. In Simple...

4 minutes read.

Utility Functions in Artificial Intelligence

The agents use the utility theory for making decisions. It is the mapping from lotteries to the real numbers. An agent is supposed to have various preferences and can choose the one...

3 minutes read.

Neural Networks

Neural Networks are one of the most popular techniques and tools in Machine learning. Neural Networks were inspired by the human brain as early as in the 1940s. Researchers studied the...

5 minutes read.

Differences in Artificial Intelligence

Difference between Intelligence and Artificial Intelligence Intelligence Artificial Intelligence It is a natural process or quality given to human beings. ...

3 minutes read.

Inference Rules in Proposition Logic

Inference rules are those rules which are used to describe certain conclusions. The inferred conclusions lead to the desired goal state. In propositional logic, there are various inference rules which can be applied to...

3 minutes read.

Alpha-beta Pruning | Artificial Intelligence

Alpha-beta pruning is an advance version of MINIMAX algorithm. The drawback of minimax strategy is that it explores each node in the tree deeply to provide the best path among all the...

3 minutes read.

Intelligent Agents | Agents in AI

What is an Agent? An agent can be viewed as anything that perceives its environment through sensors and acts upon that environment through actuators. For example, human being perceives their surroundings through...

8 minutes read.

Constraint Satisfaction Problems in Artificial Intelligence

Constraint Satisfaction Problems in Artificial Intelligence We have seen so many techniques like Local search, Adversarial search to solve different problems. The objective of every problem-solving technique is one, i.e., to find a solution to...

5 minutes read.

Probabilistic Reasoning

Probabilistic Reasoning Probabilistic Reasoning is the study of building network models which can reason under uncertainty, following the principles of probability theory. Bayesian Networks Bayesian network is a data structure which is used to represent the dependencies among variables....

7 minutes read.

Informed Search/ Heuristic Search in AI

An informed search is more efficient than an uninformed search because in informed search, along with the current state information,  some additional information is also present, which make it easy to reach the...

6 minutes read.