• 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-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-translate-body

    Post-translate a Java method body generated from an ACL2 function.

    Signature
    (atj-post-translate-body name params body tailrecp) → new-body
    Arguments
    name — Guard (stringp name).
    params — Guard (jparam-listp params).
    body — Guard (jblockp body).
    tailrecp — Guard (booleanp tailrecp).
    Returns
    new-body — Type (jblockp new-body), given the guard.

    We always fold returns into ifs.

    If the method is tail-recursive, which is signaled by the tailrecp flag, then we replace the tail recursion with a loop. It is critical that this step is performed after folding returns into ifs, because tail recursion elimination looks for recursive calls in returns.

    The other post-translation steps are always performed. These are the post-translation steps that operate at the level of individual method bodies.

    Definitions and Theorems

    Function: atj-post-translate-body

    (defun atj-post-translate-body (name params body tailrecp)
      (declare (xargs :guard (and (stringp name)
                                  (jparam-listp params)
                                  (jblockp body)
                                  (booleanp tailrecp))))
      (let ((__function__ 'atj-post-translate-body))
        (declare (ignorable __function__))
        (b* ((body (atj-fold-returns body))
             (body (if tailrecp (atj-elim-tailrec name params body)
                     body))
             (body (atj-lift-loop-test body))
             (body (atj-remove-continue-in-jblock body))
             (body (atj-remove-array-write-calls body))
             (body (atj-simplify-conds-in-jblock body)))
          body)))

    Theorem: jblockp-of-atj-post-translate-body

    (defthm jblockp-of-atj-post-translate-body
     (implies
       (and (stringp name)
            (jparam-listp params)
            (jblockp body)
            (booleanp tailrecp))
       (b*
        ((new-body (atj-post-translate-body name params body tailrecp)))
        (jblockp new-body)))
     :rule-classes :rewrite)