(bitscan-rev src) returns the bit position of the most significant
bit in
Examples:
(bitscan-rev #b0001) = 0 (bitscan-rev #b0011) = 1 (bitscan-rev #b0101) = 2 (bitscan-rev #b1001) = 3
Function:
(defun bitscan-rev (src) (declare (xargs :guard (natp src))) (let ((__function__ 'bitscan-rev)) (declare (ignorable __function__)) (if (zp src) 0 (let ((next (ash src -1))) (if (= next 0) 0 (+ 1 (bitscan-rev next)))))))
Theorem:
(defthm acl2::natp-of-bitscan-rev (b* ((position (bitscan-rev src))) (natp position)) :rule-classes :type-prescription)
Theorem:
(defthm nat-equiv-implies-equal-bitscan-rev-1 (implies (nat-equiv src src-equiv) (equal (bitscan-rev src) (bitscan-rev src-equiv))) :rule-classes (:congruence))