• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Pfcs
      • Wp-gen
      • Dimacs-reader
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Riscv
        • Semantics
        • Features
        • States
        • Decoding
          • Decode
          • Decoding-of-encoding
          • Get-fields-rtype
          • Get-fields-stype
          • Get-fields-itype
          • Get-fields-btype
          • Encoding-of-decoding
          • Get-imm-jtype
          • Get-imm-btype
          • Get-imm-utype
          • Get-fields-utype
          • Get-imm-stype
          • Get-imm-itype
          • Get-fields-jtype
          • Decoding-as-inverse
            • Encoding-validp
            • Decodei
              • Decodei-is-decode
            • Get-rs2
            • Get-rs1
            • Get-rd
            • Get-opcode
            • Get-funct7
            • Get-funct3
          • Instructions
          • Encoding
          • Reads-over-writes
          • Rv32im
          • Rv64im
          • Execution
        • Instant-runoff-voting
        • Imp-language
        • Sidekick
        • Leftist-trees
        • Java
        • Taspi
        • Bitcoin
        • 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
        • Aleo
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Community
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Decoding-as-inverse

    Decodei

    Declarative definition of instruction decoding.

    Signature
    (decodei enc feat) → instr?
    Arguments
    enc — Guard (ubyte32p enc).
    feat — Guard (featp feat).
    Returns
    instr? — Type (instr-optionp instr?).

    If there is some valid instruction whose encoding is enc, we return one such instruction. We use the witness function of encoding-validp for that.

    Since encode is injective, there is in fact at most one such instruction.

    Definitions and Theorems

    Function: decodei

    (defun decodei (enc feat)
      (declare (xargs :guard (and (ubyte32p enc) (featp feat))))
      (let ((__function__ 'decodei))
        (declare (ignorable __function__))
        (if (encoding-validp enc feat)
            (encoding-valid-witness (ubyte32-fix enc)
                                    (feat-fix feat))
          nil)))

    Theorem: instr-optionp-of-decodei

    (defthm instr-optionp-of-decodei
      (b* ((instr? (decodei enc feat)))
        (instr-optionp instr?))
      :rule-classes :rewrite)

    Theorem: encode-of-decodei

    (defthm encode-of-decodei
      (implies (encoding-validp enc feat)
               (equal (encode (decodei enc feat) feat)
                      (ubyte32-fix enc))))

    Theorem: decodei-of-ubyte32-fix-enc

    (defthm decodei-of-ubyte32-fix-enc
      (equal (decodei (ubyte32-fix enc) feat)
             (decodei enc feat)))

    Theorem: decodei-ubyte32-equiv-congruence-on-enc

    (defthm decodei-ubyte32-equiv-congruence-on-enc
      (implies (acl2::ubyte32-equiv enc enc-equiv)
               (equal (decodei enc feat)
                      (decodei enc-equiv feat)))
      :rule-classes :congruence)

    Theorem: decodei-of-feat-fix-feat

    (defthm decodei-of-feat-fix-feat
      (equal (decodei enc (feat-fix feat))
             (decodei enc feat)))

    Theorem: decodei-feat-equiv-congruence-on-feat

    (defthm decodei-feat-equiv-congruence-on-feat
      (implies (feat-equiv feat feat-equiv)
               (equal (decodei enc feat)
                      (decodei enc feat-equiv)))
      :rule-classes :congruence)