Fixing function for unsigned-byte-p.
(unsigned-byte-fix bits x) → fixed-x
Since the set denoted by unsigned-byte-p
is empty for some values of
Since unsigned-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 unsigned-byte-fix (bits x) (declare (xargs :guard (and (natp bits) (unsigned-byte-p bits x)))) (let ((__function__ 'unsigned-byte-fix)) (declare (ignorable __function__)) (mbe :logic (b* ((bits (nfix bits))) (if (unsigned-byte-p bits x) x 0)) :exec x)))
Theorem:
(defthm return-type-of-unsigned-byte-fix (implies (natp bits) (b* ((fixed-x (unsigned-byte-fix bits x))) (unsigned-byte-p bits fixed-x))) :rule-classes :rewrite)
Theorem:
(defthm unsigned-byte-fix-when-unsigned-byte-p (implies (unsigned-byte-p (nfix bits) x) (equal (unsigned-byte-fix bits x) x)))
Theorem:
(defthm unsigned-byte-fix-of-nfix-bits (equal (unsigned-byte-fix (nfix bits) x) (unsigned-byte-fix bits x)))
Theorem:
(defthm unsigned-byte-fix-of-nfix-bits-normalize-const (implies (syntaxp (and (quotep bits) (not (natp (cadr bits))))) (equal (unsigned-byte-fix bits x) (unsigned-byte-fix (nfix bits) x))))