(read-32sle channel state) reads a 32-bit, signed, little-endian value from the input channel.
Function:
(defun read-32sle (channel state) (declare (xargs :guard (and (state-p state) (symbolp channel) (open-input-channel-p channel :byte state)))) (b* (((mv x1 state) (read-byte$ channel state)) ((mv x2 state) (read-byte$ channel state)) ((mv x3 state) (read-byte$ channel state)) ((mv x4 state) (read-byte$ channel state)) ((unless x1) (mv nil state)) ((unless x4) (mv 'fail state))) (mv (combine32s x4 x3 x2 x1) state)))
Theorem:
(defthm read-32sle-signed-byte (implies (and (force (state-p1 state)) (force (open-input-channel-p1 channel :byte state)) (force (symbolp channel)) (mv-nth 0 (read-32sle channel state)) (not (equal (mv-nth 0 (read-32sle channel state)) 'fail))) (signed-byte-p 32 (mv-nth 0 (read-32sle channel state)))))
Theorem:
(defthm read-32sle-integer (implies (and (mv-nth 0 (read-32sle channel state)) (not (equal (mv-nth 0 (read-32sle channel state)) 'fail))) (integerp (mv-nth 0 (read-32sle channel state)))))
Theorem:
(defthm read-32sle-range (implies (and (force (state-p1 state)) (force (open-input-channel-p1 channel :byte state)) (force (symbolp channel)) (mv-nth 0 (read-32sle channel state)) (not (equal (mv-nth 0 (read-32sle channel state)) 'fail))) (and (<= -2147483648 (mv-nth 0 (read-32sle channel state))) (<= (- (expt 2 31)) (mv-nth 0 (read-32sle channel state))) (< (mv-nth 0 (read-32sle channel state)) 2147483648) (< (mv-nth 0 (read-32sle channel state)) (expt 2 31)))) :rule-classes :linear)
Theorem:
(defthm read-32sle-state (implies (and (force (state-p1 state)) (force (open-input-channel-p1 channel :byte state)) (force (symbolp channel))) (state-p1 (mv-nth 1 (read-32sle channel state)))))
Theorem:
(defthm read-32sle-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-32sle channel state)))))