• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
          • Syntax-for-tools
          • Atc
            • Atc-implementation
              • Atc-abstract-syntax
              • Atc-pretty-printer
              • Atc-event-and-code-generation
                • Atc-symbolic-computation-states
                • 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-check-cfun-call
                  • Atc-check-struct-write-array
                  • Atc-check-struct-read-array
                  • Atc-check-struct-write-scalar
                  • Atc-check-loop-call
                  • Atc-check-struct-read-scalar
                  • Atc-check-mv-let
                  • Atc-check-array-write
                    • Atc-check-let
                    • Atc-check-array-read
                    • Atc-check-integer-write
                    • Atc-check-declar/assign-n
                    • Atc-check-condexpr
                    • Atc-check-boolean-from-type
                    • Atc-check-integer-read
                    • Atc-check-sint-from-boolean
                  • 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
            • Language
            • Representation
            • Transformation-tools
            • Insertion-sort
            • Pack
          • Bv
          • Imp-language
          • Event-macros
          • Java
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Term-checkers-atc

    Atc-check-array-write

    Check if a let binding may represent an array write.

    Signature
    (atc-check-array-write var val) 
      → 
    (mv erp yes/no fn sub elem elem-type)
    Arguments
    var — Guard (symbolp var).
    val — Guard (pseudo-termp val).
    Returns
    yes/no — Type (booleanp yes/no).
    fn — Type (symbolp fn).
    sub — Type (pseudo-termp sub).
    elem — Type (pseudo-termp elem).
    elem-type — Type (typep elem-type).

    An array write, i.e. an assignment to an array element, is represented by a let binding of the form

    (let ((<arr> (<type>-array-write <arr> <sub> <elem>))) ...)

    where <arr> is a variable of pointer type to an integer type, which must occur identically as both the let variable and as the first argument of <type>-array-write, <sub> is an expression that yields the index of the element to write, <elem> is an expression that yields the element to write, and ... represents the code that follows the array assignment. This function takes as arguments the variable and value of a let binder, and checks if they have the form described above. If they do, the components are returned for further processing. We also return the types of the index and element as gathered from the name of the array write function.

    Definitions and Theorems

    Function: atc-check-array-write

    (defun atc-check-array-write (var val)
     (declare (xargs :guard (and (symbolp var) (pseudo-termp val))))
     (let ((__function__ 'atc-check-array-write))
      (declare (ignorable __function__))
      (b*
       (((reterr) nil nil nil nil (irr-type))
        ((acl2::fun (no))
         (retok nil nil nil nil (irr-type)))
        ((mv okp fn args)
         (fty-check-fn-call val))
        ((unless okp) (no))
        ((mv okp fixtype array write)
         (atc-check-symbol-3part fn))
        (elem-type (fixtype-to-integer-type fixtype))
        ((unless (and okp elem-type (eq array 'array)
                      (eq write 'write)))
         (no))
        ((unless (equal (symbol-package-name fn) "C"))
         (reterr
          (msg
           "Invalid function ~x0 encountered: ~
                          it has the form of an array write, ~
                          but it is not in the \"C\" package."
           fn)))
        ((unless (list-lenp 3 args))
         (reterr
              (raise "Internal error: ~x0 not applied to 3 arguments."
                     fn)))
        ((unless (equal (first args) var))
         (reterr
          (raise
               "Internal error: ~x0 is not applied to the variable ~x1."
               fn var)))
        (sub (second args))
        (elem (third args)))
       (retok t fn sub elem elem-type))))

    Theorem: booleanp-of-atc-check-array-write.yes/no

    (defthm booleanp-of-atc-check-array-write.yes/no
      (b* (((mv acl2::?erp
                ?yes/no ?fn ?sub ?elem ?elem-type)
            (atc-check-array-write var val)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: symbolp-of-atc-check-array-write.fn

    (defthm symbolp-of-atc-check-array-write.fn
      (b* (((mv acl2::?erp
                ?yes/no ?fn ?sub ?elem ?elem-type)
            (atc-check-array-write var val)))
        (symbolp fn))
      :rule-classes :rewrite)

    Theorem: pseudo-termp-of-atc-check-array-write.sub

    (defthm pseudo-termp-of-atc-check-array-write.sub
      (b* (((mv acl2::?erp
                ?yes/no ?fn ?sub ?elem ?elem-type)
            (atc-check-array-write var val)))
        (pseudo-termp sub))
      :rule-classes :rewrite)

    Theorem: pseudo-termp-of-atc-check-array-write.elem

    (defthm pseudo-termp-of-atc-check-array-write.elem
      (b* (((mv acl2::?erp
                ?yes/no ?fn ?sub ?elem ?elem-type)
            (atc-check-array-write var val)))
        (pseudo-termp elem))
      :rule-classes :rewrite)

    Theorem: typep-of-atc-check-array-write.elem-type

    (defthm typep-of-atc-check-array-write.elem-type
      (b* (((mv acl2::?erp
                ?yes/no ?fn ?sub ?elem ?elem-type)
            (atc-check-array-write var val)))
        (typep elem-type))
      :rule-classes :rewrite)

    Theorem: pseudo-term-count-of-atc-check-array-write-sub

    (defthm pseudo-term-count-of-atc-check-array-write-sub
      (b* (((mv acl2::?erp
                ?yes/no ?fn ?sub ?elem ?elem-type)
            (atc-check-array-write var val)))
        (implies yes/no
                 (< (pseudo-term-count sub)
                    (pseudo-term-count val))))
      :rule-classes :linear)

    Theorem: pseudo-term-count-of-atc-check-array-write-elem

    (defthm pseudo-term-count-of-atc-check-array-write-elem
      (b* (((mv acl2::?erp
                ?yes/no ?fn ?sub ?elem ?elem-type)
            (atc-check-array-write var val)))
        (implies yes/no
                 (< (pseudo-term-count elem)
                    (pseudo-term-count val))))
      :rule-classes :linear)