• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
          • Simplify-defun
          • Isodata
          • Tailrec
          • Schemalg
          • Restrict
          • Expdata
            • Expdata-implementation
              • Expdata-event-generation
                • Expdata-gen-everything
                • Expdata-gen-thm-instances-to-terms-back
                • Expdata-gen-new-fn-body-nonpred
                • Expdata-gen-new-fn
                  • Expdata-gen-new-fn-verify-guards
                  • Expdata-gen-new-fn-verify-guards-hints-nonpred-rec-1res/mres
                  • Expdata-gen-back-of-forth-instances-to-terms-back
                  • Expdata-gen-new-fn-verify-guards-hints-nonpred-nonrec-1res/mres
                  • Expdata-gen-forth-image-instances-to-terms-back
                  • Expdata-gen-forth-guard-instances-to-terms-back
                  • Expdata-gen-new-to-old-thm-hints-rec-1res
                  • Expdata-gen-defsurj
                  • Expdata-gen-new-to-old-thm-hints-rec-mres
                  • Expdata-gen-lemma-instances-var-to-new-forth-rec-call-args-back
                  • Expdata-gen-new-fn-verify-guards-hints-pred-rec
                  • Expdata-gen-lemma-instances-x1...xn-to-forth-rec-call-args-back
                  • Expdata-gen-thm-instances-to-x1...xn
                  • Expdata-gen-newp-of-new-thm-hints
                  • Expdata-gen-all-back-guard-instances-to-mv-nth
                  • Expdata-gen-result-vars
                  • Expdata-gen-lemma-instances-x1...xn-to-rec-call-args-back
                  • Expdata-gen-new-to-old-thm-hints-rec-0res
                  • Expdata-gen-new-fn-verify-guards-hints-nonpred-rec-0res
                  • Expdata-gen-newp-of-new-thm
                  • Expdata-gen-new-to-old-thm
                  • Expdata-gen-lemma-instances-var-to-rec-calls-back
                  • Expdata-gen-new-fn-body-pred
                  • Expdata-gen-old-to-new-thm-hints-1res
                  • Expdata-gen-new-fn-verify-guards-hints-nonpred
                  • Expdata-gen-new-fn-verify-guards-hints
                  • Expdata-gen-all-back-of-forth-instances-to-terms-back
                  • Expdata-gen-old-to-new-thm
                  • Expdata-gen-new-to-old-thm-hints
                  • Expdata-gen-new-fn-verify-guards-hints-pred-nonrec
                  • Expdata-gen-all-forth-image-instances-to-terms-back
                  • Expdata-gen-all-forth-guard-instances-to-terms-back
                  • Expdata-gen-old-to-new-thm-hints-mres
                  • Expdata-gen-appconds
                  • Expdata-xform-rec-calls
                  • Expdata-gen-back-of-forth-instances-to-mv-nth
                  • Expdata-gen-lemma-instance-x1...xn-to-forth-of-x1...xn
                  • Expdata-gen-forth-image-instances-to-mv-nth
                  • Expdata-gen-forth-guard-instances-to-mv-nth
                  • Expdata-gen-back-guard-instances-to-mv-nth
                  • Expdata-gen-all-back-of-forth-instances-to-mv-nth
                  • Expdata-gen-old-to-new-thm-formula
                  • Expdata-gen-newp-guard-instances-to-x1...xn
                  • Expdata-gen-new-to-old-thm-formula
                  • Expdata-gen-new-fn-verify-guards-hints-nonpred-nonrec-0res
                  • Expdata-gen-lemma-instance-x1...xn-to-back-of-x1...xn
                  • Expdata-gen-forth-image-instances-to-x1...xn
                  • Expdata-gen-forth-image-instances-to-terms-back-aux
                  • Expdata-gen-forth-guard-instances-to-x1...xn
                  • Expdata-gen-forth-guard-instances-to-terms-back-aux
                  • Expdata-gen-back-of-forth-instances-to-x1...xn
                  • Expdata-gen-back-of-forth-instances-to-terms-back-aux
                  • Expdata-gen-back-image-instances-to-x1...xn
                  • Expdata-gen-back-guard-instances-to-x1...xn
                  • Expdata-gen-newp-of-new-thm-formula
                  • Expdata-gen-fn-of-terms
                  • Expdata-gen-oldp-of-rec-call-args-under-contexts
                  • Expdata-gen-new-fn-termination-hints
                  • Expdata-gen-old-to-new-thm-hints
                  • Expdata-gen-lemma-instance-x1...xn-to-fn-of-x1...xn
                  • Expdata-gen-old-to-new-thm-hints-0res
                  • Expdata-gen-new-fn-verify-guards-hints-pred
                  • Expdata-gen-new-to-old-thm-hints-nonrec
                  • Expdata-gen-subst-x1...xn-with-back-of-x1...xn
                  • Expdata-gen-oldp-of-terms
                  • Expdata-gen-newp-of-terms
                  • Expdata-gen-new-fn-body
                  • Expdata-gen-forth-of-terms
                  • Expdata-gen-defsurjs
                  • Expdata-gen-back-of-terms
                  • Expdata-gen-new-fn-guard
                  • Expdata-gen-result-vars-aux
                  • Expdata-gen-new-fn-measure
                  • Expdata-formal-of-newp
                  • Expdata-formal-of-forth
                  • Expdata-formal-of-back
                  • Expdata-formal-of-unary
                • Expdata-fn
                • Expdata-input-processing
                • Expdata-macro-definition
            • Casesplit
            • Simplify-term
            • Simplify-defun-sk
            • Parteval
            • Solve
            • Wrap-output
            • Propagate-iso
            • Simplify
            • Finite-difference
            • Drop-irrelevant-params
            • Copy-function
            • Lift-iso
            • Rename-params
            • Utilities
            • Simplify-term-programmatic
            • Simplify-defun-sk-programmatic
            • Simplify-defun-programmatic
            • Simplify-defun+
            • Common-options
            • Common-concepts
          • Error-checking
          • Fty-extensions
          • Isar
          • Kestrel-utilities
          • Set
          • Soft
          • C
          • 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
    • Expdata-event-generation

    Expdata-gen-new-fn

    Generate the new function definition.

    Signature
    (expdata-gen-new-fn old$ 
                        arg-surjmaps res-surjmaps predicate$ 
                        new$ new-enable$ verify-guards$ 
                        untranslate$ appcond-thm-names wrld) 
     
      → 
    (mv new-fn-local-event new-fn-exported-event)
    Arguments
    old$ — Guard (symbolp old$).
    arg-surjmaps — Guard (expdata-symbol-surjmap-alistp arg-surjmaps).
    res-surjmaps — Guard (expdata-pos-surjmap-alistp res-surjmaps).
    predicate$ — Guard (booleanp predicate$).
    new$ — Guard (symbolp new$).
    new-enable$ — Guard (booleanp new-enable$).
    verify-guards$ — Guard (booleanp verify-guards$).
    untranslate$ — Guard (untranslate-specifier-p untranslate$).
    appcond-thm-names — Guard (symbol-symbol-alistp appcond-thm-names).
    wrld — Guard (plist-worldp wrld).
    Returns
    new-fn-local-event — A pseudo-event-formp.
    new-fn-exported-event — A pseudo-event-formp.

    The macro used to introduce the new function is determined by whether the new function must be enabled or not, and non-executable or not. We make it non-executable if and only if old is non-executable.

    The new function has the same formal arguments as the old function.

    If the new function is recursive, its well-founded relation is the same as the old function's. The new function uses all ruler extenders, in case the old function's termination depends on any ruler extender.

    Guard verification is deferred; see expdata-gen-new-fn-verify-guards.

    If the old function returns a multi-value result, we adjust the body of the new function to do the same.

    Definitions and Theorems

    Function: expdata-gen-new-fn

    (defun expdata-gen-new-fn (old$ arg-surjmaps res-surjmaps predicate$
                                    new$ new-enable$ verify-guards$
                                    untranslate$ appcond-thm-names wrld)
     (declare
         (xargs :guard (and (symbolp old$)
                            (expdata-symbol-surjmap-alistp arg-surjmaps)
                            (expdata-pos-surjmap-alistp res-surjmaps)
                            (booleanp predicate$)
                            (symbolp new$)
                            (booleanp new-enable$)
                            (booleanp verify-guards$)
                            (untranslate-specifier-p untranslate$)
                            (symbol-symbol-alistp appcond-thm-names)
                            (plist-worldp wrld))))
     (let ((__function__ 'expdata-gen-new-fn))
      (declare (ignorable __function__))
      (b*
       ((macro (function-intro-macro new-enable$
                                     (non-executablep old$ wrld)))
        (formals (formals old$ wrld))
        (body
            (expdata-gen-new-fn-body old$ arg-surjmaps
                                     res-surjmaps predicate$ new$ wrld))
        (body (if (> (number-of-results old$ wrld) 1)
                  (mvify body)
                body))
        (body (case untranslate$
                (:nice (directed-untranslate (ibody old$ wrld)
                                             (ubody old$ wrld)
                                             body nil nil wrld))
                (:nice-expanded
                     (directed-untranslate-no-lets (ibody old$ wrld)
                                                   (ubody old$ wrld)
                                                   body nil nil wrld))
                ((nil) body)
                (t (untranslate body nil wrld))))
        (guard
           (expdata-gen-new-fn-guard old$ arg-surjmaps predicate$ wrld))
        (guard (conjoin (flatten-ands-in-lit guard)))
        (guard (untranslate guard nil wrld))
        (recursive (recursivep old$ nil wrld))
        (wfrel? (if recursive (well-founded-relation old$ wrld)
                  nil))
        (measure?
             (if recursive
                 (expdata-gen-new-fn-measure old$ arg-surjmaps wrld)
               nil))
        (termination-hints?
          (if recursive
           (expdata-gen-new-fn-termination-hints appcond-thm-names
                                                 old$ arg-surjmaps wrld)
           nil))
        (local-event
         (cons
          'local
          (cons
           (cons
            macro
            (cons
             new$
             (cons
              formals
              (cons
               (cons
                'declare
                (cons
                 (cons
                     'xargs
                     (append (and recursive
                                  (list :well-founded-relation wfrel?
                                        :measure measure?
                                        :hints termination-hints?
                                        :ruler-extenders :all))
                             (cons ':guard
                                   (cons guard '(:verify-guards nil)))))
                 'nil))
               (cons body 'nil)))))
           'nil)))
        (exported-event
         (cons
          macro
          (cons
           new$
           (cons
            formals
            (cons
             (cons
              'declare
              (cons
               (cons
                  'xargs
                  (append
                       (and recursive
                            (list :well-founded-relation wfrel?
                                  :measure measure?
                                  :ruler-extenders :all))
                       (cons ':guard
                             (cons guard
                                   (cons ':verify-guards
                                         (cons verify-guards$ 'nil))))))
               'nil))
             (cons body 'nil)))))))
       (mv local-event exported-event))))