• 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
            • Formalized-subset
            • Mapping-to-language-definition
            • Input-files
            • Compilation-database
            • Printer
            • Output-files
            • Abstract-syntax-operations
            • Implementation-environments
            • Abstract-syntax
            • Concrete-syntax
            • Disambiguation
            • Validation
              • Validator
                • Valid-exprs/decls/stmts
                • Valid-stmt
                • Valid-expr
                • Valid-dirdeclor
                • Valid-binary
                • Valid-type-spec
                • Valid-transunit
                • Valid-stor-spec-list
                • Valid-prototype-args
                • Valid-fundef
                • Valid-unary
                • Valid-init-declor
                • Valid-stringlit-list
                • Valid-type-spec-list-residual
                • Valid-transunit-ensemble
                • Valid-cond
                • Valid-lookup-ord
                • Valid-c-char
                • Valid-funcall
                • Valid-iconst
                • Valid-add-ord-objfuns-file-scope
                • Valid-initer
                • Valid-declor
                • Valid-add-ord
                • Valid-arrsub
                • Valid-update-ext
                • Valid-ext-declon-list
                • Valid-ext-declon
                • Valid-univ-char-name
                • Valid-memberp
                • Valid-add-ord-file-scope
                • Valid-var
                  • Valid-s-char
                  • Valid-decl-spec
                  • Valid-cconst
                  • Valid-cast
                  • Valid-sizeof/alignof
                  • Valid-stringlit
                  • Valid-spec/qual
                  • Valid-oct-escape
                  • Valid-get-fresh-uid
                  • Valid-param-declon
                  • Valid-struct-declon
                  • Valid-struct-declor
                  • Valid-has-internalp
                  • Valid-escape
                  • Valid-enum-const
                  • Valid-gensel
                  • Valid-const
                  • Valid-desiniter-list
                  • Valid-designor
                  • Valid-param-declor
                  • Valid-dec/oct/hex-const
                  • Valid-s-char-list
                  • Valid-decl-spec-list
                  • Valid-c-char-list
                  • Valid-member
                  • Valid-init-table
                  • Valid-lookup-ord-file-scope
                  • Valid-comp-stmt
                  • Valid-spec/qual-list
                  • Valid-lookup-ext
                  • Valid-designor-list
                  • Valid-fconst
                  • Valid-block-item
                  • Valid-struct-declor-list
                  • Valid-genassoc-list
                  • Valid-align-spec
                  • Valid-enumer
                  • Valid-declon
                  • Valid-simple-escape
                  • Valid-enum-spec
                  • Valid-dirabsdeclor
                  • Valid-declor-option
                  • Valid-pop-scope
                  • Valid-initer-option
                  • Valid-expr-list
                  • Valid-block-item-list
                  • Valid-absdeclor
                  • Valid-struct-declon-list
                  • Valid-push-scope
                  • Valid-label
                  • Valid-genassoc
                  • Valid-tyname
                  • Valid-struni-spec
                  • Valid-dirabsdeclor-option
                  • Valid-const-expr
                  • Valid-init-declor-list
                  • Valid-absdeclor-option
                  • Valid-param-declon-list
                  • Valid-desiniter
                  • Valid-const-expr-option
                  • Valid-table-num-scopes
                  • Valid-expr-option
                  • Valid-statassert
                  • Valid-enumer-list
                  • Valid-member-designor
                  • Valid-declon-list
                  • Valid-empty-scope
                • Validation-information
              • Gcc-builtins
              • Preprocessing
              • Parsing
            • Atc
            • Transformation-tools
            • Language
            • 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
    • Validator

    Valid-var

    Validate a variable.

    Signature
    (valid-var var table) → (mv erp type linkage uid)
    Arguments
    var — Guard (identp var).
    table — Guard (valid-tablep table).
    Returns
    erp — Type (maybe-msgp erp).
    type — Type (typep type).
    linkage — Type (linkagep linkage).
    uid — Type (uidp uid).

    This is used to validate the :ident case of the expr fixtype. This is the case of a variable, not an enumeration constant, which is part of the :const case of expr. Recall that the parser initially parses all identifiers used as expressions under the :ident case, but the disambiguator re-classifies some of them under the :const case, as appropriate.

    A variable (i.e. identifier) is valid if it is found in the validation table, recorded as denoting an object or function [C17:6.5.1/2]. The type and the linkage are obtained from the table.

    Definitions and Theorems

    Function: valid-var

    (defun valid-var (var table)
     (declare (xargs :guard (and (identp var)
                                 (valid-tablep table))))
     (b*
      (((reterr)
        (irr-type)
        (irr-linkage)
        (irr-uid))
       ((mv info &)
        (valid-lookup-ord var table))
       ((unless info)
        (retmsg$ "The variable ~x0 is not in scope."
                 (ident-fix var)))
       ((unless (valid-ord-info-case info :objfun))
        (retmsg$
         "The identifier ~x0, used as a variable,is in scope, ~
                      but does not denote an object or function."
         (ident-fix var))))
      (retok (valid-ord-info-objfun->type info)
             (valid-ord-info-objfun->linkage info)
             (valid-ord-info-objfun->uid info))))

    Theorem: maybe-msgp-of-valid-var.erp

    (defthm maybe-msgp-of-valid-var.erp
      (b* (((mv acl2::?erp ?type ?linkage ?uid)
            (valid-var var table)))
        (maybe-msgp erp))
      :rule-classes :rewrite)

    Theorem: typep-of-valid-var.type

    (defthm typep-of-valid-var.type
      (b* (((mv acl2::?erp ?type ?linkage ?uid)
            (valid-var var table)))
        (typep type))
      :rule-classes :rewrite)

    Theorem: linkagep-of-valid-var.linkage

    (defthm linkagep-of-valid-var.linkage
      (b* (((mv acl2::?erp ?type ?linkage ?uid)
            (valid-var var table)))
        (linkagep linkage))
      :rule-classes :rewrite)

    Theorem: uidp-of-valid-var.uid

    (defthm uidp-of-valid-var.uid
      (b* (((mv acl2::?erp ?type ?linkage ?uid)
            (valid-var var table)))
        (uidp uid))
      :rule-classes :rewrite)

    Theorem: valid-var-of-ident-fix-var

    (defthm valid-var-of-ident-fix-var
      (equal (valid-var (ident-fix var) table)
             (valid-var var table)))

    Theorem: valid-var-ident-equiv-congruence-on-var

    (defthm valid-var-ident-equiv-congruence-on-var
      (implies (ident-equiv var var-equiv)
               (equal (valid-var var table)
                      (valid-var var-equiv table)))
      :rule-classes :congruence)

    Theorem: valid-var-of-valid-table-fix-table

    (defthm valid-var-of-valid-table-fix-table
      (equal (valid-var var (valid-table-fix table))
             (valid-var var table)))

    Theorem: valid-var-valid-table-equiv-congruence-on-table

    (defthm valid-var-valid-table-equiv-congruence-on-table
      (implies (valid-table-equiv table table-equiv)
               (equal (valid-var var table)
                      (valid-var var table-equiv)))
      :rule-classes :congruence)