(emptyp x) recognizes empty sets.
This function is like endp for lists, but it respects the non-set convention and always returns true for ill-formed sets.
Function:
(defun emptyp (x) (declare (xargs :guard (setp x))) (mbe :logic (or (null x) (not (setp x))) :exec (null x)))
Theorem:
(defthm emptyp-type (or (equal (emptyp x) t) (equal (emptyp x) nil)) :rule-classes :type-prescription)
Theorem:
(defthm nonempty-means-set (implies (not (emptyp x)) (setp x)))
Theorem:
(defthm emptyp-sfix-cancel (equal (emptyp (sfix x)) (emptyp x)))