• 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
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • C
        • Soft
        • Bv
        • Imp-language
        • Ethereum
        • Event-macros
        • Java
          • Atj
            • Atj-implementation
              • Atj-types
              • Atj-java-primitive-array-model
              • Atj-java-abstract-syntax
              • Atj-input-processing
              • Atj-java-pretty-printer
              • Atj-code-generation
                • Atj-gen-test-method
                • Atj-shallow-code-generation
                • Atj-common-code-generation
                • Atj-shallow-quoted-constant-generation
                • Atj-pre-translation
                • Atj-gen-everything
                • Atj-name-translation
                • Atj-gen-test-cunit
                • Atj-gen-test-class
                • Atj-gen-main-file
                • Atj-post-translation
                  • Atj-post-translation-remove-array-write-calls
                  • Atj-post-translation-cache-const-methods
                  • Atj-post-translation-tailrec-elimination
                    • Atj-make-parallel-asg
                    • Atj-elim-tailrec-in-jstatems+jblocks
                    • Atj-parallel-asg-depgraph
                    • Atj-elim-tailrec-in-return
                    • Atj-serialize-parallel-asg
                    • Atj-elim-tailrec
                    • Atj-elim-tailrec-gen-block
                    • Atj-post-translation-fold-returns
                    • Atj-post-translate-body
                    • Atj-post-translation-lift-loop-tests
                    • Atj-post-translation-simplify-conds
                    • Atj-post-translate-jcbody-elements
                    • Atj-post-translation-remove-continue
                  • Atj-deep-code-generation
                  • Atj-gen-test-methods
                  • Atj-gen-test-file
                  • Atj-gen-env-file
                  • Atj-gen-output-subdir
                • Atj-java-primitives
                • Atj-java-primitive-arrays
                • Atj-type-macros
                • Atj-java-syntax-operations
                • Atj-fn
                • Atj-library-extensions
                • Atj-java-input-types
                • Atj-test-structures
                • Aij-notions
                • Atj-macro-definition
              • Atj-tutorial
            • Aij
            • Language
          • Riscv
          • Bitcoin
          • Zcash
          • Yul
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Axe
          • Lists-light
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Atj-post-translation-tailrec-elimination

    Atj-elim-tailrec-gen-block

    Generate the block for eliminating tail recursion.

    Signature
    (atj-elim-tailrec-gen-block arg-exprs method-params) → block
    Arguments
    arg-exprs — Guard (jexpr-listp arg-exprs).
    method-params — Guard (jparam-listp method-params).
    Returns
    block — Type (jblockp block).

    This is called by atj-elim-tailrec-in-return. When we encounter a tail-recursive call of the method in a return statement, we generate a block consisting of (1) a parallel assignment of the call's actual arguments to the method's parameters, and (2) a continue statement.

    Definitions and Theorems

    Function: atj-elim-tailrec-gen-block

    (defun atj-elim-tailrec-gen-block (arg-exprs method-params)
     (declare (xargs :guard (and (jexpr-listp arg-exprs)
                                 (jparam-listp method-params))))
     (let ((__function__ 'atj-elim-tailrec-gen-block))
      (declare (ignorable __function__))
      (b*
       ((names (jparam-list->names method-params))
        (types (jparam-list->types method-params))
        ((unless (= (len names) (len arg-exprs)))
         (raise
          "Internal error: ~
                    call of tail-recursive method has ~x0 parameters ~
                    but is called with ~x1 arguments."
          (len names)
          (len arg-exprs))))
       (append (atj-make-parallel-asg names types arg-exprs)
               (jblock-continue)))))

    Theorem: jblockp-of-atj-elim-tailrec-gen-block

    (defthm jblockp-of-atj-elim-tailrec-gen-block
      (b* ((block (atj-elim-tailrec-gen-block arg-exprs method-params)))
        (jblockp block))
      :rule-classes :rewrite)