Inference & production-system drills
◈ 5 cardsBuild a forward-chaining derivation (Q8), a DFS inference tree (Q6), and contrast data- vs goal-driven control (Q2).
Three exam tasks, one engine
A production system is rules + working memory + a recognize–act cycle. The same rule base can be run in two directions, and the exam tests both plus the contrast between them.
Q2 — data-driven vs goal-driven
| Data-driven (forward chaining) | Goal-driven (backward chaining) | |
|---|---|---|
| Start from | the known facts | the goal to prove |
| Match rules by their | premises (conditions) | conclusions (actions) |
| Each step | fires a rule, adds its conclusion to working memory | turns a rule's premises into subgoals |
| Stops when | no new fact can be derived (fixpoint) | the goal traces back to known facts |
| Best when | few facts, many possible conclusions; "what follows from this data?" | a specific goal, the data set is large; "is this goal provable?" |
Rule of thumb: choose the direction with the smaller branching factor — work from whichever end has fewer choices.
Q8 — forward chaining to a fixpoint
Using the cat/dog/mouse KB from L10.1 with facts , repeatedly fire any rule whose premises are all known, add the conclusion, and loop until a full pass derives nothing new (the fixpoint):
- dog absent + cat not sleeping ⇒ derive cat_absent.
- dog absent + cat absent ⇒ derive mouse_present.
- Next pass adds nothing new ⇒ fixpoint, stop.
Every rule firing is one application of modus ponens; forward chaining is just modus ponens run to exhaustion.
Q6 — the DFS inference tree
Backward chaining proves a goal depth-first over the rules. The exam's playground KB:
Facts: , . Prove playground_empty, numbering rules in trial order:
- Goal
playground_empty. Rule 1 concludes it ⇒ try rule 1; its premises are not facts and unprovable ⇒ fail, backtrack. - Rule 5 also concludes
playground_empty⇒ try rule 5; subgoalkids_not_outside. - Rule 2 concludes
kids_not_outside⇒ its premiseplaying_videogameis a fact ⇒ succeed. kids_not_outsideproved ⇒playground_emptyproved via rules [5, 2].
The and/or structure: each rule conclusion is an OR-choice (rule 1 or rule 5 could establish the goal); each rule's premises are AND-subgoals (all must hold). DFS tries OR-children left to right, backtracking on failure.