Exercise 4.67. Devise a way to install a loop detector in the query system so as to avoid the kinds of simple loops illustrated in the text and in exercise 4.64. The general idea is that the system should maintain some sort of history of its current chain of deductions and should not begin processing a query that it is already working on. Describe what kind of information (patterns and frames) is included in this history, and how the check should be made. (After you study the details of the query-system implementation in section 4.4.4, you may want to modify the system to include your loop detector.) ———————————————————————————————————————————————————————————————————————— When processing a query, the system can record the pattern and the current frame on a stack of active (sub-)queries. If the current pattern is already on this stack, it should signal an error if the frame contains the same or fewer bindings than the frame already on the stack. As long as the sub-query is more constrained, i.e. has more variables bound than the existing query, then the query is still making progress and can proceed.