(read-32ube channel state) reads a 32-bit, unsigned, big-endian value from the input channel.
Function:
(defun read-32ube (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 (combine32u x1 x2 x3 x4) state)))
Theorem:
(defthm read-32ube-unsigned-byte (implies (and (force (state-p1 state)) (force (open-input-channel-p1 channel :byte state)) (force (symbolp channel)) (mv-nth 0 (read-32ube channel state)) (not (equal (mv-nth 0 (read-32ube channel state)) 'fail))) (unsigned-byte-p 32 (mv-nth 0 (read-32ube channel state)))))
Theorem:
(defthm read-32ube-integer (implies (and (mv-nth 0 (read-32ube channel state)) (not (equal (mv-nth 0 (read-32ube channel state)) 'fail))) (integerp (mv-nth 0 (read-32ube channel state)))))
Theorem:
(defthm read-32ube-range (implies (and (force (state-p1 state)) (force (open-input-channel-p1 channel :byte state)) (force (symbolp channel)) (mv-nth 0 (read-32ube channel state)) (not (equal (mv-nth 0 (read-32ube channel state)) 'fail))) (and (<= 0 (mv-nth 0 (read-32ube channel state))) (< (mv-nth 0 (read-32ube channel state)) 4294967296) (< (mv-nth 0 (read-32ube channel state)) (expt 2 32)))) :rule-classes :linear)
Theorem:
(defthm read-32ube-state (implies (and (force (state-p1 state)) (force (open-input-channel-p1 channel :byte state)) (force (symbolp channel))) (state-p1 (mv-nth 1 (read-32ube channel state)))))
Theorem:
(defthm read-32ube-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-32ube channel state)))))