• 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
            • Disambiguator
            • Abstract-syntax
            • Parser
            • Validator
              • Valid-exprs/decls/stmts
              • Valid-stmt
              • Valid-expr
              • Valid-dirdeclor
              • Valid-type-spec
              • Valid-transunit
              • Valid-stor-spec-list
              • Valid-binary
              • Valid-unary
              • Valid-initdeclor
              • Valid-fundef
              • Valid-type-spec-list-residual
              • Valid-cond
              • Valid-lookup-ord
              • Valid-transunit-ensemble
              • Valid-declor
              • Valid-iconst
              • Valid-initer
              • Valid-c-char
              • Valid-stringlit-list
              • Valid-funcall
              • Valid-add-ord
              • Valid-arrsub
              • Valid-univ-char-name
              • Valid-extdecl
              • Valid-extdecl-list
              • Valid-cast
              • Valid-add-ord-file-scope
              • Valid-spec/qual
              • Valid-sizeof/alignof
              • Valid-memberp
                • Valid-decl-spec
                • Valid-var
                • Valid-param-declon
                • Valid-oct-escape
                • Valid-structdeclor
                • Valid-structdecl
                • Valid-designor
                • Valid-escape
                • Valid-enum-const
                • Valid-cconst
                • Valid-s-char
                • Valid-dec/oct/hex-const
                • Valid-const
                • Valid-gensel
                • Valid-decl-spec-list
                • Valid-lookup-ord-file-scope
                • Valid-member
                • Valid-param-declor
                • Valid-spec/qual-list
                • Valid-fconst
                • Valid-stringlit
                • Valid-s-char-list
                • Valid-c-char-list
                • Valid-block-item
                • Valid-structdeclor-list
                • Valid-simple-escape
                • Valid-align-spec
                • Valid-enumer
                • Valid-dirabsdeclor
                • Valid-decl
                • Valid-pop-scope
                • Valid-enumspec
                • Valid-declor-option
                • Valid-push-scope
                • Valid-initer-option
                • Valid-block-item-list
                • Valid-absdeclor
                • Valid-label
                • Valid-genassoc
                • Valid-tyname
                • Valid-strunispec
                • Valid-structdecl-list
                • Valid-genassoc-list
                • Valid-dirabsdeclor-option
                • Valid-designor-list
                • Valid-const-expr
                • Valid-initdeclor-list
                • Valid-desiniter-list
                • Valid-absdeclor-option
                • Valid-table-num-scopes
                • Valid-expr-list
                • Valid-param-declon-list
                • Valid-desiniter
                • Valid-const-expr-option
                • Valid-expr-option
                • Valid-statassert
                • Valid-enumer-list
                • Valid-init-table
                • Valid-empty-scope
                • Valid-member-designor
                • Valid-decl-list
              • Printer
              • Formalized-subset
              • Mapping-to-language-definition
              • Input-files
              • Defpred
              • Output-files
              • Abstract-syntax-operations
              • Validation-information
              • Implementation-environments
              • Concrete-syntax
              • Unambiguity
              • Ascii-identifiers
              • Preprocessing
              • Abstraction-mapping
            • Atc
            • 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
    • Validator

    Valid-memberp

    Validate a member pointer expression, given the type of the sub-expression.

    Signature
    (valid-memberp expr type-arg) → (mv erp type)
    Arguments
    expr — Guard (exprp expr).
    type-arg — Guard (typep type-arg).
    Returns
    type — Type (typep type).

    The type of the sub-expression is calculated (recursively) by valid-expr.

    The argument type must be a pointer to a structure or union type [C17:6.5.2.3/2]. We need to convert arrays to pointers, and then we just check that we have the (one) pointer type; we will refine this when we refine our type system. We do not conver functions to pointers, because that would result into a pointer to function, which is not a pointer to structure or union as required; thus, by leaving function types unchanged, we reject them here.

    Since we cannot yet look up members in structure and union types, we return the unknown type.

    Definitions and Theorems

    Function: valid-memberp

    (defun valid-memberp (expr type-arg)
     (declare (xargs :guard (and (exprp expr) (typep type-arg))))
     (declare (xargs :guard (expr-case expr :memberp)))
     (let ((__function__ 'valid-memberp))
      (declare (ignorable __function__))
      (b*
       (((reterr) (irr-type))
        ((when (type-case type-arg :unknown))
         (retok (type-unknown)))
        (type (type-apconvert type-arg))
        ((unless (type-case type :pointer))
         (reterr
          (msg
           "In the member pointer expression ~x0, ~
                          the sub-expression has type ~x1."
           (expr-fix expr)
           (type-fix type-arg)))))
       (retok (type-unknown)))))

    Theorem: typep-of-valid-memberp.type

    (defthm typep-of-valid-memberp.type
      (b* (((mv acl2::?erp ?type)
            (valid-memberp expr type-arg)))
        (typep type))
      :rule-classes :rewrite)

    Theorem: valid-memberp-of-expr-fix-expr

    (defthm valid-memberp-of-expr-fix-expr
      (equal (valid-memberp (expr-fix expr) type-arg)
             (valid-memberp expr type-arg)))

    Theorem: valid-memberp-expr-equiv-congruence-on-expr

    (defthm valid-memberp-expr-equiv-congruence-on-expr
      (implies (expr-equiv expr expr-equiv)
               (equal (valid-memberp expr type-arg)
                      (valid-memberp expr-equiv type-arg)))
      :rule-classes :congruence)

    Theorem: valid-memberp-of-type-fix-type-arg

    (defthm valid-memberp-of-type-fix-type-arg
      (equal (valid-memberp expr (type-fix type-arg))
             (valid-memberp expr type-arg)))

    Theorem: valid-memberp-type-equiv-congruence-on-type-arg

    (defthm valid-memberp-type-equiv-congruence-on-type-arg
      (implies (type-equiv type-arg type-arg-equiv)
               (equal (valid-memberp expr type-arg)
                      (valid-memberp expr type-arg-equiv)))
      :rule-classes :congruence)