Fixing function for sparseint$ structures.
(sparseint$-fix x) → new-x
Function:
(defun sparseint$-fix$inline (x) (declare (xargs :guard (sparseint$-p x))) (let ((__function__ 'sparseint$-fix)) (declare (ignorable __function__)) (mbe :logic (case (sparseint$-kind x) (:leaf (b* ((val (ifix x))) val)) (:concat (b* ((width (pos-fix (logtail 2 (car x)))) (lsbs-taller (acl2::bool-fix (logbitp 0 (car x)))) (msbs-taller (acl2::bool-fix (logbitp 1 (car x)))) (lsbs (sparseint$-fix (cadr x))) (msbs (sparseint$-fix (cddr x)))) (cons (logcons (bool->bit lsbs-taller) (logcons (bool->bit msbs-taller) width)) (cons lsbs msbs))))) :exec x)))
Theorem:
(defthm sparseint$-p-of-sparseint$-fix (b* ((new-x (sparseint$-fix$inline x))) (sparseint$-p new-x)) :rule-classes :rewrite)
Theorem:
(defthm sparseint$-fix-when-sparseint$-p (implies (sparseint$-p x) (equal (sparseint$-fix x) x)))
Function:
(defun sparseint$-equiv$inline (x y) (declare (xargs :guard (and (sparseint$-p x) (sparseint$-p y)))) (equal (sparseint$-fix x) (sparseint$-fix y)))
Theorem:
(defthm sparseint$-equiv-is-an-equivalence (and (booleanp (sparseint$-equiv x y)) (sparseint$-equiv x x) (implies (sparseint$-equiv x y) (sparseint$-equiv y x)) (implies (and (sparseint$-equiv x y) (sparseint$-equiv y z)) (sparseint$-equiv x z))) :rule-classes (:equivalence))
Theorem:
(defthm sparseint$-equiv-implies-equal-sparseint$-fix-1 (implies (sparseint$-equiv x x-equiv) (equal (sparseint$-fix x) (sparseint$-fix x-equiv))) :rule-classes (:congruence))
Theorem:
(defthm sparseint$-fix-under-sparseint$-equiv (sparseint$-equiv (sparseint$-fix x) x) :rule-classes (:rewrite :rewrite-quoted-constant))
Theorem:
(defthm equal-of-sparseint$-fix-1-forward-to-sparseint$-equiv (implies (equal (sparseint$-fix x) y) (sparseint$-equiv x y)) :rule-classes :forward-chaining)
Theorem:
(defthm equal-of-sparseint$-fix-2-forward-to-sparseint$-equiv (implies (equal x (sparseint$-fix y)) (sparseint$-equiv x y)) :rule-classes :forward-chaining)
Theorem:
(defthm sparseint$-equiv-of-sparseint$-fix-1-forward (implies (sparseint$-equiv (sparseint$-fix x) y) (sparseint$-equiv x y)) :rule-classes :forward-chaining)
Theorem:
(defthm sparseint$-equiv-of-sparseint$-fix-2-forward (implies (sparseint$-equiv x (sparseint$-fix y)) (sparseint$-equiv x y)) :rule-classes :forward-chaining)
Theorem:
(defthm sparseint$-kind$inline-of-sparseint$-fix-x (equal (sparseint$-kind$inline (sparseint$-fix x)) (sparseint$-kind$inline x)))
Theorem:
(defthm sparseint$-kind$inline-sparseint$-equiv-congruence-on-x (implies (sparseint$-equiv x x-equiv) (equal (sparseint$-kind$inline x) (sparseint$-kind$inline x-equiv))) :rule-classes :congruence)