• 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
          • 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
    • Instructions

    Instr-validp

    Check if an instruction is valid with respect to given features.

    Signature
    (instr-validp instr feat) → yes/no
    Arguments
    instr — Guard (instrp instr).
    feat — Guard (featp feat).
    Returns
    yes/no — Type (booleanp yes/no).

    Currently our model of features only consists of one bit of information: whether we are in 32-bit mode or in 64-bit mode; more precisely, whether our base is RV32I (or RV32E) or RV64I (or RV64E). For now we implicitly assume that the M extension is present; we plan to add a choice about that in the features.

    Definitions and Theorems

    Function: instr-validp

    (defun instr-validp (instr feat)
      (declare (xargs :guard (and (instrp instr) (featp feat))))
      (let ((__function__ 'instr-validp))
        (declare (ignorable __function__))
        (b* (((feat feat) feat))
          (instr-case instr
                      :op-imm t
                      :op-imms32 (feat-32p feat)
                      :op-imms64 (feat-64p feat)
                      :op-imm-32 (feat-64p feat)
                      :op-imms-32 (feat-64p feat)
                      :lui t
                      :auipc t
                      :op t
                      :op-32 (feat-64p feat)
                      :jal t
                      :jalr t
                      :branch t
                      :load (load-funct-case instr.funct
                                             :lb t
                                             :lbu t
                                             :lh t
                                             :lhu t
                                             :lw t
                                             :lwu (feat-64p feat)
                                             :ld (feat-64p feat))
                      :store (store-funct-case instr.funct
                                               :sb t
                                               :sh t
                                               :sw t
                                               :sd (feat-64p feat))))))

    Theorem: booleanp-of-instr-validp

    (defthm booleanp-of-instr-validp
      (b* ((yes/no (instr-validp instr feat)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: instr-validp-of-instr-fix-instr

    (defthm instr-validp-of-instr-fix-instr
      (equal (instr-validp (instr-fix instr) feat)
             (instr-validp instr feat)))

    Theorem: instr-validp-instr-equiv-congruence-on-instr

    (defthm instr-validp-instr-equiv-congruence-on-instr
      (implies (instr-equiv instr instr-equiv)
               (equal (instr-validp instr feat)
                      (instr-validp instr-equiv feat)))
      :rule-classes :congruence)

    Theorem: instr-validp-of-feat-fix-feat

    (defthm instr-validp-of-feat-fix-feat
      (equal (instr-validp instr (feat-fix feat))
             (instr-validp instr feat)))

    Theorem: instr-validp-feat-equiv-congruence-on-feat

    (defthm instr-validp-feat-equiv-congruence-on-feat
      (implies (feat-equiv feat feat-equiv)
               (equal (instr-validp instr feat)
                      (instr-validp instr feat-equiv)))
      :rule-classes :congruence)