• 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
          • Atc
          • Language
          • Representation
          • Transformation-tools
            • Simpadd0
            • Deftrans
            • Splitgso
            • Constant-propagation
            • Split-fn
              • Abstract-fn
                • Split-fn-block-item-list
                • Decl-to-ident-paramdeclon-map
                • Split-fn-fundef
                • Split-fn-extdecl
                • Split-fn-filepath-transunit-map
                • Split-fn-extdecl-list
                • Param-declon-to-ident-paramdeclon-map
                • Split-fn-transunit-ensemble
                • Split-fn-transunit
                • Param-declon-list-to-ident-paramdeclon-map
                • Ident-paramdeclon-map-filter
                • Decl-to-ident-paramdeclon-map0
                • Decl-list-to-ident-paramdeclon-map
                • Expr-ident-list
                • Ident-paramdeclon-map
              • Copy-fn
              • Specialize
              • Split-all-gso
              • Rename
              • Utilities
            • 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
    • Split-fn

    Abstract-fn

    Create a new function from the block items following the split-fn split point.

    Signature
    (abstract-fn new-fn-name spec pointers items decls) 
      → 
    (mv er idents new-fn)
    Arguments
    new-fn-name — Guard (identp new-fn-name).
    spec — Guard (decl-spec-listp spec).
    pointers — Guard (typequal/attribspec-list-listp pointers).
    items — Guard (block-item-listp items).
    decls — Guard (ident-paramdeclon-mapp decls).
    Returns
    idents — The identifiers appearing in argument decls corresponding to the function parameters (in the same order).
        Type (ident-listp idents).
    new-fn — The new function definition.
        Type (fundefp new-fn).

    The new function will be created with same return type as the original.

    Arguments to the function are determined by taking the variable declarations of the original function which appear free in the block items, which will constitute the body of the new function. (Note that arguments are not currently taken by reference, but this may be necessary for general equivalence. It may be sufficient to take an argument by reference when its address is taken in an expression of the new function body.)

    Definitions and Theorems

    Function: ident-paramdeclon-map-filter

    (defun ident-paramdeclon-map-filter (map idents)
     (declare (xargs :guard (and (ident-paramdeclon-mapp map)
                                 (ident-setp idents))))
     (let ((__function__ 'ident-paramdeclon-map-filter))
      (declare (ignorable __function__))
      (b* ((map (ident-paramdeclon-map-fix map))
           ((when (omap::emptyp map)) nil)
           ((mv key val) (omap::head map)))
        (if (in key idents)
            (omap::update key val
                          (ident-paramdeclon-map-filter (omap::tail map)
                                                        idents))
          (ident-paramdeclon-map-filter (omap::tail map)
                                        idents)))))

    Theorem: ident-paramdeclon-mapp-of-ident-paramdeclon-map-filter

    (defthm ident-paramdeclon-mapp-of-ident-paramdeclon-map-filter
      (b* ((new-map (ident-paramdeclon-map-filter map idents)))
        (ident-paramdeclon-mapp new-map))
      :rule-classes :rewrite)

    Function: abstract-fn

    (defun abstract-fn (new-fn-name spec pointers items decls)
     (declare
          (xargs :guard (and (identp new-fn-name)
                             (decl-spec-listp spec)
                             (typequal/attribspec-list-listp pointers)
                             (block-item-listp items)
                             (ident-paramdeclon-mapp decls))))
     (let ((__function__ 'abstract-fn))
      (declare (ignorable __function__))
      (b* (((reterr) nil (irr-fundef))
           ((mv idents -)
            (free-vars-block-item-list items nil))
           (decls (ident-paramdeclon-map-filter decls idents))
           (idents (omap::keys decls))
           (params (strip-cdrs decls)))
       (retok
        idents
        (make-fundef
         :spec spec
         :declor
         (make-declor :pointers pointers
                      :direct (make-dirdeclor-function-params
                                   :declor (dirdeclor-ident new-fn-name)
                                   :params params))
         :body (stmt-compound items))))))

    Theorem: ident-listp-of-abstract-fn.idents

    (defthm ident-listp-of-abstract-fn.idents
      (b* (((mv acl2::?er ?idents ?new-fn)
            (abstract-fn new-fn-name spec pointers items decls)))
        (ident-listp idents))
      :rule-classes :rewrite)

    Theorem: fundefp-of-abstract-fn.new-fn

    (defthm fundefp-of-abstract-fn.new-fn
      (b* (((mv acl2::?er ?idents ?new-fn)
            (abstract-fn new-fn-name spec pointers items decls)))
        (fundefp new-fn))
      :rule-classes :rewrite)