<< Previous exercise (4.64) | Index | Next exercise (4.66) >>
find all unique tuples (variable assignments of the body of rule), but just extract some element(s) from tuple, which leads to the duplicated responses.
;;;modified rule (rule (wheel ?person ?middle-manager ?x) (and (supervisor ?middle-manager ?person) (supervisor ?x ?middle-manager))) ;;;output (wheel (Warbucks Oliver) (Scrooge Eben) (Cratchet Robert)) (wheel (Warbucks Oliver) (Bitdiddle Ben) (Tweakit Lem E)) (wheel (Bitdiddle Ben) (Hacker Alyssa P) (Reasoner Louis)) (wheel (Warbucks Oliver) (Bitdiddle Ben) (Fect Cy D)) (wheel (Warbucks Oliver) (Bitdiddle Ben) (Hacker Alyssa P))
That's because there are four middle-manager whose manager is Warbucks Oliver.
verdammelt
To add more detail:
Because Warbucks supervises:
1. Scrooge who supvervises Cratchet
2. Bitdiddle who supervises Hacker
3. Bitdiddle who supervises Fect
4. Bitdiddle who supervises Tweakit
Each path is taken and is reported as a separate case.