Fixing function for integer-range-p.
(integer-range-fix lower upper x) → fixed-x
Since the set denoted by integer-range-p
is empty for some values of
Since integer-range-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 integer-range-fix (lower upper x) (declare (xargs :guard (and (integerp lower) (integerp upper) (integer-range-p lower upper x)))) (let ((__function__ 'integer-range-fix)) (declare (ignorable __function__)) (mbe :logic (b* ((lower (ifix lower)) (upper (ifix upper)) (x (ifix x))) (if (< lower upper) (cond ((< x lower) lower) ((>= x upper) (1- upper)) (t x)) 0)) :exec x)))
Theorem:
(defthm return-type-of-integer-range-fix (implies (and (integerp lower) (integerp upper) (< lower upper)) (b* ((fixed-x (integer-range-fix lower upper x))) (integer-range-p lower upper fixed-x))) :rule-classes :rewrite)
Theorem:
(defthm integer-range-fix-when-integer-range-p (implies (and (integer-range-p (ifix lower) (ifix upper) x) (< (ifix lower) (ifix upper))) (equal (integer-range-fix lower upper x) x)))
Theorem:
(defthm integer-range-fix-of-ifix-lower (equal (integer-range-fix (ifix lower) upper x) (integer-range-fix lower upper x)))
Theorem:
(defthm integer-range-fix-int-equiv-congruence-on-lower (implies (int-equiv lower lower-equiv) (equal (integer-range-fix lower upper x) (integer-range-fix lower-equiv upper x))) :rule-classes :congruence)
Theorem:
(defthm integer-range-fix-of-ifix-upper (equal (integer-range-fix lower (ifix upper) x) (integer-range-fix lower upper x)))
Theorem:
(defthm integer-range-fix-int-equiv-congruence-on-upper (implies (int-equiv upper upper-equiv) (equal (integer-range-fix lower upper x) (integer-range-fix lower upper-equiv x))) :rule-classes :congruence)