(read-8s channel state) reads a signed byte from the input channel.
Function:
(defun read-8s (channel state) (declare (xargs :guard (and (state-p state) (symbolp channel) (open-input-channel-p channel :byte state)))) (b* (((mv byte state) (read-byte$ channel state)) ((unless byte) (mv nil state))) (mv (fast-logext 8 byte) state)))
Theorem:
(defthm read-8s-signed-byte (implies (and (mv-nth 0 (read-8s channel state)) (force (state-p1 state)) (force (open-input-channel-p1 channel :byte state)) (force (symbolp channel))) (signed-byte-p 8 (mv-nth 0 (read-8s channel state)))))
Theorem:
(defthm read-8s-integer (implies (mv-nth 0 (read-8s channel state)) (integerp (mv-nth 0 (read-8s channel state)))))
Theorem:
(defthm read-8s-range (implies (and (mv-nth 0 (read-8s channel state)) (force (state-p1 state)) (force (open-input-channel-p1 channel :byte state)) (force (symbolp channel))) (and (<= -128 (mv-nth 0 (read-8s channel state))) (<= (- (expt 2 7)) (mv-nth 0 (read-8s channel state))) (< (mv-nth 0 (read-8s channel state)) 128) (< (mv-nth 0 (read-8s channel state)) (expt 2 7)))) :rule-classes :linear)
Theorem:
(defthm read-8s-state (implies (and (force (state-p1 state)) (force (open-input-channel-p1 channel :byte state)) (force (symbolp channel))) (state-p1 (mv-nth 1 (read-8s channel state)))))
Theorem:
(defthm read-8s-open-input-channel-p1 (implies (and (force (state-p1 state)) (force (open-input-channel-p1 channel :byte state)) (force (symbolp channel))) (open-input-channel-p1 channel :byte (mv-nth 1 (read-8s channel state)))))