• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • ACL2
    • Macro-libraries
    • 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-struct-write-scalar

    Check if a let binding may represent a structure write of a scalar member.

    Signature
    (atc-check-struct-write-scalar var val prec-tags) 
      → 
    (mv erp yes/no fn mem tag member mem-type)
    Arguments
    var — Guard (symbolp var).
    val — Guard (pseudo-termp val).
    prec-tags — Guard (atc-string-taginfo-alistp prec-tags).
    Returns
    yes/no — Type (booleanp yes/no).
    fn — Type (symbolp fn).
    mem — Type (pseudo-termp mem).
    tag — Type (identp tag).
    member — Type (identp member).
    mem-type — Type (typep mem-type).

    A structure write of a scalar member, i.e. an assignment to a scalar structure member via a pointer to the structure, is represented by a let binding of the form

    (let ((<struct> (struct-<tag>-write-<member> <mem> <struct>))) ...)

    where <struct> is a variable of pointer type to a structure type, which must occur identically as both the let variable and as the last argument of struct-<tag>-write-<member>, <mem> is an expression that yields the member value to write, and ... represents the code that follows the 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 member argument is returned for further processing. We also return the tag, the member name, and the member type.

    Similarly to atc-check-struct-read-scalar, we consult the prec-tags alist, which must contain the C structure type associated to the writer.

    Definitions and Theorems

    Function: atc-check-struct-write-scalar

    (defun atc-check-struct-write-scalar (var val prec-tags)
     (declare
          (xargs :guard (and (symbolp var)
                             (pseudo-termp val)
                             (atc-string-taginfo-alistp prec-tags))))
     (let ((__function__ 'atc-check-struct-write-scalar))
      (declare (ignorable __function__))
      (b*
       (((reterr)
         nil nil nil (irr-ident)
         (irr-ident)
         (irr-type))
        ((acl2::fun (no))
         (retok nil nil nil (irr-ident)
                (irr-ident)
                (irr-type)))
        ((mv okp fn args)
         (fty-check-fn-call val))
        ((unless okp) (no))
        ((mv okp struct tag write member)
         (atc-check-symbol-4part fn))
        ((unless (and okp
                      (equal (symbol-name struct) "STRUCT")
                      (equal (symbol-name write) "WRITE")))
         (no))
        (tag (symbol-name tag))
        (info (cdr (assoc-equal tag prec-tags)))
        ((unless info)
         (reterr (raise "Internal error: no structure with tag ~x0."
                        tag)))
        (info (atc-tag-info->defstruct info))
        ((unless (member-eq fn (defstruct-info->writer-list info)))
         (reterr (raise "Internal error: no member writer ~x0."
                        fn)))
        (members (defstruct-member-info-list->memtype-list
                      (defstruct-info->members info)))
        (tag (defstruct-info->tag info))
        (member (symbol-name member))
        (member (ident member))
        (mem-type (member-type-lookup member members))
        ((unless mem-type)
         (reterr (raise "Internal error: no member type for ~x0."
                        member)))
        ((unless (list-lenp 2 args))
         (reterr
              (raise "Internal error: ~x0 not applied to 2 arguments."
                     fn)))
        (mem (first args))
        ((unless (equal (second args) var))
         (reterr
          (raise
               "Internal error: ~x0 is not applied to the variable ~x1."
               fn var))))
       (retok t fn mem tag member mem-type))))

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

    (defthm booleanp-of-atc-check-struct-write-scalar.yes/no
      (b* (((mv acl2::?erp ?yes/no
                ?fn ?mem acl2::?tag ?member ?mem-type)
            (atc-check-struct-write-scalar var val prec-tags)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: symbolp-of-atc-check-struct-write-scalar.fn

    (defthm symbolp-of-atc-check-struct-write-scalar.fn
      (b* (((mv acl2::?erp ?yes/no
                ?fn ?mem acl2::?tag ?member ?mem-type)
            (atc-check-struct-write-scalar var val prec-tags)))
        (symbolp fn))
      :rule-classes :rewrite)

    Theorem: pseudo-termp-of-atc-check-struct-write-scalar.mem

    (defthm pseudo-termp-of-atc-check-struct-write-scalar.mem
      (b* (((mv acl2::?erp ?yes/no
                ?fn ?mem acl2::?tag ?member ?mem-type)
            (atc-check-struct-write-scalar var val prec-tags)))
        (pseudo-termp mem))
      :rule-classes :rewrite)

    Theorem: identp-of-atc-check-struct-write-scalar.tag

    (defthm identp-of-atc-check-struct-write-scalar.tag
      (b* (((mv acl2::?erp ?yes/no
                ?fn ?mem acl2::?tag ?member ?mem-type)
            (atc-check-struct-write-scalar var val prec-tags)))
        (identp tag))
      :rule-classes :rewrite)

    Theorem: identp-of-atc-check-struct-write-scalar.member

    (defthm identp-of-atc-check-struct-write-scalar.member
      (b* (((mv acl2::?erp ?yes/no
                ?fn ?mem acl2::?tag ?member ?mem-type)
            (atc-check-struct-write-scalar var val prec-tags)))
        (identp member))
      :rule-classes :rewrite)

    Theorem: typep-of-atc-check-struct-write-scalar.mem-type

    (defthm typep-of-atc-check-struct-write-scalar.mem-type
      (b* (((mv acl2::?erp ?yes/no
                ?fn ?mem acl2::?tag ?member ?mem-type)
            (atc-check-struct-write-scalar var val prec-tags)))
        (typep mem-type))
      :rule-classes :rewrite)

    Theorem: pseudo-term-count-of-atc-check-struct-write-scalar

    (defthm pseudo-term-count-of-atc-check-struct-write-scalar
      (b* (((mv acl2::?erp ?yes/no
                ?fn ?mem acl2::?tag ?member ?mem-type)
            (atc-check-struct-write-scalar var val prec-tags)))
        (implies yes/no
                 (< (pseudo-term-count mem)
                    (pseudo-term-count val))))
      :rule-classes :linear)