What is Backward chaining?

Backward chaining answers a question by looking for facts that would justify a “yes.” Start with the claim you want to prove (the goal). Find a rule that could establish it. The conditions of that…

Three case cards work backward from a caution recommendation to a wet-path subgoal and a check for rain.

Backward chaining answers a question by looking for facts that would justify a “yes.” Start with the claim you want to prove (the goal). Find a rule that could establish it. The conditions of that rule become smaller questions, or subgoals. Keep going until you reach facts you have on record or run out of ways to prove a subgoal.

Think of asking a build tool for one target: it looks up that target’s prerequisites instead of starting every build in the project. The difference is that a build tool can run a command to make a missing file. A proof cannot make a missing observation true.

Two rules for a path advisory

Suppose an advisory service covers one outdoor path. Its question is “Should the sign recommend caution here now?” For this example, every fact refers to that path and the same moment. The service has just two rules:

Rule 1: If it is raining, infer that the path is wet.
Rule 2: If the path is wet, infer that the sign should recommend caution.

These are simplified policy rules, not a weather model. Rain is one sufficient reason to infer a wet path, not its only possible cause. And proving that the sign should recommend caution is not the same as switching it on.

Trace a successful proof from the goal to a fact

Goal: Should the sign recommend caution? Rule 2 has the conclusion we need. Set that conclusion aside for a moment and ask its condition: “Is the path wet?” That is a question, not yet a finding.

Subgoal: Is the path wet? Rule 1 could establish that. Its condition gives us the next question: “Is it raining?” This time the latest observation says it is raining. That recorded fact needs no further rule.

Result: proved. Read the justification back up the chain. The rain observation satisfies Rule 1, so the wet-path subgoal is proved. The wet path satisfies Rule 2, so the caution recommendation is proved. We searched backward for evidence; neither rule was applied in reverse.

What if the rain observation is missing?

Keep both rules, but remove the rain observation and start with no other facts. The same search reaches “Is it raining?” There is no observation to cite and no rule that concludes rain. With no other route to a wet path, the system reports caution not proved. It has not proved that the path is dry or that the sign should say it is safe.

What evidence would change the answer? A direct observation of a wet path would settle the first subgoal. Rule 2 would then justify caution without any rain report. It still would not justify inferring that it rained: a sprinkler could have wet the path.

Forward chaining on the same path

Now use forward chaining. Keep the same rules and restore the same rain observation. Start with what is known: it is raining. Rule 1 adds the path is wet to the known facts. Rule 2 can now add recommend caution. With the observation removed and no other facts, neither rule can add anything. Both methods give the same answer in each case; they differ in where they start looking.

Choose backward chaining when a reader asks why this advisory is warranted: its trace ends at the observation you can show them, or at the evidence you lack. Choose forward chaining when an observation arrives and several advisories might need updating. If many rules share a prerequisite, a backward search may revisit it; if only one advisory matters, a forward search may derive results nobody asked for.

Further reading

For the distinction between a failed query and a false statement, see David Poole and Alan Mackworth’s Queries and Answers and the two proof procedures (§§5.3.1–5.3.2). Stuart Russell and Peter Norvig extend the comparison to rules with variables in Chapter 9, sections 9.3 and 9.4, of Artificial Intelligence: A Modern Approach.

As an Amazon Associate I earn from qualifying purchases. Artificial Intelligence: A Modern Approach, 4th US edition (hardcover), on Amazon.