• 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
        • 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-gen-shallow-term-fns
                  • String-jmethodlist-alistp
                  • Atj-gen-shallow-fndef-method
                  • String-jfieldlist-alistp
                  • Atj-gen-shallow-test-code
                  • Atj-adapt-expr-to-type
                  • Atj-gen-shallow-fn-call
                  • Atj-check-marked-annotated-mv-let-call
                  • Atj-gen-shallow-main-class
                  • Atj-gen-shallow-fnnative-method
                  • Atj-gen-shallow-synonym-method
                  • Atj-gen-shallow-if-call
                  • Atj-gen-shallow-and-call
                  • Atj-gen-shallow-pkg-methods
                  • Atj-convert-expr-to-jprim
                  • Atj-gen-shallow-or-call
                    • Atj-convert-expr-from-jprimarr-method
                    • Atj-adapt-expr-to-types
                    • Atj-gen-shallow-all-pkg-methods
                    • Atj-convert-expr-to-jprimarr-method
                    • Atj-gen-shallow-fndef-all-methods
                    • Atj-convert-expr-from-jprim
                    • Atj-gen-shallow-mv-class
                    • Atj-gen-shallow-main-cunit
                    • Atj-gen-shallow-fndef-methods
                    • Atj-gen-shallow-mv-class-name
                    • Atj-shallow-fns-that-may-throw
                    • Atj-gen-shallow-term
                    • Atj-gen-shallow-let-bindings
                    • Atj-gen-shallow-fn-methods
                    • Atj-gen-shallow-jprimarr-new-init-call
                    • Atj-gen-shallow-fnname
                    • Atj-gen-shallow-all-fn-methods
                    • Atj-gen-shallow-not-call
                    • Atj-fnnative-method-name
                    • Atj-gen-shallow-mv-let
                    • Atj-gen-shallow-jprim-constr-call
                    • Atj-gen-shallow-jprimarr-write-call
                    • Atj-gen-shallow-fnnative-all-methods
                    • Atj-gen-shallow-pkg-class
                    • Atj-gen-shallow-jprimarr-length-call
                    • Atj-gen-shallow-pkg-fields
                    • Atj-all-mv-output-types
                    • Atj-gen-shallow-mv-call
                    • Atj-gen-shallow-jprim-binop-call
                    • Atj-gen-shallow-jprim-conv-call
                    • Atj-gen-shallow-primarray-write-method
                    • Atj-gen-shallow-mv-fields
                    • Atj-gen-shallow-jprimarr-read-call
                    • Atj-gen-shallow-jprimarr-new-len-call
                    • Atj-gen-shallow-jprimarr-conv-tolist-call
                    • Atj-gen-shallow-jprimarr-conv-fromlist-call
                    • Atj-gen-shallow-synonym-all-methods
                    • Atj-gen-shallow-jprim-deconstr-call
                    • Atj-gen-shallow-all-pkg-fields
                    • Atj-gen-shallow-test-code-asgs
                    • Atj-gen-shallow-lambda
                    • Atj-gen-shallow-jprim-unop-call
                    • Atj-jprim-binop-fn-to-jbinop
                    • Atj-gen-shallow-mv-asgs
                    • Atj-gen-shallow-env-class
                    • Atj-gen-shallow-mv-params
                    • Atj-gen-shallow-fnnative-methods
                    • Atj-gen-shallow-pkg-classes
                    • Atj-gen-shallow-env-cunit
                    • Atj-gen-shallow-all-synonym-methods
                    • Atj-convert-expr-to-jprimarr
                    • Atj-convert-expr-from-jprimarr
                    • Atj-jprim-constr-fn-of-qconst-to-expr
                    • Atj-gen-shallow-test-code-mv-asgs
                    • Atj-gen-shallow-synonym-methods
                    • Atj-gen-shallow-synonym-method-params
                    • Atj-convert-expr-to-jprimarr-method-name
                    • Atj-convert-expr-from-jprimarr-method-name
                    • Atj-jexpr-list-to-3-jexprs
                    • Atj-jblock-list-to-3-jblocks
                    • Atj-gen-shallow-test-code-comps
                    • Atj-jprim-conv-fn-to-jtype
                    • Atj-gen-shallow-terms
                    • Atj-gen-shallow-mv-field-name
                    • Atj-adapt-exprs-to-types
                    • Atj-jblock-list-to-2-jblocks
                    • Atj-gen-shallow-primarray-write-methods
                    • Atj-gen-shallow-mv-classes
                    • Atj-gen-shallow-jtype
                    • Atj-gen-shallow-build-method
                    • Atj-jexpr-list-to-2-jexprs
                    • Atj-jprimarr-write-to-method-name
                    • Atj-gen-shallow-all-jprimarr-conv-methods
                    • Atj-jprimarr-new-len-fn-to-comp-jtype
                    • Atj-jprimarr-new-init-fn-to-comp-jtype
                    • Atj-jprim-unop-fn-to-junop
                    • *atj-gen-cond-exprs*
                    • Atj-primarray-write-method-name
                    • Atj-gen-shallow-jprimarr-fromlist-methods
                    • Atj-gen-shallow-jprimarr-tolist-methods
                    • Atj-gen-shallow-mv-classes-guard
                    • *atj-mv-singleton-field-name*
                    • *atj-mv-factory-method-name*
                  • 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-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-shallow-code-generation

    Atj-gen-shallow-or-call

    Generate a shallowly embedded ACL2 or call.

    Signature
    (atj-gen-shallow-or-call left-block 
                             right-block left-expr right-expr 
                             types jvar-tmp-base jvar-tmp-index) 
     
      → 
    (mv block expr new-jvar-tmp-index)
    Arguments
    left-block — Guard (jblockp left-block).
    right-block — Guard (jblockp right-block).
    left-expr — Guard (jexprp left-expr).
    right-expr — Guard (jexprp right-expr).
    types — Guard (atj-type-listp types).
    jvar-tmp-base — Guard (stringp jvar-tmp-base).
    jvar-tmp-index — Guard (posp jvar-tmp-index).
    Returns
    block — Type (jblockp block).
    expr — Type (jexprp expr).
    new-jvar-tmp-index — Type (posp new-jvar-tmp-index), given (posp jvar-tmp-index).

    This is called after translating the arguments to Java. The resulting blocks and expressions are passed as parameters here.

    Recall that ATJ's pre-translation (see atj-pre-translation-disjunctions) turns (annotated) terms (if a a b) into (or a b). Here we recognize, and treat specially, these or calls.

    The parameter types is the type (list) of both operands. They have the same type because the type annotation step ensures that both branches of ifs, including those of the form (if a a b) that are turned into (or a b), have the same types.

    If both operands have type :aboolean, we generate the block <left-block> and the non-strict expression <left-expr> || <right-expr>: in other words, we translate ACL2's boolean or calls (in the original term) to a || binary expression in Java, preceded by any computations needed by <left-expr>; but this is possible only if the calculation of the right operand, which must be executed only if the first operand is true, involves just an expression <right-expr> and not a (non-empty) block <right-block>. In all other cases, we generate the block

    <left-block>
    <type> <tmp> = <a-expr>;
    if (<tmp> == NIL) {
        <b-block>
        <tmp> = <b-expr>;
    }

    and the Java expression <tmp>, where: <tmp> consists of the base name in the parameter jvar-tmp-base followed by the numeric index in the parameter jvar-tmp-index; and <type> is the Java type of the operands.

    Definitions and Theorems

    Function: atj-gen-shallow-or-call

    (defun atj-gen-shallow-or-call
           (left-block right-block left-expr right-expr
                       types jvar-tmp-base jvar-tmp-index)
     (declare (xargs :guard (and (jblockp left-block)
                                 (jblockp right-block)
                                 (jexprp left-expr)
                                 (jexprp right-expr)
                                 (atj-type-listp types)
                                 (stringp jvar-tmp-base)
                                 (posp jvar-tmp-index))))
     (declare (xargs :guard (consp types)))
     (let ((__function__ 'atj-gen-shallow-or-call))
      (declare (ignorable __function__))
      (if (and (equal types
                      (list (atj-type-acl2 (atj-atype-boolean))))
               (null right-block))
          (mv (jblock-fix left-block)
              (jexpr-binary (jbinop-condor)
                            left-expr right-expr)
              jvar-tmp-index)
       (b*
        (((mv tmp-locvar-block
              jvar-tmp jvar-tmp-index)
          (atj-gen-jlocvar-indexed
               (atj-gen-shallow-jtype types)
               jvar-tmp-base jvar-tmp-index left-expr))
         (if-block
            (jblock-if (jexpr-binary (jbinop-eq)
                                     (jexpr-name jvar-tmp)
                                     (atj-gen-symbol nil t nil))
                       (append right-block
                               (jblock-asg-name jvar-tmp right-expr)))))
        (mv (append (jblock-fix left-block)
                    tmp-locvar-block if-block)
            (jexpr-name jvar-tmp)
            jvar-tmp-index)))))

    Theorem: jblockp-of-atj-gen-shallow-or-call.block

    (defthm jblockp-of-atj-gen-shallow-or-call.block
      (b*
        (((mv common-lisp::?block
              ?expr ?new-jvar-tmp-index)
          (atj-gen-shallow-or-call left-block
                                   right-block left-expr right-expr
                                   types jvar-tmp-base jvar-tmp-index)))
        (jblockp block))
      :rule-classes :rewrite)

    Theorem: jexprp-of-atj-gen-shallow-or-call.expr

    (defthm jexprp-of-atj-gen-shallow-or-call.expr
      (b*
        (((mv common-lisp::?block
              ?expr ?new-jvar-tmp-index)
          (atj-gen-shallow-or-call left-block
                                   right-block left-expr right-expr
                                   types jvar-tmp-base jvar-tmp-index)))
        (jexprp expr))
      :rule-classes :rewrite)

    Theorem: posp-of-atj-gen-shallow-or-call.new-jvar-tmp-index

    (defthm posp-of-atj-gen-shallow-or-call.new-jvar-tmp-index
     (implies
       (posp jvar-tmp-index)
       (b*
        (((mv common-lisp::?block
              ?expr ?new-jvar-tmp-index)
          (atj-gen-shallow-or-call left-block
                                   right-block left-expr right-expr
                                   types jvar-tmp-base jvar-tmp-index)))
        (posp new-jvar-tmp-index)))
     :rule-classes :rewrite)