Recognizer, fixer, constructor, and destructor of
Java
We define the recognizer analogously to the one of
the fixtypes of other Java primitive values,
by tagging the underlying values introduced in doublex-value-abs.
The recognizer is non-empty if and only if
doublex-param is non-
Function:
(defun doublex-valuep (x) (declare (xargs :guard t)) (let ((__function__ 'doublex-valuep)) (declare (ignorable __function__)) (and (tuplep 2 x) (eq (first x) :doublex) (doublex-value-abs-p (second x)))))
Theorem:
(defthm booleanp-of-doublex-valuep (b* ((yes/no (doublex-valuep x))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(defthm no-doublex-value-when-unsupported (implies (not (doublex-param)) (not (doublex-valuep x))))
Function:
(defun doublex-value-fix (x) (declare (xargs :guard (doublex-valuep x))) (let ((__function__ 'doublex-value-fix)) (declare (ignorable __function__)) (mbe :logic (if (doublex-valuep x) x (list :doublex (doublex-value-abs-pos-zero))) :exec x)))
Theorem:
(defthm doublex-valuep-of-doublex-value-fix (implies (doublex-param) (b* ((fixed-x (doublex-value-fix x))) (doublex-valuep fixed-x))) :rule-classes :rewrite)
Theorem:
(defthm doublex-value-fix-when-doublex-valuep (implies (doublex-valuep x) (equal (doublex-value-fix x) x)))
Function:
(defun doublex-value (x) (declare (xargs :guard (doublex-value-abs-p x))) (let ((__function__ 'doublex-value)) (declare (ignorable __function__)) (list :doublex (doublex-value-abs-fix x))))
Theorem:
(defthm doublex-valuep-of-doublex-value (implies (doublex-param) (b* ((value (doublex-value x))) (doublex-valuep value))) :rule-classes :rewrite)
Function:
(defun doublex-value->doublex (value) (declare (xargs :guard (doublex-valuep value))) (let ((__function__ 'doublex-value->doublex)) (declare (ignorable __function__)) (second (doublex-value-fix value))))
Theorem:
(defthm doublex-value-abs-p-of-doublex-value->doublex (implies (doublex-param) (b* ((x (doublex-value->doublex value))) (doublex-value-abs-p x))) :rule-classes :rewrite)
Theorem:
(defthm doublex-value->doublex-of-doublex-value (implies (doublex-param) (equal (doublex-value->doublex (doublex-value x)) (doublex-value-abs-fix x))))