• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • 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
        • Farray
        • Rp-rewriter
        • Instant-runoff-voting
        • Imp-language
        • Sidekick
        • Leftist-trees
        • Java
        • Taspi
        • Bitcoin
        • Riscv
        • Des
        • Ethereum
        • X86isa
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Split-fn

    Split-fn-fundef

    Transform a function definition, splitting it if matches the target identifier, or else leaving it untouched.

    Signature
    (split-fn-fundef target-fn new-fn-name fundef split-point) 
      → 
    (mv er fundef1 fundef2)
    Arguments
    target-fn — Guard (identp target-fn).
    new-fn-name — Guard (identp new-fn-name).
    fundef — Guard (fundefp fundef).
    split-point — Guard (natp split-point).
    Returns
    fundef1 — Type (fundefp fundef1).
    fundef2 — Type (fundef-optionp fundef2).

    Definitions and Theorems

    Function: split-fn-fundef

    (defun split-fn-fundef (target-fn new-fn-name fundef split-point)
     (declare (xargs :guard (and (identp target-fn)
                                 (identp new-fn-name)
                                 (fundefp fundef)
                                 (natp split-point))))
     (let ((__function__ 'split-fn-fundef))
      (declare (ignorable __function__))
      (b* (((reterr) (irr-fundef) nil)
           ((fundef fundef) fundef)
           ((declor fundef.declor) fundef.declor))
       (stmt-case
        fundef.body
        :compound
        (dirdeclor-case
         fundef.declor.direct :function-params
         (b*
          (((unless
             (equal target-fn
                    (c$::dirdeclor->ident fundef.declor.direct.declor)))
            (retok (fundef-fix fundef) nil))
           ((erp new-fn truncated-items)
            (split-fn-block-item-list new-fn-name fundef.body.items
                                      fundef.spec fundef.declor.pointers
                                      (param-declon-list-to-ident-paramdeclon-map
                                           fundef.declor.direct.params)
                                      split-point)))
          (retok new-fn
                 (make-fundef :extension fundef.extension
                              :spec fundef.spec
                              :declor fundef.declor
                              :decls fundef.decls
                              :body (stmt-compound truncated-items))))
         :otherwise (retok (fundef-fix fundef) nil))
        :otherwise (retok (fundef-fix fundef) nil)))))

    Theorem: fundefp-of-split-fn-fundef.fundef1

    (defthm fundefp-of-split-fn-fundef.fundef1
      (b* (((mv acl2::?er ?fundef1 ?fundef2)
            (split-fn-fundef target-fn
                             new-fn-name fundef split-point)))
        (fundefp fundef1))
      :rule-classes :rewrite)

    Theorem: fundef-optionp-of-split-fn-fundef.fundef2

    (defthm fundef-optionp-of-split-fn-fundef.fundef2
      (b* (((mv acl2::?er ?fundef1 ?fundef2)
            (split-fn-fundef target-fn
                             new-fn-name fundef split-point)))
        (fundef-optionp fundef2))
      :rule-classes :rewrite)