• 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-collect-fns-in-term
                • Atj-worklist-iterate
                • Atj-process-test
                • Atj-process-inputs
                • Atj-process-test-input-jprim-value
                • Atj-process-output-subdir
                  • Atj-process-test-input
                  • Atj-process-output-dir
                  • Atj-process-test-input-jprim-values
                  • Atj-fns-to-translate
                  • Atj-process-test-inputs
                  • Atj-process-tests
                  • Atj-process-targets
                  • Atj-process-no-aij-types
                  • Atj-pkgs-to-translate
                  • Atj-process-java-class
                  • Atj-process-java-package
                  • *atj-default-java-class*
                  • *atj-allowed-options*
                • Atj-java-pretty-printer
                • Atj-code-generation
                • 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-input-processing

    Atj-process-output-subdir

    Process the subdirectories specified by the :output-dir and :java-package inputs.

    Signature
    (atj-process-output-subdir current-subdir 
                               current-exists next-subdirs ctx state) 
     
      → 
    (mv erp final-dir state)
    Arguments
    current-subdir — Guard (stringp current-subdir).
    current-exists — Guard (booleanp current-exists).
    next-subdirs — Guard (string-listp next-subdirs).
    ctx — Guard (ctxp ctx).
    Returns
    final-dir — Type (stringp final-dir).

    This is part of the processing of :output-dir. As explained in the user documentation, if :java-package is not nil, the Java files are generated in a subdirectory of the directory specified by :output-dir, corresponding to the identifiers that form the Java package name.

    Here we ensure that the subdirectories in the sequence either exists and are directories, or do not exist. It is allowed for no subdirectory to exist, or for some initial prefix to exist, or for all of them to exist; any non-existing subdirectories will be created just before generating the Java files.

    This ACL2 function recursively checks the subdirectories. The current-subdir parameter is the path consisting of the :output-dir directory plus the subdirectories examined so far; its initial value is :output-dir. The current-exists parameter says whether the current-subdir exists or not; its initial value is t. The next-subdirs parameter contains the remaining subdirectories to examine; its initial value is the list of identifiers that form the Java package name. As soon as a subdirectory is encountered that does not exist, the current-exists is set to nil, and it stays that way. In any case eventually the final subdirectory path, starting with :output-dir, is returned.

    Definitions and Theorems

    Function: atj-process-output-subdir

    (defun atj-process-output-subdir
           (current-subdir current-exists next-subdirs ctx state)
     (declare (xargs :stobjs (state)))
     (declare (xargs :guard (and (stringp current-subdir)
                                 (booleanp current-exists)
                                 (string-listp next-subdirs)
                                 (ctxp ctx))))
     (let ((__function__ 'atj-process-output-subdir))
      (declare (ignorable __function__))
      (b*
       (((when (endp next-subdirs))
         (value (mbe :logic (str-fix current-subdir)
                     :exec current-subdir)))
        (current-subdir
             (oslib::catpath current-subdir (car next-subdirs)))
        ((when current-exists)
         (atj-process-output-subdir current-subdir
                                    current-exists (cdr next-subdirs)
                                    ctx state))
        ((mv err-msg exists state)
         (oslib::path-exists-p current-subdir))
        ((when err-msg)
         (er-soft+
          ctx t ""
          "The existence of the output subdirectory path ~x0 ~
                       cannot be tested.  ~@1"
          current-subdir err-msg))
        ((when (not exists))
         (atj-process-output-subdir current-subdir t (cdr next-subdirs)
                                    ctx state))
        ((mv err-msg kind state)
         (oslib::file-kind current-subdir))
        ((when err-msg)
         (er-soft+
          ctx t ""
          "The kind of the output subdirectory path ~x0 ~
                       cannot be tested.  ~@1."
          current-subdir err-msg))
        ((unless (eq kind :directory))
         (er-soft+
          ctx t ""
          "The output subdirectory path ~x0 ~
                       exists but is not a directory."
          current-subdir)))
       (atj-process-output-subdir current-subdir nil (cdr next-subdirs)
                                  ctx state))))

    Theorem: stringp-of-atj-process-output-subdir.final-dir

    (defthm stringp-of-atj-process-output-subdir.final-dir
      (b* (((mv ?erp ?final-dir acl2::?state)
            (atj-process-output-subdir
                 current-subdir
                 current-exists next-subdirs ctx state)))
        (stringp final-dir))
      :rule-classes :rewrite)