• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Bitcoin
      • Riscv
        • Instructions
          • Instr
            • Instrp
            • Instr-fix
              • Instr-case
              • Instr-store
              • Instr-op-imms64
              • Instr-op-imms32
              • Instr-op-imms-32
              • Instr-op-imm-32
              • Instr-op-imm
              • Instr-op-32
              • Instr-op
              • Instr-load
              • Instr-branch
              • Instr-equiv
              • Instr-jalr
              • Instr-lui
              • Instr-jal
              • Instr-auipc
              • Instr-kind
            • Op-funct
            • Op-32-funct
            • Op-imm-funct
            • Load-funct
            • Branch-funct
            • Op-imms-funct
            • Store-funct
            • Op-imms-32-funct
            • Instr-validp
            • Instr-option
            • Op-imm-32-funct
          • States
          • Decoding
          • Encoding
          • Features
          • Semantics
          • Execution
        • Des
        • Ethereum
        • X86isa
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Instr

    Instr-fix

    Fixing function for instr structures.

    Signature
    (instr-fix x) → new-x
    Arguments
    x — Guard (instrp x).
    Returns
    new-x — Type (instrp new-x).

    Definitions and Theorems

    Function: instr-fix$inline

    (defun instr-fix$inline (x)
     (declare (xargs :guard (instrp x)))
     (let ((__function__ 'instr-fix))
      (declare (ignorable __function__))
      (mbe
       :logic
       (case (instr-kind x)
        (:op-imm (b* ((funct (op-imm-funct-fix (std::da-nth 0 (cdr x))))
                      (rd (ubyte5-fix (std::da-nth 1 (cdr x))))
                      (rs1 (ubyte5-fix (std::da-nth 2 (cdr x))))
                      (imm (ubyte12-fix (std::da-nth 3 (cdr x)))))
                   (cons :op-imm (list funct rd rs1 imm))))
        (:op-imms32
             (b* ((funct (op-imms-funct-fix (std::da-nth 0 (cdr x))))
                  (rd (ubyte5-fix (std::da-nth 1 (cdr x))))
                  (rs1 (ubyte5-fix (std::da-nth 2 (cdr x))))
                  (imm (ubyte5-fix (std::da-nth 3 (cdr x)))))
               (cons :op-imms32 (list funct rd rs1 imm))))
        (:op-imms64
             (b* ((funct (op-imms-funct-fix (std::da-nth 0 (cdr x))))
                  (rd (ubyte5-fix (std::da-nth 1 (cdr x))))
                  (rs1 (ubyte5-fix (std::da-nth 2 (cdr x))))
                  (imm (ubyte6-fix (std::da-nth 3 (cdr x)))))
               (cons :op-imms64 (list funct rd rs1 imm))))
        (:op-imm-32
             (b* ((funct (op-imm-32-funct-fix (std::da-nth 0 (cdr x))))
                  (rd (ubyte5-fix (std::da-nth 1 (cdr x))))
                  (rs1 (ubyte5-fix (std::da-nth 2 (cdr x))))
                  (imm (ubyte12-fix (std::da-nth 3 (cdr x)))))
               (cons :op-imm-32 (list funct rd rs1 imm))))
        (:op-imms-32
             (b* ((funct (op-imms-32-funct-fix (std::da-nth 0 (cdr x))))
                  (rd (ubyte5-fix (std::da-nth 1 (cdr x))))
                  (rs1 (ubyte5-fix (std::da-nth 2 (cdr x))))
                  (imm (ubyte5-fix (std::da-nth 3 (cdr x)))))
               (cons :op-imms-32 (list funct rd rs1 imm))))
        (:lui (b* ((rd (ubyte5-fix (std::da-nth 0 (cdr x))))
                   (imm (ubyte20-fix (std::da-nth 1 (cdr x)))))
                (cons :lui (list rd imm))))
        (:auipc (b* ((rd (ubyte5-fix (std::da-nth 0 (cdr x))))
                     (imm (ubyte20-fix (std::da-nth 1 (cdr x)))))
                  (cons :auipc (list rd imm))))
        (:op (b* ((funct (op-funct-fix (std::da-nth 0 (cdr x))))
                  (rd (ubyte5-fix (std::da-nth 1 (cdr x))))
                  (rs1 (ubyte5-fix (std::da-nth 2 (cdr x))))
                  (rs2 (ubyte5-fix (std::da-nth 3 (cdr x)))))
               (cons :op (list funct rd rs1 rs2))))
        (:op-32 (b* ((funct (op-32-funct-fix (std::da-nth 0 (cdr x))))
                     (rd (ubyte5-fix (std::da-nth 1 (cdr x))))
                     (rs1 (ubyte5-fix (std::da-nth 2 (cdr x))))
                     (rs2 (ubyte5-fix (std::da-nth 3 (cdr x)))))
                  (cons :op-32 (list funct rd rs1 rs2))))
        (:jal (b* ((rd (ubyte5-fix (std::da-nth 0 (cdr x))))
                   (imm (ubyte20-fix (std::da-nth 1 (cdr x)))))
                (cons :jal (list rd imm))))
        (:jalr (b* ((rd (ubyte5-fix (std::da-nth 0 (cdr x))))
                    (rs1 (ubyte5-fix (std::da-nth 1 (cdr x))))
                    (imm (ubyte12-fix (std::da-nth 2 (cdr x)))))
                 (cons :jalr (list rd rs1 imm))))
        (:branch (b* ((funct (branch-funct-fix (std::da-nth 0 (cdr x))))
                      (rs1 (ubyte5-fix (std::da-nth 1 (cdr x))))
                      (rs2 (ubyte5-fix (std::da-nth 2 (cdr x))))
                      (imm (ubyte12-fix (std::da-nth 3 (cdr x)))))
                   (cons :branch (list funct rs1 rs2 imm))))
        (:load (b* ((funct (load-funct-fix (std::da-nth 0 (cdr x))))
                    (rd (ubyte5-fix (std::da-nth 1 (cdr x))))
                    (rs1 (ubyte5-fix (std::da-nth 2 (cdr x))))
                    (imm (ubyte12-fix (std::da-nth 3 (cdr x)))))
                 (cons :load (list funct rd rs1 imm))))
        (:store (b* ((funct (store-funct-fix (std::da-nth 0 (cdr x))))
                     (rs1 (ubyte5-fix (std::da-nth 1 (cdr x))))
                     (rs2 (ubyte5-fix (std::da-nth 2 (cdr x))))
                     (imm (ubyte12-fix (std::da-nth 3 (cdr x)))))
                  (cons :store (list funct rs1 rs2 imm)))))
       :exec x)))

    Theorem: instrp-of-instr-fix

    (defthm instrp-of-instr-fix
      (b* ((new-x (instr-fix$inline x)))
        (instrp new-x))
      :rule-classes :rewrite)

    Theorem: instr-fix-when-instrp

    (defthm instr-fix-when-instrp
      (implies (instrp x)
               (equal (instr-fix x) x)))

    Function: instr-equiv$inline

    (defun instr-equiv$inline (acl2::x acl2::y)
      (declare (xargs :guard (and (instrp acl2::x)
                                  (instrp acl2::y))))
      (equal (instr-fix acl2::x)
             (instr-fix acl2::y)))

    Theorem: instr-equiv-is-an-equivalence

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

    Theorem: instr-equiv-implies-equal-instr-fix-1

    (defthm instr-equiv-implies-equal-instr-fix-1
      (implies (instr-equiv acl2::x x-equiv)
               (equal (instr-fix acl2::x)
                      (instr-fix x-equiv)))
      :rule-classes (:congruence))

    Theorem: instr-fix-under-instr-equiv

    (defthm instr-fix-under-instr-equiv
      (instr-equiv (instr-fix acl2::x)
                   acl2::x)
      :rule-classes (:rewrite :rewrite-quoted-constant))

    Theorem: equal-of-instr-fix-1-forward-to-instr-equiv

    (defthm equal-of-instr-fix-1-forward-to-instr-equiv
      (implies (equal (instr-fix acl2::x) acl2::y)
               (instr-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: equal-of-instr-fix-2-forward-to-instr-equiv

    (defthm equal-of-instr-fix-2-forward-to-instr-equiv
      (implies (equal acl2::x (instr-fix acl2::y))
               (instr-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: instr-equiv-of-instr-fix-1-forward

    (defthm instr-equiv-of-instr-fix-1-forward
      (implies (instr-equiv (instr-fix acl2::x)
                            acl2::y)
               (instr-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: instr-equiv-of-instr-fix-2-forward

    (defthm instr-equiv-of-instr-fix-2-forward
      (implies (instr-equiv acl2::x (instr-fix acl2::y))
               (instr-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: instr-kind$inline-of-instr-fix-x

    (defthm instr-kind$inline-of-instr-fix-x
      (equal (instr-kind$inline (instr-fix x))
             (instr-kind$inline x)))

    Theorem: instr-kind$inline-instr-equiv-congruence-on-x

    (defthm instr-kind$inline-instr-equiv-congruence-on-x
      (implies (instr-equiv x x-equiv)
               (equal (instr-kind$inline x)
                      (instr-kind$inline x-equiv)))
      :rule-classes :congruence)

    Theorem: consp-of-instr-fix

    (defthm consp-of-instr-fix
      (consp (instr-fix x))
      :rule-classes :type-prescription)