• 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-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
          • 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-shallow-code-generation

    Atj-gen-shallow-pkg-methods

    Generate all the methods of the class for an ACL2 package.

    Signature
    (atj-gen-shallow-pkg-methods pkg fns-by-pkg fns fns-that-may-throw 
                                 qconsts pkg-class-names 
                                 fn-method-names mv-typess 
                                 guards$ no-aij-types$ verbose$ wrld) 
     
      → 
    (mv methods new-qconsts new-mv-typess)
    Arguments
    pkg — Guard (stringp pkg).
    fns-by-pkg — Guard (string-symbollist-alistp fns-by-pkg).
    fns — Guard (symbol-listp fns).
    fns-that-may-throw — Guard (symbol-listp fns-that-may-throw).
    qconsts — Guard (atj-qconstants-p qconsts).
    pkg-class-names — Guard (string-string-alistp pkg-class-names).
    fn-method-names — Guard (symbol-string-alistp fn-method-names).
    mv-typess — Guard (atj-type-list-listp mv-typess).
    guards$ — Guard (booleanp guards$).
    no-aij-types$ — Guard (booleanp no-aij-types$).
    verbose$ — Guard (booleanp verbose$).
    wrld — Guard (plist-worldp wrld).
    Returns
    methods — Type (jmethod-listp methods).
    new-qconsts — Type (atj-qconstants-p new-qconsts), given (atj-qconstants-p qconsts).
    new-mv-typess — Type (and (atj-type-list-listp new-mv-typess) (cons-listp new-mv-typess)), given (and (atj-type-list-listp mv-typess) (cons-listp mv-typess)).

    We generate methods for the functions in fns-by-pkg (i.e. the functions to translate to Java, organized by package) that are associated to pkg.

    We also generate synonym methods for all the functions in fns (i.e. the functions to translate to Java) that are in other ACL2 packages but that are imported by pkg; see atj-gen-shallow-synonym-method for motivation. However, if fns-by-pkg has no functions associated to pkg, then we skip these synonym methods, because they are not needed by any other code in the class for pkg; in fact, unless the class has fields for symbols, we do not generate the class (see atj-gen-shallow-pkg-classes).

    Recall that, for each ACL2 function or function synonym, we generate one overloaded method for each primary or secondary type of the function.

    We sort all the methods.

    We also collect all the quoted constants that occur in the functions in pkg that are translated to Java.

    Definitions and Theorems

    Function: atj-gen-shallow-pkg-methods

    (defun atj-gen-shallow-pkg-methods
           (pkg fns-by-pkg fns fns-that-may-throw
                qconsts pkg-class-names
                fn-method-names mv-typess
                guards$ no-aij-types$ verbose$ wrld)
     (declare (xargs :guard (and (stringp pkg)
                                 (string-symbollist-alistp fns-by-pkg)
                                 (symbol-listp fns)
                                 (symbol-listp fns-that-may-throw)
                                 (atj-qconstants-p qconsts)
                                 (string-string-alistp pkg-class-names)
                                 (symbol-string-alistp fn-method-names)
                                 (atj-type-list-listp mv-typess)
                                 (booleanp guards$)
                                 (booleanp no-aij-types$)
                                 (booleanp verbose$)
                                 (plist-worldp wrld))))
     (declare (xargs :guard (cons-listp mv-typess)))
     (let ((__function__ 'atj-gen-shallow-pkg-methods))
      (declare (ignorable __function__))
      (b*
       ((fns-in-pkg (cdr (assoc-equal pkg fns-by-pkg)))
        ((run-when (and verbose$ (consp fns-in-pkg)))
         (cw
          "~%Generate the Java methods ~
                   for the ACL2 functions in package ~s0:~%"
          pkg))
        ((mv fn-methods qconsts mv-typess)
         (atj-gen-shallow-all-fn-methods
              fns-in-pkg fns-that-may-throw
              qconsts pkg-class-names
              fn-method-names mv-typess
              guards$ no-aij-types$ verbose$ wrld))
        (synonym-methods
         (and
             (consp fns-in-pkg)
             (b* ((imported-fns (intersection-eq fns (pkg-imports pkg)))
                  (imported-fns (sort-symbol-listp imported-fns)))
               (atj-gen-shallow-all-synonym-methods
                    imported-fns
                    fns-that-may-throw pkg-class-names
                    fn-method-names guards$ wrld))))
        (all-methods (append synonym-methods fn-methods)))
       (mv (mergesort-jmethods all-methods)
           qconsts mv-typess))))

    Theorem: jmethod-listp-of-atj-gen-shallow-pkg-methods.methods

    (defthm jmethod-listp-of-atj-gen-shallow-pkg-methods.methods
      (b* (((mv ?methods ?new-qconsts ?new-mv-typess)
            (atj-gen-shallow-pkg-methods
                 pkg fns-by-pkg fns fns-that-may-throw
                 qconsts pkg-class-names
                 fn-method-names mv-typess
                 guards$ no-aij-types$ verbose$ wrld)))
        (jmethod-listp methods))
      :rule-classes :rewrite)

    Theorem: atj-qconstants-p-of-atj-gen-shallow-pkg-methods.new-qconsts

    (defthm atj-qconstants-p-of-atj-gen-shallow-pkg-methods.new-qconsts
      (implies (atj-qconstants-p qconsts)
               (b* (((mv ?methods ?new-qconsts ?new-mv-typess)
                     (atj-gen-shallow-pkg-methods
                          pkg fns-by-pkg fns fns-that-may-throw
                          qconsts pkg-class-names
                          fn-method-names mv-typess
                          guards$ no-aij-types$ verbose$ wrld)))
                 (atj-qconstants-p new-qconsts)))
      :rule-classes :rewrite)

    Theorem: return-type-of-atj-gen-shallow-pkg-methods.new-mv-typess

    (defthm return-type-of-atj-gen-shallow-pkg-methods.new-mv-typess
      (implies (and (atj-type-list-listp mv-typess)
                    (cons-listp mv-typess))
               (b* (((mv ?methods ?new-qconsts ?new-mv-typess)
                     (atj-gen-shallow-pkg-methods
                          pkg fns-by-pkg fns fns-that-may-throw
                          qconsts pkg-class-names
                          fn-method-names mv-typess
                          guards$ no-aij-types$ verbose$ wrld)))
                 (and (atj-type-list-listp new-mv-typess)
                      (cons-listp new-mv-typess))))
      :rule-classes :rewrite)