• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
      • Std/lists
      • Std/alists
      • Obags
      • Std/util
      • Std/strings
      • Std/osets
      • Std/io
        • Open-channel-lemmas
        • Std/io/read-char$
        • Std/io/read-object
        • Std/io/open-output-channel
        • Unsound-read
        • Read-string
        • Read-bytes$
        • File-measure
        • Read-bytes$-n
        • Std/io/read-byte$
        • Std/io/open-input-channel
        • Read-file-lines-no-newlines
        • Print-compressed
        • Nthcdr-bytes
        • Read-file-lines
        • Std/io/close-output-channel
        • Read-file-characters
        • Read-file-bytes
        • Print-legibly
        • Std/io/close-input-channel
        • Read-file-objects
          • Read-object-all
          • Logical-story-of-io
          • Take-bytes
          • Std/io/peek-char$
          • Read-file-characters-rev
          • Read-file-as-string
          • Std/io/write-byte$
          • Std/io/set-serialize-character
          • Std/io/print-object$
          • Std/io/princ$
          • Std/io/read-file-into-string
          • *file-types*
        • Std/basic
        • Std/system
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Read-file-objects

    Read-object-all

    (read-object-all channel state) reads all remaining objects from a file.

    This is the main loop inside read-file-objects. It reads everything in the file, but doesn't handle opening or closing the file.

    Definitions and Theorems

    Function: tr-read-object-all

    (defun tr-read-object-all (channel state acc)
     (declare (xargs :guard (and (state-p state)
                                 (symbolp channel)
                                 (open-input-channel-p channel
                                                       :object state))))
     (b* (((unless (mbt (state-p state)))
           (mv acc state))
          ((mv eofp obj state)
           (read-object channel state))
          ((when eofp) (mv acc state)))
       (tr-read-object-all channel state (cons obj acc))))

    Function: read-object-all

    (defun read-object-all (channel state)
     (declare (xargs :guard (and (state-p state)
                                 (symbolp channel)
                                 (open-input-channel-p channel
                                                       :object state))))
     (mbe :logic
          (b* (((unless (state-p state))
                (mv nil state))
               ((mv eofp obj state)
                (read-object channel state))
               ((when eofp) (mv nil state))
               ((mv rest state)
                (read-object-all channel state)))
            (mv (cons obj rest) state))
          :exec
          (b* (((mv acc state)
                (tr-read-object-all channel state nil)))
            (mv (reverse acc) state))))

    Theorem: tr-read-object-all-removal

    (defthm tr-read-object-all-removal
      (equal (tr-read-object-all channel state nil)
             (mv (rev (mv-nth 0 (read-object-all channel state)))
                 (mv-nth 1 (read-object-all channel state)))))

    Theorem: true-listp-of-read-object-all

    (defthm true-listp-of-read-object-all
      (true-listp (mv-nth 0 (read-object-all channel state)))
      :rule-classes :type-prescription)

    Theorem: state-p1-of-read-object-all

    (defthm state-p1-of-read-object-all
      (implies (and (force (state-p1 state))
                    (force (symbolp channel))
                    (force (open-input-channel-p1 channel
                                                  :object state)))
               (state-p1 (mv-nth 1 (read-object-all channel state)))))

    Theorem: open-input-channel-p1-of-read-object-all

    (defthm open-input-channel-p1-of-read-object-all
     (implies (and (force (state-p1 state))
                   (force (symbolp channel))
                   (force (open-input-channel-p1 channel
                                                 :object state)))
              (open-input-channel-p1
                   channel
                   :object (mv-nth 1 (read-object-all channel state)))))