Function:
(defun s4vec-countones (x) (declare (xargs :guard (s4vec-p x))) (let ((__function__ 's4vec-countones)) (declare (ignorable __function__)) (b* (((unless (s4vec-2vec-p x)) (s4vec-x)) (xint (s4vec->upper x)) ((when (sparseint-< xint 0)) (s4vec-x)) (xval (s4vec-sparseint-val (s4vec->upper x)))) (s2vec (int-to-sparseint (logcount xval))))))
Theorem:
(defthm s4vec-p-of-s4vec-countones (b* ((res (s4vec-countones x))) (s4vec-p res)) :rule-classes :rewrite)
Theorem:
(defthm s4vec-countones-correct (b* ((?res (s4vec-countones x))) (equal (s4vec->4vec res) (4vec-countones (s4vec->4vec x)))))
Theorem:
(defthm s4vec-countones-of-s4vec-fix-x (equal (s4vec-countones (s4vec-fix x)) (s4vec-countones x)))
Theorem:
(defthm s4vec-countones-s4vec-equiv-congruence-on-x (implies (s4vec-equiv x x-equiv) (equal (s4vec-countones x) (s4vec-countones x-equiv))) :rule-classes :congruence)