• 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
            • Tailrec-implementation
              • Tailrec-event-generation
                • Tailrec-gen-new-to-old-thm
                • Tailrec-gen-new-fn
                • Tailrec-gen-everything
                • Tailrec-gen-old-to-new-thm
                • Tailrec-gen-wrapper-fn
                • Tailrec-gen-domain-of-old-thm
                • Tailrec-gen-combine-left-identity-ground-thm
                • Tailrec-gen-appconds
                • Tailrec-gen-wrapper-to-old-thm
                • Tailrec-gen-old-to-wrapper-thm
                • Tailrec-gen-old-guard-of-alpha-thm
                • Tailrec-gen-alpha-fn
                  • Tailrec-gen-domain-of-ground-base-thm
                  • Tailrec-gen-test-of-alpha-thm
                  • Tailrec-gen-old-as-new-term
                  • Tailrec-gen-base-guard-thm
                  • Tailrec-gen-alpha-component-terms
                  • Tailrec-gen-combine-op
                  • Tailrec-gen-id-var-u
                  • Tailrec-gen-alpha-component-terms-aux
                  • Tailrec-gen-var-v
                  • Tailrec-gen-var-u
                  • Tailrec-gen-var-w
                • Tailrec-fn
                • Tailrec-macro-definition
                • Tailrec-input-processing
            • 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
          • 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
    • Tailrec-event-generation

    Tailrec-gen-alpha-fn

    Generate the definition of the \alpha function of the design notes.

    Signature
    (tailrec-gen-alpha-fn old$ test updates names-to-avoid wrld) 
      → 
    (mv event name updated-names-to-avoid)
    Arguments
    old$ — Guard (symbolp old$).
    test — Guard (pseudo-termp test).
    updates — Guard (pseudo-term-listp updates).
    names-to-avoid — Guard (symbol-listp names-to-avoid).
    wrld — Guard (plist-worldp wrld).
    Returns
    event — A pseudo-event-formp.
    name — A symbolp.
    updated-names-to-avoid — A symbol-listp.

    This function is generated only locally, because its purpose is just to prove local theorems (a\alpha and \gamma_f\alpha in the design notes). Since this function is only used in theorems, it has a t guard and its guards are not verified. The termination proof follows the design notes: measure and well-founded relation are the same as old. We do not normalize the function, so we can better control the proofs.

    The name used for \alpha is returned, along with the event.

    Definitions and Theorems

    Function: tailrec-gen-alpha-fn

    (defun tailrec-gen-alpha-fn (old$ test updates names-to-avoid wrld)
     (declare (xargs :guard (and (symbolp old$)
                                 (pseudo-termp test)
                                 (pseudo-term-listp updates)
                                 (symbol-listp names-to-avoid)
                                 (plist-worldp wrld))))
     (let ((__function__ 'tailrec-gen-alpha-fn))
      (declare (ignorable __function__))
      (b*
       (((mv name names-to-avoid)
         (fresh-logical-name-with-$s-suffix 'alpha
                                            'function
                                            names-to-avoid wrld))
        (formals (formals old$ wrld))
        (body (cons 'if
                    (cons test
                          (cons (cons 'list formals)
                                (cons (cons name updates) 'nil)))))
        (wfrel (well-founded-relation old$ wrld))
        (measure (measure old$ wrld))
        (termination-hints
             (cons (cons '"Goal"
                         (cons ':use
                               (cons (cons ':termination-theorem
                                           (cons old$ 'nil))
                                     '(:in-theory nil))))
                   'nil))
        (event
         (cons
          'local
          (cons
           (cons
            'defun
            (cons
             name
             (cons
              formals
              (cons
               (cons
                'declare
                (cons
                 (cons
                  'xargs
                  (cons
                   ':well-founded-relation
                   (cons
                    wfrel
                    (cons
                       ':measure
                       (cons measure
                             (cons ':hints
                                   (cons termination-hints
                                         '(:guard t
                                                  :verify-guards nil
                                                  :normalize nil))))))))
                 'nil))
               (cons body 'nil)))))
           'nil))))
       (mv event name names-to-avoid))))