(install-bit n val x) sets
Function:
(defun install-bit (n val x) (declare (xargs :guard (and (natp n) (bitp val) (integerp x)))) (let ((__function__ 'install-bit)) (declare (ignorable __function__)) (mbe :logic (b* ((x (ifix x)) (n (nfix n)) (val (bfix val)) (place (ash 1 n)) (mask (lognot place))) (logior (logand x mask) (ash val n))) :exec (logior (logand x (lognot (ash 1 n))) (ash val n)))))
Theorem:
(defthm install-bit** (equal (install-bit n val x) (if (zp n) (logcons val (logcdr x)) (logcons (logcar x) (install-bit (1- n) val (logcdr x))))) :rule-classes ((:definition :clique (install-bit) :controller-alist ((install-bit t nil nil)))))
Theorem:
(defthm natp-install-bit (implies (not (and (integerp x) (< x 0))) (natp (install-bit n val x))) :rule-classes :type-prescription)
Theorem:
(defthm nat-equiv-implies-equal-install-bit-1 (implies (nat-equiv n n-equiv) (equal (install-bit n val x) (install-bit n-equiv val x))) :rule-classes (:congruence))
Theorem:
(defthm bit-equiv-implies-equal-install-bit-2 (implies (bit-equiv val val-equiv) (equal (install-bit n val x) (install-bit n val-equiv x))) :rule-classes (:congruence))
Theorem:
(defthm int-equiv-implies-equal-install-bit-3 (implies (int-equiv x x-equiv) (equal (install-bit n val x) (install-bit n val x-equiv))) :rule-classes (:congruence))
Theorem:
(defthm logbitp-of-install-bit-split (equal (logbitp m (install-bit n val x)) (if (= (nfix m) (nfix n)) (equal val 1) (logbitp m x))))
Theorem:
(defthm logbitp-of-install-bit-same (equal (logbitp m (install-bit m val x)) (equal val 1)))
Theorem:
(defthm logbitp-of-install-bit-diff (implies (not (equal (nfix m) (nfix n))) (equal (logbitp m (install-bit n val x)) (logbitp m x))))
Theorem:
(defthm install-bit-of-install-bit-same (equal (install-bit a v (install-bit a v2 x)) (install-bit a v x)))
Theorem:
(defthm install-bit-of-install-bit-diff (implies (not (equal (nfix a) (nfix b))) (equal (install-bit a v (install-bit b v2 x)) (install-bit b v2 (install-bit a v x)))) :rule-classes ((:rewrite :loop-stopper ((a b install-bit)))))
Theorem:
(defthm install-bit-when-redundant (implies (equal (logbit n x) b) (equal (install-bit n b x) (ifix x))))
Theorem:
(defthm unsigned-byte-p-of-install-bit (implies (and (unsigned-byte-p n x) (< (nfix i) n)) (unsigned-byte-p n (install-bit i v x))))