A measure for admitting functions that read from files.
Signature: (file-measure channel state-state) returns a natural number.
This is a logic-mode function, but its logical definition is tricky; see logical-story-of-io. The basic gist is that it returns how many objects are left in the channel and hence how many functions can still be read.
This function is only meant to be used to admit functions, and cannot be executed on the real ACL2 state.
Function:
(defun file-measure (channel state-state) (declare (xargs :guard (and (symbolp channel) (state-p1 state-state)))) (+ (len (cddr (assoc-equal channel (open-input-channels state-state)))) (if (consp (cddr (assoc-equal channel (open-input-channels state-state)))) (if (cdr (last (cddr (assoc-equal channel (open-input-channels state-state))))) 1 0) (if (cddr (assoc-equal channel (open-input-channels state-state))) 1 0))))
Theorem:
(defthm file-measure-of-read-byte$-weak (<= (file-measure channel (mv-nth 1 (read-byte$ channel state))) (file-measure channel state)) :rule-classes (:rewrite :linear))
Theorem:
(defthm file-measure-of-read-byte$-strong (implies (mv-nth 0 (read-byte$ channel state)) (< (file-measure channel (mv-nth 1 (read-byte$ channel state))) (file-measure channel state))) :rule-classes (:rewrite :linear))
Theorem:
(defthm file-measure-of-read-byte$-rw (implies (mv-nth 0 (read-byte$ channel state)) (equal (file-measure channel (mv-nth 1 (read-byte$ channel state))) (+ -1 (file-measure channel state)))))
Theorem:
(defthm file-measure-of-read-char$-weak (<= (file-measure channel (mv-nth 1 (read-char$ channel state))) (file-measure channel state)) :rule-classes (:rewrite :linear))
Theorem:
(defthm file-measure-of-read-char$-strong (implies (mv-nth 0 (read-char$ channel state)) (< (file-measure channel (mv-nth 1 (read-char$ channel state))) (file-measure channel state))) :rule-classes (:rewrite :linear))
Theorem:
(defthm file-measure-of-read-char$-rw (implies (mv-nth 0 (read-char$ channel state)) (equal (file-measure channel (mv-nth 1 (read-char$ channel state))) (1- (file-measure channel state)))))
Theorem:
(defthm file-measure-of-read-object-weak (<= (file-measure channel (mv-nth 2 (read-object channel state))) (file-measure channel state)) :rule-classes (:rewrite :linear))
Theorem:
(defthm file-measure-of-read-object-rw (implies (not (mv-nth 0 (read-object channel state))) (equal (file-measure channel (mv-nth 2 (read-object channel state))) (1- (file-measure channel state)))))
Theorem:
(defthm file-measure-of-read-object-strong (implies (not (mv-nth 0 (read-object channel state))) (< (file-measure channel (mv-nth 2 (read-object channel state))) (file-measure channel state))) :rule-classes (:rewrite :linear))
Theorem:
(defthm file-measure-type (natp (file-measure channel state)) :rule-classes :type-prescription)