• 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-extdecl

    Validate an external declaration.

    Signature
    (valid-extdecl edecl table ienv) 
      → 
    (mv erp new-edecl new-table)
    Arguments
    edecl — Guard (extdeclp edecl).
    table — Guard (valid-tablep table).
    ienv — Guard (ienvp ienv).
    Returns
    new-edecl — Type (extdeclp new-edecl).
    new-table — Type (valid-tablep new-table).

    For now we do not do anything with assembler statements. The empty external declaration is always valid. We check that declarations contain no return statements.

    Definitions and Theorems

    Function: valid-extdecl

    (defun valid-extdecl (edecl table ienv)
     (declare (xargs :guard (and (extdeclp edecl)
                                 (valid-tablep table)
                                 (ienvp ienv))))
     (declare (xargs :guard (extdecl-unambp edecl)))
     (let ((__function__ 'valid-extdecl))
      (declare (ignorable __function__))
      (b* (((reterr)
            (irr-extdecl)
            (irr-valid-table)))
       (extdecl-case
        edecl :fundef
        (b* (((erp new-fundef table)
              (valid-fundef edecl.unwrap table ienv)))
          (retok (extdecl-fundef new-fundef)
                 table))
        :decl
        (b*
         (((erp new-decl types table)
           (valid-decl edecl.unwrap table ienv))
          ((unless (emptyp types))
           (reterr
            (msg
             "The top-level declaration ~x0 ~
                                   contains return statements."
             edecl.unwrap))))
         (retok (extdecl-decl new-decl) table))
        :empty (retok (extdecl-empty)
                      (valid-table-fix table))
        :asm (retok (extdecl-fix edecl)
                    (valid-table-fix table))))))

    Theorem: extdeclp-of-valid-extdecl.new-edecl

    (defthm extdeclp-of-valid-extdecl.new-edecl
      (b* (((mv acl2::?erp ?new-edecl ?new-table)
            (valid-extdecl edecl table ienv)))
        (extdeclp new-edecl))
      :rule-classes :rewrite)

    Theorem: valid-tablep-of-valid-extdecl.new-table

    (defthm valid-tablep-of-valid-extdecl.new-table
      (b* (((mv acl2::?erp ?new-edecl ?new-table)
            (valid-extdecl edecl table ienv)))
        (valid-tablep new-table))
      :rule-classes :rewrite)

    Theorem: extdecl-unambp-of-valid-extdecl

    (defthm extdecl-unambp-of-valid-extdecl
      (implies (extdecl-unambp edecl)
               (b* (((mv acl2::?erp ?new-edecl ?new-table)
                     (valid-extdecl edecl table ienv)))
                 (implies (not erp)
                          (extdecl-unambp new-edecl)))))

    Theorem: valid-extdecl-of-extdecl-fix-edecl

    (defthm valid-extdecl-of-extdecl-fix-edecl
      (equal (valid-extdecl (extdecl-fix edecl)
                            table ienv)
             (valid-extdecl edecl table ienv)))

    Theorem: valid-extdecl-extdecl-equiv-congruence-on-edecl

    (defthm valid-extdecl-extdecl-equiv-congruence-on-edecl
      (implies (extdecl-equiv edecl edecl-equiv)
               (equal (valid-extdecl edecl table ienv)
                      (valid-extdecl edecl-equiv table ienv)))
      :rule-classes :congruence)

    Theorem: valid-extdecl-of-valid-table-fix-table

    (defthm valid-extdecl-of-valid-table-fix-table
      (equal (valid-extdecl edecl (valid-table-fix table)
                            ienv)
             (valid-extdecl edecl table ienv)))

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

    (defthm valid-extdecl-valid-table-equiv-congruence-on-table
      (implies (valid-table-equiv table table-equiv)
               (equal (valid-extdecl edecl table ienv)
                      (valid-extdecl edecl table-equiv ienv)))
      :rule-classes :congruence)

    Theorem: valid-extdecl-of-ienv-fix-ienv

    (defthm valid-extdecl-of-ienv-fix-ienv
      (equal (valid-extdecl edecl table (ienv-fix ienv))
             (valid-extdecl edecl table ienv)))

    Theorem: valid-extdecl-ienv-equiv-congruence-on-ienv

    (defthm valid-extdecl-ienv-equiv-congruence-on-ienv
      (implies (ienv-equiv ienv ienv-equiv)
               (equal (valid-extdecl edecl table ienv)
                      (valid-extdecl edecl table ienv-equiv)))
      :rule-classes :congruence)