• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
        • Bv
        • Imp-language
        • Event-macros
        • Java
        • Riscv
          • Specification
          • Executable
          • Specialized
          • Optimized
            • State-stobj
              • Stat1
              • Write1-memory-unsigned64
              • Stat1-iso
              • Read1-memory-unsigned64
              • Stat1-from-stat
              • Write1-memory-unsigned32
              • Read1-memory-unsigned32
              • Write1-memory-unsigned16
                • Write1-memory-unsigned8
                • Read1-memory-unsigned16
                • Read1-instruction
                • Stat-from-stat1
                • Write1-xreg
                • Read1-xreg-unsigned32
                • Read1-xreg-unsigned
                • Read1-memory-unsigned8
                • Write1-xreg-32
                • Stat1-validp
                • Read1-xreg-signed32
                • Read1-xreg-signed
                • Write1-pc
                • Make-stat1
                • Error1
                • Read1-pc
                • Inc41-pc
                • Stat1->memory
                • Errorp1
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • State-stobj

    Write1-memory-unsigned16

    Refine write-memory-unsigned16 to use the stobj states.

    Definitions and Theorems

    Function: write1-memory-unsigned16

    (defun write1-memory-unsigned16 (addr val stat feat)
     (declare (xargs :non-executable t))
     (declare
        (xargs :guard (non-exec (and (stat1p stat)
                                     (integerp addr)
                                     (ubyte16p val)
                                     (statp (stat-from-stat1 stat))
                                     (featp feat)
                                     (stat-validp (stat-from-stat1 stat)
                                                  feat)))))
     (prog2$
      (acl2::throw-nonexec-error 'write1-memory-unsigned16
                                 (list addr val stat feat))
      (if
       (acl2::mbt$ (stat1p stat))
       (let ((val (ubyte16-fix val))
             (stat (stat-from-stat1 stat)))
        (let* ((b0 (bitops::part-select-width-low val 8 0))
               (b1 (bitops::part-select-width-low val 8 8)))
         (mv-let (1st-byte 2nd-byte)
                 (if (feat-little-endianp feat)
                     (mv b0 b1)
                   (mv b1 b0))
          (let* ((stat (write-memory-unsigned8 addr 1st-byte stat feat))
                 (stat (write-memory-unsigned8 (+ (lifix addr) 1)
                                               2nd-byte stat feat)))
            stat))))
       0)))

    Theorem: write1-memory-unsigned16-to-write-memory-unsigned16

    (defthm write1-memory-unsigned16-to-write-memory-unsigned16
     (implies
         (stat1p stat)
         (equal (write1-memory-unsigned16 addr val stat feat)
                (write-memory-unsigned16 addr val (stat-from-stat1 stat)
                                         feat)))
     :rule-classes :rewrite)

    Theorem: write-memory-unsigned16-to-write1-memory-unsigned16

    (defthm write-memory-unsigned16-to-write1-memory-unsigned16
     (implies
        (statp stat)
        (equal (write-memory-unsigned16 addr val stat feat)
               (write1-memory-unsigned16 addr val (stat1-from-stat stat)
                                         feat)))
     :rule-classes :rewrite)