• 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
        • Syntax-for-tools
        • Atc
        • Language
        • Representation
        • Transformation-tools
          • Simpadd0
          • Deftrans
          • Splitgso
          • Constant-propagation
            • Value-to-expr
            • Const-prop-eval-impure-binop-expr
            • Env
              • Envp
              • Env-fix
              • Union-env
              • Env-equiv
              • Write-env
                • Declare-var-env
                • Read-env
                • Push-scope-env
                • In-scope-env
                • Pop-scope-env
                • Merge-block-env
                • Env-block
              • Const-prop-eval-pure-binop-expr
              • Const-prop-filepath-transunit-map
              • Const-prop-eval-unop-expr
              • Const-prop-transunit-ensemble
              • Const-prop-fundef
              • Value-result-to-option
              • Const-prop-extdecl-list
              • Const-prop-extdecl
              • Zero-valuep
              • Iconst-to-value
              • Const-to-value
              • Expr-to-ident
              • Const-prop-transunit
              • Pure-binopp
              • Const-prop-initdeclor-list
              • Const-prop-initdeclor
              • Const-prop-structdeclor-list
              • Const-prop-structdecl-list
              • Const-prop-param-declon-list
              • Const-prop-initer-option
              • Const-prop-initer
              • Const-prop-expr-option
              • Const-prop-dirabsdeclor-option
              • Const-prop-dirabsdeclor
              • Const-prop-const-expr-option
              • Const-prop-absdeclor-option
              • Const-prop-type-spec
              • Const-prop-strunispec
              • Const-prop-structdeclor
              • Const-prop-structdecl
              • Const-prop-statassert
              • Const-prop-spec/qual-list
              • Const-prop-spec/qual
              • Const-prop-param-declor
              • Const-prop-param-declon
              • Const-prop-member-designor
              • Const-prop-genassoc-list
              • Const-prop-genassoc
              • Const-prop-expr-list
              • Const-prop-expr
              • Const-prop-enumspec
              • Const-prop-enumer-list
              • Const-prop-dirdeclor
              • Const-prop-desiniter-list
              • Const-prop-desiniter
              • Const-prop-designor-list
              • Const-prop-designor
              • Const-prop-declor-option
              • Const-prop-decl-spec-list
              • Const-prop-decl-spec
              • Const-prop-decl-list
              • Const-prop-block-item-list
              • Const-prop-align-spec
              • Const-prop-absdeclor
              • Const-prop-tyname
              • Const-prop-stmt
              • Const-prop-label
              • Const-prop-enumer
              • Const-prop-declor
              • Const-prop-decl
              • Const-prop-const-expr
              • Const-prop-block-item
            • Split-fn
            • Copy-fn
            • Specialize
            • Split-all-gso
            • Rename
            • Utilities
          • Insertion-sort
          • Pack
        • Farray
        • Rp-rewriter
        • Instant-runoff-voting
        • Imp-language
        • Sidekick
        • Leftist-trees
        • Java
        • Taspi
        • Bitcoin
        • Riscv
        • 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
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Env

    Write-env

    Overwrite the value of a variable.

    Signature
    (write-env ident value? env) → new-env
    Arguments
    ident — Guard (identp ident).
    value? — Guard (c::value-optionp value?).
    env — Guard (envp env).
    Returns
    new-env — Type (envp new-env).

    This assumes that the variable is already declared (see declare-var-env). If the variable has been shadowed, only the unshadowed variable is overwritten.

    Definitions and Theorems

    Function: write-env

    (defun write-env (ident value? env)
      (declare (xargs :guard (and (identp ident)
                                  (c::value-optionp value?)
                                  (envp env))))
      (let ((__function__ 'write-env))
        (declare (ignorable __function__))
        (b* ((env (env-fix env))
             (value? (c::value-option-fix value?))
             ((when (endp env)) nil)
             (lookup (omap::assoc ident (first env))))
          (if lookup (cons (omap::update ident value? (first env))
                           (rest env))
            (cons (first env)
                  (write-env ident value? (rest env)))))))

    Theorem: envp-of-write-env

    (defthm envp-of-write-env
      (b* ((new-env (write-env ident value? env)))
        (envp new-env))
      :rule-classes :rewrite)