• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
      • Operational-semantics
      • Real
      • Start-here
      • Debugging
      • Miscellaneous
      • Output-controls
      • Macros
      • Interfacing-tools
        • Io
        • Defttag
        • Sys-call
        • Save-exec
        • Quicklisp
        • Std/io
        • Oslib
          • File-types
          • Argv
          • Copy
          • Catpath
          • Ls
          • Universal-time
          • Tempfile
            • Default-tempfile-aux
              • Default-tempdir
              • Default-tempfile
            • Basename
            • Dirname
            • Copy!
            • Ls-files
            • Mkdir
            • Rmtree
            • Lisp-version
            • Lisp-type
            • Ls-subdirs
            • Date
            • Getpid
            • Dirnames
            • Basenames
            • Basename!
            • Ls-subdirs!
            • Ls-files!
            • Dirname!
            • Ls!
            • Catpaths
            • Mkdir!
            • Rmtree!
            • Remove-nonstrings
          • Bridge
          • Clex
          • Tshell
          • Unsound-eval
          • Hacker
          • ACL2s-interface
          • Startup-banner
          • Command-line
      • Interfacing-tools
        • Io
        • Defttag
        • Sys-call
        • Save-exec
        • Quicklisp
        • Std/io
        • Oslib
          • File-types
          • Argv
          • Copy
          • Catpath
          • Ls
          • Universal-time
          • Tempfile
            • Default-tempfile-aux
              • Default-tempdir
              • Default-tempfile
            • Basename
            • Dirname
            • Copy!
            • Ls-files
            • Mkdir
            • Rmtree
            • Lisp-version
            • Lisp-type
            • Ls-subdirs
            • Date
            • Getpid
            • Dirnames
            • Basenames
            • Basename!
            • Ls-subdirs!
            • Ls-files!
            • Dirname!
            • Ls!
            • Catpaths
            • Mkdir!
            • Rmtree!
            • Remove-nonstrings
          • Bridge
          • Clex
          • Tshell
          • Unsound-eval
          • Hacker
          • ACL2s-interface
          • Startup-banner
          • Command-line
        • Hardware-verification
        • Software-verification
        • Math
        • Testing-utilities
      • Tempfile

      Default-tempfile-aux

      Join together a temp directory, the user name, the PID, and the base name to create a temporary filename.

      Signature
      (default-tempfile-aux tempdir basename state) 
        → 
      (mv tempfile new-state)
      Arguments
      tempdir — Directory to generate the file in.
          Guard (stringp tempdir).
      basename — Base name to use for the new file.
          Guard (stringp basename).
      Returns
      tempfile — Something like $TEMPDIR/$USER-$PID-$BASENAME.
          Type (or (stringp tempfile) (not tempfile)).
      new-state — Type (state-p1 new-state), given (force (state-p1 state)).

      Definitions and Theorems

      Function: default-tempfile-aux

      (defun default-tempfile-aux (tempdir basename state)
        (declare (xargs :stobjs (state)))
        (declare (xargs :guard (and (stringp tempdir)
                                    (stringp basename))))
        (let ((__function__ 'default-tempfile-aux))
          (declare (ignorable __function__))
          (b* (((mv pid state) (getpid state))
               ((unless (natp pid))
                (er hard? __function__ "getpid failed")
                (mv nil state))
               ((mv ?err user state)
                (getenv$ "USER" state))
               ((unless (stringp user))
                (er hard?
                    __function__ "reading $USER failed")
                (mv nil state))
               (filename (cat user "-" (str::nat-to-dec-string pid)
                              "-" basename))
               (path (catpath tempdir filename)))
            (mv path state))))

      Theorem: return-type-of-default-tempfile-aux.tempfile

      (defthm return-type-of-default-tempfile-aux.tempfile
        (b* (((mv ?tempfile ?new-state)
              (default-tempfile-aux tempdir basename state)))
          (or (stringp tempfile) (not tempfile)))
        :rule-classes :type-prescription)

      Theorem: state-p1-of-default-tempfile-aux.new-state

      (defthm state-p1-of-default-tempfile-aux.new-state
        (implies (force (state-p1 state))
                 (b* (((mv ?tempfile ?new-state)
                       (default-tempfile-aux tempdir basename state)))
                   (state-p1 new-state)))
        :rule-classes :rewrite)

      Theorem: w-state-of-default-tempfile-aux

      (defthm w-state-of-default-tempfile-aux
        (b* (((mv ?tempfile ?new-state)
              (default-tempfile-aux tempdir basename state)))
          (equal (w new-state) (w state))))