Forward Chaining and Backward Chaining
Forward Chaining and Backward Chaining
Inference engine:
The inference engine is the component of the intelligent system in artificial intelligence,
which applies logical rules to the knowledge base to infer new information from known
facts. The first inference engine was part of the expert system. Inference engine
commonly proceeds in two modes, which are:
a. Forward chaining
b. Backward chaining
A. Forward Chaining
Forward chaining is also known as a forward deduction or forward reasoning method
when using an inference engine. Forward chaining is a form of reasoning which start
with atomic sentences in the knowledge base and applies inference rules (Modus
Ponens) in the forward direction to extract more data until a goal is reached.
The Forward-chaining algorithm starts from known facts, triggers all rules whose
premises are satisfied, and add their conclusion to the known facts. This process repeats
until the problem is solved.
Properties of Forward-Chaining:
Consider the following famous example which we will use in both approaches:
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."
To solve the above problem, first, we will convert all the above facts into first-order
definite clauses, and then we will use a forward-chaining algorithm to reach the goal.
o It is a crime for an American to sell weapons to hostile nations. (Let's say p, q, and r are
variables)
American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p) ...(1)
o Country A has some missiles.
o ?p Owns(A, p) ∧ Missile(p). .......(2)
o All of the missiles were sold to country A by Robert.
All p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A) ......(3)
o Missies are weapons.
Missile(p) → Weapons (q) .......(4)
o Enemy of America is known as hostile.
Enemy(r, America) →Hostile(r) ........(5)
o Country A is an enemy of America.
Enemy (A, America) .........(7)
o Robert is American
American(Robert). ..........(8)
Criminal (Robert)
B. Backward Chaining:
Backward-chaining is also known as a backward deduction or backward reasoning
method when using an inference engine. A backward chaining algorithm is a form of
reasoning, which starts with the goal and works backward, chaining through rules to find
known facts that support the goal.
Example:
In backward-chaining, we will use the same above example, and will rewrite all the rules.
o It is a crime for an American to sell weapons to hostile nations. (Let's say p, q, and r are
variables)
American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p) ...(1)
o Country A has some missiles.
o ?p Owns(A, p) ∧ Missile(p). .......(2)
o All of the missiles were sold to country A by Robert.
All p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A) ......(3)
o Missies are weapons.
Missile(p) → Weapons (q).......(4)
o Enemy of America is known as hostile.
Enemy(r, America) →Hostile(r) ........(5)
o Country A is an enemy of America.
Enemy (A, America) .........(7)
o Robert is American
American(Robert). ..........(8)
American(Robert)
Weapon(q) Missiles(p)
Criminal(
Robert)
Sells(Robert,q,r) Missile(q)
Owns(A,P)
Hostile(r)
Enemy(r,America
)