Function:
(defun s4vec-onehot (x) (declare (xargs :guard (s4vec-p x))) (let ((__function__ 's4vec-onehot)) (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 (bool->bit (eql (logcount xval) 1)))))))
Theorem:
(defthm s4vec-p-of-s4vec-onehot (b* ((res (s4vec-onehot x))) (s4vec-p res)) :rule-classes :rewrite)
Theorem:
(defthm s4vec-onehot-correct (b* ((?res (s4vec-onehot x))) (equal (s4vec->4vec res) (4vec-onehot (s4vec->4vec x)))))
Theorem:
(defthm s4vec-onehot-of-s4vec-fix-x (equal (s4vec-onehot (s4vec-fix x)) (s4vec-onehot x)))
Theorem:
(defthm s4vec-onehot-s4vec-equiv-congruence-on-x (implies (s4vec-equiv x x-equiv) (equal (s4vec-onehot x) (s4vec-onehot x-equiv))) :rule-classes :congruence)