• 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-check-liftable-loop-test
                    • Atj-check-single-return-with-expr
                    • Atj-lift-loop-test
                    • 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-lift-loop-tests

    Atj-lift-loop-test

    Lift an if test to the enclosing loop.

    Signature
    (atj-lift-loop-test block) → new-block
    Arguments
    block — Guard (jblockp block).
    Returns
    new-block — Type (jblockp new-block), given the guard.

    If the block is a loop of the form described here, we transform into the equivalent code also described here. We do it only once, not recursively, because ATJ's ACL2-to-Java translation currently does not generate nested loops.

    Definitions and Theorems

    Function: atj-lift-loop-test

    (defun atj-lift-loop-test (block)
      (declare (xargs :guard (jblockp block)))
      (let ((__function__ 'atj-lift-loop-test))
        (declare (ignorable __function__))
        (b* (((mv matchp test return body)
              (atj-check-liftable-loop-test block))
             ((unless matchp) block))
          (append (jblock-while test body)
                  (jblock-return return)))))

    Theorem: jblockp-of-atj-lift-loop-test

    (defthm jblockp-of-atj-lift-loop-test
      (implies (and (jblockp block))
               (b* ((new-block (atj-lift-loop-test block)))
                 (jblockp new-block)))
      :rule-classes :rewrite)