The derived? predicated determined wheather its argument is a derived Sol set. This is somewhat tricky because derived sets are defined by operations on other sets.
(define (derived? obj)
; First check to see if obj is a list.
(if (and (not (null? obj)) (list? obj))
; Assign the first elemth to
; OPERATION, the second to A,
; and the third to B.
(let ((operation (car obj)))
(case operation
((union intersection difference)
; Make sure that the list is
; of length three and that the
; two operands are sets.
(and (= (length obj) 3) (set? (cadr obj)) (set? (caddr obj))))
((cross)
; Don't do full checking for
; the cartesian product. Just
; make sure the length is at
; least three.
(>= (length obj) 3))
(else #f)))
#f))