• 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-var-to-jvar
                  • Atj-char-to-jchars-id
                  • Atj-fn-to-method
                  • Atj-pkg-to-class
                    • Atj-fns-to-methods
                    • *atj-disallowed-class-names*
                    • Atj-pkgs-to-classes
                    • *atj-predefined-method-names*
                    • Atj-chars-to-jchars-id
                    • *atj-disallowed-jvar-names*
                    • Atj-get-pkg-class-name
                    • Atj-get-fn-method-name
                    • Atj-var-add-index
                    • *atj-disallowed-method-names*
                  • 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-name-translation

    Atj-pkg-to-class

    Turn an ACL2 package name into a Java class name.

    Signature
    (atj-pkg-to-class pkg java-class$) → class
    Arguments
    pkg — Guard (stringp pkg).
    java-class$ — Guard (stringp java-class$).
    Returns
    class — Type (stringp class).

    In the shallow embedding approach, a Java class is generated for each ACL2 package that includes ACL2 functions that we generate Java code for; each ACL2 function is turned into a Java method in that Java class.

    The name of the Java class for the ACL2 package is obtained by turning the ACL2 package name into a valid Java identifier, using atj-chars-to-jchars-id, but without flipping uppercase and lowercase. The resulting Java class name must not be in *atj-disallowed-class-names*. Since the Java class is contained in the main class generated by ATJ, we also ensure that the name is distinct from the containing class, whose name is passed to this function. We also ensure that the Java class name is distinct from all the mv class names: we do so by checking that the class name does not start with MV_, which is a little stronger than necessary but simpler and in practice should not be too restrictive.

    Definitions and Theorems

    Function: atj-pkg-to-class

    (defun atj-pkg-to-class (pkg java-class$)
     (declare (xargs :guard (and (stringp pkg)
                                 (stringp java-class$))))
     (let ((__function__ 'atj-pkg-to-class))
      (declare (ignorable __function__))
      (b*
       ((jchars (atj-chars-to-jchars-id (explode pkg)
                                        t
                                        :dash nil))
        (jstring (implode jchars))
        (jstring
             (if (or (member-equal jstring *atj-disallowed-class-names*)
                     (equal jstring java-class$)
                     (and (>= (length jstring) 3)
                          (eql (char jstring 0) #\M)
                          (eql (char jstring 1) #\V)
                          (eql (char jstring 2) #\_)))
                 (str::cat jstring "$")
               jstring)))
       jstring)))

    Theorem: stringp-of-atj-pkg-to-class

    (defthm stringp-of-atj-pkg-to-class
      (b* ((class (atj-pkg-to-class pkg java-class$)))
        (stringp class))
      :rule-classes :rewrite)