Bitstruct definitions to store a ModR/M byte and its fields.
Function:
(defun modr/m-p$inline (x) (declare (xargs :guard t)) (mbe :logic (unsigned-byte-p 8 x) :exec (and (natp x) (< x 256))))
Theorem:
(defthm modr/m-p-when-unsigned-byte-p (implies (unsigned-byte-p 8 x) (modr/m-p x)))
Theorem:
(defthm unsigned-byte-p-when-modr/m-p (implies (modr/m-p x) (unsigned-byte-p 8 x)))
Theorem:
(defthm modr/m-p-compound-recognizer (implies (modr/m-p x) (natp x)) :rule-classes :compound-recognizer)
Function:
(defun modr/m-fix$inline (x) (declare (xargs :guard (modr/m-p x))) (mbe :logic (loghead 8 x) :exec x))
Theorem:
(defthm modr/m-p-of-modr/m-fix (b* ((fty::fixed (modr/m-fix$inline x))) (modr/m-p fty::fixed)) :rule-classes :rewrite)
Theorem:
(defthm modr/m-fix-when-modr/m-p (implies (modr/m-p x) (equal (modr/m-fix x) x)))
Function:
(defun modr/m-equiv$inline (x y) (declare (xargs :guard (and (modr/m-p x) (modr/m-p y)))) (equal (modr/m-fix x) (modr/m-fix y)))
Theorem:
(defthm modr/m-equiv-is-an-equivalence (and (booleanp (modr/m-equiv x y)) (modr/m-equiv x x) (implies (modr/m-equiv x y) (modr/m-equiv y x)) (implies (and (modr/m-equiv x y) (modr/m-equiv y z)) (modr/m-equiv x z))) :rule-classes (:equivalence))
Theorem:
(defthm modr/m-equiv-implies-equal-modr/m-fix-1 (implies (modr/m-equiv x x-equiv) (equal (modr/m-fix x) (modr/m-fix x-equiv))) :rule-classes (:congruence))
Theorem:
(defthm modr/m-fix-under-modr/m-equiv (modr/m-equiv (modr/m-fix x) x) :rule-classes (:rewrite :rewrite-quoted-constant))
Function:
(defun modr/m$inline (r/m reg mod) (declare (xargs :guard (and (3bits-p r/m) (3bits-p reg) (2bits-p mod)))) (b* ((r/m (mbe :logic (3bits-fix r/m) :exec r/m)) (reg (mbe :logic (3bits-fix reg) :exec reg)) (mod (mbe :logic (2bits-fix mod) :exec mod))) (logapp 3 r/m (logapp 3 reg mod))))
Theorem:
(defthm modr/m-p-of-modr/m (b* ((modr/m (modr/m$inline r/m reg mod))) (modr/m-p modr/m)) :rule-classes :rewrite)
Theorem:
(defthm modr/m$inline-of-3bits-fix-r/m (equal (modr/m$inline (3bits-fix r/m) reg mod) (modr/m$inline r/m reg mod)))
Theorem:
(defthm modr/m$inline-3bits-equiv-congruence-on-r/m (implies (3bits-equiv r/m r/m-equiv) (equal (modr/m$inline r/m reg mod) (modr/m$inline r/m-equiv reg mod))) :rule-classes :congruence)
Theorem:
(defthm modr/m$inline-of-3bits-fix-reg (equal (modr/m$inline r/m (3bits-fix reg) mod) (modr/m$inline r/m reg mod)))
Theorem:
(defthm modr/m$inline-3bits-equiv-congruence-on-reg (implies (3bits-equiv reg reg-equiv) (equal (modr/m$inline r/m reg mod) (modr/m$inline r/m reg-equiv mod))) :rule-classes :congruence)
Theorem:
(defthm modr/m$inline-of-2bits-fix-mod (equal (modr/m$inline r/m reg (2bits-fix mod)) (modr/m$inline r/m reg mod)))
Theorem:
(defthm modr/m$inline-2bits-equiv-congruence-on-mod (implies (2bits-equiv mod mod-equiv) (equal (modr/m$inline r/m reg mod) (modr/m$inline r/m reg mod-equiv))) :rule-classes :congruence)
Function:
(defun modr/m-equiv-under-mask$inline (x x1 mask) (declare (xargs :guard (and (modr/m-p x) (modr/m-p x1) (integerp mask)))) (fty::int-equiv-under-mask (modr/m-fix x) (modr/m-fix x1) mask))
Function:
(defun modr/m->r/m$inline (x) (declare (xargs :guard (modr/m-p x))) (mbe :logic (let ((x (modr/m-fix x))) (part-select x :low 0 :width 3)) :exec (the (unsigned-byte 3) (logand (the (unsigned-byte 3) 7) (the (unsigned-byte 8) x)))))
Theorem:
(defthm 3bits-p-of-modr/m->r/m (b* ((r/m (modr/m->r/m$inline x))) (3bits-p r/m)) :rule-classes :rewrite)
Theorem:
(defthm modr/m->r/m$inline-of-modr/m-fix-x (equal (modr/m->r/m$inline (modr/m-fix x)) (modr/m->r/m$inline x)))
Theorem:
(defthm modr/m->r/m$inline-modr/m-equiv-congruence-on-x (implies (modr/m-equiv x x-equiv) (equal (modr/m->r/m$inline x) (modr/m->r/m$inline x-equiv))) :rule-classes :congruence)
Theorem:
(defthm modr/m->r/m-of-modr/m (equal (modr/m->r/m (modr/m r/m reg mod)) (3bits-fix r/m)))
Theorem:
(defthm modr/m->r/m-of-write-with-mask (implies (and (fty::bitstruct-read-over-write-hyps x modr/m-equiv-under-mask) (modr/m-equiv-under-mask x y fty::mask) (equal (logand (lognot fty::mask) 7) 0)) (equal (modr/m->r/m x) (modr/m->r/m y))))
Function:
(defun modr/m->reg$inline (x) (declare (xargs :guard (modr/m-p x))) (mbe :logic (let ((x (modr/m-fix x))) (part-select x :low 3 :width 3)) :exec (the (unsigned-byte 3) (logand (the (unsigned-byte 3) 7) (the (unsigned-byte 5) (ash (the (unsigned-byte 8) x) -3))))))
Theorem:
(defthm 3bits-p-of-modr/m->reg (b* ((reg (modr/m->reg$inline x))) (3bits-p reg)) :rule-classes :rewrite)
Theorem:
(defthm modr/m->reg$inline-of-modr/m-fix-x (equal (modr/m->reg$inline (modr/m-fix x)) (modr/m->reg$inline x)))
Theorem:
(defthm modr/m->reg$inline-modr/m-equiv-congruence-on-x (implies (modr/m-equiv x x-equiv) (equal (modr/m->reg$inline x) (modr/m->reg$inline x-equiv))) :rule-classes :congruence)
Theorem:
(defthm modr/m->reg-of-modr/m (equal (modr/m->reg (modr/m r/m reg mod)) (3bits-fix reg)))
Theorem:
(defthm modr/m->reg-of-write-with-mask (implies (and (fty::bitstruct-read-over-write-hyps x modr/m-equiv-under-mask) (modr/m-equiv-under-mask x y fty::mask) (equal (logand (lognot fty::mask) 56) 0)) (equal (modr/m->reg x) (modr/m->reg y))))
Function:
(defun modr/m->mod$inline (x) (declare (xargs :guard (modr/m-p x))) (mbe :logic (let ((x (modr/m-fix x))) (part-select x :low 6 :width 2)) :exec (the (unsigned-byte 2) (logand (the (unsigned-byte 2) 3) (the (unsigned-byte 2) (ash (the (unsigned-byte 8) x) -6))))))
Theorem:
(defthm 2bits-p-of-modr/m->mod (b* ((mod (modr/m->mod$inline x))) (2bits-p mod)) :rule-classes :rewrite)
Theorem:
(defthm modr/m->mod$inline-of-modr/m-fix-x (equal (modr/m->mod$inline (modr/m-fix x)) (modr/m->mod$inline x)))
Theorem:
(defthm modr/m->mod$inline-modr/m-equiv-congruence-on-x (implies (modr/m-equiv x x-equiv) (equal (modr/m->mod$inline x) (modr/m->mod$inline x-equiv))) :rule-classes :congruence)
Theorem:
(defthm modr/m->mod-of-modr/m (equal (modr/m->mod (modr/m r/m reg mod)) (2bits-fix mod)))
Theorem:
(defthm modr/m->mod-of-write-with-mask (implies (and (fty::bitstruct-read-over-write-hyps x modr/m-equiv-under-mask) (modr/m-equiv-under-mask x y fty::mask) (equal (logand (lognot fty::mask) 192) 0)) (equal (modr/m->mod x) (modr/m->mod y))))
Theorem:
(defthm modr/m-fix-in-terms-of-modr/m (equal (modr/m-fix x) (change-modr/m x)))
Function:
(defun !modr/m->r/m$inline (r/m x) (declare (xargs :guard (and (3bits-p r/m) (modr/m-p x)))) (mbe :logic (b* ((r/m (mbe :logic (3bits-fix r/m) :exec r/m)) (x (modr/m-fix x))) (part-install r/m x :width 3 :low 0)) :exec (the (unsigned-byte 8) (logior (the (unsigned-byte 8) (logand (the (unsigned-byte 8) x) (the (signed-byte 4) -8))) (the (unsigned-byte 3) r/m)))))
Theorem:
(defthm modr/m-p-of-!modr/m->r/m (b* ((new-x (!modr/m->r/m$inline r/m x))) (modr/m-p new-x)) :rule-classes :rewrite)
Theorem:
(defthm !modr/m->r/m$inline-of-3bits-fix-r/m (equal (!modr/m->r/m$inline (3bits-fix r/m) x) (!modr/m->r/m$inline r/m x)))
Theorem:
(defthm !modr/m->r/m$inline-3bits-equiv-congruence-on-r/m (implies (3bits-equiv r/m r/m-equiv) (equal (!modr/m->r/m$inline r/m x) (!modr/m->r/m$inline r/m-equiv x))) :rule-classes :congruence)
Theorem:
(defthm !modr/m->r/m$inline-of-modr/m-fix-x (equal (!modr/m->r/m$inline r/m (modr/m-fix x)) (!modr/m->r/m$inline r/m x)))
Theorem:
(defthm !modr/m->r/m$inline-modr/m-equiv-congruence-on-x (implies (modr/m-equiv x x-equiv) (equal (!modr/m->r/m$inline r/m x) (!modr/m->r/m$inline r/m x-equiv))) :rule-classes :congruence)
Theorem:
(defthm !modr/m->r/m-is-modr/m (equal (!modr/m->r/m r/m x) (change-modr/m x :r/m r/m)))
Theorem:
(defthm modr/m->r/m-of-!modr/m->r/m (b* ((?new-x (!modr/m->r/m$inline r/m x))) (equal (modr/m->r/m new-x) (3bits-fix r/m))))
Theorem:
(defthm !modr/m->r/m-equiv-under-mask (b* ((?new-x (!modr/m->r/m$inline r/m x))) (modr/m-equiv-under-mask new-x x -8)))
Function:
(defun !modr/m->reg$inline (reg x) (declare (xargs :guard (and (3bits-p reg) (modr/m-p x)))) (mbe :logic (b* ((reg (mbe :logic (3bits-fix reg) :exec reg)) (x (modr/m-fix x))) (part-install reg x :width 3 :low 3)) :exec (the (unsigned-byte 8) (logior (the (unsigned-byte 8) (logand (the (unsigned-byte 8) x) (the (signed-byte 7) -57))) (the (unsigned-byte 6) (ash (the (unsigned-byte 3) reg) 3))))))
Theorem:
(defthm modr/m-p-of-!modr/m->reg (b* ((new-x (!modr/m->reg$inline reg x))) (modr/m-p new-x)) :rule-classes :rewrite)
Theorem:
(defthm !modr/m->reg$inline-of-3bits-fix-reg (equal (!modr/m->reg$inline (3bits-fix reg) x) (!modr/m->reg$inline reg x)))
Theorem:
(defthm !modr/m->reg$inline-3bits-equiv-congruence-on-reg (implies (3bits-equiv reg reg-equiv) (equal (!modr/m->reg$inline reg x) (!modr/m->reg$inline reg-equiv x))) :rule-classes :congruence)
Theorem:
(defthm !modr/m->reg$inline-of-modr/m-fix-x (equal (!modr/m->reg$inline reg (modr/m-fix x)) (!modr/m->reg$inline reg x)))
Theorem:
(defthm !modr/m->reg$inline-modr/m-equiv-congruence-on-x (implies (modr/m-equiv x x-equiv) (equal (!modr/m->reg$inline reg x) (!modr/m->reg$inline reg x-equiv))) :rule-classes :congruence)
Theorem:
(defthm !modr/m->reg-is-modr/m (equal (!modr/m->reg reg x) (change-modr/m x :reg reg)))
Theorem:
(defthm modr/m->reg-of-!modr/m->reg (b* ((?new-x (!modr/m->reg$inline reg x))) (equal (modr/m->reg new-x) (3bits-fix reg))))
Theorem:
(defthm !modr/m->reg-equiv-under-mask (b* ((?new-x (!modr/m->reg$inline reg x))) (modr/m-equiv-under-mask new-x x -57)))
Function:
(defun !modr/m->mod$inline (mod x) (declare (xargs :guard (and (2bits-p mod) (modr/m-p x)))) (mbe :logic (b* ((mod (mbe :logic (2bits-fix mod) :exec mod)) (x (modr/m-fix x))) (part-install mod x :width 2 :low 6)) :exec (the (unsigned-byte 8) (logior (the (unsigned-byte 8) (logand (the (unsigned-byte 8) x) (the (signed-byte 9) -193))) (the (unsigned-byte 8) (ash (the (unsigned-byte 2) mod) 6))))))
Theorem:
(defthm modr/m-p-of-!modr/m->mod (b* ((new-x (!modr/m->mod$inline mod x))) (modr/m-p new-x)) :rule-classes :rewrite)
Theorem:
(defthm !modr/m->mod$inline-of-2bits-fix-mod (equal (!modr/m->mod$inline (2bits-fix mod) x) (!modr/m->mod$inline mod x)))
Theorem:
(defthm !modr/m->mod$inline-2bits-equiv-congruence-on-mod (implies (2bits-equiv mod mod-equiv) (equal (!modr/m->mod$inline mod x) (!modr/m->mod$inline mod-equiv x))) :rule-classes :congruence)
Theorem:
(defthm !modr/m->mod$inline-of-modr/m-fix-x (equal (!modr/m->mod$inline mod (modr/m-fix x)) (!modr/m->mod$inline mod x)))
Theorem:
(defthm !modr/m->mod$inline-modr/m-equiv-congruence-on-x (implies (modr/m-equiv x x-equiv) (equal (!modr/m->mod$inline mod x) (!modr/m->mod$inline mod x-equiv))) :rule-classes :congruence)
Theorem:
(defthm !modr/m->mod-is-modr/m (equal (!modr/m->mod mod x) (change-modr/m x :mod mod)))
Theorem:
(defthm modr/m->mod-of-!modr/m->mod (b* ((?new-x (!modr/m->mod$inline mod x))) (equal (modr/m->mod new-x) (2bits-fix mod))))
Theorem:
(defthm !modr/m->mod-equiv-under-mask (b* ((?new-x (!modr/m->mod$inline mod x))) (modr/m-equiv-under-mask new-x x 63)))
Function:
(defun modr/m-debug$inline (x) (declare (xargs :guard (modr/m-p x))) (b* (((modr/m x))) (cons (cons 'r/m x.r/m) (cons (cons 'reg x.reg) (cons (cons 'mod x.mod) nil)))))
Theorem:
(defthm return-type-of-modr/m->r/m-linear (< (modr/m->r/m modr/m) 8) :rule-classes :linear)
Theorem:
(defthm return-type-of-modr/m->reg-linear (< (modr/m->reg modr/m) 8) :rule-classes :linear)
Theorem:
(defthm return-type-of-modr/m->mod-linear (< (modr/m->mod modr/m) 4) :rule-classes :linear)