(sfix x) is a fixing function for sets.
We return any proper setp unchanged, but coerce any non-setp into the empty set.
This does for sets what functions like nfix or rfix do for
numbers. It is often useful to use
Function:
(defun sfix (x) (declare (xargs :guard (setp x))) (mbe :logic (if (emptyp x) nil x) :exec x))
Theorem:
(defthm sfix-produces-set (setp (sfix x)))
Theorem:
(defthm sfix-set-identity (implies (setp x) (equal (sfix x) x)))
Theorem:
(defthm sfix-when-emptyp (implies (emptyp x) (equal (sfix x) nil)))