4.58 Exercise 4.58

Let a "big shot" in a division be anyone who does not have a supervisor in that division. The first question we should ask ourselves is whether the division itself should be a part of the rule – that is, do we want to ask whether a person is a big shot in any division, or in this division? What we might realize is that the more specific question can be used to write a query to solve the more general question – all we have to do is parametize the division. We can do that like this:

(rule (is-big-shot ?person ?division)
      (and (job ?person (?division . ?position))
           (not (and (supervisor ?person ?supervisor)
                     (job ?supervisor (?division . ?supervisor-position))))))
 
(is-big-shot (Bitdiddle Ben) computer) ; Determine whether Ben is a big shot in the computer division
(is-big-shot (Bitdiddle Ben) ?division) ; Find all of the divisions for which Ben is a big shot