• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • ACL2
    • Macro-libraries
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
        • Bv
        • Imp-language
        • 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
        • 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
  • Atj-post-translation

Atj-post-translation-tailrec-elimination

Post-translation step: eliminate tail recursions in favor of loops.

It is well-known that tail recursions can be turned into loops; this process is often called `tail recursion elimination'. This post-translation step does that, by surrounding the body of a tail-recursive method in a while (true) { ... } loop, and replacing each recursive call with a continue preceded by an assignment to the method's parameters of the values passed to the recursive call.

We remark that the assignment to the method's parameters is an instance of destructive updates, which is idiomatic in Java.

It seems better to realize this as a post-translation step, rather than as part of the ACL2-to-Java translation, which is already fairly complicated.

Subtopics

Atj-make-parallel-asg
Generate a block that performs a parallel assignment of the given expressions to the given variables.
Atj-elim-tailrec-in-jstatems+jblocks
Eliminate all the tail-recursive calls in a method's statement or block.
Atj-parallel-asg-depgraph
Calculate a dependency graph for a parallel assignment.
Atj-elim-tailrec-in-return
Eliminate any tail-recursive call in a return statement.
Atj-serialize-parallel-asg
Generate a block that performs a parallel assignment of the given expressions to the given variables, according to the supplied serialization.
Atj-elim-tailrec
Turn the body of a tail-recursive method into a loop.
Atj-elim-tailrec-gen-block
Generate the block for eliminating tail recursion.