Fixing function for signed-byte-p.
(signed-byte-fix bits x) → fixed-x
Since the set denoted by signed-byte-p
is empty for some values of
Since signed-byte-p is enabled by default, this fixing function is also enabled by default. When these functions are enabled, they are meant as abbreviations, and theorems triggered by them may not fire during proofs.
Function:
(defun signed-byte-fix (bits x) (declare (xargs :guard (and (posp bits) (signed-byte-p bits x)))) (let ((__function__ 'signed-byte-fix)) (declare (ignorable __function__)) (mbe :logic (b* ((bits (pos-fix bits))) (if (signed-byte-p bits x) x 0)) :exec x)))
Theorem:
(defthm return-type-of-signed-byte-fix (implies (posp bits) (b* ((fixed-x (signed-byte-fix bits x))) (signed-byte-p bits fixed-x))) :rule-classes :rewrite)
Theorem:
(defthm signed-byte-fix-when-signed-byte-p (implies (signed-byte-p (pos-fix bits) x) (equal (signed-byte-fix bits x) x)))
Theorem:
(defthm signed-byte-fix-of-pos-fix-bits (equal (signed-byte-fix (pos-fix bits) x) (signed-byte-fix bits x)))
Theorem:
(defthm signed-byte-fix-of-pos-fix-bits-normalize-const (implies (syntaxp (and (quotep bits) (not (natp (cadr bits))))) (equal (signed-byte-fix bits x) (signed-byte-fix (pos-fix bits) x))))