Memra

Inference & production-system drills

Build 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 $\{dog\_absent, cat\_not\_sleeping\}$, repeatedly fire any rule whose premises are all known, add the conclusion, and loop until a full pass derives nothing new (the fixpoint):

  1. *dog absent* + *cat not sleeping* ⇒ derive cat_absent.
  2. *dog absent* + *cat absent* ⇒ derive mouse_present.
  3. 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:

  1. $raining \land temp\_cold \to playground\_empty$
  2. $playing\_videogame \to kids\_not\_outside$
  3. $kids\_not\_outside \to (videogames \lor at\_school)$
  4. $not\_school\_day \to (outside \lor videogames)$
  5. $kids\_not\_outside \to playground\_empty$

Facts: $not\_school\_day$, $playing\_videogame$. Prove playground_empty, numbering rules in trial order:

- Goal playground_empty. Rule 1 concludes it ⇒ try rule 1; its premises $raining, temp\_cold$ are not facts and unprovablefail, backtrack. - Rule 5 also concludes playground_empty ⇒ try rule 5; subgoal kids_not_outside. - Rule 2 concludes kids_not_outside ⇒ its premise playing_videogame is a fact ⇒ succeed. - kids_not_outside proved ⇒ playground_empty proved 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.

NORMAL ~/memra/learn/comp-456/inference-production-system-drills utf-8 LF