Read an entire file into a list of ACL2 objects.
Signature: (read-file-objects filename state) returns
On success,
On failure, e.g., perhaps
Function:
(defun read-file-objects (filename state) "Returns (MV ERRMSG/OBJECTS STATE)" (declare (xargs :guard (and (state-p state) (stringp filename)))) (b* ((filename (mbe :logic (if (stringp filename) filename "") :exec filename)) ((mv channel state) (open-input-channel filename :object state)) ((unless channel) (mv (concatenate 'string "Error opening file " filename) state)) ((mv data state) (read-object-all channel state)) (state (close-input-channel channel state))) (mv data state)))
Theorem:
(defthm state-p1-of-read-file-objects (implies (force (state-p1 state)) (state-p1 (mv-nth 1 (read-file-objects filename state)))))
Theorem:
(defthm true-listp-of-read-file-objects (equal (true-listp (mv-nth 0 (read-file-objects filename state))) (not (stringp (mv-nth 0 (read-file-objects filename state))))))
Theorem:
(defthm type-of-read-file-objects (or (stringp (mv-nth 0 (read-file-objects filename state))) (true-listp (mv-nth 0 (read-file-objects filename state)))) :rule-classes :type-prescription)