• 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
          • Isodata
            • Isodata-implementation
              • Isodata-event-generation
                • Isodata-gen-everything
                • Isodata-gen-thm-instances-to-terms-back
                • Isodata-gen-new-fn
                  • Isodata-gen-new-fn-body-nonpred
                  • Isodata-gen-new-fn-verify-guards
                  • Isodata-gen-new-fn-verify-guards-hints-nonpred-rec-1res/mres
                  • Isodata-gen-new-to-list-of-mv-nth
                  • Isodata-gen-new-to-old-lemma
                  • Isodata-gen-forth-image-instances-to-terms-back
                  • Isodata-gen-forth-guard-instances-to-terms-back
                  • Isodata-gen-back-of-forth-instances-to-terms-back
                  • Isodata-gen-new-fn-verify-guards-hints-nonpred-nonrec-1res/mres
                  • Isodata-gen-defiso
                  • Isodata-gen-new-to-old-lemma-hints
                  • Isodata-gen-old-to-new-lemma
                  • Isodata-gen-new-to-old-thm-hints-1res
                  • Isodata-gen-lemma-instances-var-to-new-forth-rec-call-args-back
                  • Isodata-gen-new-to-old-thm
                  • Isodata-gen-lemma-instances-x1...xn-to-forth-rec-call-args-back
                  • Isodata-gen-thm-instances-to-x1...xn
                  • Isodata-gen-old-to-new-thm
                  • Isodata-gen-new-fn-verify-guards-hints-pred-rec
                  • Isodata-gen-all-back-guard-instances-to-mv-nth
                  • Isodata-gen-newp-of-new-thm-hints
                  • Isodata-gen-lemma-instances-x1...xn-to-rec-call-args-back
                  • Isodata-gen-result-vars
                  • Isodata-gen-old-to-new-lemma-hints
                  • Isodata-gen-newp-of-new-thm
                  • Isodata-gen-new-to-old-thm-hints-0res
                  • Isodata-gen-new-to-old-thm-hints
                  • Isodata-gen-new-fn-verify-guards-hints-nonpred-rec-0res
                  • Isodata-gen-lemma-instances-var-to-rec-calls-back
                  • Isodata-gen-new-fn-body-pred
                  • Isodata-gen-all-back-of-forth-instances-to-mv-nth
                  • Isodata-gen-new-fn-verify-guards-hints-nonpred
                  • Isodata-gen-new-fn-verify-guards-hints
                  • Isodata-gen-all-back-of-forth-instances-to-terms-back
                  • Isodata-gen-old-to-new-thm-hints-1res
                  • Isodata-gen-all-forth-image-instances-to-terms-back
                  • Isodata-gen-all-forth-guard-instances-to-terms-back
                  • Isodata-gen-old-to-new-thm-hints
                  • Isodata-gen-old-to-list-of-mv-nth
                  • Isodata-gen-new-fn-verify-guards-hints-pred-nonrec
                  • Isodata-gen-appconds
                  • Isodata-gen-forth-image-instances-to-mv-nth
                  • Isodata-gen-forth-guard-instances-to-mv-nth
                  • Isodata-gen-back-of-forth-instances-to-mv-nth
                  • Isodata-gen-back-guard-instances-to-mv-nth
                  • Isodata-xform-rec-calls
                  • Isodata-gen-old-to-new-thm-formula
                  • Isodata-gen-new-fn-verify-guards-hints-nonpred-nonrec-0res
                  • Isodata-gen-lemma-instance-x1...xn-to-forth-of-x1...xn
                  • Isodata-gen-lemma-instance-x1...xn-to-back-of-x1...xn
                  • Isodata-gen-forth-image-instances-to-x1...xn
                  • Isodata-gen-forth-guard-instances-to-x1...xn
                  • Isodata-gen-back-of-forth-instances-to-x1...xn
                  • Isodata-gen-old-to-new-lemma-formula
                  • Isodata-gen-newp-of-new-thm-formula
                  • Isodata-gen-newp-guard-instances-to-x1...xn
                  • Isodata-gen-new-to-old-lemma-formula
                  • Isodata-gen-fn-of-terms
                  • Isodata-gen-back-image-instances-to-x1...xn
                  • Isodata-gen-back-guard-instances-to-x1...xn
                  • Isodata-gen-oldp-of-rec-call-args-under-contexts
                  • Isodata-gen-new-to-old-thm-formula
                  • Isodata-gen-new-fn-termination-hints
                  • Isodata-gen-new-fn-body
                  • Isodata-gen-lemma-instance-x1...xn-to-fn-of-x1...xn
                  • Isodata-gen-old-to-new-thm-hints-0res
                  • Isodata-gen-new-fn-verify-guards-hints-pred
                  • Isodata-gen-new-fn-guard
                  • Isodata-gen-subst-x1...xn-with-back-of-x1...xn
                  • Isodata-gen-oldp-of-terms
                  • Isodata-gen-newp-of-terms
                  • Isodata-gen-forth-of-terms
                  • Isodata-gen-defisos
                  • Isodata-gen-back-of-terms
                  • Isodata-gen-old-to-new-thm-hints-mres
                  • Isodata-gen-new-to-old-thm-hints-mres
                  • Isodata-gen-new-fn-measure
                  • Isodata-formal-of-newp
                  • Isodata-formal-of-forth
                  • Isodata-formal-of-back
                  • Isodata-formal-of-unary
                • Isodata-fn
                • Isodata-input-processing
                • Isodata-macro-definition
            • Simplify-defun
            • Tailrec
            • Schemalg
            • Restrict
            • Expdata
            • 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
          • Riscv
          • 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
    • Isodata-event-generation

    Isodata-gen-new-fn

    Generate the new function definition.

    Signature
    (isodata-gen-new-fn old$ 
                        arg-isomaps res-isomaps xform-stobjs-p 
                        predicate$ undefined$ new$ 
                        new-enable$ verify-guards$ untranslate$ 
                        compatibility appcond-thm-names wrld) 
     
      → 
    (mv new-fn-local-event new-fn-exported-event)
    Arguments
    old$ — Guard (symbolp old$).
    arg-isomaps — Guard (isodata-symbol-isomap-alistp arg-isomaps).
    res-isomaps — Guard (isodata-pos-isomap-alistp res-isomaps).
    xform-stobjs-p — Guard (booleanp xform-stobjs-p).
    predicate$ — Guard (booleanp predicate$).
    undefined$ — Either :base-case-then, :base-case-else, or a pseudo-termp.
    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 or some stobjs are transformed.

    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 isodata-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: isodata-gen-new-fn

    (defun isodata-gen-new-fn
           (old$ arg-isomaps res-isomaps xform-stobjs-p
                 predicate$ undefined$ new$
                 new-enable$ verify-guards$ untranslate$
                 compatibility appcond-thm-names wrld)
     (declare
          (xargs :guard (and (symbolp old$)
                             (isodata-symbol-isomap-alistp arg-isomaps)
                             (isodata-pos-isomap-alistp res-isomaps)
                             (booleanp xform-stobjs-p)
                             (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__ 'isodata-gen-new-fn))
      (declare (ignorable __function__))
      (b*
       ((non-executablep (or (non-executablep old$ wrld)
                             xform-stobjs-p))
        (macro (function-intro-macro new-enable$ non-executablep))
        (formals (formals old$ wrld))
        (body (isodata-gen-new-fn-body
                   old$ arg-isomaps res-isomaps predicate$
                   undefined$ new$ compatibility 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
             (isodata-gen-new-fn-guard old$ arg-isomaps
                                       xform-stobjs-p predicate$ wrld))
        (guard (conjoin (flatten-ands-in-lit guard)))
        (guard (untranslate guard nil wrld))
        (recursive (recursivep old$ nil wrld))
        (wfrel? (if recursive (get-well-founded-relation old$ wrld)
                  nil))
        (measure? (if recursive
                      (isodata-gen-new-fn-measure old$ arg-isomaps wrld)
                    nil))
        (termination-hints?
             (if recursive (isodata-gen-new-fn-termination-hints
                                appcond-thm-names old$ arg-isomaps 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))))