Memra

Data-driven (forward) vs goal-driven (backward) chaining

◈ 2 cards

The exam Q2 contrast: when to push facts forward to a conclusion and when to pull a goal backward to the facts.

Two directions for the same rule base

A production system can run a rule base in either direction. This is exam Q2 verbatim"contrast data-driven vs goal-driven strategy for search control in production systems."

Data-driven (forward chaining). Start with the known facts in working memory. Match rules by their conditions (IF parts): when a rule's conditions are all present, fire it and add its conclusion to working memory. Repeat. The known set of facts grows outward until the goal appears or no rule can fire. Reasoning flows facts → conclusions.

Goal-driven (backward chaining). Start with the goal in working memory. Match rules by their conclusions (THEN parts): when a rule concludes the goal, its conditions become new subgoals. Recurse on each subgoal until every subgoal is either a known fact or supplied by the user. Reasoning flows goal → facts.

How to choose the direction

Pick the direction with the smaller branching factor, and consider what you start with:

  • Use data-driven when you begin with lots of data and want to know what follows — interpretation/monitoring problems (a stream of sensor readings), where there is no single starting goal. The risk: it fans out in all directions and can derive irrelevant facts.
  • Use goal-driven when you have a specific hypothesis to confirm and the set of possible goals is small — diagnosis ("is it disease X?"). It stays focused and, crucially, gives better explanations: the goal/subgoal tree is the justification, so answering "why did you ask that?" is free.

Worked contrast

Rule base: R1: A∧B → C, R2: C → D, facts {A, B}, target D.

  • Forward: {A,B} fires R1 → add C; now {A,B,C} fires R2 → add D. Done. Two firings, driven by the data.
  • Backward: goal D; R2 concludes D → subgoal C; R1 concludes C → subgoals A,B; both are facts → success. The rule chain R2 ← R1 read backward is the proof of D.

Same rules, same answer, opposite traversal. The choice is a control decision, not a logical one.

R1: A∧B→CABknown factsR2: C→DCDtarget reached
Forward chaining grows the tree <strong>away from what you know</strong>. Nothing in the search points at <code>D</code>; it simply turns up because everything derivable gets derived. On a bigger rule base that is the risk — the same two firings would sit inside a cloud of irrelevant conclusions.
R2: C→DDgoalR1: A∧B→CR1: A∧B→CCsubgoalAfactBfact
Same two rules, traversed the other way: <code>D</code> is matched against <em>conclusions</em>, so <code>R2</code> turns it into the subgoal <code>C</code>, and <code>R1</code> turns that into <code>A</code> and <code>B</code> — both already facts. What is left standing is a proof of <code>D</code>, which is why goal-driven systems explain themselves for free.
NORMAL ~/memra/learn/comp-456/data-driven-vs-goal-driven-chaining utf-8 LF