(read-64sbe channel state) reads a 64-bit, signed, big-endian value from the input channel.
Function:
(defun read-64sbe (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)) ((mv x5 state) (read-byte$ channel state)) ((mv x6 state) (read-byte$ channel state)) ((mv x7 state) (read-byte$ channel state)) ((mv x8 state) (read-byte$ channel state)) ((unless x1) (mv nil state)) ((unless x8) (mv 'fail state))) (mv (combine64s x1 x2 x3 x4 x5 x6 x7 x8) state)))
Theorem:
(defthm read-64sbe-signed-byte (implies (and (force (state-p1 state)) (force (open-input-channel-p1 channel :byte state)) (force (symbolp channel)) (mv-nth 0 (read-64sbe channel state)) (not (equal (mv-nth 0 (read-64sbe channel state)) 'fail))) (signed-byte-p 64 (mv-nth 0 (read-64sbe channel state)))))
Theorem:
(defthm read-64sbe-integer (implies (and (mv-nth 0 (read-64sbe channel state)) (not (equal (mv-nth 0 (read-64sbe channel state)) 'fail))) (integerp (mv-nth 0 (read-64sbe channel state)))))
Theorem:
(defthm read-64sbe-range (implies (and (force (state-p1 state)) (force (open-input-channel-p1 channel :byte state)) (force (symbolp channel)) (mv-nth 0 (read-64sbe channel state)) (not (equal (mv-nth 0 (read-64sbe channel state)) 'fail))) (and (<= -9223372036854775808 (mv-nth 0 (read-64sbe channel state))) (<= (- (expt 2 63)) (mv-nth 0 (read-64sbe channel state))) (< (mv-nth 0 (read-64sbe channel state)) 9223372036854775808) (< (mv-nth 0 (read-64sbe channel state)) (expt 2 63)))) :rule-classes :linear)
Theorem:
(defthm read-64sbe-state (implies (and (force (state-p1 state)) (force (open-input-channel-p1 channel :byte state)) (force (symbolp channel))) (state-p1 (mv-nth 1 (read-64sbe channel state)))))
Theorem:
(defthm read-64sbe-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-64sbe channel state)))))