Read an entire file into a character-listp.
(read-file-characters filename state) → (mv errmsg/contents state)
Function:
(defun read-file-characters (filename state) (declare (xargs :stobjs (state))) (declare (xargs :guard (stringp filename))) (let ((__function__ 'read-file-characters)) (declare (ignorable __function__)) (b* ((filename (mbe :logic (if (stringp filename) filename "") :exec filename)) ((mv channel state) (open-input-channel filename :character state)) ((unless channel) (mv (concatenate 'string "Error opening file " filename) state)) ((mv contents state) (read-char$-all channel state)) (state (close-input-channel channel state))) (mv contents state))))
Theorem:
(defthm state-p1-of-read-file-characters (implies (force (state-p1 state)) (state-p1 (mv-nth 1 (read-file-characters filename state)))))
Theorem:
(defthm character-listp-of-read-file-characters (let ((contents (mv-nth 0 (read-file-characters filename state)))) (equal (character-listp contents) (not (stringp contents)))))
Theorem:
(defthm type-of-read-file-characters (or (true-listp (mv-nth 0 (read-file-characters filename state))) (stringp (mv-nth 0 (read-file-characters filename state)))) :rule-classes :type-prescription)