• 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
            • Atc-implementation
              • Atc-abstract-syntax
              • Atc-pretty-printer
              • Atc-event-and-code-generation
                • Atc-symbolic-computation-states
                  • Update-var
                  • Atc-write-var-rules
                    • Atc-write-object-rules
                    • Atc-update-object-rules
                    • Add-var
                    • Atc-update-var-rules
                    • Update-object
                    • Atc-write-static-var-rules
                    • Atc-read-var-rules
                    • Atc-create-var-rules
                    • Update-static-var
                    • Atc-read-object-rules
                    • Add-frame
                    • Var-autop
                    • Var-in-scopes-p
                    • Atc-push-frame-rules
                    • Atc-update-static-var-rules
                    • Atc-compustate-frames-number-rules
                    • Objdesign->base-address
                    • Atc-read-static-var-rules
                    • Atc-exit-scope-rules
                    • Atc-var-autop-rules
                    • Atc-pop-frame-rules
                    • *atc-write-object-rules*
                    • *atc-symbolic-computation-state-rules*
                    • *atc-write-static-var-rules*
                    • *atc-update-object-rules*
                    • *atc-read-object-rules*
                    • *atc-compustate-frames-number-rules*
                    • Atc-enter-scope-rules
                    • *atc-write-var-rules*
                    • *atc-var-autop-rules*
                    • *atc-update-var-rules*
                    • *atc-update-static-var-rules*
                    • *atc-read-var-rules*
                    • *atc-read-static-var-rules*
                    • *atc-push-frame-rules*
                    • *atc-pop-frame-rules*
                    • *atc-exit-scope-rules*
                    • *atc-create-var-rules*
                  • Atc-symbolic-execution-rules
                  • Atc-gen-ext-declon-lists
                  • Atc-function-and-loop-generation
                  • Atc-statement-generation
                  • Atc-gen-fileset
                  • Atc-gen-everything
                  • Atc-gen-obj-declon
                  • Atc-gen-fileset-event
                  • Atc-tag-tables
                  • Atc-expression-generation
                  • Atc-generation-contexts
                  • Atc-gen-wf-thm
                  • Term-checkers-atc
                  • Atc-variable-tables
                  • Term-checkers-common
                  • Atc-gen-init-fun-env-thm
                  • Atc-gen-appconds
                  • Read-write-variables
                  • Atc-gen-thm-assert-events
                  • Test*
                  • Atc-gen-prog-const
                  • Atc-gen-expr-bool
                  • Atc-theorem-generation
                  • Atc-tag-generation
                  • Atc-gen-expr-pure
                  • Atc-function-tables
                  • Atc-object-tables
                • Fty-pseudo-term-utilities
                • Atc-term-recognizers
                • Atc-input-processing
                • Atc-shallow-embedding
                • Atc-process-inputs-and-gen-everything
                • Atc-table
                • Atc-fn
                • Atc-pretty-printing-options
                • Atc-types
                • Atc-macro-definition
              • Atc-tutorial
              • Pure-expression-execution
            • Transformation-tools
            • 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
    • Atc-symbolic-computation-states

    Atc-write-var-rules

    Rules about write-var.

    The theorem about write-var turns it into update-var, similarly to create-var being turned into add-var. The condition for the replacemenet is captured by write-var-okp, for which we supply rules to go through the computation state layers. When the computation state (meta) variable is reached, it must be the case that there are hypotheses available saying that reading the variable yields a value: this happens for loop proofs, for variables created outside the loop, which are therefore not visible as add-vars. The rule is used as last resort, only if the computation state is an ACL2 variable (as enforced by the syntaxp hypothesis).

    We also include the executable counterpart of typep in the list of rules related to write-var. This is needed to discharge some typep hypotheses that arise during symbolic execution and are applied to quoted constants. We may arrange things in the future so that these quoted constants do not arise and thus there is no need for the executable counterpart of typep to be included in the list of rules here.

    Also see atc-write-static-var-rules for a rule that relates write-var-okp and add-frame.

    Definitions and Theorems

    Function: write-var-aux-okp

    (defun write-var-aux-okp (var val scopes)
      (declare (xargs :guard (and (identp var)
                                  (valuep val)
                                  (scope-listp scopes))))
      (let ((__function__ 'write-var-aux-okp))
        (declare (ignorable __function__))
        (b* (((when (endp scopes)) nil)
             (scope (scope-fix (car scopes)))
             (pair (omap::assoc (ident-fix var) scope))
             ((when (consp pair))
              (equal (type-of-value (cdr pair))
                     (type-of-value val))))
          (write-var-aux-okp var val (cdr scopes)))))

    Theorem: booleanp-of-write-var-aux-okp

    (defthm booleanp-of-write-var-aux-okp
      (b* ((yes/no (write-var-aux-okp var val scopes)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: write-var-aux-okp-of-ident-fix-var

    (defthm write-var-aux-okp-of-ident-fix-var
      (equal (write-var-aux-okp (ident-fix var)
                                val scopes)
             (write-var-aux-okp var val scopes)))

    Theorem: write-var-aux-okp-ident-equiv-congruence-on-var

    (defthm write-var-aux-okp-ident-equiv-congruence-on-var
      (implies (ident-equiv var var-equiv)
               (equal (write-var-aux-okp var val scopes)
                      (write-var-aux-okp var-equiv val scopes)))
      :rule-classes :congruence)

    Theorem: write-var-aux-okp-of-value-fix-val

    (defthm write-var-aux-okp-of-value-fix-val
      (equal (write-var-aux-okp var (value-fix val)
                                scopes)
             (write-var-aux-okp var val scopes)))

    Theorem: write-var-aux-okp-value-equiv-congruence-on-val

    (defthm write-var-aux-okp-value-equiv-congruence-on-val
      (implies (value-equiv val val-equiv)
               (equal (write-var-aux-okp var val scopes)
                      (write-var-aux-okp var val-equiv scopes)))
      :rule-classes :congruence)

    Theorem: write-var-aux-okp-of-scope-list-fix-scopes

    (defthm write-var-aux-okp-of-scope-list-fix-scopes
      (equal (write-var-aux-okp var val (scope-list-fix scopes))
             (write-var-aux-okp var val scopes)))

    Theorem: write-var-aux-okp-scope-list-equiv-congruence-on-scopes

    (defthm write-var-aux-okp-scope-list-equiv-congruence-on-scopes
      (implies (scope-list-equiv scopes scopes-equiv)
               (equal (write-var-aux-okp var val scopes)
                      (write-var-aux-okp var val scopes-equiv)))
      :rule-classes :congruence)

    Function: write-var-okp

    (defun write-var-okp (var val compst)
      (declare (xargs :guard (and (identp var)
                                  (valuep val)
                                  (compustatep compst))))
      (declare (xargs :guard (> (compustate-frames-number compst)
                                0)))
      (let ((__function__ 'write-var-okp))
        (declare (ignorable __function__))
        (b* ((scopes (frame->scopes (top-frame compst)))
             (autop (var-in-scopes-p var scopes))
             ((when autop)
              (write-var-aux-okp var val scopes))
             (static (compustate->static compst))
             (pair (omap::assoc (ident-fix var) static)))
          (and (consp pair)
               (equal (type-of-value (cdr pair))
                      (type-of-value val))))))

    Theorem: booleanp-of-write-var-okp

    (defthm booleanp-of-write-var-okp
      (b* ((yes/no (write-var-okp var val compst)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: write-var-okp-of-ident-fix-var

    (defthm write-var-okp-of-ident-fix-var
      (equal (write-var-okp (ident-fix var)
                            val compst)
             (write-var-okp var val compst)))

    Theorem: write-var-okp-ident-equiv-congruence-on-var

    (defthm write-var-okp-ident-equiv-congruence-on-var
      (implies (ident-equiv var var-equiv)
               (equal (write-var-okp var val compst)
                      (write-var-okp var-equiv val compst)))
      :rule-classes :congruence)

    Theorem: write-var-okp-of-value-fix-val

    (defthm write-var-okp-of-value-fix-val
      (equal (write-var-okp var (value-fix val)
                            compst)
             (write-var-okp var val compst)))

    Theorem: write-var-okp-value-equiv-congruence-on-val

    (defthm write-var-okp-value-equiv-congruence-on-val
      (implies (value-equiv val val-equiv)
               (equal (write-var-okp var val compst)
                      (write-var-okp var val-equiv compst)))
      :rule-classes :congruence)

    Theorem: write-var-okp-of-compustate-fix-compst

    (defthm write-var-okp-of-compustate-fix-compst
      (equal (write-var-okp var val (compustate-fix compst))
             (write-var-okp var val compst)))

    Theorem: write-var-okp-compustate-equiv-congruence-on-compst

    (defthm write-var-okp-compustate-equiv-congruence-on-compst
      (implies (compustate-equiv compst compst-equiv)
               (equal (write-var-okp var val compst)
                      (write-var-okp var val compst-equiv)))
      :rule-classes :congruence)

    Theorem: write-var-okp-of-enter-scope

    (defthm write-var-okp-of-enter-scope
      (equal (write-var-okp var val (enter-scope compst))
             (write-var-okp var val compst)))

    Theorem: write-var-okp-of-add-var

    (defthm write-var-okp-of-add-var
      (equal (write-var-okp var val (add-var var2 val2 compst))
             (if (equal (ident-fix var) (ident-fix var2))
                 (equal (type-of-value val2)
                        (type-of-value val))
               (write-var-okp var val compst))))

    Theorem: write-var-okp-of-update-var

    (defthm write-var-okp-of-update-var
      (equal (write-var-okp var val (update-var var2 val2 compst))
             (if (equal (ident-fix var) (ident-fix var2))
                 (equal (type-of-value val2)
                        (type-of-value val))
               (write-var-okp var val compst))))

    Theorem: write-var-okp-of-update-static-var

    (defthm write-var-okp-of-update-static-var
      (implies
           (not (equal (ident-fix var)
                       (ident-fix var2)))
           (equal (write-var-okp var val
                                 (update-static-var var2 val2 compst))
                  (write-var-okp var val compst))))

    Theorem: write-var-okp-of-update-object

    (defthm write-var-okp-of-update-object
      (equal (write-var-okp var
                            val (update-object objdes obj compst))
             (write-var-okp var val compst)))

    Theorem: write-var-okp-when-valuep-of-read-var

    (defthm write-var-okp-when-valuep-of-read-var
      (implies (and (syntaxp (symbolp compst))
                    (> (compustate-frames-number compst) 0)
                    (equal old-val (read-var var compst))
                    (valuep old-val))
               (equal (write-var-okp var val compst)
                      (equal (type-of-value val)
                             (type-of-value old-val)))))

    Theorem: write-var-to-update-var

    (defthm write-var-to-update-var
      (implies (and (> (compustate-frames-number compst) 0)
                    (write-var-okp var val compst))
               (equal (write-var var val compst)
                      (update-var var val compst))))

    Theorem: write-var-to-write-static-var

    (defthm write-var-to-write-static-var
      (implies (not (var-autop var compst))
               (equal (write-var var val compst)
                      (write-static-var var val compst))))