Count the 1 bits in a sparseint if positive, 0 bits if negative, starting from offset.
(sparseint-bitcount-from offset x) → count
Function:
(defun sparseint-bitcount-from (offset x) (declare (xargs :guard (and (natp offset) (sparseint-p x)))) (let ((__function__ 'sparseint-bitcount-from)) (declare (ignorable __function__)) (sparseint$-bitcount-rec offset (bool->bit (sparseint-< x 0)) (sparseint-fix x))))
Theorem:
(defthm natp-of-sparseint-bitcount-from (b* ((count (sparseint-bitcount-from offset x))) (natp count)) :rule-classes :type-prescription)
Theorem:
(defthm sparseint-bitcount-from-correct (b* ((common-lisp::?count (sparseint-bitcount-from offset x))) (equal count (logcount (logtail offset (sparseint-val x))))))
Theorem:
(defthm sparseint-bitcount-from-of-nfix-offset (equal (sparseint-bitcount-from (nfix offset) x) (sparseint-bitcount-from offset x)))
Theorem:
(defthm sparseint-bitcount-from-nat-equiv-congruence-on-offset (implies (nat-equiv offset offset-equiv) (equal (sparseint-bitcount-from offset x) (sparseint-bitcount-from offset-equiv x))) :rule-classes :congruence)
Theorem:
(defthm sparseint-bitcount-from-of-sparseint-fix-x (equal (sparseint-bitcount-from offset (sparseint-fix x)) (sparseint-bitcount-from offset x)))
Theorem:
(defthm sparseint-bitcount-from-sparseint-equiv-congruence-on-x (implies (sparseint-equiv x x-equiv) (equal (sparseint-bitcount-from offset x) (sparseint-bitcount-from offset x-equiv))) :rule-classes :congruence)