• 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
        • States
          • Stat
          • Stat-validp
          • Write-memory-unsigned64
          • Write-memory-unsigned32
            • Write-memory-unsigned8
            • Write-memory-unsigned16
            • Read-xreg-unsigned
            • Write-xreg-32
            • States64
            • Write-xreg
            • Read-memory-unsigned8
            • Read-memory-unsigned64
            • Read-memory-unsigned32
            • Read-memory-unsigned16
            • Read-xreg-signed
            • Read-xreg-unsigned32
            • States32
            • Write-pc
            • Read-xreg-signed32
            • Read-pc
            • Inc4-pc
          • 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
    • States

    Write-memory-unsigned32

    Write an unsigned 32-bit integer to memory.

    Signature
    (write-memory-unsigned32 addr val stat feat) → new-stat
    Arguments
    addr — Guard (integerp addr).
    val — Guard (ubyte32p val).
    stat — Guard (statp stat).
    feat — Guard (featp feat).
    Returns
    new-stat — Type (statp new-stat).

    The memory address is the one of the first byte; we write that, and the subsequent bytes. For now we only support little endian memory, so the first byte is the lowest one.

    As in write-memory-unsigned8, we let the address be any integer. We use write-memory-unsigned8 twice. Note that if addr is close to 2^XLEN - 1, then the subsequent addresses may wrap around to address 0.

    Definitions and Theorems

    Function: write-memory-unsigned32

    (defun write-memory-unsigned32 (addr val stat feat)
      (declare (xargs :guard (and (integerp addr)
                                  (ubyte32p val)
                                  (statp stat)
                                  (featp feat))))
      (declare (xargs :guard (stat-validp stat feat)))
      (let ((__function__ 'write-memory-unsigned32))
        (declare (ignorable __function__))
        (b* ((addr (lifix addr))
             (val (ubyte32-fix val))
             (b0 (logand val 255))
             (b1 (logand (ash val -8) 255))
             (b2 (logand (ash val -16) 255))
             (b3 (ash val -24))
             (stat (write-memory-unsigned8 addr b0 stat feat))
             (stat (write-memory-unsigned8 (+ addr 1)
                                           b1 stat feat))
             (stat (write-memory-unsigned8 (+ addr 2)
                                           b2 stat feat))
             (stat (write-memory-unsigned8 (+ addr 3)
                                           b3 stat feat)))
          stat)))

    Theorem: statp-of-write-memory-unsigned32

    (defthm statp-of-write-memory-unsigned32
      (b* ((new-stat (write-memory-unsigned32 addr val stat feat)))
        (statp new-stat))
      :rule-classes :rewrite)

    Theorem: stat-validp-of-write-memory-unsigned32

    (defthm stat-validp-of-write-memory-unsigned32
     (implies
          (stat-validp stat feat)
          (b* ((?new-stat (write-memory-unsigned32 addr val stat feat)))
            (stat-validp new-stat feat))))

    Theorem: write-memory-unsigned32-of-ifix-addr

    (defthm write-memory-unsigned32-of-ifix-addr
      (equal (write-memory-unsigned32 (ifix addr)
                                      val stat feat)
             (write-memory-unsigned32 addr val stat feat)))

    Theorem: write-memory-unsigned32-int-equiv-congruence-on-addr

    (defthm write-memory-unsigned32-int-equiv-congruence-on-addr
      (implies
           (acl2::int-equiv addr addr-equiv)
           (equal (write-memory-unsigned32 addr val stat feat)
                  (write-memory-unsigned32 addr-equiv val stat feat)))
      :rule-classes :congruence)

    Theorem: write-memory-unsigned32-of-ubyte32-fix-val

    (defthm write-memory-unsigned32-of-ubyte32-fix-val
      (equal (write-memory-unsigned32 addr (ubyte32-fix val)
                                      stat feat)
             (write-memory-unsigned32 addr val stat feat)))

    Theorem: write-memory-unsigned32-ubyte32-equiv-congruence-on-val

    (defthm write-memory-unsigned32-ubyte32-equiv-congruence-on-val
      (implies
           (acl2::ubyte32-equiv val val-equiv)
           (equal (write-memory-unsigned32 addr val stat feat)
                  (write-memory-unsigned32 addr val-equiv stat feat)))
      :rule-classes :congruence)

    Theorem: write-memory-unsigned32-of-stat-fix-stat

    (defthm write-memory-unsigned32-of-stat-fix-stat
      (equal (write-memory-unsigned32 addr val (stat-fix stat)
                                      feat)
             (write-memory-unsigned32 addr val stat feat)))

    Theorem: write-memory-unsigned32-stat-equiv-congruence-on-stat

    (defthm write-memory-unsigned32-stat-equiv-congruence-on-stat
      (implies
           (stat-equiv stat stat-equiv)
           (equal (write-memory-unsigned32 addr val stat feat)
                  (write-memory-unsigned32 addr val stat-equiv feat)))
      :rule-classes :congruence)

    Theorem: write-memory-unsigned32-of-feat-fix-feat

    (defthm write-memory-unsigned32-of-feat-fix-feat
      (equal (write-memory-unsigned32 addr val stat (feat-fix feat))
             (write-memory-unsigned32 addr val stat feat)))

    Theorem: write-memory-unsigned32-feat-equiv-congruence-on-feat

    (defthm write-memory-unsigned32-feat-equiv-congruence-on-feat
      (implies
           (feat-equiv feat feat-equiv)
           (equal (write-memory-unsigned32 addr val stat feat)
                  (write-memory-unsigned32 addr val stat feat-equiv)))
      :rule-classes :congruence)