Check if a mathematical integer is
in the range of (i.e. representable in) type
Function:
(defun ushort-rangep (val ienv) (declare (xargs :guard (and (integerp val) (ienvp ienv)))) (let ((__function__ 'ushort-rangep)) (declare (ignorable __function__)) (and (<= 0 (ifix val)) (<= (ifix val) (ushort-max ienv)))))
Theorem:
(defthm booleanp-of-ushort-rangep (b* ((yes/no (ushort-rangep val ienv))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(defthm ushort-rangep-of-ifix-val (equal (ushort-rangep (ifix val) ienv) (ushort-rangep val ienv)))
Theorem:
(defthm ushort-rangep-int-equiv-congruence-on-val (implies (acl2::int-equiv val val-equiv) (equal (ushort-rangep val ienv) (ushort-rangep val-equiv ienv))) :rule-classes :congruence)
Theorem:
(defthm ushort-rangep-of-ienv-fix-ienv (equal (ushort-rangep val (ienv-fix ienv)) (ushort-rangep val ienv)))
Theorem:
(defthm ushort-rangep-ienv-equiv-congruence-on-ienv (implies (ienv-equiv ienv ienv-equiv) (equal (ushort-rangep val ienv) (ushort-rangep val ienv-equiv))) :rule-classes :congruence)