• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • 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
        • Soft
        • C
          • Syntax-for-tools
          • Atc
          • 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
                • Preprocess
                • Wellformed
                • Check-tyspecseq
                • Check-param-declon-list
                • Check-iconst
                • Check-expr-pure-list
                • Var-sinfo-option
                • Fun-sinfo-option
                • Var-scope-all-definedp
                • Funtab+vartab+tagenv
                • Var-sinfo
                • Var-table-lookup
                • Apconvert-type
                • Var-table
                • Check-tyname
                • Types+vartab-result
                • Funtab+vartab+tagenv-result
                • Fun-table-lookup
                • Wellformed-result
                • Var-table-add-block
                • Var-table-scope
                • Var-table-result
                • 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
              • Integer-formats
              • Types
              • Portable-ascii-identifiers
              • Values
              • Integer-operations
              • Computation-states
              • Object-designators
              • Operations
              • Errors
              • Tag-environments
              • Function-environments
              • Character-sets
              • Flexible-array-member-removal
              • Arithmetic-operations
              • Pointer-operations
              • Bytes
              • Keywords
              • Real-operations
              • Array-operations
              • Scalar-operations
              • Structure-operations
            • 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
    • Static-semantics

    Struct-member-lookup

    Look up a member in a structure type in the tag environment.

    Signature
    (struct-member-lookup tag mem tagenv) → type
    Arguments
    tag — Guard (identp tag).
    mem — Guard (identp mem).
    tagenv — Guard (tag-envp tagenv).
    Returns
    type — Type (type-resultp type).

    We first look up the tag, ensuring we find a structure type. Then we look for the member in the structure type, returning its type if successful. We propagate errors.

    This is used to check member expressions, both the . kind and the -> kind.

    Definitions and Theorems

    Function: struct-member-lookup

    (defun struct-member-lookup (tag mem tagenv)
      (declare (xargs :guard (and (identp tag)
                                  (identp mem)
                                  (tag-envp tagenv))))
      (let ((__function__ 'struct-member-lookup))
        (declare (ignorable __function__))
        (b* ((info (tag-env-lookup tag tagenv))
             ((when (tag-info-option-case info :none))
              (reserrf (list :struct-not-found (ident-fix tag)
                             (tag-env-fix tagenv))))
             (info (tag-info-option-some->val info))
             ((unless (tag-info-case info :struct))
              (reserrf (list :tag-not-struct (ident-fix tag)
                             info)))
             (members (tag-info-struct->members info))
             (type (member-type-lookup mem members))
             ((when (type-option-case type :none))
              (reserrf (list :member-not-found (ident-fix tag)
                             (ident-fix mem)
                             members))))
          (type-option-some->val type))))

    Theorem: type-resultp-of-struct-member-lookup

    (defthm type-resultp-of-struct-member-lookup
      (b* ((type (struct-member-lookup tag mem tagenv)))
        (type-resultp type))
      :rule-classes :rewrite)

    Theorem: struct-member-lookup-of-ident-fix-tag

    (defthm struct-member-lookup-of-ident-fix-tag
      (equal (struct-member-lookup (ident-fix tag)
                                   mem tagenv)
             (struct-member-lookup tag mem tagenv)))

    Theorem: struct-member-lookup-ident-equiv-congruence-on-tag

    (defthm struct-member-lookup-ident-equiv-congruence-on-tag
      (implies (ident-equiv tag tag-equiv)
               (equal (struct-member-lookup tag mem tagenv)
                      (struct-member-lookup tag-equiv mem tagenv)))
      :rule-classes :congruence)

    Theorem: struct-member-lookup-of-ident-fix-mem

    (defthm struct-member-lookup-of-ident-fix-mem
      (equal (struct-member-lookup tag (ident-fix mem)
                                   tagenv)
             (struct-member-lookup tag mem tagenv)))

    Theorem: struct-member-lookup-ident-equiv-congruence-on-mem

    (defthm struct-member-lookup-ident-equiv-congruence-on-mem
      (implies (ident-equiv mem mem-equiv)
               (equal (struct-member-lookup tag mem tagenv)
                      (struct-member-lookup tag mem-equiv tagenv)))
      :rule-classes :congruence)

    Theorem: struct-member-lookup-of-tag-env-fix-tagenv

    (defthm struct-member-lookup-of-tag-env-fix-tagenv
      (equal (struct-member-lookup tag mem (tag-env-fix tagenv))
             (struct-member-lookup tag mem tagenv)))

    Theorem: struct-member-lookup-tag-env-equiv-congruence-on-tagenv

    (defthm struct-member-lookup-tag-env-equiv-congruence-on-tagenv
      (implies (tag-env-equiv tagenv tagenv-equiv)
               (equal (struct-member-lookup tag mem tagenv)
                      (struct-member-lookup tag mem tagenv-equiv)))
      :rule-classes :congruence)