(setp x) recognizes well-formed ordered sets.
A proper ordered set is a true-listp whose elements are fully ordered under <<. Note that this implicitly means that sets have no duplicate elements.
Testing
Function:
(defun setp (x) (declare (xargs :guard t)) (if (atom x) (null x) (or (null (cdr x)) (and (consp (cdr x)) (fast-<< (car x) (cadr x)) (setp (cdr x))))))
Theorem:
(defthm setp-type (or (equal (setp x) t) (equal (setp x) nil)) :rule-classes :type-prescription)
Theorem:
(defthm sets-are-true-lists (implies (setp x) (true-listp x)))
Theorem:
(defthm sets-are-true-lists-compound-recognizer (implies (setp x) (true-listp x)) :rule-classes :compound-recognizer)
Theorem:
(defthm sets-are-true-lists-cheap (implies (setp x) (true-listp x)) :rule-classes ((:rewrite :backchain-limit-lst (1))))