3.3. The Production System Interpreter

The third component of a production system, the production system interpreter, is the program that applies the rules. It repeatedly performs the following steps:

  1. Match: find the rules whose conditions are satisfied by the current contents of working memory.
  2. Conflict resolution: decide which rule to use. If the condition part of none of the productions is satisfied, then halt the interpreter.
  3. Act: perform the actions in the rule's body.
  4. Go to step 1.

The cycle is usually repeated until either no rule can be found whose condition part is true -- that is, whose head matches the database -- or some rule is fired which has the action part `stop'.

If more than one rule is triggered, then the interpreter will have to decide which of them it will fire. The choice of conflict resolution strategy may well depend on the nature of the task for which the particular system is being used. Three examples of possible conflict resolution strategies are

  • To select the first rule in the rulebase that matches the contents of the database. We might further stipulate that after it has been fired once, the same rule cannot be used again.
  • To use that rule amongst those triggered whose conditions for firing include all those of another plus some further conditions, on the grounds that it is more specialized. For example, there is little point in applying suntan lotion if you are still wearing your street clothes:

	rule 3 :
          if    [temperature, in, sun, hot]
          then  add [apply, suntan, lotion].

       rule 4 :
          if    [temperature, in, sun, hot] &
                [clothes, on]
                [swimsuit, off] &
          then  remove [clothes, on] &
                remove [swimsuit, off] &
                add [clothes, off] &
                add [swimsuit, on].

  • To give priority to special case rules over more generally applicable rules. It may happen, perhaps, that two rule heads can be matched to the working memory, one fully specified and the other containing variables which might match a number of patterns. In this case the more specific rule would be applied first. Even when both rule heads are fully specified, one may be more general than the other. Consider, for example, rules 1 and 3 where rule 3 covers the more specific case of the sun being too hot for sunbathing:
	rule 1 :
          if    [temperature, in, sun, hot]
          then  add [apply, suntan, lotion].

       rule 3 :
          if    [temperature, in, sun, greater_than_100F]
          then  add [stay, in, shade].