• 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
          • Language
            • Abstract-syntax
            • Integer-ranges
            • Implementation-environments
            • Dynamic-semantics
            • Static-semantics
              • Check-stmt
              • Check-cond
              • Check-binary-pure
              • Var-table-add-var
              • Check-unary
              • Check-obj-declon
              • Fun-table-add-fun
              • Check-fundef
              • Fun-sinfo
              • Check-expr-asg
              • Check-expr-call
              • Check-arrsub
              • Uaconvert-types
              • Apconvert-type-list
              • Check-initer
              • Adjust-type-list
              • Types+vartab
              • Promote-type
              • Check-tag-declon
              • Check-expr-call-or-asg
              • Check-ext-declon
              • Check-param-declon
              • Check-member
              • Check-expr-pure
              • Init-type-matchp
              • Check-obj-adeclor
              • Check-memberp
              • Check-expr-call-or-pure
              • Check-cast
              • Check-struct-declon-list
                • Check-fun-declor
                • Expr-type
                • Check-ext-declon-list
                • Check-transunit
                • Check-fun-declon
                • Var-defstatus
                • Struct-member-lookup
                • Wellformed
                • Preprocess
                • Check-tyspecseq
                • Check-param-declon-list
                • Check-iconst
                • Check-expr-pure-list
                • Var-sinfo-option
                • Fun-sinfo-option
                • Funtab+vartab+tagenv
                • Var-scope-all-definedp
                • Var-sinfo
                • Var-table-lookup
                • Apconvert-type
                • Var-table
                • Check-tyname
                • Types+vartab-result
                • Funtab+vartab+tagenv-result
                • Wellformed-result
                • Fun-table-lookup
                • Var-table-scope
                • Var-table-result
                • Var-table-add-block
                • Fun-table-result
                • Expr-type-result
                • Adjust-type
                • Check-fileset
                • Var-table-all-definedp
                • Check-const
                • Fun-table-all-definedp
                • Check-ident
                • Fun-table
                • Var-table-init
                • Fun-table-init
              • Grammar
              • Types
              • Integer-formats-definitions
              • Computation-states
              • Portable-ascii-identifiers
              • Values
              • Integer-operations
              • Object-designators
              • Operations
              • Errors
              • Tag-environments
              • Function-environments
              • Character-sets
              • Flexible-array-member-removal
              • Arithmetic-operations
              • Pointer-operations
              • Real-operations
              • Array-operations
              • Scalar-operations
              • Structure-operations
            • 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
    • Static-semantics

    Check-struct-declon-list

    Check a list of structure declarations.

    Signature
    (check-struct-declon-list declons tagenv) → members
    Arguments
    declons — Guard (struct-declon-listp declons).
    tagenv — Guard (tag-envp tagenv).
    Returns
    members — Type (member-type-list-resultp members).

    These specify the members of a structure or union type (see struct-declon); for now we only use this for the members of a structure type, since we do not model union types.

    We go through the declarations and turn each of them into member types (see member-type). We ensure that each member name is well-formed. We check that each type is well-formed. We also check that each type either is complete [C17:6.7.2.1/9], or is an array type of unspecified size in the last member; the latter is a flexible array member [C17:6.7.2.1/18]. By using member-type-add-first, we ensure that there are no duplicate member names.

    Definitions and Theorems

    Function: check-struct-declon-list

    (defun check-struct-declon-list (declons tagenv)
      (declare (xargs :guard (and (struct-declon-listp declons)
                                  (tag-envp tagenv))))
      (let ((__function__ 'check-struct-declon-list))
        (declare (ignorable __function__))
        (b* (((when (endp declons)) nil)
             (lastp (endp (cdr declons)))
             ((okf members)
              (check-struct-declon-list (cdr declons)
                                        tagenv))
             ((mv name tyname)
              (struct-declon-to-ident+tyname (car declons)))
             ((okf type)
              (check-tyname tyname tagenv))
             (completep (type-completep type))
             (flexiblep (and lastp (type-case type :array)
                             (not (type-array->size type))))
             ((unless (or completep flexiblep))
              (reserrf (list :incomplete-member-type type)))
             ((okf &) (check-ident name))
             (members-opt (member-type-add-first name type members)))
          (member-type-list-option-case
               members-opt
               :some members-opt.val
               :none (reserrf (list :duplicate-member name))))))

    Theorem: member-type-list-resultp-of-check-struct-declon-list

    (defthm member-type-list-resultp-of-check-struct-declon-list
      (b* ((members (check-struct-declon-list declons tagenv)))
        (member-type-list-resultp members))
      :rule-classes :rewrite)

    Theorem: check-struct-declon-list-of-struct-declon-list-fix-declons

    (defthm check-struct-declon-list-of-struct-declon-list-fix-declons
      (equal (check-struct-declon-list (struct-declon-list-fix declons)
                                       tagenv)
             (check-struct-declon-list declons tagenv)))

    Theorem: check-struct-declon-list-struct-declon-list-equiv-congruence-on-declons

    (defthm
     check-struct-declon-list-struct-declon-list-equiv-congruence-on-declons
     (implies (struct-declon-list-equiv declons declons-equiv)
              (equal (check-struct-declon-list declons tagenv)
                     (check-struct-declon-list declons-equiv tagenv)))
     :rule-classes :congruence)

    Theorem: check-struct-declon-list-of-tag-env-fix-tagenv

    (defthm check-struct-declon-list-of-tag-env-fix-tagenv
      (equal (check-struct-declon-list declons (tag-env-fix tagenv))
             (check-struct-declon-list declons tagenv)))

    Theorem: check-struct-declon-list-tag-env-equiv-congruence-on-tagenv

    (defthm check-struct-declon-list-tag-env-equiv-congruence-on-tagenv
      (implies (tag-env-equiv tagenv tagenv-equiv)
               (equal (check-struct-declon-list declons tagenv)
                      (check-struct-declon-list declons tagenv-equiv)))
      :rule-classes :congruence)

    Theorem: consp-of-check-struct-declon-list

    (defthm consp-of-check-struct-declon-list
      (b* nil
        (equal (consp (check-struct-declon-list declons tagenv))
               (consp declons))))