• 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-add-ord

    Add an ordinary identifier to the validation table.

    Signature
    (valid-add-ord ident info table) → new-table
    Arguments
    ident — Guard (identp ident).
    info — Guard (valid-ord-infop info).
    table — Guard (valid-tablep table).
    Returns
    new-table — Type (valid-tablep new-table).

    We pass the information to associate to the identifier.

    The identifier is always added to the first (i.e. innermost, i.e. current) scope. We check the existence of at least one scope; recall that there must be always a file scope.

    If the identifier is already present in the current scope, its information is overwritten, but we only call this function after checking that this overwriting is acceptable, i.e. when it ``refines'' the validation information for the identifier. We could consider adding a guard to this function that characterizes the acceptable overwriting.

    If info indicates external linkage, we update the externals map. See valid-update-ext.

    Definitions and Theorems

    Function: valid-add-ord

    (defun valid-add-ord (ident info table)
     (declare (xargs :guard (and (identp ident)
                                 (valid-ord-infop info)
                                 (valid-tablep table))))
     (let ((__function__ 'valid-add-ord))
      (declare (ignorable __function__))
      (b*
       (((valid-table table) table)
        ((unless (> (valid-table-num-scopes table) 0))
         (raise "Internal error: no scopes in validation table.")
         (valid-table-fix table))
        (scope (car table.scopes))
        (ord-scope (valid-scope->ord scope))
        (new-ord-scope (acons (ident-fix ident)
                              (valid-ord-info-fix info)
                              ord-scope))
        (new-scope (change-valid-scope scope
                                       :ord new-ord-scope))
        (new-scopes (cons new-scope (cdr table.scopes)))
        (table (change-valid-table table
                                   :scopes new-scopes)
    )
        (table
         (valid-ord-info-case
          info
          :objfun
          (linkage-case
             info.linkage
             :external (valid-update-ext ident info.type info.uid table)
             :otherwise table)
          :otherwise table)
    ))
       table)))

    Theorem: valid-tablep-of-valid-add-ord

    (defthm valid-tablep-of-valid-add-ord
      (b* ((new-table (valid-add-ord ident info table)))
        (valid-tablep new-table))
      :rule-classes :rewrite)

    Theorem: valid-add-ord-of-ident-fix-ident

    (defthm valid-add-ord-of-ident-fix-ident
      (equal (valid-add-ord (ident-fix ident)
                            info table)
             (valid-add-ord ident info table)))

    Theorem: valid-add-ord-ident-equiv-congruence-on-ident

    (defthm valid-add-ord-ident-equiv-congruence-on-ident
      (implies (ident-equiv ident ident-equiv)
               (equal (valid-add-ord ident info table)
                      (valid-add-ord ident-equiv info table)))
      :rule-classes :congruence)

    Theorem: valid-add-ord-of-valid-ord-info-fix-info

    (defthm valid-add-ord-of-valid-ord-info-fix-info
      (equal (valid-add-ord ident (valid-ord-info-fix info)
                            table)
             (valid-add-ord ident info table)))

    Theorem: valid-add-ord-valid-ord-info-equiv-congruence-on-info

    (defthm valid-add-ord-valid-ord-info-equiv-congruence-on-info
      (implies (valid-ord-info-equiv info info-equiv)
               (equal (valid-add-ord ident info table)
                      (valid-add-ord ident info-equiv table)))
      :rule-classes :congruence)

    Theorem: valid-add-ord-of-valid-table-fix-table

    (defthm valid-add-ord-of-valid-table-fix-table
      (equal (valid-add-ord ident info (valid-table-fix table))
             (valid-add-ord ident info table)))

    Theorem: valid-add-ord-valid-table-equiv-congruence-on-table

    (defthm valid-add-ord-valid-table-equiv-congruence-on-table
      (implies (valid-table-equiv table table-equiv)
               (equal (valid-add-ord ident info table)
                      (valid-add-ord ident info table-equiv)))
      :rule-classes :congruence)