• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
      • Io
      • Defttag
      • Sys-call
      • Save-exec
      • Quicklisp
      • Std/io
        • Open-channel-lemmas
        • Std/io/read-char$
        • Std/io/read-object
        • Std/io/open-output-channel
        • Unsound-read
        • Read-string
        • Read-bytes$
          • Read-64ule
          • Read-64ube
          • Read-64sle
          • Read-64sbe
          • Read-32ule
          • Read-32sle
          • Read-32sbe
          • Read-32ube
          • Read-16sle
          • Read-16sbe
          • Read-16ule
          • Read-16ube
          • Read-8s
            • Combine-functions
          • File-measure
          • Read-bytes$-n
          • Std/io/read-byte$
          • Std/io/open-input-channel
          • Read-file-lines-no-newlines
          • Print-compressed
          • Nthcdr-bytes
          • Read-file-lines
          • Std/io/close-output-channel
          • Read-file-characters
          • Read-file-bytes
          • Print-legibly
          • Std/io/close-input-channel
          • Read-file-objects
          • Logical-story-of-io
          • Take-bytes
          • Std/io/peek-char$
          • Read-file-characters-rev
          • Read-file-as-string
          • Std/io/write-byte$
          • Std/io/set-serialize-character
          • Std/io/print-object$
          • Std/io/princ$
          • Std/io/read-file-into-string
          • *file-types*
        • Oslib
        • Bridge
        • Clex
        • Tshell
        • Unsound-eval
        • Hacker
        • ACL2s-interface
        • Startup-banner
        • Command-line
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Read-bytes$

    Read-8s

    (read-8s channel state) reads a signed byte from the input channel.

    Definitions and Theorems

    Function: read-8s

    (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: read-8s-signed-byte

    (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: read-8s-integer

    (defthm read-8s-integer
      (implies (mv-nth 0 (read-8s channel state))
               (integerp (mv-nth 0 (read-8s channel state)))))

    Theorem: read-8s-range

    (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: read-8s-state

    (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: read-8s-open-input-channel-p1

    (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)))))