4.64 Exercise 4.64
Louis Reasoner has retyped in the outranked-by rule as follows:
(rule (outranked-by ?staff-person ?boss) (or (supervisor ?staff-person ?boss) (and (outranked-by ?middle-manager ?boss) (supervisor ?staff-person ?middle-manager))))
(His mistake was to flip the arguments to the and predicate.)
The problem with this mistake is that it causes an infinite loop when evaluating expressions such as (outranked-by (Bitdiddle Ben) ?who). In the second branch of the or expression, this will try to find all database entries which match the form (outranked-by ?middle-manager ?boss), where neither of the variables are bound. Since this will not match any database entries (as this is only a rule), this will recursively try to match database entries against the body of the outranked-by rule. However, in evaluating the body of this rule, it will try to evaluate (outranked-by ?middle-manager ?boss) again, thereby creating an infinite loop.
The recursive reference to the outranked-by rule was not meant to be applied to the database directly, but to a stream of frames where ?middle-manager has been bound to the direct supervisor of the original ?staff-person. Interchanging the order of these expressions has prevented it from doing its job (and the entire expression from terminating).