• 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

    Instrp

    Recognizer for instr structures.

    Signature
    (instrp x) → *

    Definitions and Theorems

    Function: instrp

    (defun instrp (x)
      (declare (xargs :guard t))
      (let ((__function__ 'instrp))
        (declare (ignorable __function__))
        (and (consp x)
             (cond ((or (atom x) (eq (car x) :op-imm))
                    (and (true-listp (cdr x))
                         (eql (len (cdr x)) 4)
                         (b* ((funct (std::da-nth 0 (cdr x)))
                              (rd (std::da-nth 1 (cdr x)))
                              (rs1 (std::da-nth 2 (cdr x)))
                              (imm (std::da-nth 3 (cdr x))))
                           (and (op-imm-funct-p funct)
                                (ubyte5p rd)
                                (ubyte5p rs1)
                                (ubyte12p imm)))))
                   ((eq (car x) :op-imms32)
                    (and (true-listp (cdr x))
                         (eql (len (cdr x)) 4)
                         (b* ((funct (std::da-nth 0 (cdr x)))
                              (rd (std::da-nth 1 (cdr x)))
                              (rs1 (std::da-nth 2 (cdr x)))
                              (imm (std::da-nth 3 (cdr x))))
                           (and (op-imms-funct-p funct)
                                (ubyte5p rd)
                                (ubyte5p rs1)
                                (ubyte5p imm)))))
                   ((eq (car x) :op-imms64)
                    (and (true-listp (cdr x))
                         (eql (len (cdr x)) 4)
                         (b* ((funct (std::da-nth 0 (cdr x)))
                              (rd (std::da-nth 1 (cdr x)))
                              (rs1 (std::da-nth 2 (cdr x)))
                              (imm (std::da-nth 3 (cdr x))))
                           (and (op-imms-funct-p funct)
                                (ubyte5p rd)
                                (ubyte5p rs1)
                                (ubyte6p imm)))))
                   ((eq (car x) :op-imm-32)
                    (and (true-listp (cdr x))
                         (eql (len (cdr x)) 4)
                         (b* ((funct (std::da-nth 0 (cdr x)))
                              (rd (std::da-nth 1 (cdr x)))
                              (rs1 (std::da-nth 2 (cdr x)))
                              (imm (std::da-nth 3 (cdr x))))
                           (and (op-imm-32-funct-p funct)
                                (ubyte5p rd)
                                (ubyte5p rs1)
                                (ubyte12p imm)))))
                   ((eq (car x) :op-imms-32)
                    (and (true-listp (cdr x))
                         (eql (len (cdr x)) 4)
                         (b* ((funct (std::da-nth 0 (cdr x)))
                              (rd (std::da-nth 1 (cdr x)))
                              (rs1 (std::da-nth 2 (cdr x)))
                              (imm (std::da-nth 3 (cdr x))))
                           (and (op-imms-32-funct-p funct)
                                (ubyte5p rd)
                                (ubyte5p rs1)
                                (ubyte5p imm)))))
                   ((eq (car x) :lui)
                    (and (true-listp (cdr x))
                         (eql (len (cdr x)) 2)
                         (b* ((rd (std::da-nth 0 (cdr x)))
                              (imm (std::da-nth 1 (cdr x))))
                           (and (ubyte5p rd) (ubyte20p imm)))))
                   ((eq (car x) :auipc)
                    (and (true-listp (cdr x))
                         (eql (len (cdr x)) 2)
                         (b* ((rd (std::da-nth 0 (cdr x)))
                              (imm (std::da-nth 1 (cdr x))))
                           (and (ubyte5p rd) (ubyte20p imm)))))
                   ((eq (car x) :op)
                    (and (true-listp (cdr x))
                         (eql (len (cdr x)) 4)
                         (b* ((funct (std::da-nth 0 (cdr x)))
                              (rd (std::da-nth 1 (cdr x)))
                              (rs1 (std::da-nth 2 (cdr x)))
                              (rs2 (std::da-nth 3 (cdr x))))
                           (and (op-funct-p funct)
                                (ubyte5p rd)
                                (ubyte5p rs1)
                                (ubyte5p rs2)))))
                   ((eq (car x) :op-32)
                    (and (true-listp (cdr x))
                         (eql (len (cdr x)) 4)
                         (b* ((funct (std::da-nth 0 (cdr x)))
                              (rd (std::da-nth 1 (cdr x)))
                              (rs1 (std::da-nth 2 (cdr x)))
                              (rs2 (std::da-nth 3 (cdr x))))
                           (and (op-32-funct-p funct)
                                (ubyte5p rd)
                                (ubyte5p rs1)
                                (ubyte5p rs2)))))
                   ((eq (car x) :jal)
                    (and (true-listp (cdr x))
                         (eql (len (cdr x)) 2)
                         (b* ((rd (std::da-nth 0 (cdr x)))
                              (imm (std::da-nth 1 (cdr x))))
                           (and (ubyte5p rd) (ubyte20p imm)))))
                   ((eq (car x) :jalr)
                    (and (true-listp (cdr x))
                         (eql (len (cdr x)) 3)
                         (b* ((rd (std::da-nth 0 (cdr x)))
                              (rs1 (std::da-nth 1 (cdr x)))
                              (imm (std::da-nth 2 (cdr x))))
                           (and (ubyte5p rd)
                                (ubyte5p rs1)
                                (ubyte12p imm)))))
                   ((eq (car x) :branch)
                    (and (true-listp (cdr x))
                         (eql (len (cdr x)) 4)
                         (b* ((funct (std::da-nth 0 (cdr x)))
                              (rs1 (std::da-nth 1 (cdr x)))
                              (rs2 (std::da-nth 2 (cdr x)))
                              (imm (std::da-nth 3 (cdr x))))
                           (and (branch-funct-p funct)
                                (ubyte5p rs1)
                                (ubyte5p rs2)
                                (ubyte12p imm)))))
                   ((eq (car x) :load)
                    (and (true-listp (cdr x))
                         (eql (len (cdr x)) 4)
                         (b* ((funct (std::da-nth 0 (cdr x)))
                              (rd (std::da-nth 1 (cdr x)))
                              (rs1 (std::da-nth 2 (cdr x)))
                              (imm (std::da-nth 3 (cdr x))))
                           (and (load-funct-p funct)
                                (ubyte5p rd)
                                (ubyte5p rs1)
                                (ubyte12p imm)))))
                   (t (and (eq (car x) :store)
                           (and (true-listp (cdr x))
                                (eql (len (cdr x)) 4))
                           (b* ((funct (std::da-nth 0 (cdr x)))
                                (rs1 (std::da-nth 1 (cdr x)))
                                (rs2 (std::da-nth 2 (cdr x)))
                                (imm (std::da-nth 3 (cdr x))))
                             (and (store-funct-p funct)
                                  (ubyte5p rs1)
                                  (ubyte5p rs2)
                                  (ubyte12p imm)))))))))

    Theorem: consp-when-instrp

    (defthm consp-when-instrp
      (implies (instrp x) (consp x))
      :rule-classes :compound-recognizer)