• 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
            • Semantics
            • Features
            • Instructions
            • Encoding
            • States
              • Stat
              • Stat-validp
              • Read-instruction
              • Write-memory-unsigned64
              • Write-memory-unsigned32
              • Write-memory-unsigned8
              • Write-memory-unsigned16
              • Write-xreg-32
              • Read-xreg-unsigned
              • Write-xreg
              • Read-memory-unsigned64
              • Read-memory-unsigned8
              • Read-memory-unsigned32
              • Read-xreg-signed
              • Read-memory-unsigned16
              • Read-xreg-unsigned32
              • Write-pc
              • Read-xreg-signed32
              • Inc4-pc
                • Read-pc
                • Errorp
                • Error
              • Reads-over-writes
              • Semantics-equivalences
              • Decoding
              • Execution
            • Executable
            • Specialized
            • Optimized
          • 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
    • States

    Inc4-pc

    Increment the program counter by 4.

    Signature
    (inc4-pc stat feat) → new-stat
    Arguments
    stat — Guard (statp stat).
    feat — Guard (featp feat).
    Returns
    new-stat — Type (statp new-stat).

    In the normal instruction encodings, instructions take 32 bits each. Thus, it is common to increment the program counter by 4 (bytes), which this function provides a concise way to do.

    We read the program counter, we add 4, and we write the result. Recall that write-pc wraps around if needed [ISA:1.4].

    Definitions and Theorems

    Function: inc4-pc

    (defun inc4-pc (stat feat)
      (declare (xargs :guard (and (statp stat) (featp feat))))
      (declare (xargs :guard (stat-validp stat feat)))
      (let ((__function__ 'inc4-pc))
        (declare (ignorable __function__))
        (write-pc (+ (read-pc stat feat) 4)
                  stat feat)))

    Theorem: statp-of-inc4-pc

    (defthm statp-of-inc4-pc
      (b* ((new-stat (inc4-pc stat feat)))
        (statp new-stat))
      :rule-classes :rewrite)

    Theorem: stat-validp-of-inc4-pc

    (defthm stat-validp-of-inc4-pc
      (implies (stat-validp stat feat)
               (b* ((?new-stat (inc4-pc stat feat)))
                 (stat-validp new-stat feat))))

    Theorem: inc4-pc-of-stat-fix-stat

    (defthm inc4-pc-of-stat-fix-stat
      (equal (inc4-pc (stat-fix stat) feat)
             (inc4-pc stat feat)))

    Theorem: inc4-pc-stat-equiv-congruence-on-stat

    (defthm inc4-pc-stat-equiv-congruence-on-stat
      (implies (stat-equiv stat stat-equiv)
               (equal (inc4-pc stat feat)
                      (inc4-pc stat-equiv feat)))
      :rule-classes :congruence)

    Theorem: inc4-pc-of-feat-fix-feat

    (defthm inc4-pc-of-feat-fix-feat
      (equal (inc4-pc stat (feat-fix feat))
             (inc4-pc stat feat)))

    Theorem: inc4-pc-feat-equiv-congruence-on-feat

    (defthm inc4-pc-feat-equiv-congruence-on-feat
      (implies (feat-equiv feat feat-equiv)
               (equal (inc4-pc stat feat)
                      (inc4-pc stat feat-equiv)))
      :rule-classes :congruence)