• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
      • X86isa
        • Program-execution
        • Introduction
        • X86isa-build-instructions
        • Publications
        • Contributors
        • Machine
        • Implemented-opcodes
        • Proof-utilities
        • To-do
        • Concrete-simulation-examples
        • Model-validation
        • Utils
          • Structures
            • Rflagsbits
            • Cr4bits
            • Cr0bits
            • Xcr0bits
            • Prefixes
            • Ia32_eferbits
            • Evex-byte1
            • Cr3bits
            • Evex-byte3
            • Vex3-byte2
            • Vex3-byte1
            • Vex2-byte1
            • Evex-prefixes
            • Evex-byte2
            • Vex-prefixes
            • Sib
            • Modr/m-structures
            • Vex-prefixes-layout-structures
              • Sib-structures
              • Legacy-prefixes-layout-structure
              • Evex-prefixes-layout-structures
              • Cr8bits
              • Opcode-maps-structures
              • Segmentation-bitstructs
              • 8bits
              • 2bits
              • 4bits
              • 16bits
              • Paging-bitstructs
              • 3bits
              • 11bits
              • 40bits
              • 5bits
              • 32bits
              • 19bits
              • 10bits
              • 64bits
              • 7bits
              • 54bits
              • 31bits
              • 24bits
              • 22bits
              • 17bits
              • 13bits
              • 12bits
              • 6bits
              • Vex-prefixes-map-p
              • Vex-prefixes-byte0-p
              • Vex->w
              • Vex->vvvv
              • Fp-bitstructs
              • Vex->pp
              • Vex->l
              • Rflagsbits-debug
              • Evex->v-prime
              • Cr4bits-debug
              • Evex->z
              • Evex->w
              • Evex->vvvv
              • Evex->vl/rc
              • Evex->pp
              • Evex->aaa
              • Vex3-byte1-equiv-under-mask
              • Xcr0bits-debug
              • Vex3-byte2-equiv-under-mask
              • Vex2-byte1-equiv-under-mask
              • Vex-prefixes-equiv-under-mask
              • Rflagsbits-equiv-under-mask
              • Ia32_eferbits-equiv-under-mask
              • Evex-prefixes-equiv-under-mask
              • Evex-byte3-equiv-under-mask
              • Evex-byte2-equiv-under-mask
              • Evex-byte1-equiv-under-mask
              • Cr0bits-debug
              • Xcr0bits-equiv-under-mask
              • Sib-equiv-under-mask
              • Prefixes-equiv-under-mask
              • Cr8bits-equiv-under-mask
              • Cr4bits-equiv-under-mask
              • Cr3bits-equiv-under-mask
              • Cr0bits-equiv-under-mask
              • Vex3-byte1-debug
              • Prefixes-debug
              • Ia32_eferbits-debug
              • Evex-byte1-debug
              • Vex3-byte2-debug
              • Vex2-byte1-debug
              • Vex-prefixes-debug
              • Evex-prefixes-debug
              • Evex-byte3-debug
              • Evex-byte2-debug
              • Cr3bits-debug
              • Sib-debug
              • Cr8bits-debug
            • Utilities
          • Debugging-code-proofs
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Structures

    Vex-prefixes-layout-structures

    Functions to decode and collect VEX prefix bytes from an x86 instruction

    Definitions and Theorems

    Function: vex-prefixes-p$inline

    (defun vex-prefixes-p$inline (x)
      (declare (xargs :guard t))
      (mbe :logic (unsigned-byte-p 24 x)
           :exec (and (natp x) (< x 16777216))))

    Theorem: vex-prefixes-p-when-unsigned-byte-p

    (defthm vex-prefixes-p-when-unsigned-byte-p
      (implies (unsigned-byte-p 24 x)
               (vex-prefixes-p x)))

    Theorem: unsigned-byte-p-when-vex-prefixes-p

    (defthm unsigned-byte-p-when-vex-prefixes-p
      (implies (vex-prefixes-p x)
               (unsigned-byte-p 24 x)))

    Theorem: vex-prefixes-p-compound-recognizer

    (defthm vex-prefixes-p-compound-recognizer
      (implies (vex-prefixes-p x) (natp x))
      :rule-classes :compound-recognizer)

    Function: vex-prefixes-fix$inline

    (defun vex-prefixes-fix$inline (x)
      (declare (xargs :guard (vex-prefixes-p x)))
      (mbe :logic (loghead 24 x) :exec x))

    Theorem: vex-prefixes-p-of-vex-prefixes-fix

    (defthm vex-prefixes-p-of-vex-prefixes-fix
      (b* ((fty::fixed (vex-prefixes-fix$inline x)))
        (vex-prefixes-p fty::fixed))
      :rule-classes :rewrite)

    Theorem: vex-prefixes-fix-when-vex-prefixes-p

    (defthm vex-prefixes-fix-when-vex-prefixes-p
      (implies (vex-prefixes-p x)
               (equal (vex-prefixes-fix x) x)))

    Function: vex-prefixes-equiv$inline

    (defun vex-prefixes-equiv$inline (x y)
      (declare (xargs :guard (and (vex-prefixes-p x)
                                  (vex-prefixes-p y))))
      (equal (vex-prefixes-fix x)
             (vex-prefixes-fix y)))

    Theorem: vex-prefixes-equiv-is-an-equivalence

    (defthm vex-prefixes-equiv-is-an-equivalence
      (and (booleanp (vex-prefixes-equiv x y))
           (vex-prefixes-equiv x x)
           (implies (vex-prefixes-equiv x y)
                    (vex-prefixes-equiv y x))
           (implies (and (vex-prefixes-equiv x y)
                         (vex-prefixes-equiv y z))
                    (vex-prefixes-equiv x z)))
      :rule-classes (:equivalence))

    Theorem: vex-prefixes-equiv-implies-equal-vex-prefixes-fix-1

    (defthm vex-prefixes-equiv-implies-equal-vex-prefixes-fix-1
      (implies (vex-prefixes-equiv x x-equiv)
               (equal (vex-prefixes-fix x)
                      (vex-prefixes-fix x-equiv)))
      :rule-classes (:congruence))

    Theorem: vex-prefixes-fix-under-vex-prefixes-equiv

    (defthm vex-prefixes-fix-under-vex-prefixes-equiv
      (vex-prefixes-equiv (vex-prefixes-fix x)
                          x)
      :rule-classes (:rewrite :rewrite-quoted-constant))

    Function: vex-prefixes$inline

    (defun vex-prefixes$inline (byte0 byte1 byte2)
      (declare (xargs :guard (and (8bits-p byte0)
                                  (8bits-p byte1)
                                  (8bits-p byte2))))
      (b* ((byte0 (mbe :logic (8bits-fix byte0)
                       :exec byte0))
           (byte1 (mbe :logic (8bits-fix byte1)
                       :exec byte1))
           (byte2 (mbe :logic (8bits-fix byte2)
                       :exec byte2)))
        (logapp 8 byte0 (logapp 8 byte1 byte2))))

    Theorem: vex-prefixes-p-of-vex-prefixes

    (defthm vex-prefixes-p-of-vex-prefixes
      (b* ((vex-prefixes (vex-prefixes$inline byte0 byte1 byte2)))
        (vex-prefixes-p vex-prefixes))
      :rule-classes :rewrite)

    Theorem: vex-prefixes$inline-of-8bits-fix-byte0

    (defthm vex-prefixes$inline-of-8bits-fix-byte0
      (equal (vex-prefixes$inline (8bits-fix byte0)
                                  byte1 byte2)
             (vex-prefixes$inline byte0 byte1 byte2)))

    Theorem: vex-prefixes$inline-8bits-equiv-congruence-on-byte0

    (defthm vex-prefixes$inline-8bits-equiv-congruence-on-byte0
      (implies (8bits-equiv byte0 byte0-equiv)
               (equal (vex-prefixes$inline byte0 byte1 byte2)
                      (vex-prefixes$inline byte0-equiv byte1 byte2)))
      :rule-classes :congruence)

    Theorem: vex-prefixes$inline-of-8bits-fix-byte1

    (defthm vex-prefixes$inline-of-8bits-fix-byte1
      (equal (vex-prefixes$inline byte0 (8bits-fix byte1)
                                  byte2)
             (vex-prefixes$inline byte0 byte1 byte2)))

    Theorem: vex-prefixes$inline-8bits-equiv-congruence-on-byte1

    (defthm vex-prefixes$inline-8bits-equiv-congruence-on-byte1
      (implies (8bits-equiv byte1 byte1-equiv)
               (equal (vex-prefixes$inline byte0 byte1 byte2)
                      (vex-prefixes$inline byte0 byte1-equiv byte2)))
      :rule-classes :congruence)

    Theorem: vex-prefixes$inline-of-8bits-fix-byte2

    (defthm vex-prefixes$inline-of-8bits-fix-byte2
      (equal (vex-prefixes$inline byte0 byte1 (8bits-fix byte2))
             (vex-prefixes$inline byte0 byte1 byte2)))

    Theorem: vex-prefixes$inline-8bits-equiv-congruence-on-byte2

    (defthm vex-prefixes$inline-8bits-equiv-congruence-on-byte2
      (implies (8bits-equiv byte2 byte2-equiv)
               (equal (vex-prefixes$inline byte0 byte1 byte2)
                      (vex-prefixes$inline byte0 byte1 byte2-equiv)))
      :rule-classes :congruence)

    Function: vex-prefixes-equiv-under-mask$inline

    (defun vex-prefixes-equiv-under-mask$inline (x x1 mask)
      (declare (xargs :guard (and (vex-prefixes-p x)
                                  (vex-prefixes-p x1)
                                  (integerp mask))))
      (fty::int-equiv-under-mask (vex-prefixes-fix x)
                                 (vex-prefixes-fix x1)
                                 mask))

    Function: vex-prefixes->byte0$inline

    (defun vex-prefixes->byte0$inline (x)
      (declare (xargs :guard (vex-prefixes-p x)))
      (mbe :logic
           (let ((x (vex-prefixes-fix x)))
             (part-select x :low 0 :width 8))
           :exec (the (unsigned-byte 8)
                      (logand (the (unsigned-byte 8) 255)
                              (the (unsigned-byte 24) x)))))

    Theorem: 8bits-p-of-vex-prefixes->byte0

    (defthm 8bits-p-of-vex-prefixes->byte0
      (b* ((byte0 (vex-prefixes->byte0$inline x)))
        (8bits-p byte0))
      :rule-classes :rewrite)

    Theorem: vex-prefixes->byte0$inline-of-vex-prefixes-fix-x

    (defthm vex-prefixes->byte0$inline-of-vex-prefixes-fix-x
      (equal (vex-prefixes->byte0$inline (vex-prefixes-fix x))
             (vex-prefixes->byte0$inline x)))

    Theorem: vex-prefixes->byte0$inline-vex-prefixes-equiv-congruence-on-x

    (defthm
          vex-prefixes->byte0$inline-vex-prefixes-equiv-congruence-on-x
      (implies (vex-prefixes-equiv x x-equiv)
               (equal (vex-prefixes->byte0$inline x)
                      (vex-prefixes->byte0$inline x-equiv)))
      :rule-classes :congruence)

    Theorem: vex-prefixes->byte0-of-vex-prefixes

    (defthm vex-prefixes->byte0-of-vex-prefixes
      (equal (vex-prefixes->byte0 (vex-prefixes byte0 byte1 byte2))
             (8bits-fix byte0)))

    Theorem: vex-prefixes->byte0-of-write-with-mask

    (defthm vex-prefixes->byte0-of-write-with-mask
      (implies (and (fty::bitstruct-read-over-write-hyps
                         x vex-prefixes-equiv-under-mask)
                    (vex-prefixes-equiv-under-mask x y fty::mask)
                    (equal (logand (lognot fty::mask) 255)
                           0))
               (equal (vex-prefixes->byte0 x)
                      (vex-prefixes->byte0 y))))

    Function: vex-prefixes->byte1$inline

    (defun vex-prefixes->byte1$inline (x)
     (declare (xargs :guard (vex-prefixes-p x)))
     (mbe
        :logic
        (let ((x (vex-prefixes-fix x)))
          (part-select x :low 8 :width 8))
        :exec (the (unsigned-byte 8)
                   (logand (the (unsigned-byte 8) 255)
                           (the (unsigned-byte 16)
                                (ash (the (unsigned-byte 24) x) -8))))))

    Theorem: 8bits-p-of-vex-prefixes->byte1

    (defthm 8bits-p-of-vex-prefixes->byte1
      (b* ((byte1 (vex-prefixes->byte1$inline x)))
        (8bits-p byte1))
      :rule-classes :rewrite)

    Theorem: vex-prefixes->byte1$inline-of-vex-prefixes-fix-x

    (defthm vex-prefixes->byte1$inline-of-vex-prefixes-fix-x
      (equal (vex-prefixes->byte1$inline (vex-prefixes-fix x))
             (vex-prefixes->byte1$inline x)))

    Theorem: vex-prefixes->byte1$inline-vex-prefixes-equiv-congruence-on-x

    (defthm
          vex-prefixes->byte1$inline-vex-prefixes-equiv-congruence-on-x
      (implies (vex-prefixes-equiv x x-equiv)
               (equal (vex-prefixes->byte1$inline x)
                      (vex-prefixes->byte1$inline x-equiv)))
      :rule-classes :congruence)

    Theorem: vex-prefixes->byte1-of-vex-prefixes

    (defthm vex-prefixes->byte1-of-vex-prefixes
      (equal (vex-prefixes->byte1 (vex-prefixes byte0 byte1 byte2))
             (8bits-fix byte1)))

    Theorem: vex-prefixes->byte1-of-write-with-mask

    (defthm vex-prefixes->byte1-of-write-with-mask
      (implies (and (fty::bitstruct-read-over-write-hyps
                         x vex-prefixes-equiv-under-mask)
                    (vex-prefixes-equiv-under-mask x y fty::mask)
                    (equal (logand (lognot fty::mask) 65280)
                           0))
               (equal (vex-prefixes->byte1 x)
                      (vex-prefixes->byte1 y))))

    Function: vex-prefixes->byte2$inline

    (defun vex-prefixes->byte2$inline (x)
      (declare (xargs :guard (vex-prefixes-p x)))
      (mbe :logic
           (let ((x (vex-prefixes-fix x)))
             (part-select x :low 16 :width 8))
           :exec (the (unsigned-byte 8)
                      (logand (the (unsigned-byte 8) 255)
                              (the (unsigned-byte 8)
                                   (ash (the (unsigned-byte 24) x)
                                        -16))))))

    Theorem: 8bits-p-of-vex-prefixes->byte2

    (defthm 8bits-p-of-vex-prefixes->byte2
      (b* ((byte2 (vex-prefixes->byte2$inline x)))
        (8bits-p byte2))
      :rule-classes :rewrite)

    Theorem: vex-prefixes->byte2$inline-of-vex-prefixes-fix-x

    (defthm vex-prefixes->byte2$inline-of-vex-prefixes-fix-x
      (equal (vex-prefixes->byte2$inline (vex-prefixes-fix x))
             (vex-prefixes->byte2$inline x)))

    Theorem: vex-prefixes->byte2$inline-vex-prefixes-equiv-congruence-on-x

    (defthm
          vex-prefixes->byte2$inline-vex-prefixes-equiv-congruence-on-x
      (implies (vex-prefixes-equiv x x-equiv)
               (equal (vex-prefixes->byte2$inline x)
                      (vex-prefixes->byte2$inline x-equiv)))
      :rule-classes :congruence)

    Theorem: vex-prefixes->byte2-of-vex-prefixes

    (defthm vex-prefixes->byte2-of-vex-prefixes
      (equal (vex-prefixes->byte2 (vex-prefixes byte0 byte1 byte2))
             (8bits-fix byte2)))

    Theorem: vex-prefixes->byte2-of-write-with-mask

    (defthm vex-prefixes->byte2-of-write-with-mask
      (implies (and (fty::bitstruct-read-over-write-hyps
                         x vex-prefixes-equiv-under-mask)
                    (vex-prefixes-equiv-under-mask x y fty::mask)
                    (equal (logand (lognot fty::mask) 16711680)
                           0))
               (equal (vex-prefixes->byte2 x)
                      (vex-prefixes->byte2 y))))

    Theorem: vex-prefixes-fix-in-terms-of-vex-prefixes

    (defthm vex-prefixes-fix-in-terms-of-vex-prefixes
      (equal (vex-prefixes-fix x)
             (change-vex-prefixes x)))

    Function: !vex-prefixes->byte0$inline

    (defun !vex-prefixes->byte0$inline (byte0 x)
      (declare (xargs :guard (and (8bits-p byte0)
                                  (vex-prefixes-p x))))
      (mbe :logic
           (b* ((byte0 (mbe :logic (8bits-fix byte0)
                            :exec byte0))
                (x (vex-prefixes-fix x)))
             (part-install byte0 x :width 8 :low 0))
           :exec (the (unsigned-byte 24)
                      (logior (the (unsigned-byte 24)
                                   (logand (the (unsigned-byte 24) x)
                                           (the (signed-byte 9) -256)))
                              (the (unsigned-byte 8) byte0)))))

    Theorem: vex-prefixes-p-of-!vex-prefixes->byte0

    (defthm vex-prefixes-p-of-!vex-prefixes->byte0
      (b* ((new-x (!vex-prefixes->byte0$inline byte0 x)))
        (vex-prefixes-p new-x))
      :rule-classes :rewrite)

    Theorem: !vex-prefixes->byte0$inline-of-8bits-fix-byte0

    (defthm !vex-prefixes->byte0$inline-of-8bits-fix-byte0
      (equal (!vex-prefixes->byte0$inline (8bits-fix byte0)
                                          x)
             (!vex-prefixes->byte0$inline byte0 x)))

    Theorem: !vex-prefixes->byte0$inline-8bits-equiv-congruence-on-byte0

    (defthm !vex-prefixes->byte0$inline-8bits-equiv-congruence-on-byte0
      (implies (8bits-equiv byte0 byte0-equiv)
               (equal (!vex-prefixes->byte0$inline byte0 x)
                      (!vex-prefixes->byte0$inline byte0-equiv x)))
      :rule-classes :congruence)

    Theorem: !vex-prefixes->byte0$inline-of-vex-prefixes-fix-x

    (defthm !vex-prefixes->byte0$inline-of-vex-prefixes-fix-x
      (equal (!vex-prefixes->byte0$inline byte0 (vex-prefixes-fix x))
             (!vex-prefixes->byte0$inline byte0 x)))

    Theorem: !vex-prefixes->byte0$inline-vex-prefixes-equiv-congruence-on-x

    (defthm
         !vex-prefixes->byte0$inline-vex-prefixes-equiv-congruence-on-x
      (implies (vex-prefixes-equiv x x-equiv)
               (equal (!vex-prefixes->byte0$inline byte0 x)
                      (!vex-prefixes->byte0$inline byte0 x-equiv)))
      :rule-classes :congruence)

    Theorem: !vex-prefixes->byte0-is-vex-prefixes

    (defthm !vex-prefixes->byte0-is-vex-prefixes
      (equal (!vex-prefixes->byte0 byte0 x)
             (change-vex-prefixes x :byte0 byte0)))

    Theorem: vex-prefixes->byte0-of-!vex-prefixes->byte0

    (defthm vex-prefixes->byte0-of-!vex-prefixes->byte0
      (b* ((?new-x (!vex-prefixes->byte0$inline byte0 x)))
        (equal (vex-prefixes->byte0 new-x)
               (8bits-fix byte0))))

    Theorem: !vex-prefixes->byte0-equiv-under-mask

    (defthm !vex-prefixes->byte0-equiv-under-mask
      (b* ((?new-x (!vex-prefixes->byte0$inline byte0 x)))
        (vex-prefixes-equiv-under-mask new-x x -256)))

    Function: !vex-prefixes->byte1$inline

    (defun !vex-prefixes->byte1$inline (byte1 x)
     (declare (xargs :guard (and (8bits-p byte1)
                                 (vex-prefixes-p x))))
     (mbe
         :logic
         (b* ((byte1 (mbe :logic (8bits-fix byte1)
                          :exec byte1))
              (x (vex-prefixes-fix x)))
           (part-install byte1 x :width 8 :low 8))
         :exec (the (unsigned-byte 24)
                    (logior (the (unsigned-byte 24)
                                 (logand (the (unsigned-byte 24) x)
                                         (the (signed-byte 17) -65281)))
                            (the (unsigned-byte 16)
                                 (ash (the (unsigned-byte 8) byte1)
                                      8))))))

    Theorem: vex-prefixes-p-of-!vex-prefixes->byte1

    (defthm vex-prefixes-p-of-!vex-prefixes->byte1
      (b* ((new-x (!vex-prefixes->byte1$inline byte1 x)))
        (vex-prefixes-p new-x))
      :rule-classes :rewrite)

    Theorem: !vex-prefixes->byte1$inline-of-8bits-fix-byte1

    (defthm !vex-prefixes->byte1$inline-of-8bits-fix-byte1
      (equal (!vex-prefixes->byte1$inline (8bits-fix byte1)
                                          x)
             (!vex-prefixes->byte1$inline byte1 x)))

    Theorem: !vex-prefixes->byte1$inline-8bits-equiv-congruence-on-byte1

    (defthm !vex-prefixes->byte1$inline-8bits-equiv-congruence-on-byte1
      (implies (8bits-equiv byte1 byte1-equiv)
               (equal (!vex-prefixes->byte1$inline byte1 x)
                      (!vex-prefixes->byte1$inline byte1-equiv x)))
      :rule-classes :congruence)

    Theorem: !vex-prefixes->byte1$inline-of-vex-prefixes-fix-x

    (defthm !vex-prefixes->byte1$inline-of-vex-prefixes-fix-x
      (equal (!vex-prefixes->byte1$inline byte1 (vex-prefixes-fix x))
             (!vex-prefixes->byte1$inline byte1 x)))

    Theorem: !vex-prefixes->byte1$inline-vex-prefixes-equiv-congruence-on-x

    (defthm
         !vex-prefixes->byte1$inline-vex-prefixes-equiv-congruence-on-x
      (implies (vex-prefixes-equiv x x-equiv)
               (equal (!vex-prefixes->byte1$inline byte1 x)
                      (!vex-prefixes->byte1$inline byte1 x-equiv)))
      :rule-classes :congruence)

    Theorem: !vex-prefixes->byte1-is-vex-prefixes

    (defthm !vex-prefixes->byte1-is-vex-prefixes
      (equal (!vex-prefixes->byte1 byte1 x)
             (change-vex-prefixes x :byte1 byte1)))

    Theorem: vex-prefixes->byte1-of-!vex-prefixes->byte1

    (defthm vex-prefixes->byte1-of-!vex-prefixes->byte1
      (b* ((?new-x (!vex-prefixes->byte1$inline byte1 x)))
        (equal (vex-prefixes->byte1 new-x)
               (8bits-fix byte1))))

    Theorem: !vex-prefixes->byte1-equiv-under-mask

    (defthm !vex-prefixes->byte1-equiv-under-mask
      (b* ((?new-x (!vex-prefixes->byte1$inline byte1 x)))
        (vex-prefixes-equiv-under-mask new-x x -65281)))

    Function: !vex-prefixes->byte2$inline

    (defun !vex-prefixes->byte2$inline (byte2 x)
     (declare (xargs :guard (and (8bits-p byte2)
                                 (vex-prefixes-p x))))
     (mbe
      :logic
      (b* ((byte2 (mbe :logic (8bits-fix byte2)
                       :exec byte2))
           (x (vex-prefixes-fix x)))
        (part-install byte2 x :width 8 :low 16))
      :exec (the (unsigned-byte 24)
                 (logior (the (unsigned-byte 24)
                              (logand (the (unsigned-byte 24) x)
                                      (the (signed-byte 25) -16711681)))
                         (the (unsigned-byte 24)
                              (ash (the (unsigned-byte 8) byte2)
                                   16))))))

    Theorem: vex-prefixes-p-of-!vex-prefixes->byte2

    (defthm vex-prefixes-p-of-!vex-prefixes->byte2
      (b* ((new-x (!vex-prefixes->byte2$inline byte2 x)))
        (vex-prefixes-p new-x))
      :rule-classes :rewrite)

    Theorem: !vex-prefixes->byte2$inline-of-8bits-fix-byte2

    (defthm !vex-prefixes->byte2$inline-of-8bits-fix-byte2
      (equal (!vex-prefixes->byte2$inline (8bits-fix byte2)
                                          x)
             (!vex-prefixes->byte2$inline byte2 x)))

    Theorem: !vex-prefixes->byte2$inline-8bits-equiv-congruence-on-byte2

    (defthm !vex-prefixes->byte2$inline-8bits-equiv-congruence-on-byte2
      (implies (8bits-equiv byte2 byte2-equiv)
               (equal (!vex-prefixes->byte2$inline byte2 x)
                      (!vex-prefixes->byte2$inline byte2-equiv x)))
      :rule-classes :congruence)

    Theorem: !vex-prefixes->byte2$inline-of-vex-prefixes-fix-x

    (defthm !vex-prefixes->byte2$inline-of-vex-prefixes-fix-x
      (equal (!vex-prefixes->byte2$inline byte2 (vex-prefixes-fix x))
             (!vex-prefixes->byte2$inline byte2 x)))

    Theorem: !vex-prefixes->byte2$inline-vex-prefixes-equiv-congruence-on-x

    (defthm
         !vex-prefixes->byte2$inline-vex-prefixes-equiv-congruence-on-x
      (implies (vex-prefixes-equiv x x-equiv)
               (equal (!vex-prefixes->byte2$inline byte2 x)
                      (!vex-prefixes->byte2$inline byte2 x-equiv)))
      :rule-classes :congruence)

    Theorem: !vex-prefixes->byte2-is-vex-prefixes

    (defthm !vex-prefixes->byte2-is-vex-prefixes
      (equal (!vex-prefixes->byte2 byte2 x)
             (change-vex-prefixes x :byte2 byte2)))

    Theorem: vex-prefixes->byte2-of-!vex-prefixes->byte2

    (defthm vex-prefixes->byte2-of-!vex-prefixes->byte2
      (b* ((?new-x (!vex-prefixes->byte2$inline byte2 x)))
        (equal (vex-prefixes->byte2 new-x)
               (8bits-fix byte2))))

    Theorem: !vex-prefixes->byte2-equiv-under-mask

    (defthm !vex-prefixes->byte2-equiv-under-mask
      (b* ((?new-x (!vex-prefixes->byte2$inline byte2 x)))
        (vex-prefixes-equiv-under-mask new-x x 65535)))

    Function: vex-prefixes-debug$inline

    (defun vex-prefixes-debug$inline (x)
      (declare (xargs :guard (vex-prefixes-p x)))
      (b* (((vex-prefixes x)))
        (cons (cons 'byte0 x.byte0)
              (cons (cons 'byte1 x.byte1)
                    (cons (cons 'byte2 x.byte2) nil)))))

    Function: vex-prefixes-byte0-p$inline

    (defun vex-prefixes-byte0-p$inline (vex-prefixes)
      (declare (xargs :guard (vex-prefixes-p vex-prefixes)))
      (let ((byte0 (vex-prefixes->byte0 vex-prefixes)))
        (or (equal byte0 197)
            (equal byte0 196))))

    Theorem: booleanp-of-vex-prefixes-byte0-p

    (defthm booleanp-of-vex-prefixes-byte0-p
      (b* ((ok (vex-prefixes-byte0-p$inline vex-prefixes)))
        (booleanp ok))
      :rule-classes :rewrite)

    Function: vex2-byte1-p$inline

    (defun vex2-byte1-p$inline (x)
      (declare (xargs :guard t))
      (mbe :logic (unsigned-byte-p 8 x)
           :exec (and (natp x) (< x 256))))

    Theorem: vex2-byte1-p-when-unsigned-byte-p

    (defthm vex2-byte1-p-when-unsigned-byte-p
      (implies (unsigned-byte-p 8 x)
               (vex2-byte1-p x)))

    Theorem: unsigned-byte-p-when-vex2-byte1-p

    (defthm unsigned-byte-p-when-vex2-byte1-p
      (implies (vex2-byte1-p x)
               (unsigned-byte-p 8 x)))

    Theorem: vex2-byte1-p-compound-recognizer

    (defthm vex2-byte1-p-compound-recognizer
      (implies (vex2-byte1-p x) (natp x))
      :rule-classes :compound-recognizer)

    Function: vex2-byte1-fix$inline

    (defun vex2-byte1-fix$inline (x)
      (declare (xargs :guard (vex2-byte1-p x)))
      (mbe :logic (loghead 8 x) :exec x))

    Theorem: vex2-byte1-p-of-vex2-byte1-fix

    (defthm vex2-byte1-p-of-vex2-byte1-fix
      (b* ((fty::fixed (vex2-byte1-fix$inline x)))
        (vex2-byte1-p fty::fixed))
      :rule-classes :rewrite)

    Theorem: vex2-byte1-fix-when-vex2-byte1-p

    (defthm vex2-byte1-fix-when-vex2-byte1-p
      (implies (vex2-byte1-p x)
               (equal (vex2-byte1-fix x) x)))

    Function: vex2-byte1-equiv$inline

    (defun vex2-byte1-equiv$inline (x y)
      (declare (xargs :guard (and (vex2-byte1-p x)
                                  (vex2-byte1-p y))))
      (equal (vex2-byte1-fix x)
             (vex2-byte1-fix y)))

    Theorem: vex2-byte1-equiv-is-an-equivalence

    (defthm vex2-byte1-equiv-is-an-equivalence
      (and (booleanp (vex2-byte1-equiv x y))
           (vex2-byte1-equiv x x)
           (implies (vex2-byte1-equiv x y)
                    (vex2-byte1-equiv y x))
           (implies (and (vex2-byte1-equiv x y)
                         (vex2-byte1-equiv y z))
                    (vex2-byte1-equiv x z)))
      :rule-classes (:equivalence))

    Theorem: vex2-byte1-equiv-implies-equal-vex2-byte1-fix-1

    (defthm vex2-byte1-equiv-implies-equal-vex2-byte1-fix-1
      (implies (vex2-byte1-equiv x x-equiv)
               (equal (vex2-byte1-fix x)
                      (vex2-byte1-fix x-equiv)))
      :rule-classes (:congruence))

    Theorem: vex2-byte1-fix-under-vex2-byte1-equiv

    (defthm vex2-byte1-fix-under-vex2-byte1-equiv
      (vex2-byte1-equiv (vex2-byte1-fix x) x)
      :rule-classes (:rewrite :rewrite-quoted-constant))

    Function: vex2-byte1$inline

    (defun vex2-byte1$inline (pp l vvvv r)
      (declare (xargs :guard (and (2bits-p pp)
                                  (bitp l)
                                  (4bits-p vvvv)
                                  (bitp r))))
      (b* ((pp (mbe :logic (2bits-fix pp) :exec pp))
           (l (mbe :logic (bfix l) :exec l))
           (vvvv (mbe :logic (4bits-fix vvvv)
                      :exec vvvv))
           (r (mbe :logic (bfix r) :exec r)))
        (logapp 2 pp (logapp 1 l (logapp 4 vvvv r)))))

    Theorem: vex2-byte1-p-of-vex2-byte1

    (defthm vex2-byte1-p-of-vex2-byte1
      (b* ((vex2-byte1 (vex2-byte1$inline pp l vvvv r)))
        (vex2-byte1-p vex2-byte1))
      :rule-classes :rewrite)

    Theorem: vex2-byte1$inline-of-2bits-fix-pp

    (defthm vex2-byte1$inline-of-2bits-fix-pp
      (equal (vex2-byte1$inline (2bits-fix pp)
                                l vvvv r)
             (vex2-byte1$inline pp l vvvv r)))

    Theorem: vex2-byte1$inline-2bits-equiv-congruence-on-pp

    (defthm vex2-byte1$inline-2bits-equiv-congruence-on-pp
      (implies (2bits-equiv pp pp-equiv)
               (equal (vex2-byte1$inline pp l vvvv r)
                      (vex2-byte1$inline pp-equiv l vvvv r)))
      :rule-classes :congruence)

    Theorem: vex2-byte1$inline-of-bfix-l

    (defthm vex2-byte1$inline-of-bfix-l
      (equal (vex2-byte1$inline pp (bfix l) vvvv r)
             (vex2-byte1$inline pp l vvvv r)))

    Theorem: vex2-byte1$inline-bit-equiv-congruence-on-l

    (defthm vex2-byte1$inline-bit-equiv-congruence-on-l
      (implies (bit-equiv l l-equiv)
               (equal (vex2-byte1$inline pp l vvvv r)
                      (vex2-byte1$inline pp l-equiv vvvv r)))
      :rule-classes :congruence)

    Theorem: vex2-byte1$inline-of-4bits-fix-vvvv

    (defthm vex2-byte1$inline-of-4bits-fix-vvvv
      (equal (vex2-byte1$inline pp l (4bits-fix vvvv)
                                r)
             (vex2-byte1$inline pp l vvvv r)))

    Theorem: vex2-byte1$inline-4bits-equiv-congruence-on-vvvv

    (defthm vex2-byte1$inline-4bits-equiv-congruence-on-vvvv
      (implies (4bits-equiv vvvv vvvv-equiv)
               (equal (vex2-byte1$inline pp l vvvv r)
                      (vex2-byte1$inline pp l vvvv-equiv r)))
      :rule-classes :congruence)

    Theorem: vex2-byte1$inline-of-bfix-r

    (defthm vex2-byte1$inline-of-bfix-r
      (equal (vex2-byte1$inline pp l vvvv (bfix r))
             (vex2-byte1$inline pp l vvvv r)))

    Theorem: vex2-byte1$inline-bit-equiv-congruence-on-r

    (defthm vex2-byte1$inline-bit-equiv-congruence-on-r
      (implies (bit-equiv r r-equiv)
               (equal (vex2-byte1$inline pp l vvvv r)
                      (vex2-byte1$inline pp l vvvv r-equiv)))
      :rule-classes :congruence)

    Function: vex2-byte1-equiv-under-mask$inline

    (defun vex2-byte1-equiv-under-mask$inline (x x1 mask)
      (declare (xargs :guard (and (vex2-byte1-p x)
                                  (vex2-byte1-p x1)
                                  (integerp mask))))
      (fty::int-equiv-under-mask (vex2-byte1-fix x)
                                 (vex2-byte1-fix x1)
                                 mask))

    Function: vex2-byte1->pp$inline

    (defun vex2-byte1->pp$inline (x)
      (declare (xargs :guard (vex2-byte1-p x)))
      (mbe :logic
           (let ((x (vex2-byte1-fix x)))
             (part-select x :low 0 :width 2))
           :exec (the (unsigned-byte 2)
                      (logand (the (unsigned-byte 2) 3)
                              (the (unsigned-byte 8) x)))))

    Theorem: 2bits-p-of-vex2-byte1->pp

    (defthm 2bits-p-of-vex2-byte1->pp
      (b* ((pp (vex2-byte1->pp$inline x)))
        (2bits-p pp))
      :rule-classes :rewrite)

    Theorem: vex2-byte1->pp$inline-of-vex2-byte1-fix-x

    (defthm vex2-byte1->pp$inline-of-vex2-byte1-fix-x
      (equal (vex2-byte1->pp$inline (vex2-byte1-fix x))
             (vex2-byte1->pp$inline x)))

    Theorem: vex2-byte1->pp$inline-vex2-byte1-equiv-congruence-on-x

    (defthm vex2-byte1->pp$inline-vex2-byte1-equiv-congruence-on-x
      (implies (vex2-byte1-equiv x x-equiv)
               (equal (vex2-byte1->pp$inline x)
                      (vex2-byte1->pp$inline x-equiv)))
      :rule-classes :congruence)

    Theorem: vex2-byte1->pp-of-vex2-byte1

    (defthm vex2-byte1->pp-of-vex2-byte1
      (equal (vex2-byte1->pp (vex2-byte1 pp l vvvv r))
             (2bits-fix pp)))

    Theorem: vex2-byte1->pp-of-write-with-mask

    (defthm vex2-byte1->pp-of-write-with-mask
      (implies (and (fty::bitstruct-read-over-write-hyps
                         x vex2-byte1-equiv-under-mask)
                    (vex2-byte1-equiv-under-mask x y fty::mask)
                    (equal (logand (lognot fty::mask) 3) 0))
               (equal (vex2-byte1->pp x)
                      (vex2-byte1->pp y))))

    Function: vex2-byte1->l$inline

    (defun vex2-byte1->l$inline (x)
     (declare (xargs :guard (vex2-byte1-p x)))
     (mbe
         :logic
         (let ((x (vex2-byte1-fix x)))
           (part-select x :low 2 :width 1))
         :exec (the (unsigned-byte 1)
                    (logand (the (unsigned-byte 1) 1)
                            (the (unsigned-byte 6)
                                 (ash (the (unsigned-byte 8) x) -2))))))

    Theorem: bitp-of-vex2-byte1->l

    (defthm bitp-of-vex2-byte1->l
      (b* ((l (vex2-byte1->l$inline x)))
        (bitp l))
      :rule-classes :rewrite)

    Theorem: vex2-byte1->l$inline-of-vex2-byte1-fix-x

    (defthm vex2-byte1->l$inline-of-vex2-byte1-fix-x
      (equal (vex2-byte1->l$inline (vex2-byte1-fix x))
             (vex2-byte1->l$inline x)))

    Theorem: vex2-byte1->l$inline-vex2-byte1-equiv-congruence-on-x

    (defthm vex2-byte1->l$inline-vex2-byte1-equiv-congruence-on-x
      (implies (vex2-byte1-equiv x x-equiv)
               (equal (vex2-byte1->l$inline x)
                      (vex2-byte1->l$inline x-equiv)))
      :rule-classes :congruence)

    Theorem: vex2-byte1->l-of-vex2-byte1

    (defthm vex2-byte1->l-of-vex2-byte1
      (equal (vex2-byte1->l (vex2-byte1 pp l vvvv r))
             (bfix l)))

    Theorem: vex2-byte1->l-of-write-with-mask

    (defthm vex2-byte1->l-of-write-with-mask
      (implies (and (fty::bitstruct-read-over-write-hyps
                         x vex2-byte1-equiv-under-mask)
                    (vex2-byte1-equiv-under-mask x y fty::mask)
                    (equal (logand (lognot fty::mask) 4) 0))
               (equal (vex2-byte1->l x)
                      (vex2-byte1->l y))))

    Function: vex2-byte1->vvvv$inline

    (defun vex2-byte1->vvvv$inline (x)
     (declare (xargs :guard (vex2-byte1-p x)))
     (mbe
         :logic
         (let ((x (vex2-byte1-fix x)))
           (part-select x :low 3 :width 4))
         :exec (the (unsigned-byte 4)
                    (logand (the (unsigned-byte 4) 15)
                            (the (unsigned-byte 5)
                                 (ash (the (unsigned-byte 8) x) -3))))))

    Theorem: 4bits-p-of-vex2-byte1->vvvv

    (defthm 4bits-p-of-vex2-byte1->vvvv
      (b* ((vvvv (vex2-byte1->vvvv$inline x)))
        (4bits-p vvvv))
      :rule-classes :rewrite)

    Theorem: vex2-byte1->vvvv$inline-of-vex2-byte1-fix-x

    (defthm vex2-byte1->vvvv$inline-of-vex2-byte1-fix-x
      (equal (vex2-byte1->vvvv$inline (vex2-byte1-fix x))
             (vex2-byte1->vvvv$inline x)))

    Theorem: vex2-byte1->vvvv$inline-vex2-byte1-equiv-congruence-on-x

    (defthm vex2-byte1->vvvv$inline-vex2-byte1-equiv-congruence-on-x
      (implies (vex2-byte1-equiv x x-equiv)
               (equal (vex2-byte1->vvvv$inline x)
                      (vex2-byte1->vvvv$inline x-equiv)))
      :rule-classes :congruence)

    Theorem: vex2-byte1->vvvv-of-vex2-byte1

    (defthm vex2-byte1->vvvv-of-vex2-byte1
      (equal (vex2-byte1->vvvv (vex2-byte1 pp l vvvv r))
             (4bits-fix vvvv)))

    Theorem: vex2-byte1->vvvv-of-write-with-mask

    (defthm vex2-byte1->vvvv-of-write-with-mask
      (implies (and (fty::bitstruct-read-over-write-hyps
                         x vex2-byte1-equiv-under-mask)
                    (vex2-byte1-equiv-under-mask x y fty::mask)
                    (equal (logand (lognot fty::mask) 120)
                           0))
               (equal (vex2-byte1->vvvv x)
                      (vex2-byte1->vvvv y))))

    Function: vex2-byte1->r$inline

    (defun vex2-byte1->r$inline (x)
     (declare (xargs :guard (vex2-byte1-p x)))
     (mbe
         :logic
         (let ((x (vex2-byte1-fix x)))
           (part-select x :low 7 :width 1))
         :exec (the (unsigned-byte 1)
                    (logand (the (unsigned-byte 1) 1)
                            (the (unsigned-byte 1)
                                 (ash (the (unsigned-byte 8) x) -7))))))

    Theorem: bitp-of-vex2-byte1->r

    (defthm bitp-of-vex2-byte1->r
      (b* ((r (vex2-byte1->r$inline x)))
        (bitp r))
      :rule-classes :rewrite)

    Theorem: vex2-byte1->r$inline-of-vex2-byte1-fix-x

    (defthm vex2-byte1->r$inline-of-vex2-byte1-fix-x
      (equal (vex2-byte1->r$inline (vex2-byte1-fix x))
             (vex2-byte1->r$inline x)))

    Theorem: vex2-byte1->r$inline-vex2-byte1-equiv-congruence-on-x

    (defthm vex2-byte1->r$inline-vex2-byte1-equiv-congruence-on-x
      (implies (vex2-byte1-equiv x x-equiv)
               (equal (vex2-byte1->r$inline x)
                      (vex2-byte1->r$inline x-equiv)))
      :rule-classes :congruence)

    Theorem: vex2-byte1->r-of-vex2-byte1

    (defthm vex2-byte1->r-of-vex2-byte1
      (equal (vex2-byte1->r (vex2-byte1 pp l vvvv r))
             (bfix r)))

    Theorem: vex2-byte1->r-of-write-with-mask

    (defthm vex2-byte1->r-of-write-with-mask
      (implies (and (fty::bitstruct-read-over-write-hyps
                         x vex2-byte1-equiv-under-mask)
                    (vex2-byte1-equiv-under-mask x y fty::mask)
                    (equal (logand (lognot fty::mask) 128)
                           0))
               (equal (vex2-byte1->r x)
                      (vex2-byte1->r y))))

    Theorem: vex2-byte1-fix-in-terms-of-vex2-byte1

    (defthm vex2-byte1-fix-in-terms-of-vex2-byte1
      (equal (vex2-byte1-fix x)
             (change-vex2-byte1 x)))

    Function: !vex2-byte1->pp$inline

    (defun !vex2-byte1->pp$inline (pp x)
      (declare (xargs :guard (and (2bits-p pp) (vex2-byte1-p x))))
      (mbe :logic
           (b* ((pp (mbe :logic (2bits-fix pp) :exec pp))
                (x (vex2-byte1-fix x)))
             (part-install pp x :width 2 :low 0))
           :exec (the (unsigned-byte 8)
                      (logior (the (unsigned-byte 8)
                                   (logand (the (unsigned-byte 8) x)
                                           (the (signed-byte 3) -4)))
                              (the (unsigned-byte 2) pp)))))

    Theorem: vex2-byte1-p-of-!vex2-byte1->pp

    (defthm vex2-byte1-p-of-!vex2-byte1->pp
      (b* ((new-x (!vex2-byte1->pp$inline pp x)))
        (vex2-byte1-p new-x))
      :rule-classes :rewrite)

    Theorem: !vex2-byte1->pp$inline-of-2bits-fix-pp

    (defthm !vex2-byte1->pp$inline-of-2bits-fix-pp
      (equal (!vex2-byte1->pp$inline (2bits-fix pp)
                                     x)
             (!vex2-byte1->pp$inline pp x)))

    Theorem: !vex2-byte1->pp$inline-2bits-equiv-congruence-on-pp

    (defthm !vex2-byte1->pp$inline-2bits-equiv-congruence-on-pp
      (implies (2bits-equiv pp pp-equiv)
               (equal (!vex2-byte1->pp$inline pp x)
                      (!vex2-byte1->pp$inline pp-equiv x)))
      :rule-classes :congruence)

    Theorem: !vex2-byte1->pp$inline-of-vex2-byte1-fix-x

    (defthm !vex2-byte1->pp$inline-of-vex2-byte1-fix-x
      (equal (!vex2-byte1->pp$inline pp (vex2-byte1-fix x))
             (!vex2-byte1->pp$inline pp x)))

    Theorem: !vex2-byte1->pp$inline-vex2-byte1-equiv-congruence-on-x

    (defthm !vex2-byte1->pp$inline-vex2-byte1-equiv-congruence-on-x
      (implies (vex2-byte1-equiv x x-equiv)
               (equal (!vex2-byte1->pp$inline pp x)
                      (!vex2-byte1->pp$inline pp x-equiv)))
      :rule-classes :congruence)

    Theorem: !vex2-byte1->pp-is-vex2-byte1

    (defthm !vex2-byte1->pp-is-vex2-byte1
      (equal (!vex2-byte1->pp pp x)
             (change-vex2-byte1 x :pp pp)))

    Theorem: vex2-byte1->pp-of-!vex2-byte1->pp

    (defthm vex2-byte1->pp-of-!vex2-byte1->pp
      (b* ((?new-x (!vex2-byte1->pp$inline pp x)))
        (equal (vex2-byte1->pp new-x)
               (2bits-fix pp))))

    Theorem: !vex2-byte1->pp-equiv-under-mask

    (defthm !vex2-byte1->pp-equiv-under-mask
      (b* ((?new-x (!vex2-byte1->pp$inline pp x)))
        (vex2-byte1-equiv-under-mask new-x x -4)))

    Function: !vex2-byte1->l$inline

    (defun !vex2-byte1->l$inline (l x)
     (declare (xargs :guard (and (bitp l) (vex2-byte1-p x))))
     (mbe :logic
          (b* ((l (mbe :logic (bfix l) :exec l))
               (x (vex2-byte1-fix x)))
            (part-install l x :width 1 :low 2))
          :exec (the (unsigned-byte 8)
                     (logior (the (unsigned-byte 8)
                                  (logand (the (unsigned-byte 8) x)
                                          (the (signed-byte 4) -5)))
                             (the (unsigned-byte 3)
                                  (ash (the (unsigned-byte 1) l) 2))))))

    Theorem: vex2-byte1-p-of-!vex2-byte1->l

    (defthm vex2-byte1-p-of-!vex2-byte1->l
      (b* ((new-x (!vex2-byte1->l$inline l x)))
        (vex2-byte1-p new-x))
      :rule-classes :rewrite)

    Theorem: !vex2-byte1->l$inline-of-bfix-l

    (defthm !vex2-byte1->l$inline-of-bfix-l
      (equal (!vex2-byte1->l$inline (bfix l) x)
             (!vex2-byte1->l$inline l x)))

    Theorem: !vex2-byte1->l$inline-bit-equiv-congruence-on-l

    (defthm !vex2-byte1->l$inline-bit-equiv-congruence-on-l
      (implies (bit-equiv l l-equiv)
               (equal (!vex2-byte1->l$inline l x)
                      (!vex2-byte1->l$inline l-equiv x)))
      :rule-classes :congruence)

    Theorem: !vex2-byte1->l$inline-of-vex2-byte1-fix-x

    (defthm !vex2-byte1->l$inline-of-vex2-byte1-fix-x
      (equal (!vex2-byte1->l$inline l (vex2-byte1-fix x))
             (!vex2-byte1->l$inline l x)))

    Theorem: !vex2-byte1->l$inline-vex2-byte1-equiv-congruence-on-x

    (defthm !vex2-byte1->l$inline-vex2-byte1-equiv-congruence-on-x
      (implies (vex2-byte1-equiv x x-equiv)
               (equal (!vex2-byte1->l$inline l x)
                      (!vex2-byte1->l$inline l x-equiv)))
      :rule-classes :congruence)

    Theorem: !vex2-byte1->l-is-vex2-byte1

    (defthm !vex2-byte1->l-is-vex2-byte1
      (equal (!vex2-byte1->l l x)
             (change-vex2-byte1 x :l l)))

    Theorem: vex2-byte1->l-of-!vex2-byte1->l

    (defthm vex2-byte1->l-of-!vex2-byte1->l
      (b* ((?new-x (!vex2-byte1->l$inline l x)))
        (equal (vex2-byte1->l new-x) (bfix l))))

    Theorem: !vex2-byte1->l-equiv-under-mask

    (defthm !vex2-byte1->l-equiv-under-mask
      (b* ((?new-x (!vex2-byte1->l$inline l x)))
        (vex2-byte1-equiv-under-mask new-x x -5)))

    Function: !vex2-byte1->vvvv$inline

    (defun !vex2-byte1->vvvv$inline (vvvv x)
      (declare (xargs :guard (and (4bits-p vvvv) (vex2-byte1-p x))))
      (mbe :logic
           (b* ((vvvv (mbe :logic (4bits-fix vvvv)
                           :exec vvvv))
                (x (vex2-byte1-fix x)))
             (part-install vvvv x :width 4 :low 3))
           :exec (the (unsigned-byte 8)
                      (logior (the (unsigned-byte 8)
                                   (logand (the (unsigned-byte 8) x)
                                           (the (signed-byte 8) -121)))
                              (the (unsigned-byte 7)
                                   (ash (the (unsigned-byte 4) vvvv)
                                        3))))))

    Theorem: vex2-byte1-p-of-!vex2-byte1->vvvv

    (defthm vex2-byte1-p-of-!vex2-byte1->vvvv
      (b* ((new-x (!vex2-byte1->vvvv$inline vvvv x)))
        (vex2-byte1-p new-x))
      :rule-classes :rewrite)

    Theorem: !vex2-byte1->vvvv$inline-of-4bits-fix-vvvv

    (defthm !vex2-byte1->vvvv$inline-of-4bits-fix-vvvv
      (equal (!vex2-byte1->vvvv$inline (4bits-fix vvvv)
                                       x)
             (!vex2-byte1->vvvv$inline vvvv x)))

    Theorem: !vex2-byte1->vvvv$inline-4bits-equiv-congruence-on-vvvv

    (defthm !vex2-byte1->vvvv$inline-4bits-equiv-congruence-on-vvvv
      (implies (4bits-equiv vvvv vvvv-equiv)
               (equal (!vex2-byte1->vvvv$inline vvvv x)
                      (!vex2-byte1->vvvv$inline vvvv-equiv x)))
      :rule-classes :congruence)

    Theorem: !vex2-byte1->vvvv$inline-of-vex2-byte1-fix-x

    (defthm !vex2-byte1->vvvv$inline-of-vex2-byte1-fix-x
      (equal (!vex2-byte1->vvvv$inline vvvv (vex2-byte1-fix x))
             (!vex2-byte1->vvvv$inline vvvv x)))

    Theorem: !vex2-byte1->vvvv$inline-vex2-byte1-equiv-congruence-on-x

    (defthm !vex2-byte1->vvvv$inline-vex2-byte1-equiv-congruence-on-x
      (implies (vex2-byte1-equiv x x-equiv)
               (equal (!vex2-byte1->vvvv$inline vvvv x)
                      (!vex2-byte1->vvvv$inline vvvv x-equiv)))
      :rule-classes :congruence)

    Theorem: !vex2-byte1->vvvv-is-vex2-byte1

    (defthm !vex2-byte1->vvvv-is-vex2-byte1
      (equal (!vex2-byte1->vvvv vvvv x)
             (change-vex2-byte1 x :vvvv vvvv)))

    Theorem: vex2-byte1->vvvv-of-!vex2-byte1->vvvv

    (defthm vex2-byte1->vvvv-of-!vex2-byte1->vvvv
      (b* ((?new-x (!vex2-byte1->vvvv$inline vvvv x)))
        (equal (vex2-byte1->vvvv new-x)
               (4bits-fix vvvv))))

    Theorem: !vex2-byte1->vvvv-equiv-under-mask

    (defthm !vex2-byte1->vvvv-equiv-under-mask
      (b* ((?new-x (!vex2-byte1->vvvv$inline vvvv x)))
        (vex2-byte1-equiv-under-mask new-x x -121)))

    Function: !vex2-byte1->r$inline

    (defun !vex2-byte1->r$inline (r x)
     (declare (xargs :guard (and (bitp r) (vex2-byte1-p x))))
     (mbe :logic
          (b* ((r (mbe :logic (bfix r) :exec r))
               (x (vex2-byte1-fix x)))
            (part-install r x :width 1 :low 7))
          :exec (the (unsigned-byte 8)
                     (logior (the (unsigned-byte 8)
                                  (logand (the (unsigned-byte 8) x)
                                          (the (signed-byte 9) -129)))
                             (the (unsigned-byte 8)
                                  (ash (the (unsigned-byte 1) r) 7))))))

    Theorem: vex2-byte1-p-of-!vex2-byte1->r

    (defthm vex2-byte1-p-of-!vex2-byte1->r
      (b* ((new-x (!vex2-byte1->r$inline r x)))
        (vex2-byte1-p new-x))
      :rule-classes :rewrite)

    Theorem: !vex2-byte1->r$inline-of-bfix-r

    (defthm !vex2-byte1->r$inline-of-bfix-r
      (equal (!vex2-byte1->r$inline (bfix r) x)
             (!vex2-byte1->r$inline r x)))

    Theorem: !vex2-byte1->r$inline-bit-equiv-congruence-on-r

    (defthm !vex2-byte1->r$inline-bit-equiv-congruence-on-r
      (implies (bit-equiv r r-equiv)
               (equal (!vex2-byte1->r$inline r x)
                      (!vex2-byte1->r$inline r-equiv x)))
      :rule-classes :congruence)

    Theorem: !vex2-byte1->r$inline-of-vex2-byte1-fix-x

    (defthm !vex2-byte1->r$inline-of-vex2-byte1-fix-x
      (equal (!vex2-byte1->r$inline r (vex2-byte1-fix x))
             (!vex2-byte1->r$inline r x)))

    Theorem: !vex2-byte1->r$inline-vex2-byte1-equiv-congruence-on-x

    (defthm !vex2-byte1->r$inline-vex2-byte1-equiv-congruence-on-x
      (implies (vex2-byte1-equiv x x-equiv)
               (equal (!vex2-byte1->r$inline r x)
                      (!vex2-byte1->r$inline r x-equiv)))
      :rule-classes :congruence)

    Theorem: !vex2-byte1->r-is-vex2-byte1

    (defthm !vex2-byte1->r-is-vex2-byte1
      (equal (!vex2-byte1->r r x)
             (change-vex2-byte1 x :r r)))

    Theorem: vex2-byte1->r-of-!vex2-byte1->r

    (defthm vex2-byte1->r-of-!vex2-byte1->r
      (b* ((?new-x (!vex2-byte1->r$inline r x)))
        (equal (vex2-byte1->r new-x) (bfix r))))

    Theorem: !vex2-byte1->r-equiv-under-mask

    (defthm !vex2-byte1->r-equiv-under-mask
      (b* ((?new-x (!vex2-byte1->r$inline r x)))
        (vex2-byte1-equiv-under-mask new-x x 127)))

    Function: vex2-byte1-debug$inline

    (defun vex2-byte1-debug$inline (x)
      (declare (xargs :guard (vex2-byte1-p x)))
      (b* (((vex2-byte1 x)))
        (cons (cons 'pp x.pp)
              (cons (cons 'l x.l)
                    (cons (cons 'vvvv x.vvvv)
                          (cons (cons 'r x.r) nil))))))

    Function: vex3-byte1-p$inline

    (defun vex3-byte1-p$inline (vex3byte1)
      (declare (xargs :guard t))
      (mbe :logic (unsigned-byte-p 8 vex3byte1)
           :exec (and (natp vex3byte1)
                      (< vex3byte1 256))))

    Theorem: vex3-byte1-p-when-unsigned-byte-p

    (defthm vex3-byte1-p-when-unsigned-byte-p
      (implies (unsigned-byte-p 8 vex3byte1)
               (vex3-byte1-p vex3byte1)))

    Theorem: unsigned-byte-p-when-vex3-byte1-p

    (defthm unsigned-byte-p-when-vex3-byte1-p
      (implies (vex3-byte1-p vex3byte1)
               (unsigned-byte-p 8 vex3byte1)))

    Theorem: vex3-byte1-p-compound-recognizer

    (defthm vex3-byte1-p-compound-recognizer
      (implies (vex3-byte1-p vex3byte1)
               (natp vex3byte1))
      :rule-classes :compound-recognizer)

    Function: vex3-byte1-fix$inline

    (defun vex3-byte1-fix$inline (vex3byte1)
      (declare (xargs :guard (vex3-byte1-p vex3byte1)))
      (mbe :logic (loghead 8 vex3byte1)
           :exec vex3byte1))

    Theorem: vex3-byte1-p-of-vex3-byte1-fix

    (defthm vex3-byte1-p-of-vex3-byte1-fix
      (b* ((fty::fixed (vex3-byte1-fix$inline vex3byte1)))
        (vex3-byte1-p fty::fixed))
      :rule-classes :rewrite)

    Theorem: vex3-byte1-fix-when-vex3-byte1-p

    (defthm vex3-byte1-fix-when-vex3-byte1-p
      (implies (vex3-byte1-p vex3byte1)
               (equal (vex3-byte1-fix vex3byte1)
                      vex3byte1)))

    Function: vex3-byte1-equiv$inline

    (defun vex3-byte1-equiv$inline (x y)
      (declare (xargs :guard (and (vex3-byte1-p x)
                                  (vex3-byte1-p y))))
      (equal (vex3-byte1-fix x)
             (vex3-byte1-fix y)))

    Theorem: vex3-byte1-equiv-is-an-equivalence

    (defthm vex3-byte1-equiv-is-an-equivalence
      (and (booleanp (vex3-byte1-equiv x y))
           (vex3-byte1-equiv x x)
           (implies (vex3-byte1-equiv x y)
                    (vex3-byte1-equiv y x))
           (implies (and (vex3-byte1-equiv x y)
                         (vex3-byte1-equiv y z))
                    (vex3-byte1-equiv x z)))
      :rule-classes (:equivalence))

    Theorem: vex3-byte1-equiv-implies-equal-vex3-byte1-fix-1

    (defthm vex3-byte1-equiv-implies-equal-vex3-byte1-fix-1
      (implies (vex3-byte1-equiv x x-equiv)
               (equal (vex3-byte1-fix x)
                      (vex3-byte1-fix x-equiv)))
      :rule-classes (:congruence))

    Theorem: vex3-byte1-fix-under-vex3-byte1-equiv

    (defthm vex3-byte1-fix-under-vex3-byte1-equiv
      (vex3-byte1-equiv (vex3-byte1-fix x) x)
      :rule-classes (:rewrite :rewrite-quoted-constant))

    Function: vex3-byte1$inline

    (defun vex3-byte1$inline (m-mmmm b x r)
      (declare (xargs :guard (and (5bits-p m-mmmm)
                                  (bitp b)
                                  (bitp x)
                                  (bitp r))))
      (b* ((m-mmmm (mbe :logic (5bits-fix m-mmmm)
                        :exec m-mmmm))
           (b (mbe :logic (bfix b) :exec b))
           (x (mbe :logic (bfix x) :exec x))
           (r (mbe :logic (bfix r) :exec r)))
        (logapp 5 m-mmmm (logapp 1 b (logapp 1 x r)))))

    Theorem: vex3-byte1-p-of-vex3-byte1

    (defthm vex3-byte1-p-of-vex3-byte1
      (b* ((vex3-byte1 (vex3-byte1$inline m-mmmm b x r)))
        (vex3-byte1-p vex3-byte1))
      :rule-classes :rewrite)

    Theorem: vex3-byte1$inline-of-5bits-fix-m-mmmm

    (defthm vex3-byte1$inline-of-5bits-fix-m-mmmm
      (equal (vex3-byte1$inline (5bits-fix m-mmmm)
                                b x r)
             (vex3-byte1$inline m-mmmm b x r)))

    Theorem: vex3-byte1$inline-5bits-equiv-congruence-on-m-mmmm

    (defthm vex3-byte1$inline-5bits-equiv-congruence-on-m-mmmm
      (implies (5bits-equiv m-mmmm m-mmmm-equiv)
               (equal (vex3-byte1$inline m-mmmm b x r)
                      (vex3-byte1$inline m-mmmm-equiv b x r)))
      :rule-classes :congruence)

    Theorem: vex3-byte1$inline-of-bfix-b

    (defthm vex3-byte1$inline-of-bfix-b
      (equal (vex3-byte1$inline m-mmmm (bfix b) x r)
             (vex3-byte1$inline m-mmmm b x r)))

    Theorem: vex3-byte1$inline-bit-equiv-congruence-on-b

    (defthm vex3-byte1$inline-bit-equiv-congruence-on-b
      (implies (bit-equiv b b-equiv)
               (equal (vex3-byte1$inline m-mmmm b x r)
                      (vex3-byte1$inline m-mmmm b-equiv x r)))
      :rule-classes :congruence)

    Theorem: vex3-byte1$inline-of-bfix-x

    (defthm vex3-byte1$inline-of-bfix-x
      (equal (vex3-byte1$inline m-mmmm b (bfix x) r)
             (vex3-byte1$inline m-mmmm b x r)))

    Theorem: vex3-byte1$inline-bit-equiv-congruence-on-x

    (defthm vex3-byte1$inline-bit-equiv-congruence-on-x
      (implies (bit-equiv x x-equiv)
               (equal (vex3-byte1$inline m-mmmm b x r)
                      (vex3-byte1$inline m-mmmm b x-equiv r)))
      :rule-classes :congruence)

    Theorem: vex3-byte1$inline-of-bfix-r

    (defthm vex3-byte1$inline-of-bfix-r
      (equal (vex3-byte1$inline m-mmmm b x (bfix r))
             (vex3-byte1$inline m-mmmm b x r)))

    Theorem: vex3-byte1$inline-bit-equiv-congruence-on-r

    (defthm vex3-byte1$inline-bit-equiv-congruence-on-r
      (implies (bit-equiv r r-equiv)
               (equal (vex3-byte1$inline m-mmmm b x r)
                      (vex3-byte1$inline m-mmmm b x r-equiv)))
      :rule-classes :congruence)

    Function: vex3-byte1-equiv-under-mask$inline

    (defun vex3-byte1-equiv-under-mask$inline
           (vex3byte1 vex3byte11 mask)
      (declare (xargs :guard (and (vex3-byte1-p vex3byte1)
                                  (vex3-byte1-p vex3byte11)
                                  (integerp mask))))
      (fty::int-equiv-under-mask (vex3-byte1-fix vex3byte1)
                                 (vex3-byte1-fix vex3byte11)
                                 mask))

    Function: vex3-byte1->m-mmmm$inline

    (defun vex3-byte1->m-mmmm$inline (vex3byte1)
      (declare (xargs :guard (vex3-byte1-p vex3byte1)))
      (mbe :logic
           (let ((vex3byte1 (vex3-byte1-fix vex3byte1)))
             (part-select vex3byte1 :low 0 :width 5))
           :exec (the (unsigned-byte 5)
                      (logand (the (unsigned-byte 5) 31)
                              (the (unsigned-byte 8) vex3byte1)))))

    Theorem: 5bits-p-of-vex3-byte1->m-mmmm

    (defthm 5bits-p-of-vex3-byte1->m-mmmm
      (b* ((m-mmmm (vex3-byte1->m-mmmm$inline vex3byte1)))
        (5bits-p m-mmmm))
      :rule-classes :rewrite)

    Theorem: vex3-byte1->m-mmmm$inline-of-vex3-byte1-fix-vex3byte1

    (defthm vex3-byte1->m-mmmm$inline-of-vex3-byte1-fix-vex3byte1
      (equal (vex3-byte1->m-mmmm$inline (vex3-byte1-fix vex3byte1))
             (vex3-byte1->m-mmmm$inline vex3byte1)))

    Theorem: vex3-byte1->m-mmmm$inline-vex3-byte1-equiv-congruence-on-vex3byte1

    (defthm
     vex3-byte1->m-mmmm$inline-vex3-byte1-equiv-congruence-on-vex3byte1
     (implies (vex3-byte1-equiv vex3byte1 vex3byte1-equiv)
              (equal (vex3-byte1->m-mmmm$inline vex3byte1)
                     (vex3-byte1->m-mmmm$inline vex3byte1-equiv)))
     :rule-classes :congruence)

    Theorem: vex3-byte1->m-mmmm-of-vex3-byte1

    (defthm vex3-byte1->m-mmmm-of-vex3-byte1
      (equal (vex3-byte1->m-mmmm (vex3-byte1 m-mmmm b x r))
             (5bits-fix m-mmmm)))

    Theorem: vex3-byte1->m-mmmm-of-write-with-mask

    (defthm vex3-byte1->m-mmmm-of-write-with-mask
      (implies (and (fty::bitstruct-read-over-write-hyps
                         vex3byte1 vex3-byte1-equiv-under-mask)
                    (vex3-byte1-equiv-under-mask vex3byte1 y fty::mask)
                    (equal (logand (lognot fty::mask) 31)
                           0))
               (equal (vex3-byte1->m-mmmm vex3byte1)
                      (vex3-byte1->m-mmmm y))))

    Function: vex3-byte1->b$inline

    (defun vex3-byte1->b$inline (vex3byte1)
     (declare (xargs :guard (vex3-byte1-p vex3byte1)))
     (mbe :logic
          (let ((vex3byte1 (vex3-byte1-fix vex3byte1)))
            (part-select vex3byte1 :low 5 :width 1))
          :exec (the (unsigned-byte 1)
                     (logand (the (unsigned-byte 1) 1)
                             (the (unsigned-byte 3)
                                  (ash (the (unsigned-byte 8) vex3byte1)
                                       -5))))))

    Theorem: bitp-of-vex3-byte1->b

    (defthm bitp-of-vex3-byte1->b
      (b* ((b (vex3-byte1->b$inline vex3byte1)))
        (bitp b))
      :rule-classes :rewrite)

    Theorem: vex3-byte1->b$inline-of-vex3-byte1-fix-vex3byte1

    (defthm vex3-byte1->b$inline-of-vex3-byte1-fix-vex3byte1
      (equal (vex3-byte1->b$inline (vex3-byte1-fix vex3byte1))
             (vex3-byte1->b$inline vex3byte1)))

    Theorem: vex3-byte1->b$inline-vex3-byte1-equiv-congruence-on-vex3byte1

    (defthm
          vex3-byte1->b$inline-vex3-byte1-equiv-congruence-on-vex3byte1
      (implies (vex3-byte1-equiv vex3byte1 vex3byte1-equiv)
               (equal (vex3-byte1->b$inline vex3byte1)
                      (vex3-byte1->b$inline vex3byte1-equiv)))
      :rule-classes :congruence)

    Theorem: vex3-byte1->b-of-vex3-byte1

    (defthm vex3-byte1->b-of-vex3-byte1
      (equal (vex3-byte1->b (vex3-byte1 m-mmmm b x r))
             (bfix b)))

    Theorem: vex3-byte1->b-of-write-with-mask

    (defthm vex3-byte1->b-of-write-with-mask
      (implies (and (fty::bitstruct-read-over-write-hyps
                         vex3byte1 vex3-byte1-equiv-under-mask)
                    (vex3-byte1-equiv-under-mask vex3byte1 y fty::mask)
                    (equal (logand (lognot fty::mask) 32)
                           0))
               (equal (vex3-byte1->b vex3byte1)
                      (vex3-byte1->b y))))

    Function: vex3-byte1->x$inline

    (defun vex3-byte1->x$inline (vex3byte1)
     (declare (xargs :guard (vex3-byte1-p vex3byte1)))
     (mbe :logic
          (let ((vex3byte1 (vex3-byte1-fix vex3byte1)))
            (part-select vex3byte1 :low 6 :width 1))
          :exec (the (unsigned-byte 1)
                     (logand (the (unsigned-byte 1) 1)
                             (the (unsigned-byte 2)
                                  (ash (the (unsigned-byte 8) vex3byte1)
                                       -6))))))

    Theorem: bitp-of-vex3-byte1->x

    (defthm bitp-of-vex3-byte1->x
      (b* ((x (vex3-byte1->x$inline vex3byte1)))
        (bitp x))
      :rule-classes :rewrite)

    Theorem: vex3-byte1->x$inline-of-vex3-byte1-fix-vex3byte1

    (defthm vex3-byte1->x$inline-of-vex3-byte1-fix-vex3byte1
      (equal (vex3-byte1->x$inline (vex3-byte1-fix vex3byte1))
             (vex3-byte1->x$inline vex3byte1)))

    Theorem: vex3-byte1->x$inline-vex3-byte1-equiv-congruence-on-vex3byte1

    (defthm
          vex3-byte1->x$inline-vex3-byte1-equiv-congruence-on-vex3byte1
      (implies (vex3-byte1-equiv vex3byte1 vex3byte1-equiv)
               (equal (vex3-byte1->x$inline vex3byte1)
                      (vex3-byte1->x$inline vex3byte1-equiv)))
      :rule-classes :congruence)

    Theorem: vex3-byte1->x-of-vex3-byte1

    (defthm vex3-byte1->x-of-vex3-byte1
      (equal (vex3-byte1->x (vex3-byte1 m-mmmm b x r))
             (bfix x)))

    Theorem: vex3-byte1->x-of-write-with-mask

    (defthm vex3-byte1->x-of-write-with-mask
      (implies (and (fty::bitstruct-read-over-write-hyps
                         vex3byte1 vex3-byte1-equiv-under-mask)
                    (vex3-byte1-equiv-under-mask vex3byte1 y fty::mask)
                    (equal (logand (lognot fty::mask) 64)
                           0))
               (equal (vex3-byte1->x vex3byte1)
                      (vex3-byte1->x y))))

    Function: vex3-byte1->r$inline

    (defun vex3-byte1->r$inline (vex3byte1)
     (declare (xargs :guard (vex3-byte1-p vex3byte1)))
     (mbe :logic
          (let ((vex3byte1 (vex3-byte1-fix vex3byte1)))
            (part-select vex3byte1 :low 7 :width 1))
          :exec (the (unsigned-byte 1)
                     (logand (the (unsigned-byte 1) 1)
                             (the (unsigned-byte 1)
                                  (ash (the (unsigned-byte 8) vex3byte1)
                                       -7))))))

    Theorem: bitp-of-vex3-byte1->r

    (defthm bitp-of-vex3-byte1->r
      (b* ((r (vex3-byte1->r$inline vex3byte1)))
        (bitp r))
      :rule-classes :rewrite)

    Theorem: vex3-byte1->r$inline-of-vex3-byte1-fix-vex3byte1

    (defthm vex3-byte1->r$inline-of-vex3-byte1-fix-vex3byte1
      (equal (vex3-byte1->r$inline (vex3-byte1-fix vex3byte1))
             (vex3-byte1->r$inline vex3byte1)))

    Theorem: vex3-byte1->r$inline-vex3-byte1-equiv-congruence-on-vex3byte1

    (defthm
          vex3-byte1->r$inline-vex3-byte1-equiv-congruence-on-vex3byte1
      (implies (vex3-byte1-equiv vex3byte1 vex3byte1-equiv)
               (equal (vex3-byte1->r$inline vex3byte1)
                      (vex3-byte1->r$inline vex3byte1-equiv)))
      :rule-classes :congruence)

    Theorem: vex3-byte1->r-of-vex3-byte1

    (defthm vex3-byte1->r-of-vex3-byte1
      (equal (vex3-byte1->r (vex3-byte1 m-mmmm b x r))
             (bfix r)))

    Theorem: vex3-byte1->r-of-write-with-mask

    (defthm vex3-byte1->r-of-write-with-mask
      (implies (and (fty::bitstruct-read-over-write-hyps
                         vex3byte1 vex3-byte1-equiv-under-mask)
                    (vex3-byte1-equiv-under-mask vex3byte1 y fty::mask)
                    (equal (logand (lognot fty::mask) 128)
                           0))
               (equal (vex3-byte1->r vex3byte1)
                      (vex3-byte1->r y))))

    Theorem: vex3-byte1-fix-in-terms-of-vex3-byte1

    (defthm vex3-byte1-fix-in-terms-of-vex3-byte1
      (equal (vex3-byte1-fix vex3byte1)
             (change-vex3-byte1 vex3byte1)))

    Function: !vex3-byte1->m-mmmm$inline

    (defun !vex3-byte1->m-mmmm$inline (m-mmmm vex3byte1)
     (declare (xargs :guard (and (5bits-p m-mmmm)
                                 (vex3-byte1-p vex3byte1))))
     (mbe
       :logic
       (b* ((m-mmmm (mbe :logic (5bits-fix m-mmmm)
                         :exec m-mmmm))
            (vex3byte1 (vex3-byte1-fix vex3byte1)))
         (part-install m-mmmm vex3byte1
                       :width 5
                       :low 0))
       :exec (the (unsigned-byte 8)
                  (logior (the (unsigned-byte 8)
                               (logand (the (unsigned-byte 8) vex3byte1)
                                       (the (signed-byte 6) -32)))
                          (the (unsigned-byte 5) m-mmmm)))))

    Theorem: vex3-byte1-p-of-!vex3-byte1->m-mmmm

    (defthm vex3-byte1-p-of-!vex3-byte1->m-mmmm
     (b* ((new-vex3byte1 (!vex3-byte1->m-mmmm$inline m-mmmm vex3byte1)))
       (vex3-byte1-p new-vex3byte1))
     :rule-classes :rewrite)

    Theorem: !vex3-byte1->m-mmmm$inline-of-5bits-fix-m-mmmm

    (defthm !vex3-byte1->m-mmmm$inline-of-5bits-fix-m-mmmm
      (equal (!vex3-byte1->m-mmmm$inline (5bits-fix m-mmmm)
                                         vex3byte1)
             (!vex3-byte1->m-mmmm$inline m-mmmm vex3byte1)))

    Theorem: !vex3-byte1->m-mmmm$inline-5bits-equiv-congruence-on-m-mmmm

    (defthm !vex3-byte1->m-mmmm$inline-5bits-equiv-congruence-on-m-mmmm
      (implies
           (5bits-equiv m-mmmm m-mmmm-equiv)
           (equal (!vex3-byte1->m-mmmm$inline m-mmmm vex3byte1)
                  (!vex3-byte1->m-mmmm$inline m-mmmm-equiv vex3byte1)))
      :rule-classes :congruence)

    Theorem: !vex3-byte1->m-mmmm$inline-of-vex3-byte1-fix-vex3byte1

    (defthm !vex3-byte1->m-mmmm$inline-of-vex3-byte1-fix-vex3byte1
     (equal
          (!vex3-byte1->m-mmmm$inline m-mmmm (vex3-byte1-fix vex3byte1))
          (!vex3-byte1->m-mmmm$inline m-mmmm vex3byte1)))

    Theorem: !vex3-byte1->m-mmmm$inline-vex3-byte1-equiv-congruence-on-vex3byte1

    (defthm
     !vex3-byte1->m-mmmm$inline-vex3-byte1-equiv-congruence-on-vex3byte1
     (implies
          (vex3-byte1-equiv vex3byte1 vex3byte1-equiv)
          (equal (!vex3-byte1->m-mmmm$inline m-mmmm vex3byte1)
                 (!vex3-byte1->m-mmmm$inline m-mmmm vex3byte1-equiv)))
     :rule-classes :congruence)

    Theorem: !vex3-byte1->m-mmmm-is-vex3-byte1

    (defthm !vex3-byte1->m-mmmm-is-vex3-byte1
      (equal (!vex3-byte1->m-mmmm m-mmmm vex3byte1)
             (change-vex3-byte1 vex3byte1
                                :m-mmmm m-mmmm)))

    Theorem: vex3-byte1->m-mmmm-of-!vex3-byte1->m-mmmm

    (defthm vex3-byte1->m-mmmm-of-!vex3-byte1->m-mmmm
      (b*
        ((?new-vex3byte1 (!vex3-byte1->m-mmmm$inline m-mmmm vex3byte1)))
        (equal (vex3-byte1->m-mmmm new-vex3byte1)
               (5bits-fix m-mmmm))))

    Theorem: !vex3-byte1->m-mmmm-equiv-under-mask

    (defthm !vex3-byte1->m-mmmm-equiv-under-mask
      (b*
        ((?new-vex3byte1 (!vex3-byte1->m-mmmm$inline m-mmmm vex3byte1)))
        (vex3-byte1-equiv-under-mask new-vex3byte1 vex3byte1 -32)))

    Function: !vex3-byte1->b$inline

    (defun !vex3-byte1->b$inline (b vex3byte1)
     (declare (xargs :guard (and (bitp b)
                                 (vex3-byte1-p vex3byte1))))
     (mbe
       :logic
       (b* ((b (mbe :logic (bfix b) :exec b))
            (vex3byte1 (vex3-byte1-fix vex3byte1)))
         (part-install b vex3byte1
                       :width 1
                       :low 5))
       :exec (the (unsigned-byte 8)
                  (logior (the (unsigned-byte 8)
                               (logand (the (unsigned-byte 8) vex3byte1)
                                       (the (signed-byte 7) -33)))
                          (the (unsigned-byte 6)
                               (ash (the (unsigned-byte 1) b) 5))))))

    Theorem: vex3-byte1-p-of-!vex3-byte1->b

    (defthm vex3-byte1-p-of-!vex3-byte1->b
      (b* ((new-vex3byte1 (!vex3-byte1->b$inline b vex3byte1)))
        (vex3-byte1-p new-vex3byte1))
      :rule-classes :rewrite)

    Theorem: !vex3-byte1->b$inline-of-bfix-b

    (defthm !vex3-byte1->b$inline-of-bfix-b
      (equal (!vex3-byte1->b$inline (bfix b)
                                    vex3byte1)
             (!vex3-byte1->b$inline b vex3byte1)))

    Theorem: !vex3-byte1->b$inline-bit-equiv-congruence-on-b

    (defthm !vex3-byte1->b$inline-bit-equiv-congruence-on-b
      (implies (bit-equiv b b-equiv)
               (equal (!vex3-byte1->b$inline b vex3byte1)
                      (!vex3-byte1->b$inline b-equiv vex3byte1)))
      :rule-classes :congruence)

    Theorem: !vex3-byte1->b$inline-of-vex3-byte1-fix-vex3byte1

    (defthm !vex3-byte1->b$inline-of-vex3-byte1-fix-vex3byte1
      (equal (!vex3-byte1->b$inline b (vex3-byte1-fix vex3byte1))
             (!vex3-byte1->b$inline b vex3byte1)))

    Theorem: !vex3-byte1->b$inline-vex3-byte1-equiv-congruence-on-vex3byte1

    (defthm
         !vex3-byte1->b$inline-vex3-byte1-equiv-congruence-on-vex3byte1
      (implies (vex3-byte1-equiv vex3byte1 vex3byte1-equiv)
               (equal (!vex3-byte1->b$inline b vex3byte1)
                      (!vex3-byte1->b$inline b vex3byte1-equiv)))
      :rule-classes :congruence)

    Theorem: !vex3-byte1->b-is-vex3-byte1

    (defthm !vex3-byte1->b-is-vex3-byte1
      (equal (!vex3-byte1->b b vex3byte1)
             (change-vex3-byte1 vex3byte1 :b b)))

    Theorem: vex3-byte1->b-of-!vex3-byte1->b

    (defthm vex3-byte1->b-of-!vex3-byte1->b
      (b* ((?new-vex3byte1 (!vex3-byte1->b$inline b vex3byte1)))
        (equal (vex3-byte1->b new-vex3byte1)
               (bfix b))))

    Theorem: !vex3-byte1->b-equiv-under-mask

    (defthm !vex3-byte1->b-equiv-under-mask
      (b* ((?new-vex3byte1 (!vex3-byte1->b$inline b vex3byte1)))
        (vex3-byte1-equiv-under-mask new-vex3byte1 vex3byte1 -33)))

    Function: !vex3-byte1->x$inline

    (defun !vex3-byte1->x$inline (x vex3byte1)
     (declare (xargs :guard (and (bitp x)
                                 (vex3-byte1-p vex3byte1))))
     (mbe
       :logic
       (b* ((x (mbe :logic (bfix x) :exec x))
            (vex3byte1 (vex3-byte1-fix vex3byte1)))
         (part-install x vex3byte1
                       :width 1
                       :low 6))
       :exec (the (unsigned-byte 8)
                  (logior (the (unsigned-byte 8)
                               (logand (the (unsigned-byte 8) vex3byte1)
                                       (the (signed-byte 8) -65)))
                          (the (unsigned-byte 7)
                               (ash (the (unsigned-byte 1) x) 6))))))

    Theorem: vex3-byte1-p-of-!vex3-byte1->x

    (defthm vex3-byte1-p-of-!vex3-byte1->x
      (b* ((new-vex3byte1 (!vex3-byte1->x$inline x vex3byte1)))
        (vex3-byte1-p new-vex3byte1))
      :rule-classes :rewrite)

    Theorem: !vex3-byte1->x$inline-of-bfix-x

    (defthm !vex3-byte1->x$inline-of-bfix-x
      (equal (!vex3-byte1->x$inline (bfix x)
                                    vex3byte1)
             (!vex3-byte1->x$inline x vex3byte1)))

    Theorem: !vex3-byte1->x$inline-bit-equiv-congruence-on-x

    (defthm !vex3-byte1->x$inline-bit-equiv-congruence-on-x
      (implies (bit-equiv x x-equiv)
               (equal (!vex3-byte1->x$inline x vex3byte1)
                      (!vex3-byte1->x$inline x-equiv vex3byte1)))
      :rule-classes :congruence)

    Theorem: !vex3-byte1->x$inline-of-vex3-byte1-fix-vex3byte1

    (defthm !vex3-byte1->x$inline-of-vex3-byte1-fix-vex3byte1
      (equal (!vex3-byte1->x$inline x (vex3-byte1-fix vex3byte1))
             (!vex3-byte1->x$inline x vex3byte1)))

    Theorem: !vex3-byte1->x$inline-vex3-byte1-equiv-congruence-on-vex3byte1

    (defthm
         !vex3-byte1->x$inline-vex3-byte1-equiv-congruence-on-vex3byte1
      (implies (vex3-byte1-equiv vex3byte1 vex3byte1-equiv)
               (equal (!vex3-byte1->x$inline x vex3byte1)
                      (!vex3-byte1->x$inline x vex3byte1-equiv)))
      :rule-classes :congruence)

    Theorem: !vex3-byte1->x-is-vex3-byte1

    (defthm !vex3-byte1->x-is-vex3-byte1
      (equal (!vex3-byte1->x x vex3byte1)
             (change-vex3-byte1 vex3byte1 :x x)))

    Theorem: vex3-byte1->x-of-!vex3-byte1->x

    (defthm vex3-byte1->x-of-!vex3-byte1->x
      (b* ((?new-vex3byte1 (!vex3-byte1->x$inline x vex3byte1)))
        (equal (vex3-byte1->x new-vex3byte1)
               (bfix x))))

    Theorem: !vex3-byte1->x-equiv-under-mask

    (defthm !vex3-byte1->x-equiv-under-mask
      (b* ((?new-vex3byte1 (!vex3-byte1->x$inline x vex3byte1)))
        (vex3-byte1-equiv-under-mask new-vex3byte1 vex3byte1 -65)))

    Function: !vex3-byte1->r$inline

    (defun !vex3-byte1->r$inline (r vex3byte1)
     (declare (xargs :guard (and (bitp r)
                                 (vex3-byte1-p vex3byte1))))
     (mbe
       :logic
       (b* ((r (mbe :logic (bfix r) :exec r))
            (vex3byte1 (vex3-byte1-fix vex3byte1)))
         (part-install r vex3byte1
                       :width 1
                       :low 7))
       :exec (the (unsigned-byte 8)
                  (logior (the (unsigned-byte 8)
                               (logand (the (unsigned-byte 8) vex3byte1)
                                       (the (signed-byte 9) -129)))
                          (the (unsigned-byte 8)
                               (ash (the (unsigned-byte 1) r) 7))))))

    Theorem: vex3-byte1-p-of-!vex3-byte1->r

    (defthm vex3-byte1-p-of-!vex3-byte1->r
      (b* ((new-vex3byte1 (!vex3-byte1->r$inline r vex3byte1)))
        (vex3-byte1-p new-vex3byte1))
      :rule-classes :rewrite)

    Theorem: !vex3-byte1->r$inline-of-bfix-r

    (defthm !vex3-byte1->r$inline-of-bfix-r
      (equal (!vex3-byte1->r$inline (bfix r)
                                    vex3byte1)
             (!vex3-byte1->r$inline r vex3byte1)))

    Theorem: !vex3-byte1->r$inline-bit-equiv-congruence-on-r

    (defthm !vex3-byte1->r$inline-bit-equiv-congruence-on-r
      (implies (bit-equiv r r-equiv)
               (equal (!vex3-byte1->r$inline r vex3byte1)
                      (!vex3-byte1->r$inline r-equiv vex3byte1)))
      :rule-classes :congruence)

    Theorem: !vex3-byte1->r$inline-of-vex3-byte1-fix-vex3byte1

    (defthm !vex3-byte1->r$inline-of-vex3-byte1-fix-vex3byte1
      (equal (!vex3-byte1->r$inline r (vex3-byte1-fix vex3byte1))
             (!vex3-byte1->r$inline r vex3byte1)))

    Theorem: !vex3-byte1->r$inline-vex3-byte1-equiv-congruence-on-vex3byte1

    (defthm
         !vex3-byte1->r$inline-vex3-byte1-equiv-congruence-on-vex3byte1
      (implies (vex3-byte1-equiv vex3byte1 vex3byte1-equiv)
               (equal (!vex3-byte1->r$inline r vex3byte1)
                      (!vex3-byte1->r$inline r vex3byte1-equiv)))
      :rule-classes :congruence)

    Theorem: !vex3-byte1->r-is-vex3-byte1

    (defthm !vex3-byte1->r-is-vex3-byte1
      (equal (!vex3-byte1->r r vex3byte1)
             (change-vex3-byte1 vex3byte1 :r r)))

    Theorem: vex3-byte1->r-of-!vex3-byte1->r

    (defthm vex3-byte1->r-of-!vex3-byte1->r
      (b* ((?new-vex3byte1 (!vex3-byte1->r$inline r vex3byte1)))
        (equal (vex3-byte1->r new-vex3byte1)
               (bfix r))))

    Theorem: !vex3-byte1->r-equiv-under-mask

    (defthm !vex3-byte1->r-equiv-under-mask
      (b* ((?new-vex3byte1 (!vex3-byte1->r$inline r vex3byte1)))
        (vex3-byte1-equiv-under-mask new-vex3byte1 vex3byte1 127)))

    Function: vex3-byte1-debug$inline

    (defun vex3-byte1-debug$inline (vex3byte1)
      (declare (xargs :guard (vex3-byte1-p vex3byte1)))
      (b* (((vex3-byte1 vex3byte1)))
        (cons (cons 'm-mmmm vex3byte1.m-mmmm)
              (cons (cons 'b vex3byte1.b)
                    (cons (cons 'x vex3byte1.x)
                          (cons (cons 'r vex3byte1.r) nil))))))

    Function: vex3-byte2-p$inline

    (defun vex3-byte2-p$inline (x)
      (declare (xargs :guard t))
      (mbe :logic (unsigned-byte-p 8 x)
           :exec (and (natp x) (< x 256))))

    Theorem: vex3-byte2-p-when-unsigned-byte-p

    (defthm vex3-byte2-p-when-unsigned-byte-p
      (implies (unsigned-byte-p 8 x)
               (vex3-byte2-p x)))

    Theorem: unsigned-byte-p-when-vex3-byte2-p

    (defthm unsigned-byte-p-when-vex3-byte2-p
      (implies (vex3-byte2-p x)
               (unsigned-byte-p 8 x)))

    Theorem: vex3-byte2-p-compound-recognizer

    (defthm vex3-byte2-p-compound-recognizer
      (implies (vex3-byte2-p x) (natp x))
      :rule-classes :compound-recognizer)

    Function: vex3-byte2-fix$inline

    (defun vex3-byte2-fix$inline (x)
      (declare (xargs :guard (vex3-byte2-p x)))
      (mbe :logic (loghead 8 x) :exec x))

    Theorem: vex3-byte2-p-of-vex3-byte2-fix

    (defthm vex3-byte2-p-of-vex3-byte2-fix
      (b* ((fty::fixed (vex3-byte2-fix$inline x)))
        (vex3-byte2-p fty::fixed))
      :rule-classes :rewrite)

    Theorem: vex3-byte2-fix-when-vex3-byte2-p

    (defthm vex3-byte2-fix-when-vex3-byte2-p
      (implies (vex3-byte2-p x)
               (equal (vex3-byte2-fix x) x)))

    Function: vex3-byte2-equiv$inline

    (defun vex3-byte2-equiv$inline (x y)
      (declare (xargs :guard (and (vex3-byte2-p x)
                                  (vex3-byte2-p y))))
      (equal (vex3-byte2-fix x)
             (vex3-byte2-fix y)))

    Theorem: vex3-byte2-equiv-is-an-equivalence

    (defthm vex3-byte2-equiv-is-an-equivalence
      (and (booleanp (vex3-byte2-equiv x y))
           (vex3-byte2-equiv x x)
           (implies (vex3-byte2-equiv x y)
                    (vex3-byte2-equiv y x))
           (implies (and (vex3-byte2-equiv x y)
                         (vex3-byte2-equiv y z))
                    (vex3-byte2-equiv x z)))
      :rule-classes (:equivalence))

    Theorem: vex3-byte2-equiv-implies-equal-vex3-byte2-fix-1

    (defthm vex3-byte2-equiv-implies-equal-vex3-byte2-fix-1
      (implies (vex3-byte2-equiv x x-equiv)
               (equal (vex3-byte2-fix x)
                      (vex3-byte2-fix x-equiv)))
      :rule-classes (:congruence))

    Theorem: vex3-byte2-fix-under-vex3-byte2-equiv

    (defthm vex3-byte2-fix-under-vex3-byte2-equiv
      (vex3-byte2-equiv (vex3-byte2-fix x) x)
      :rule-classes (:rewrite :rewrite-quoted-constant))

    Function: vex3-byte2$inline

    (defun vex3-byte2$inline (pp l vvvv w)
      (declare (xargs :guard (and (2bits-p pp)
                                  (bitp l)
                                  (4bits-p vvvv)
                                  (bitp w))))
      (b* ((pp (mbe :logic (2bits-fix pp) :exec pp))
           (l (mbe :logic (bfix l) :exec l))
           (vvvv (mbe :logic (4bits-fix vvvv)
                      :exec vvvv))
           (w (mbe :logic (bfix w) :exec w)))
        (logapp 2 pp (logapp 1 l (logapp 4 vvvv w)))))

    Theorem: vex3-byte2-p-of-vex3-byte2

    (defthm vex3-byte2-p-of-vex3-byte2
      (b* ((vex3-byte2 (vex3-byte2$inline pp l vvvv w)))
        (vex3-byte2-p vex3-byte2))
      :rule-classes :rewrite)

    Theorem: vex3-byte2$inline-of-2bits-fix-pp

    (defthm vex3-byte2$inline-of-2bits-fix-pp
      (equal (vex3-byte2$inline (2bits-fix pp)
                                l vvvv w)
             (vex3-byte2$inline pp l vvvv w)))

    Theorem: vex3-byte2$inline-2bits-equiv-congruence-on-pp

    (defthm vex3-byte2$inline-2bits-equiv-congruence-on-pp
      (implies (2bits-equiv pp pp-equiv)
               (equal (vex3-byte2$inline pp l vvvv w)
                      (vex3-byte2$inline pp-equiv l vvvv w)))
      :rule-classes :congruence)

    Theorem: vex3-byte2$inline-of-bfix-l

    (defthm vex3-byte2$inline-of-bfix-l
      (equal (vex3-byte2$inline pp (bfix l) vvvv w)
             (vex3-byte2$inline pp l vvvv w)))

    Theorem: vex3-byte2$inline-bit-equiv-congruence-on-l

    (defthm vex3-byte2$inline-bit-equiv-congruence-on-l
      (implies (bit-equiv l l-equiv)
               (equal (vex3-byte2$inline pp l vvvv w)
                      (vex3-byte2$inline pp l-equiv vvvv w)))
      :rule-classes :congruence)

    Theorem: vex3-byte2$inline-of-4bits-fix-vvvv

    (defthm vex3-byte2$inline-of-4bits-fix-vvvv
      (equal (vex3-byte2$inline pp l (4bits-fix vvvv)
                                w)
             (vex3-byte2$inline pp l vvvv w)))

    Theorem: vex3-byte2$inline-4bits-equiv-congruence-on-vvvv

    (defthm vex3-byte2$inline-4bits-equiv-congruence-on-vvvv
      (implies (4bits-equiv vvvv vvvv-equiv)
               (equal (vex3-byte2$inline pp l vvvv w)
                      (vex3-byte2$inline pp l vvvv-equiv w)))
      :rule-classes :congruence)

    Theorem: vex3-byte2$inline-of-bfix-w

    (defthm vex3-byte2$inline-of-bfix-w
      (equal (vex3-byte2$inline pp l vvvv (bfix w))
             (vex3-byte2$inline pp l vvvv w)))

    Theorem: vex3-byte2$inline-bit-equiv-congruence-on-w

    (defthm vex3-byte2$inline-bit-equiv-congruence-on-w
      (implies (bit-equiv w w-equiv)
               (equal (vex3-byte2$inline pp l vvvv w)
                      (vex3-byte2$inline pp l vvvv w-equiv)))
      :rule-classes :congruence)

    Function: vex3-byte2-equiv-under-mask$inline

    (defun vex3-byte2-equiv-under-mask$inline (x x1 mask)
      (declare (xargs :guard (and (vex3-byte2-p x)
                                  (vex3-byte2-p x1)
                                  (integerp mask))))
      (fty::int-equiv-under-mask (vex3-byte2-fix x)
                                 (vex3-byte2-fix x1)
                                 mask))

    Function: vex3-byte2->pp$inline

    (defun vex3-byte2->pp$inline (x)
      (declare (xargs :guard (vex3-byte2-p x)))
      (mbe :logic
           (let ((x (vex3-byte2-fix x)))
             (part-select x :low 0 :width 2))
           :exec (the (unsigned-byte 2)
                      (logand (the (unsigned-byte 2) 3)
                              (the (unsigned-byte 8) x)))))

    Theorem: 2bits-p-of-vex3-byte2->pp

    (defthm 2bits-p-of-vex3-byte2->pp
      (b* ((pp (vex3-byte2->pp$inline x)))
        (2bits-p pp))
      :rule-classes :rewrite)

    Theorem: vex3-byte2->pp$inline-of-vex3-byte2-fix-x

    (defthm vex3-byte2->pp$inline-of-vex3-byte2-fix-x
      (equal (vex3-byte2->pp$inline (vex3-byte2-fix x))
             (vex3-byte2->pp$inline x)))

    Theorem: vex3-byte2->pp$inline-vex3-byte2-equiv-congruence-on-x

    (defthm vex3-byte2->pp$inline-vex3-byte2-equiv-congruence-on-x
      (implies (vex3-byte2-equiv x x-equiv)
               (equal (vex3-byte2->pp$inline x)
                      (vex3-byte2->pp$inline x-equiv)))
      :rule-classes :congruence)

    Theorem: vex3-byte2->pp-of-vex3-byte2

    (defthm vex3-byte2->pp-of-vex3-byte2
      (equal (vex3-byte2->pp (vex3-byte2 pp l vvvv w))
             (2bits-fix pp)))

    Theorem: vex3-byte2->pp-of-write-with-mask

    (defthm vex3-byte2->pp-of-write-with-mask
      (implies (and (fty::bitstruct-read-over-write-hyps
                         x vex3-byte2-equiv-under-mask)
                    (vex3-byte2-equiv-under-mask x y fty::mask)
                    (equal (logand (lognot fty::mask) 3) 0))
               (equal (vex3-byte2->pp x)
                      (vex3-byte2->pp y))))

    Function: vex3-byte2->l$inline

    (defun vex3-byte2->l$inline (x)
     (declare (xargs :guard (vex3-byte2-p x)))
     (mbe
         :logic
         (let ((x (vex3-byte2-fix x)))
           (part-select x :low 2 :width 1))
         :exec (the (unsigned-byte 1)
                    (logand (the (unsigned-byte 1) 1)
                            (the (unsigned-byte 6)
                                 (ash (the (unsigned-byte 8) x) -2))))))

    Theorem: bitp-of-vex3-byte2->l

    (defthm bitp-of-vex3-byte2->l
      (b* ((l (vex3-byte2->l$inline x)))
        (bitp l))
      :rule-classes :rewrite)

    Theorem: vex3-byte2->l$inline-of-vex3-byte2-fix-x

    (defthm vex3-byte2->l$inline-of-vex3-byte2-fix-x
      (equal (vex3-byte2->l$inline (vex3-byte2-fix x))
             (vex3-byte2->l$inline x)))

    Theorem: vex3-byte2->l$inline-vex3-byte2-equiv-congruence-on-x

    (defthm vex3-byte2->l$inline-vex3-byte2-equiv-congruence-on-x
      (implies (vex3-byte2-equiv x x-equiv)
               (equal (vex3-byte2->l$inline x)
                      (vex3-byte2->l$inline x-equiv)))
      :rule-classes :congruence)

    Theorem: vex3-byte2->l-of-vex3-byte2

    (defthm vex3-byte2->l-of-vex3-byte2
      (equal (vex3-byte2->l (vex3-byte2 pp l vvvv w))
             (bfix l)))

    Theorem: vex3-byte2->l-of-write-with-mask

    (defthm vex3-byte2->l-of-write-with-mask
      (implies (and (fty::bitstruct-read-over-write-hyps
                         x vex3-byte2-equiv-under-mask)
                    (vex3-byte2-equiv-under-mask x y fty::mask)
                    (equal (logand (lognot fty::mask) 4) 0))
               (equal (vex3-byte2->l x)
                      (vex3-byte2->l y))))

    Function: vex3-byte2->vvvv$inline

    (defun vex3-byte2->vvvv$inline (x)
     (declare (xargs :guard (vex3-byte2-p x)))
     (mbe
         :logic
         (let ((x (vex3-byte2-fix x)))
           (part-select x :low 3 :width 4))
         :exec (the (unsigned-byte 4)
                    (logand (the (unsigned-byte 4) 15)
                            (the (unsigned-byte 5)
                                 (ash (the (unsigned-byte 8) x) -3))))))

    Theorem: 4bits-p-of-vex3-byte2->vvvv

    (defthm 4bits-p-of-vex3-byte2->vvvv
      (b* ((vvvv (vex3-byte2->vvvv$inline x)))
        (4bits-p vvvv))
      :rule-classes :rewrite)

    Theorem: vex3-byte2->vvvv$inline-of-vex3-byte2-fix-x

    (defthm vex3-byte2->vvvv$inline-of-vex3-byte2-fix-x
      (equal (vex3-byte2->vvvv$inline (vex3-byte2-fix x))
             (vex3-byte2->vvvv$inline x)))

    Theorem: vex3-byte2->vvvv$inline-vex3-byte2-equiv-congruence-on-x

    (defthm vex3-byte2->vvvv$inline-vex3-byte2-equiv-congruence-on-x
      (implies (vex3-byte2-equiv x x-equiv)
               (equal (vex3-byte2->vvvv$inline x)
                      (vex3-byte2->vvvv$inline x-equiv)))
      :rule-classes :congruence)

    Theorem: vex3-byte2->vvvv-of-vex3-byte2

    (defthm vex3-byte2->vvvv-of-vex3-byte2
      (equal (vex3-byte2->vvvv (vex3-byte2 pp l vvvv w))
             (4bits-fix vvvv)))

    Theorem: vex3-byte2->vvvv-of-write-with-mask

    (defthm vex3-byte2->vvvv-of-write-with-mask
      (implies (and (fty::bitstruct-read-over-write-hyps
                         x vex3-byte2-equiv-under-mask)
                    (vex3-byte2-equiv-under-mask x y fty::mask)
                    (equal (logand (lognot fty::mask) 120)
                           0))
               (equal (vex3-byte2->vvvv x)
                      (vex3-byte2->vvvv y))))

    Function: vex3-byte2->w$inline

    (defun vex3-byte2->w$inline (x)
     (declare (xargs :guard (vex3-byte2-p x)))
     (mbe
         :logic
         (let ((x (vex3-byte2-fix x)))
           (part-select x :low 7 :width 1))
         :exec (the (unsigned-byte 1)
                    (logand (the (unsigned-byte 1) 1)
                            (the (unsigned-byte 1)
                                 (ash (the (unsigned-byte 8) x) -7))))))

    Theorem: bitp-of-vex3-byte2->w

    (defthm bitp-of-vex3-byte2->w
      (b* ((w (vex3-byte2->w$inline x)))
        (bitp w))
      :rule-classes :rewrite)

    Theorem: vex3-byte2->w$inline-of-vex3-byte2-fix-x

    (defthm vex3-byte2->w$inline-of-vex3-byte2-fix-x
      (equal (vex3-byte2->w$inline (vex3-byte2-fix x))
             (vex3-byte2->w$inline x)))

    Theorem: vex3-byte2->w$inline-vex3-byte2-equiv-congruence-on-x

    (defthm vex3-byte2->w$inline-vex3-byte2-equiv-congruence-on-x
      (implies (vex3-byte2-equiv x x-equiv)
               (equal (vex3-byte2->w$inline x)
                      (vex3-byte2->w$inline x-equiv)))
      :rule-classes :congruence)

    Theorem: vex3-byte2->w-of-vex3-byte2

    (defthm vex3-byte2->w-of-vex3-byte2
      (equal (vex3-byte2->w (vex3-byte2 pp l vvvv w))
             (bfix w)))

    Theorem: vex3-byte2->w-of-write-with-mask

    (defthm vex3-byte2->w-of-write-with-mask
      (implies (and (fty::bitstruct-read-over-write-hyps
                         x vex3-byte2-equiv-under-mask)
                    (vex3-byte2-equiv-under-mask x y fty::mask)
                    (equal (logand (lognot fty::mask) 128)
                           0))
               (equal (vex3-byte2->w x)
                      (vex3-byte2->w y))))

    Theorem: vex3-byte2-fix-in-terms-of-vex3-byte2

    (defthm vex3-byte2-fix-in-terms-of-vex3-byte2
      (equal (vex3-byte2-fix x)
             (change-vex3-byte2 x)))

    Function: !vex3-byte2->pp$inline

    (defun !vex3-byte2->pp$inline (pp x)
      (declare (xargs :guard (and (2bits-p pp) (vex3-byte2-p x))))
      (mbe :logic
           (b* ((pp (mbe :logic (2bits-fix pp) :exec pp))
                (x (vex3-byte2-fix x)))
             (part-install pp x :width 2 :low 0))
           :exec (the (unsigned-byte 8)
                      (logior (the (unsigned-byte 8)
                                   (logand (the (unsigned-byte 8) x)
                                           (the (signed-byte 3) -4)))
                              (the (unsigned-byte 2) pp)))))

    Theorem: vex3-byte2-p-of-!vex3-byte2->pp

    (defthm vex3-byte2-p-of-!vex3-byte2->pp
      (b* ((new-x (!vex3-byte2->pp$inline pp x)))
        (vex3-byte2-p new-x))
      :rule-classes :rewrite)

    Theorem: !vex3-byte2->pp$inline-of-2bits-fix-pp

    (defthm !vex3-byte2->pp$inline-of-2bits-fix-pp
      (equal (!vex3-byte2->pp$inline (2bits-fix pp)
                                     x)
             (!vex3-byte2->pp$inline pp x)))

    Theorem: !vex3-byte2->pp$inline-2bits-equiv-congruence-on-pp

    (defthm !vex3-byte2->pp$inline-2bits-equiv-congruence-on-pp
      (implies (2bits-equiv pp pp-equiv)
               (equal (!vex3-byte2->pp$inline pp x)
                      (!vex3-byte2->pp$inline pp-equiv x)))
      :rule-classes :congruence)

    Theorem: !vex3-byte2->pp$inline-of-vex3-byte2-fix-x

    (defthm !vex3-byte2->pp$inline-of-vex3-byte2-fix-x
      (equal (!vex3-byte2->pp$inline pp (vex3-byte2-fix x))
             (!vex3-byte2->pp$inline pp x)))

    Theorem: !vex3-byte2->pp$inline-vex3-byte2-equiv-congruence-on-x

    (defthm !vex3-byte2->pp$inline-vex3-byte2-equiv-congruence-on-x
      (implies (vex3-byte2-equiv x x-equiv)
               (equal (!vex3-byte2->pp$inline pp x)
                      (!vex3-byte2->pp$inline pp x-equiv)))
      :rule-classes :congruence)

    Theorem: !vex3-byte2->pp-is-vex3-byte2

    (defthm !vex3-byte2->pp-is-vex3-byte2
      (equal (!vex3-byte2->pp pp x)
             (change-vex3-byte2 x :pp pp)))

    Theorem: vex3-byte2->pp-of-!vex3-byte2->pp

    (defthm vex3-byte2->pp-of-!vex3-byte2->pp
      (b* ((?new-x (!vex3-byte2->pp$inline pp x)))
        (equal (vex3-byte2->pp new-x)
               (2bits-fix pp))))

    Theorem: !vex3-byte2->pp-equiv-under-mask

    (defthm !vex3-byte2->pp-equiv-under-mask
      (b* ((?new-x (!vex3-byte2->pp$inline pp x)))
        (vex3-byte2-equiv-under-mask new-x x -4)))

    Function: !vex3-byte2->l$inline

    (defun !vex3-byte2->l$inline (l x)
     (declare (xargs :guard (and (bitp l) (vex3-byte2-p x))))
     (mbe :logic
          (b* ((l (mbe :logic (bfix l) :exec l))
               (x (vex3-byte2-fix x)))
            (part-install l x :width 1 :low 2))
          :exec (the (unsigned-byte 8)
                     (logior (the (unsigned-byte 8)
                                  (logand (the (unsigned-byte 8) x)
                                          (the (signed-byte 4) -5)))
                             (the (unsigned-byte 3)
                                  (ash (the (unsigned-byte 1) l) 2))))))

    Theorem: vex3-byte2-p-of-!vex3-byte2->l

    (defthm vex3-byte2-p-of-!vex3-byte2->l
      (b* ((new-x (!vex3-byte2->l$inline l x)))
        (vex3-byte2-p new-x))
      :rule-classes :rewrite)

    Theorem: !vex3-byte2->l$inline-of-bfix-l

    (defthm !vex3-byte2->l$inline-of-bfix-l
      (equal (!vex3-byte2->l$inline (bfix l) x)
             (!vex3-byte2->l$inline l x)))

    Theorem: !vex3-byte2->l$inline-bit-equiv-congruence-on-l

    (defthm !vex3-byte2->l$inline-bit-equiv-congruence-on-l
      (implies (bit-equiv l l-equiv)
               (equal (!vex3-byte2->l$inline l x)
                      (!vex3-byte2->l$inline l-equiv x)))
      :rule-classes :congruence)

    Theorem: !vex3-byte2->l$inline-of-vex3-byte2-fix-x

    (defthm !vex3-byte2->l$inline-of-vex3-byte2-fix-x
      (equal (!vex3-byte2->l$inline l (vex3-byte2-fix x))
             (!vex3-byte2->l$inline l x)))

    Theorem: !vex3-byte2->l$inline-vex3-byte2-equiv-congruence-on-x

    (defthm !vex3-byte2->l$inline-vex3-byte2-equiv-congruence-on-x
      (implies (vex3-byte2-equiv x x-equiv)
               (equal (!vex3-byte2->l$inline l x)
                      (!vex3-byte2->l$inline l x-equiv)))
      :rule-classes :congruence)

    Theorem: !vex3-byte2->l-is-vex3-byte2

    (defthm !vex3-byte2->l-is-vex3-byte2
      (equal (!vex3-byte2->l l x)
             (change-vex3-byte2 x :l l)))

    Theorem: vex3-byte2->l-of-!vex3-byte2->l

    (defthm vex3-byte2->l-of-!vex3-byte2->l
      (b* ((?new-x (!vex3-byte2->l$inline l x)))
        (equal (vex3-byte2->l new-x) (bfix l))))

    Theorem: !vex3-byte2->l-equiv-under-mask

    (defthm !vex3-byte2->l-equiv-under-mask
      (b* ((?new-x (!vex3-byte2->l$inline l x)))
        (vex3-byte2-equiv-under-mask new-x x -5)))

    Function: !vex3-byte2->vvvv$inline

    (defun !vex3-byte2->vvvv$inline (vvvv x)
      (declare (xargs :guard (and (4bits-p vvvv) (vex3-byte2-p x))))
      (mbe :logic
           (b* ((vvvv (mbe :logic (4bits-fix vvvv)
                           :exec vvvv))
                (x (vex3-byte2-fix x)))
             (part-install vvvv x :width 4 :low 3))
           :exec (the (unsigned-byte 8)
                      (logior (the (unsigned-byte 8)
                                   (logand (the (unsigned-byte 8) x)
                                           (the (signed-byte 8) -121)))
                              (the (unsigned-byte 7)
                                   (ash (the (unsigned-byte 4) vvvv)
                                        3))))))

    Theorem: vex3-byte2-p-of-!vex3-byte2->vvvv

    (defthm vex3-byte2-p-of-!vex3-byte2->vvvv
      (b* ((new-x (!vex3-byte2->vvvv$inline vvvv x)))
        (vex3-byte2-p new-x))
      :rule-classes :rewrite)

    Theorem: !vex3-byte2->vvvv$inline-of-4bits-fix-vvvv

    (defthm !vex3-byte2->vvvv$inline-of-4bits-fix-vvvv
      (equal (!vex3-byte2->vvvv$inline (4bits-fix vvvv)
                                       x)
             (!vex3-byte2->vvvv$inline vvvv x)))

    Theorem: !vex3-byte2->vvvv$inline-4bits-equiv-congruence-on-vvvv

    (defthm !vex3-byte2->vvvv$inline-4bits-equiv-congruence-on-vvvv
      (implies (4bits-equiv vvvv vvvv-equiv)
               (equal (!vex3-byte2->vvvv$inline vvvv x)
                      (!vex3-byte2->vvvv$inline vvvv-equiv x)))
      :rule-classes :congruence)

    Theorem: !vex3-byte2->vvvv$inline-of-vex3-byte2-fix-x

    (defthm !vex3-byte2->vvvv$inline-of-vex3-byte2-fix-x
      (equal (!vex3-byte2->vvvv$inline vvvv (vex3-byte2-fix x))
             (!vex3-byte2->vvvv$inline vvvv x)))

    Theorem: !vex3-byte2->vvvv$inline-vex3-byte2-equiv-congruence-on-x

    (defthm !vex3-byte2->vvvv$inline-vex3-byte2-equiv-congruence-on-x
      (implies (vex3-byte2-equiv x x-equiv)
               (equal (!vex3-byte2->vvvv$inline vvvv x)
                      (!vex3-byte2->vvvv$inline vvvv x-equiv)))
      :rule-classes :congruence)

    Theorem: !vex3-byte2->vvvv-is-vex3-byte2

    (defthm !vex3-byte2->vvvv-is-vex3-byte2
      (equal (!vex3-byte2->vvvv vvvv x)
             (change-vex3-byte2 x :vvvv vvvv)))

    Theorem: vex3-byte2->vvvv-of-!vex3-byte2->vvvv

    (defthm vex3-byte2->vvvv-of-!vex3-byte2->vvvv
      (b* ((?new-x (!vex3-byte2->vvvv$inline vvvv x)))
        (equal (vex3-byte2->vvvv new-x)
               (4bits-fix vvvv))))

    Theorem: !vex3-byte2->vvvv-equiv-under-mask

    (defthm !vex3-byte2->vvvv-equiv-under-mask
      (b* ((?new-x (!vex3-byte2->vvvv$inline vvvv x)))
        (vex3-byte2-equiv-under-mask new-x x -121)))

    Function: !vex3-byte2->w$inline

    (defun !vex3-byte2->w$inline (w x)
     (declare (xargs :guard (and (bitp w) (vex3-byte2-p x))))
     (mbe :logic
          (b* ((w (mbe :logic (bfix w) :exec w))
               (x (vex3-byte2-fix x)))
            (part-install w x :width 1 :low 7))
          :exec (the (unsigned-byte 8)
                     (logior (the (unsigned-byte 8)
                                  (logand (the (unsigned-byte 8) x)
                                          (the (signed-byte 9) -129)))
                             (the (unsigned-byte 8)
                                  (ash (the (unsigned-byte 1) w) 7))))))

    Theorem: vex3-byte2-p-of-!vex3-byte2->w

    (defthm vex3-byte2-p-of-!vex3-byte2->w
      (b* ((new-x (!vex3-byte2->w$inline w x)))
        (vex3-byte2-p new-x))
      :rule-classes :rewrite)

    Theorem: !vex3-byte2->w$inline-of-bfix-w

    (defthm !vex3-byte2->w$inline-of-bfix-w
      (equal (!vex3-byte2->w$inline (bfix w) x)
             (!vex3-byte2->w$inline w x)))

    Theorem: !vex3-byte2->w$inline-bit-equiv-congruence-on-w

    (defthm !vex3-byte2->w$inline-bit-equiv-congruence-on-w
      (implies (bit-equiv w w-equiv)
               (equal (!vex3-byte2->w$inline w x)
                      (!vex3-byte2->w$inline w-equiv x)))
      :rule-classes :congruence)

    Theorem: !vex3-byte2->w$inline-of-vex3-byte2-fix-x

    (defthm !vex3-byte2->w$inline-of-vex3-byte2-fix-x
      (equal (!vex3-byte2->w$inline w (vex3-byte2-fix x))
             (!vex3-byte2->w$inline w x)))

    Theorem: !vex3-byte2->w$inline-vex3-byte2-equiv-congruence-on-x

    (defthm !vex3-byte2->w$inline-vex3-byte2-equiv-congruence-on-x
      (implies (vex3-byte2-equiv x x-equiv)
               (equal (!vex3-byte2->w$inline w x)
                      (!vex3-byte2->w$inline w x-equiv)))
      :rule-classes :congruence)

    Theorem: !vex3-byte2->w-is-vex3-byte2

    (defthm !vex3-byte2->w-is-vex3-byte2
      (equal (!vex3-byte2->w w x)
             (change-vex3-byte2 x :w w)))

    Theorem: vex3-byte2->w-of-!vex3-byte2->w

    (defthm vex3-byte2->w-of-!vex3-byte2->w
      (b* ((?new-x (!vex3-byte2->w$inline w x)))
        (equal (vex3-byte2->w new-x) (bfix w))))

    Theorem: !vex3-byte2->w-equiv-under-mask

    (defthm !vex3-byte2->w-equiv-under-mask
      (b* ((?new-x (!vex3-byte2->w$inline w x)))
        (vex3-byte2-equiv-under-mask new-x x 127)))

    Function: vex3-byte2-debug$inline

    (defun vex3-byte2-debug$inline (x)
      (declare (xargs :guard (vex3-byte2-p x)))
      (b* (((vex3-byte2 x)))
        (cons (cons 'pp x.pp)
              (cons (cons 'l x.l)
                    (cons (cons 'vvvv x.vvvv)
                          (cons (cons 'w x.w) nil))))))

    Function: vex-prefixes-map-p$inline

    (defun vex-prefixes-map-p$inline (bytes vex-prefixes)
      (declare (type (unsigned-byte 16) bytes))
      (declare (xargs :guard (vex-prefixes-p vex-prefixes)))
      (declare (xargs :guard (and (vex-prefixes-byte0-p vex-prefixes)
                                  (or (equal bytes 15)
                                      (equal bytes 3896)
                                      (equal bytes 3898)))))
      (b* ((byte0 (vex-prefixes->byte0 vex-prefixes))
           (byte1 (vex-prefixes->byte1 vex-prefixes)))
        (case bytes
          (15 (or (equal byte0 197)
                  (and (equal byte0 196)
                       (equal (vex3-byte1->m-mmmm byte1) 1))))
          (otherwise (and (equal byte0 196)
                          (if (equal bytes 3896)
                              (equal (vex3-byte1->m-mmmm byte1) 2)
                            (equal (vex3-byte1->m-mmmm byte1)
                                   3)))))))

    Theorem: booleanp-of-vex-prefixes-map-p

    (defthm booleanp-of-vex-prefixes-map-p
      (b* ((ok (vex-prefixes-map-p$inline bytes vex-prefixes)))
        (booleanp ok))
      :rule-classes :rewrite)

    Function: vex->vvvv$inline

    (defun vex->vvvv$inline (vex-prefixes)
      (declare (xargs :guard (vex-prefixes-p vex-prefixes)))
      (declare (xargs :guard (vex-prefixes-byte0-p vex-prefixes)))
      (case (vex-prefixes->byte0 vex-prefixes)
        (197 (vex2-byte1->vvvv (vex-prefixes->byte1 vex-prefixes)))
        (196 (vex3-byte2->vvvv (vex-prefixes->byte2 vex-prefixes)))
        (otherwise -1)))

    Theorem: return-type-of-vex->vvvv

    (defthm return-type-of-vex->vvvv
      (implies (vex-prefixes-byte0-p vex-prefixes)
               (b* ((vvvv (vex->vvvv$inline vex-prefixes)))
                 (unsigned-byte-p 4 vvvv)))
      :rule-classes :rewrite)

    Function: vex->l$inline

    (defun vex->l$inline (vex-prefixes)
      (declare (type (unsigned-byte 24) vex-prefixes))
      (declare (xargs :guard (vex-prefixes-byte0-p vex-prefixes)))
      (case (vex-prefixes->byte0 vex-prefixes)
        (197 (vex2-byte1->l (vex-prefixes->byte1 vex-prefixes)))
        (196 (vex3-byte2->l (vex-prefixes->byte2 vex-prefixes)))
        (otherwise -1)))

    Theorem: return-type-of-vex->l

    (defthm return-type-of-vex->l
      (implies (vex-prefixes-byte0-p vex-prefixes)
               (b* ((l (vex->l$inline vex-prefixes)))
                 (unsigned-byte-p 1 l)))
      :rule-classes :rewrite)

    Function: vex->pp$inline

    (defun vex->pp$inline (vex-prefixes)
      (declare (type (unsigned-byte 24) vex-prefixes))
      (declare (xargs :guard (vex-prefixes-byte0-p vex-prefixes)))
      (case (vex-prefixes->byte0 vex-prefixes)
        (197 (vex2-byte1->pp (vex-prefixes->byte1 vex-prefixes)))
        (196 (vex3-byte2->pp (vex-prefixes->byte2 vex-prefixes)))
        (otherwise -1)))

    Theorem: return-type-of-vex->pp

    (defthm return-type-of-vex->pp
      (implies (vex-prefixes-byte0-p vex-prefixes)
               (b* ((pp (vex->pp$inline vex-prefixes)))
                 (unsigned-byte-p 2 pp)))
      :rule-classes :rewrite)

    Function: vex->w$inline

    (defun vex->w$inline (vex-prefixes)
      (declare (type (unsigned-byte 24) vex-prefixes))
      (declare (xargs :guard (vex-prefixes-byte0-p vex-prefixes)))
      (case (vex-prefixes->byte0 vex-prefixes)
        (196 (vex3-byte2->w (vex-prefixes->byte2 vex-prefixes)))
        (otherwise 0)))

    Theorem: return-type-of-vex->w

    (defthm return-type-of-vex->w
      (implies (vex-prefixes-byte0-p vex-prefixes)
               (b* ((w (vex->w$inline vex-prefixes)))
                 (unsigned-byte-p 1 w)))
      :rule-classes :rewrite)

    Theorem: if-not-vex3-byte0-then-vex-w=0

    (defthm if-not-vex3-byte0-then-vex-w=0
      (b* nil
        (implies (not (equal (vex-prefixes->byte0 vex-prefixes)
                             196))
                 (equal (vex->w vex-prefixes) 0))))