Change the sign bit of an integer to a new value.
Function:
(defun int-set-sign (negp i) (declare (xargs :guard (integerp i))) (let ((__function__ 'int-set-sign)) (declare (ignorable __function__)) (let ((i (lifix i))) (logapp (integer-length i) i (if negp -1 0)))))
Theorem:
(defthm integerp-of-int-set-sign (b* ((new-i (int-set-sign negp i))) (integerp new-i)) :rule-classes :type-prescription)
Theorem:
(defthm sign-of-int-set-sign (iff (< (int-set-sign negp i) 0) negp))