• 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
      • Riscv
      • Taspi
      • Bitcoin
      • 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
      • Aleo
        • Aleobft
        • Aleovm
        • Leo
          • Grammar
          • Early-version
            • Json2ast
            • Testing
            • Definition
              • Flattening
              • Abstract-syntax
              • Dynamic-semantics
                • Execution
                  • Exec-expressions/statements
                  • Init-for-loop
                  • Exec-file-main
                  • Update-variable-value-in-scope-list
                  • Step-for-loop
                  • Update-variable-value-in-scope
                  • Expr-value-to-value
                    • Exec-binary
                    • Exec-expression
                    • Init-vcscope-dinfo-call
                    • Value?+denv
                    • Exec-statement
                    • End-of-for-loop-p
                    • Expr-value
                    • Evalue+denv
                    • Write-location
                    • Read-location
                    • Exec-for-loop-iterations
                    • Update-variable-value
                    • Exec-unary
                    • Values+denv
                    • Init-vcscope-dinfo-loop
                    • Extend-denv-with-structdecl
                    • Exec-var/const
                    • Valuemap+denv
                    • Namevalue+denv
                    • Extend-denv-with-fundecl
                    • Ensure-boolean
                    • Int+denv
                    • Push-vcscope-dinfo
                    • Extend-denv-with-topdecl-list
                    • Exec-literal
                    • Build-denv-from-file
                    • Namevalue+denv-result
                    • Extend-denv-with-topdecl
                    • Evalue+denv-result
                    • Value?+denv-result
                    • Values+denv-result
                    • Valuemap+denv-result
                    • Int+denv-result
                    • Push-call-dinfo
                    • Exec-print
                    • Pop-vcscope-dinfo
                    • Exec-if
                    • Exec-function
                    • Pop-call-dinfo
                    • Exec-statement-list
                    • Exec-block
                    • Exec-struct-init-list
                    • Exec-struct-init
                    • Exec-expression-list
                  • Values
                  • Dynamic-environments
                  • Arithmetic-operations
                  • Curve-parameterization
                  • Shift-operations
                  • Errors
                  • Value-expressions
                  • Locations
                  • Input-execution
                  • Edwards-bls12-generator
                  • Equality-operations
                  • Logical-operations
                  • Program-execution
                  • Ordering-operations
                  • Bitwise-operations
                  • Literal-evaluation
                  • Type-maps-for-struct-components
                  • Output-execution
                  • Tuple-operations
                  • Struct-operations
                • Compilation
                • Static-semantics
                • Concrete-syntax
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Execution

    Expr-value-to-value

    Turn an expression value into a value.

    Signature
    (expr-value-to-value eval env) → val
    Arguments
    eval — Guard (expr-valuep eval).
    env — Guard (denvp env).
    Returns
    val — Type (value-resultp val).

    As explained in expr-value, an expression may evaluate to a location or to a value. When the expression is a sub-expression of a larger one, in some cases the location and value cases are treated differently, but in other cases the value of the expression is needed, whether it denotes a value or a location: if it denotes a location, the value stored in it is read; this way, expressions can be uniformly treated as returning values, when needed in the context of certain larger expressions.

    This ACL2 function performs this conversion. If the expression value is just a value, it is returned. If the expression value is a location, the value is read from the location. The latter requires a dynamic environment, which is an additional parameter of this ACL2 function.

    We return an error if the location cannot be read, but this should never be the case when we call this ACL2 function. We plan to look into formalizing and proving this invariant, e.g. via suitable guards.

    Definitions and Theorems

    Function: expr-value-to-value

    (defun expr-value-to-value (eval env)
      (declare (xargs :guard (and (expr-valuep eval) (denvp env))))
      (let ((__function__ 'expr-value-to-value))
        (declare (ignorable __function__))
        (expr-value-case eval
                         :location (read-location eval.get env)
                         :value eval.get)))

    Theorem: value-resultp-of-expr-value-to-value

    (defthm value-resultp-of-expr-value-to-value
      (b* ((val (expr-value-to-value eval env)))
        (value-resultp val))
      :rule-classes :rewrite)

    Theorem: expr-value-to-value-of-expr-value-fix-eval

    (defthm expr-value-to-value-of-expr-value-fix-eval
      (equal (expr-value-to-value (expr-value-fix eval)
                                  env)
             (expr-value-to-value eval env)))

    Theorem: expr-value-to-value-expr-value-equiv-congruence-on-eval

    (defthm expr-value-to-value-expr-value-equiv-congruence-on-eval
      (implies (expr-value-equiv eval eval-equiv)
               (equal (expr-value-to-value eval env)
                      (expr-value-to-value eval-equiv env)))
      :rule-classes :congruence)

    Theorem: expr-value-to-value-of-denv-fix-env

    (defthm expr-value-to-value-of-denv-fix-env
      (equal (expr-value-to-value eval (denv-fix env))
             (expr-value-to-value eval env)))

    Theorem: expr-value-to-value-denv-equiv-congruence-on-env

    (defthm expr-value-to-value-denv-equiv-congruence-on-env
      (implies (denv-equiv env env-equiv)
               (equal (expr-value-to-value eval env)
                      (expr-value-to-value eval env-equiv)))
      :rule-classes :congruence)