• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • 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
        • Bitcoin
        • Ethereum
        • Yul
          • Transformations
          • Language
            • Abstract-syntax
            • Dynamic-semantics
              • Exec
              • Find-fun
              • Init-local
              • Write-vars-values
              • Add-vars-values
              • Add-funs
              • Eoutcome
              • Soutcome
              • Ensure-funscope-disjoint
              • Write-var-value
              • Restrict-vars
              • Add-var-value
              • Funinfo
              • Exec-top-block
              • Values
              • Cstate
              • Funinfo+funenv
              • Read-vars-values
              • Read-var-value
                • Funenv
                • Funscope-for-fundefs
                • Exec-path
                • Path-to-var
                • Funinfo+funenv-result
                • Exec-literal
                • Soutcome-result
                • Mode-set-result
                • Literal-evaluation
                • Funscope-result
                • Funinfo-result
                • Funenv-result
                • Eoutcome-result
                • Cstate-result
                • Paths-to-vars
                • Funinfo-for-fundef
                • Lstate
                • Funscope
                • Mode-set
                • Modes
              • Concrete-syntax
              • Static-soundness
              • Static-semantics
              • Errors
            • Yul-json
          • 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
    • Dynamic-semantics

    Read-var-value

    Read a variable value from the computation state.

    Signature
    (read-var-value var cstate) → val
    Arguments
    var — Guard (identifierp var).
    cstate — Guard (cstatep cstate).
    Returns
    val — Type (value-resultp val).

    An error is returned if the variable does not exist.

    Definitions and Theorems

    Function: read-var-value

    (defun read-var-value (var cstate)
     (declare (xargs :guard (and (identifierp var)
                                 (cstatep cstate))))
     (let ((__function__ 'read-var-value))
       (declare (ignorable __function__))
       (b* ((lstate (cstate->local cstate))
            (var-val (omap::assoc (identifier-fix var)
                                  lstate))
            ((unless (consp var-val))
             (reserrf (list :variable-not-found (identifier-fix var)))))
         (value-fix (cdr var-val)))))

    Theorem: value-resultp-of-read-var-value

    (defthm value-resultp-of-read-var-value
      (b* ((val (read-var-value var cstate)))
        (value-resultp val))
      :rule-classes :rewrite)

    Theorem: error-info-wfp-of-read-var-value

    (defthm error-info-wfp-of-read-var-value
      (b* ((?val (read-var-value var cstate)))
        (implies (reserrp val)
                 (error-info-wfp val))))

    Theorem: read-var-value-of-identifier-fix-var

    (defthm read-var-value-of-identifier-fix-var
      (equal (read-var-value (identifier-fix var)
                             cstate)
             (read-var-value var cstate)))

    Theorem: read-var-value-identifier-equiv-congruence-on-var

    (defthm read-var-value-identifier-equiv-congruence-on-var
      (implies (identifier-equiv var var-equiv)
               (equal (read-var-value var cstate)
                      (read-var-value var-equiv cstate)))
      :rule-classes :congruence)

    Theorem: read-var-value-of-cstate-fix-cstate

    (defthm read-var-value-of-cstate-fix-cstate
      (equal (read-var-value var (cstate-fix cstate))
             (read-var-value var cstate)))

    Theorem: read-var-value-cstate-equiv-congruence-on-cstate

    (defthm read-var-value-cstate-equiv-congruence-on-cstate
      (implies (cstate-equiv cstate cstate-equiv)
               (equal (read-var-value var cstate)
                      (read-var-value var cstate-equiv)))
      :rule-classes :congruence)