• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • 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
        • C
          • Syntax-for-tools
          • Atc
          • Transformation-tools
            • Simpadd0
            • Proof-generation
            • Split-gso
            • Wrap-fn
            • Constant-propagation
              • Value-to-expr
              • Const-prop-eval-impure-binop-expr
                • Env
                • 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
                • Const-prop-code-ensemble
                • Expr-to-ident
                • Const-prop-transunit
                • Pure-binopp
                • Const-prop-initdeclor-list
                • Const-prop-initdeclor
                • Const-prop-struct-declor-list
                • Const-prop-struct-declor
                • Const-prop-struct-declon-list
                • Const-prop-struct-declon
                • 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-struni-spec
                • 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-enumer-list
                • Const-prop-enum-spec
                • 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-comp-stmt
                • Const-prop-block-item
              • Specialize
              • Split-fn
              • Split-fn-when
              • Split-all-gso
              • Copy-fn
              • Variables-in-computation-states
              • Rename
              • Utilities
              • Proof-generation-theorems
              • Input-processing
            • Language
            • Representation
            • Insertion-sort
            • Pack
          • Soft
          • Bv
          • Imp-language
          • Ethereum
          • Event-macros
          • Java
          • Riscv
          • Bitcoin
          • Zcash
          • Yul
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Axe
          • Lists-light
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Constant-propagation

    Const-prop-eval-impure-binop-expr

    Propogate a constant through an impure c$::binop.

    Signature
    (const-prop-eval-impure-binop-expr binop left right env) 
      → 
    (mv value? env)
    Arguments
    binop — Guard (binopp binop).
    left — Guard (exprp left).
    right — Guard (c::valuep right).
    env — Guard (envp env).
    Returns
    value? — Type (c::value-optionp value?).
    env — Type (envp env).

    If the lvalue cannot be resolved, the environment is nullified, as we cannot be sure what has been mutated. For instance, consider the following sequence of statements:

    int a = 1;
    int b = 4;
    *x = 0;
    int c = a + b;

    Without knowing the value of x, we cannot constant fold the initializer of c. For instance, the constraints x == &a, x == &b, and x != &a && x != &b would all produce different results.

    Definitions and Theorems

    Function: const-prop-eval-impure-binop-expr

    (defun const-prop-eval-impure-binop-expr (binop left right env)
     (declare (xargs :guard (and (binopp binop)
                                 (exprp left)
                                 (c::valuep right)
                                 (envp env))))
     (declare (xargs :guard (not (pure-binopp binop))))
     (let ((__function__ 'const-prop-eval-impure-binop-expr))
      (declare (ignorable __function__))
      (b* ((env (env-fix env))
           (right (c::value-fix right)))
        (binop-case binop :asg
                    (b* ((ident? (expr-to-ident left)))
                      (if ident? (mv right (write-env ident? right env))
                        (mv nil nil)))
                    :otherwise (mv nil nil)))))

    Theorem: value-optionp-of-const-prop-eval-impure-binop-expr.value?

    (defthm value-optionp-of-const-prop-eval-impure-binop-expr.value?
      (b* (((mv ?value? ?env)
            (const-prop-eval-impure-binop-expr binop left right env)))
        (c::value-optionp value?))
      :rule-classes :rewrite)

    Theorem: envp-of-const-prop-eval-impure-binop-expr.env

    (defthm envp-of-const-prop-eval-impure-binop-expr.env
      (b* (((mv ?value? ?env)
            (const-prop-eval-impure-binop-expr binop left right env)))
        (envp env))
      :rule-classes :rewrite)