• 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

    Read-location

    Read the value stored in a location.

    Signature
    (read-location loc env) → val
    Arguments
    loc — Guard (locationp loc).
    env — Guard (denvp env).
    Returns
    val — Type (value-resultp val).

    If the location is a variable, we read its value. We retrieve the variable or constant with the given name (if any), and we ensure that it is a variable and not a constant; this should always be the case, for locations obtained by evaluating expressions without error, and we plan to formally prove that.

    If the location is a tuple or struct component, we first read the tuple or struct value, then we extract the component.

    Definitions and Theorems

    Function: read-location

    (defun read-location (loc env)
      (declare (xargs :guard (and (locationp loc) (denvp env))))
      (let ((__function__ 'read-location))
        (declare (ignorable __function__))
        (location-case loc :var
                       (b* ((var loc.name)
                            (info (get-var/const-dinfo var env))
                            ((when (not info))
                             (reserrf (list :var-not-found var)))
                            ((when (var/const-dinfo->constp info))
                             (reserrf (list :const-location var))))
                         (var/const-dinfo->value info))
                       :tuple-comp
                       (b* (((okf tuple)
                             (read-location loc.tuple env)))
                         (op-tuple-read tuple loc.index))
                       :struct-comp
                       (b* (((okf struct)
                             (read-location loc.struct env)))
                         (op-struct-read struct loc.name)))))

    Theorem: value-resultp-of-read-location

    (defthm value-resultp-of-read-location
      (b* ((val (read-location loc env)))
        (value-resultp val))
      :rule-classes :rewrite)

    Theorem: read-location-of-location-fix-loc

    (defthm read-location-of-location-fix-loc
      (equal (read-location (location-fix loc) env)
             (read-location loc env)))

    Theorem: read-location-location-equiv-congruence-on-loc

    (defthm read-location-location-equiv-congruence-on-loc
      (implies (location-equiv loc loc-equiv)
               (equal (read-location loc env)
                      (read-location loc-equiv env)))
      :rule-classes :congruence)

    Theorem: read-location-of-denv-fix-env

    (defthm read-location-of-denv-fix-env
      (equal (read-location loc (denv-fix env))
             (read-location loc env)))

    Theorem: read-location-denv-equiv-congruence-on-env

    (defthm read-location-denv-equiv-congruence-on-env
      (implies (denv-equiv env env-equiv)
               (equal (read-location loc env)
                      (read-location loc env-equiv)))
      :rule-classes :congruence)