Like logbit for 4vecs; the bit position must be a natp.
We extract the
We require that
For a more general (but less efficient) function that drops this restriction
and allows
Function:
(defun 4vec-bit-index (n x) (declare (xargs :guard (and (natp n) (4vec-p x)))) (let ((__function__ '4vec-bit-index)) (declare (ignorable __function__)) (if-2vec-p (x) (2vec (logbit (lnfix n) (2vec->val x))) (make-4vec :upper (logbit (lnfix n) (4vec->upper x)) :lower (logbit (lnfix n) (4vec->lower x))))))
Theorem:
(defthm 4vec-p-of-4vec-bit-index (b* ((bit (4vec-bit-index n x))) (4vec-p bit)) :rule-classes :rewrite)
Theorem:
(defthm 4vec-bit-index-of-nfix-n (equal (4vec-bit-index (nfix n) x) (4vec-bit-index n x)))
Theorem:
(defthm 4vec-bit-index-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (4vec-bit-index n x) (4vec-bit-index n-equiv x))) :rule-classes :congruence)
Theorem:
(defthm 4vec-bit-index-of-4vec-fix-x (equal (4vec-bit-index n (4vec-fix x)) (4vec-bit-index n x)))
Theorem:
(defthm 4vec-bit-index-4vec-equiv-congruence-on-x (implies (4vec-equiv x x-equiv) (equal (4vec-bit-index n x) (4vec-bit-index n x-equiv))) :rule-classes :congruence)