Skip to content
StackDecode
AI & ML Atlas
Artificial IntelligencealgorithmInteractive simulation

Backward Chaining

Starts from the goal and works back to see if the facts support it.

The idea

Goal-driven reasoning: to prove a goal, find a rule that concludes it and try to prove that rule's conditions as sub-goals, recursively, until you reach known facts. It only explores what is relevant to the question, which is how Prolog works.

Watch it run

This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.

R1R2R3R4R5ABECGDFH
  • known / proved
  • active rule or sub-goal
  • unknown

Work backwards from the goal H: which rule would give it, and what must be true for that rule?

1/17

Circles are statements, squares are IF-THEN rules. A rule links its inputs to its conclusion.

Step by step

  1. 1State the goal to prove.
  2. 2If it is a known fact, succeed.
  3. 3Otherwise find a rule that concludes the goal.
  4. 4Prove each condition of that rule as a new sub-goal.
  5. 5If one rule fails, try another; if none work, the goal fails.

Where it is used

Diagnosis, Prolog, question answering over rules.

Watch out for

Can loop forever on circular rules unless it tracks goals already being proved.

Related