• 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

    Update-variable-value

    Update the value in a variable in a dynamic environment.

    Signature
    (update-variable-value var val env) → new-env
    Arguments
    var — Guard (identifierp var).
    val — Guard (valuep val).
    env — Guard (denvp env).
    Returns
    new-env — Type (denv-resultp new-env).

    The variable must be in the top call frame.

    Definitions and Theorems

    Function: update-variable-value

    (defun update-variable-value (var val env)
      (declare (xargs :guard (and (identifierp var)
                                  (valuep val)
                                  (denvp env))))
      (let ((__function__ 'update-variable-value))
        (declare (ignorable __function__))
        (b* ((calls (denv->call-stack env))
             ((when (endp calls))
              (reserrf :empty-call-stack))
             (top-call (car calls))
             (scopes (call-dinfo->scopes top-call))
             ((okf new-scopes)
              (update-variable-value-in-scope-list var val scopes))
             (new-top-call (change-call-dinfo top-call
                                              :scopes new-scopes))
             (new-calls (cons new-top-call (cdr calls)))
             (new-env (change-denv env
                                   :call-stack new-calls)))
          new-env)))

    Theorem: denv-resultp-of-update-variable-value

    (defthm denv-resultp-of-update-variable-value
      (b* ((new-env (update-variable-value var val env)))
        (denv-resultp new-env))
      :rule-classes :rewrite)

    Theorem: update-variable-value-of-identifier-fix-var

    (defthm update-variable-value-of-identifier-fix-var
      (equal (update-variable-value (identifier-fix var)
                                    val env)
             (update-variable-value var val env)))

    Theorem: update-variable-value-identifier-equiv-congruence-on-var

    (defthm update-variable-value-identifier-equiv-congruence-on-var
      (implies (identifier-equiv var var-equiv)
               (equal (update-variable-value var val env)
                      (update-variable-value var-equiv val env)))
      :rule-classes :congruence)

    Theorem: update-variable-value-of-value-fix-val

    (defthm update-variable-value-of-value-fix-val
      (equal (update-variable-value var (value-fix val)
                                    env)
             (update-variable-value var val env)))

    Theorem: update-variable-value-value-equiv-congruence-on-val

    (defthm update-variable-value-value-equiv-congruence-on-val
      (implies (value-equiv val val-equiv)
               (equal (update-variable-value var val env)
                      (update-variable-value var val-equiv env)))
      :rule-classes :congruence)

    Theorem: update-variable-value-of-denv-fix-env

    (defthm update-variable-value-of-denv-fix-env
      (equal (update-variable-value var val (denv-fix env))
             (update-variable-value var val env)))

    Theorem: update-variable-value-denv-equiv-congruence-on-env

    (defthm update-variable-value-denv-equiv-congruence-on-env
      (implies (denv-equiv env env-equiv)
               (equal (update-variable-value var val env)
                      (update-variable-value var val env-equiv)))
      :rule-classes :congruence)