(all-equalp a x) determines if every member of
(all-equalp a x) → *
In the logic, we define
We usually leave this enabled and prefer to reason about
For better execution speed, we use a recursive definition that does no consing.
Function:
(defun all-equalp (a x) (declare (xargs :guard t)) (let ((__function__ 'all-equalp)) (declare (ignorable __function__)) (mbe :logic (equal (list-fix x) (repeat (len x) a)) :exec (if (consp x) (and (equal a (car x)) (all-equalp a (cdr x))) t))))
Theorem:
(defthm all-equalp-when-atom (implies (atom x) (all-equalp a x)))
Theorem:
(defthm all-equalp-of-cons (equal (all-equalp a (cons b x)) (and (equal a b) (all-equalp a x))))
Theorem:
(defthm car-when-all-equalp (implies (all-equalp a x) (equal (car x) (if (consp x) a nil))) :rule-classes ((:rewrite :backchain-limit-lst 0)))
Theorem:
(defthm all-equalp-of-cdr-when-all-equalp (implies (all-equalp a x) (all-equalp a (cdr x))))
Theorem:
(defthm member-equal-when-all-equalp (implies (all-equalp a x) (iff (member-equal b x) (and (consp x) (equal a b)))))
Theorem:
(defthm all-equalp-by-superset (implies (and (all-equalp a y) (subsetp-equal x y)) (all-equalp a x)))
Theorem:
(defthm set-equiv-implies-equal-all-equalp-2 (implies (set-equiv x x-equiv) (equal (all-equalp a x) (all-equalp a x-equiv))) :rule-classes (:congruence))
Theorem:
(defthm all-equalp-of-append (equal (all-equalp a (append x y)) (and (all-equalp a x) (all-equalp a y))))
Theorem:
(defthm all-equalp-of-list-fix (equal (all-equalp a (list-fix x)) (all-equalp a x)))
Theorem:
(defthm all-equalp-of-rev (equal (all-equalp a (rev x)) (all-equalp a x)))
Theorem:
(defthm all-equalp-of-repeat (equal (all-equalp a (repeat n b)) (or (equal a b) (zp n))))
Theorem:
(defthm all-equalp-of-take (implies (all-equalp a x) (equal (all-equalp a (take n x)) (or (not a) (<= (nfix n) (len x))))))
Theorem:
(defthm all-equalp-of-nthcdr (implies (all-equalp a x) (all-equalp a (nthcdr n x))))