• 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
          • Atc
          • Transformation-tools
            • Simpadd0
            • Proof-generation
            • Split-gso
            • Wrap-fn
              • Wrap-fn-implementation
                • Init-declor-list-wrap-fn-add-wrapper-def
                • Declor-wrap-fn-add-wrapper-def
                  • Ext-declon-wrap-fn-add-wrapper-def
                  • Fundef-wrap-fn-add-wrapper-def
                  • Declon-wrap-fn-add-wrapper-def
                  • Ext-declon-list-wrap-fn
                  • Wrap-fn-process-param-declon-list-loop
                  • Filepath-transunit-map-wrap-fn
                  • Wrap-fn-process-param-declon-list
                  • Transunit-wrap-fn
                  • Transunit-ensemble-wrap-fn
                  • Code-ensemble-wrap-fn
                  • Code-ensemble-wrap-fn-multiple
                  • Declor-wrap-fn-make-wrapper
                  • Dirdeclor-wrap-fn-make-wrapper
                  • Wrap-fn-input-processing
                  • Wrap-fn-event-generation
              • Constant-propagation
              • Specialize
              • Split-fn
              • Split-fn-when
              • Split-all-gso
              • Copy-fn
              • Variables-in-computation-states
              • Rename
              • Utilities
              • Proof-generation-theorems
              • Input-processing
            • 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
    • Wrap-fn-implementation

    Declor-wrap-fn-add-wrapper-def

    Check if a declarator matches the target, and create the function wrapper if so.

    Signature
    (declor-wrap-fn-add-wrapper-def declor target-name 
                                    wrapper-name? blacklist specs) 
     
      → 
    (mv er? foundp wrapper? wrapper-name?$)
    Arguments
    declor — Guard (declorp declor).
    target-name — Guard (identp target-name).
    wrapper-name? — Guard (ident-optionp wrapper-name?).
    blacklist — Guard (ident-setp blacklist).
    specs — Guard (decl-spec-listp specs).
    Returns
    er? — Type (maybe-msgp er?).
    foundp — Type (booleanp foundp).
    wrapper? — Type (fundef-optionp wrapper?).
    wrapper-name?$ — Type (ident-optionp wrapper-name?$).

    If the foundp return value is t but wrapper? is nil, that means the declarator matched the target, but some aspect of it is unsupported by the current implementation.

    Definitions and Theorems

    Function: declor-wrap-fn-add-wrapper-def

    (defun declor-wrap-fn-add-wrapper-def
           (declor target-name
                   wrapper-name? blacklist specs)
     (declare (xargs :guard (and (declorp declor)
                                 (identp target-name)
                                 (ident-optionp wrapper-name?)
                                 (ident-setp blacklist)
                                 (decl-spec-listp specs))))
     (b*
      (((reterr) nil nil nil)
       ((unless (c$::ident-equiv (declor->ident declor)
                                 target-name))
        (retok nil nil nil))
       (wrapper-base-name
        (or
          wrapper-name?
          (ident
               (concatenate
                    'string
                    "wrapper_"
                    (let ((target-name-str (ident->unwrap target-name)))
                      (if (stringp target-name-str)
                          target-name-str
                        ""))))))
       (wrapper-name (fresh-ident wrapper-base-name blacklist))
       (arg-base-name (ident "arg"))
       ((mv - found-paramsp can-create-wrapperp
            wrapper-declor idents)
        (declor-wrap-fn-make-wrapper
             declor
             wrapper-name arg-base-name blacklist))
       ((unless found-paramsp)
        (retok nil nil nil))
       ((unless can-create-wrapperp)
        (retok t nil nil))
       (wrapper-body
        (make-comp-stmt
         :items
         (list
          (make-block-item-stmt
           :stmt
           (make-stmt-return
                :expr?
                (make-expr-funcall
                     :fun (make-expr-ident :ident target-name)
                     :args (c$::ident-list-map-expr-ident idents))))))))
      (retok
           t
           (make-fundef :specs (c$::declor-spec-list-make-static specs)
                        :declor wrapper-declor
                        :body wrapper-body
                        :info nil)
           wrapper-name)))

    Theorem: maybe-msgp-of-declor-wrap-fn-add-wrapper-def.er?

    (defthm maybe-msgp-of-declor-wrap-fn-add-wrapper-def.er?
     (b*
      (((mv ?er? ?foundp ?wrapper? ?wrapper-name?$)
        (declor-wrap-fn-add-wrapper-def declor target-name
                                        wrapper-name? blacklist specs)))
      (maybe-msgp er?))
     :rule-classes :rewrite)

    Theorem: booleanp-of-declor-wrap-fn-add-wrapper-def.foundp

    (defthm booleanp-of-declor-wrap-fn-add-wrapper-def.foundp
     (b*
      (((mv ?er? ?foundp ?wrapper? ?wrapper-name?$)
        (declor-wrap-fn-add-wrapper-def declor target-name
                                        wrapper-name? blacklist specs)))
      (booleanp foundp))
     :rule-classes :type-prescription)

    Theorem: fundef-optionp-of-declor-wrap-fn-add-wrapper-def.wrapper?

    (defthm fundef-optionp-of-declor-wrap-fn-add-wrapper-def.wrapper?
     (b*
      (((mv ?er? ?foundp ?wrapper? ?wrapper-name?$)
        (declor-wrap-fn-add-wrapper-def declor target-name
                                        wrapper-name? blacklist specs)))
      (fundef-optionp wrapper?))
     :rule-classes :rewrite)

    Theorem: ident-optionp-of-declor-wrap-fn-add-wrapper-def.wrapper-name?$

    (defthm
         ident-optionp-of-declor-wrap-fn-add-wrapper-def.wrapper-name?$
     (b*
      (((mv ?er? ?foundp ?wrapper? ?wrapper-name?$)
        (declor-wrap-fn-add-wrapper-def declor target-name
                                        wrapper-name? blacklist specs)))
      (ident-optionp wrapper-name?$))
     :rule-classes :rewrite)

    Theorem: fundefp-of-declor-wrap-fn-add-wrapper-def.wrapper?-under-iff

    (defthm fundefp-of-declor-wrap-fn-add-wrapper-def.wrapper?-under-iff
     (b*
      (((mv ?er? ?foundp ?wrapper? ?wrapper-name?$)
        (declor-wrap-fn-add-wrapper-def declor target-name
                                        wrapper-name? blacklist specs)))
      (iff (fundefp wrapper?) wrapper?)))

    Theorem: identp-of-declor-wrap-fn-add-wrapper-def.wrapper-name?$

    (defthm identp-of-declor-wrap-fn-add-wrapper-def.wrapper-name?$
     (b*
      (((mv ?er? ?foundp ?wrapper? ?wrapper-name?$)
        (declor-wrap-fn-add-wrapper-def declor target-name
                                        wrapper-name? blacklist specs)))
      (equal (identp wrapper-name?$)
             (fundefp wrapper?))))

    Theorem: declor-wrap-fn-add-wrapper-def-of-declor-fix-declor

    (defthm declor-wrap-fn-add-wrapper-def-of-declor-fix-declor
     (equal
        (declor-wrap-fn-add-wrapper-def (declor-fix declor)
                                        target-name
                                        wrapper-name? blacklist specs)
        (declor-wrap-fn-add-wrapper-def declor target-name
                                        wrapper-name? blacklist specs)))

    Theorem: declor-wrap-fn-add-wrapper-def-declor-equiv-congruence-on-declor

    (defthm
       declor-wrap-fn-add-wrapper-def-declor-equiv-congruence-on-declor
     (implies
      (c$::declor-equiv declor declor-equiv)
      (equal
        (declor-wrap-fn-add-wrapper-def declor target-name
                                        wrapper-name? blacklist specs)
        (declor-wrap-fn-add-wrapper-def declor-equiv target-name
                                        wrapper-name? blacklist specs)))
     :rule-classes :congruence)

    Theorem: declor-wrap-fn-add-wrapper-def-of-ident-fix-target-name

    (defthm declor-wrap-fn-add-wrapper-def-of-ident-fix-target-name
     (equal
        (declor-wrap-fn-add-wrapper-def declor (ident-fix target-name)
                                        wrapper-name? blacklist specs)
        (declor-wrap-fn-add-wrapper-def declor target-name
                                        wrapper-name? blacklist specs)))

    Theorem: declor-wrap-fn-add-wrapper-def-ident-equiv-congruence-on-target-name

    (defthm
     declor-wrap-fn-add-wrapper-def-ident-equiv-congruence-on-target-name
     (implies
      (c$::ident-equiv target-name target-name-equiv)
      (equal
        (declor-wrap-fn-add-wrapper-def declor target-name
                                        wrapper-name? blacklist specs)
        (declor-wrap-fn-add-wrapper-def declor target-name-equiv
                                        wrapper-name? blacklist specs)))
     :rule-classes :congruence)

    Theorem: declor-wrap-fn-add-wrapper-def-of-ident-option-fix-wrapper-name?

    (defthm
       declor-wrap-fn-add-wrapper-def-of-ident-option-fix-wrapper-name?
     (equal
        (declor-wrap-fn-add-wrapper-def declor target-name
                                        (ident-option-fix wrapper-name?)
                                        blacklist specs)
        (declor-wrap-fn-add-wrapper-def declor target-name
                                        wrapper-name? blacklist specs)))

    Theorem: declor-wrap-fn-add-wrapper-def-ident-option-equiv-congruence-on-wrapper-name?

    (defthm
     declor-wrap-fn-add-wrapper-def-ident-option-equiv-congruence-on-wrapper-name?
     (implies
      (c$::ident-option-equiv wrapper-name? wrapper-name?-equiv)
      (equal
          (declor-wrap-fn-add-wrapper-def declor target-name
                                          wrapper-name? blacklist specs)
          (declor-wrap-fn-add-wrapper-def
               declor target-name
               wrapper-name?-equiv blacklist specs)))
     :rule-classes :congruence)

    Theorem: declor-wrap-fn-add-wrapper-def-of-ident-set-fix-blacklist

    (defthm declor-wrap-fn-add-wrapper-def-of-ident-set-fix-blacklist
     (equal
        (declor-wrap-fn-add-wrapper-def
             declor target-name
             wrapper-name? (ident-set-fix blacklist)
             specs)
        (declor-wrap-fn-add-wrapper-def declor target-name
                                        wrapper-name? blacklist specs)))

    Theorem: declor-wrap-fn-add-wrapper-def-ident-set-equiv-congruence-on-blacklist

    (defthm
     declor-wrap-fn-add-wrapper-def-ident-set-equiv-congruence-on-blacklist
     (implies
      (c$::ident-set-equiv blacklist blacklist-equiv)
      (equal
          (declor-wrap-fn-add-wrapper-def declor target-name
                                          wrapper-name? blacklist specs)
          (declor-wrap-fn-add-wrapper-def
               declor target-name
               wrapper-name? blacklist-equiv specs)))
     :rule-classes :congruence)

    Theorem: declor-wrap-fn-add-wrapper-def-of-decl-spec-list-fix-specs

    (defthm declor-wrap-fn-add-wrapper-def-of-decl-spec-list-fix-specs
     (equal
        (declor-wrap-fn-add-wrapper-def
             declor target-name wrapper-name?
             blacklist (decl-spec-list-fix specs))
        (declor-wrap-fn-add-wrapper-def declor target-name
                                        wrapper-name? blacklist specs)))

    Theorem: declor-wrap-fn-add-wrapper-def-decl-spec-list-equiv-congruence-on-specs

    (defthm
     declor-wrap-fn-add-wrapper-def-decl-spec-list-equiv-congruence-on-specs
     (implies
      (c$::decl-spec-list-equiv specs specs-equiv)
      (equal
          (declor-wrap-fn-add-wrapper-def declor target-name
                                          wrapper-name? blacklist specs)
          (declor-wrap-fn-add-wrapper-def
               declor target-name
               wrapper-name? blacklist specs-equiv)))
     :rule-classes :congruence)