Rotate a bit-vector by a single place to the left.
Function:
(defun rotate-left-1 (x width) (declare (xargs :guard (and (integerp x) (posp width)))) (let ((__function__ 'rotate-left-1)) (declare (ignorable __function__)) (b* (((when (mbe :logic (zp width) :exec nil)) 0) (msb (logbit (- width 1) x)) (chop (loghead (- width 1) x))) (logcons msb chop))))
Theorem:
(defthm acl2::natp-of-rotate-left-1 (b* ((rotated (rotate-left-1 x width))) (natp rotated)) :rule-classes :type-prescription)
Theorem:
(defthm int-equiv-implies-equal-rotate-left-1-1 (implies (int-equiv x x-equiv) (equal (rotate-left-1 x width) (rotate-left-1 x-equiv width))) :rule-classes (:congruence))
Theorem:
(defthm nat-equiv-implies-equal-rotate-left-1-2 (implies (nat-equiv width width-equiv) (equal (rotate-left-1 x width) (rotate-left-1 x width-equiv))) :rule-classes (:congruence))
Theorem:
(defthm logbitp-of-rotate-left-1-split (equal (logbitp n (rotate-left-1 x width)) (b* ((n (nfix n)) (width (nfix width))) (cond ((>= n width) nil) ((equal n 0) (logbitp (+ -1 width) x)) (t (logbitp (+ -1 n) x))))))
Theorem:
(defthm unsigned-byte-p-of-rotate-left-1 (implies (natp width) (unsigned-byte-p width (rotate-left-1 x width))))