• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
          • World
          • Io
            • Fmt
            • Msg
            • Cw
            • Set-evisc-tuple
            • Set-iprint
            • Print-control
            • Read-file-into-string
            • Std/io
              • Open-channel-lemmas
              • Std/io/read-char$
              • Std/io/read-object
              • Std/io/open-output-channel
              • Unsound-read
              • Read-string
              • Read-bytes$
              • 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*
            • Msgp
            • Printing-to-strings
            • Evisc-tuple
            • Output-controls
            • Observation
            • *standard-co*
            • Ppr-special-syms
            • Standard-oi
            • Standard-co
            • Without-evisc
            • Serialize
            • Output-to-file
            • Fmt-to-comment-window
            • Princ$
            • Character-encoding
            • Open-output-channel!
            • Cw-print-base-radix
            • Set-print-case
            • Set-print-base
            • Print-object$
            • Extend-pathname
            • Print-object$+
            • Fmx-cw
            • Set-print-radix
            • Set-fmt-hard-right-margin
            • File-write-date$
            • Proofs-co
            • Set-print-base-radix
            • Print-base-p
            • *standard-oi*
            • Wof
            • File-length$
            • Fms!-lst
            • Delete-file$
            • *standard-ci*
            • Write-list
            • Trace-co
            • Fmt!
            • Fms
            • Cw!
            • Fmt-to-comment-window!
            • Fms!
            • Eviscerate-hide-terms
            • Fmt1!
            • Fmt-to-comment-window!+
            • Read-file-into-byte-array-stobj
            • Fmt1
            • Fmt-to-comment-window+
            • Cw-print-base-radix!
            • Read-file-into-character-array-stobj
            • Fmx
            • Cw!+
            • Read-objects-from-book
            • Newline
            • Cw+
            • Probe-file
            • Write-objects-to-file!
            • Write-objects-to-file
            • Read-objects-from-file
            • Read-object-from-file
            • Read-file-into-byte-list
            • Set-fmt-soft-right-margin
            • Read-file-into-character-list
            • Io-utilities
          • Wormhole
          • Programming-with-state
          • W
          • Set-state-ok
          • Random$
        • Mutual-recursion
        • Memoize
        • Mbe
        • Io
          • Fmt
          • Msg
          • Cw
          • Set-evisc-tuple
          • Set-iprint
          • Print-control
          • Read-file-into-string
          • Std/io
            • Open-channel-lemmas
            • Std/io/read-char$
            • Std/io/read-object
            • Std/io/open-output-channel
            • Unsound-read
            • Read-string
            • Read-bytes$
            • 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*
          • Msgp
          • Printing-to-strings
          • Evisc-tuple
          • Output-controls
          • Observation
          • *standard-co*
          • Ppr-special-syms
          • Standard-oi
          • Standard-co
          • Without-evisc
          • Serialize
          • Output-to-file
          • Fmt-to-comment-window
          • Princ$
          • Character-encoding
          • Open-output-channel!
          • Cw-print-base-radix
          • Set-print-case
          • Set-print-base
          • Print-object$
          • Extend-pathname
          • Print-object$+
          • Fmx-cw
          • Set-print-radix
          • Set-fmt-hard-right-margin
          • File-write-date$
          • Proofs-co
          • Set-print-base-radix
          • Print-base-p
          • *standard-oi*
          • Wof
          • File-length$
          • Fms!-lst
          • Delete-file$
          • *standard-ci*
          • Write-list
          • Trace-co
          • Fmt!
          • Fms
          • Cw!
          • Fmt-to-comment-window!
          • Fms!
          • Eviscerate-hide-terms
          • Fmt1!
          • Fmt-to-comment-window!+
          • Read-file-into-byte-array-stobj
          • Fmt1
          • Fmt-to-comment-window+
          • Cw-print-base-radix!
          • Read-file-into-character-array-stobj
          • Fmx
          • Cw!+
          • Read-objects-from-book
          • Newline
          • Cw+
          • Probe-file
          • Write-objects-to-file!
          • Write-objects-to-file
          • Read-objects-from-file
          • Read-object-from-file
          • Read-file-into-byte-list
          • Set-fmt-soft-right-margin
          • Read-file-into-character-list
          • Io-utilities
        • Defpkg
        • Apply$
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Defmacro
        • Loop$-primer
        • Fast-alists
        • Defconst
        • Evaluation
        • Guard
        • Equality-variants
        • Compilation
        • Hons
        • ACL2-built-ins
        • Developers-guide
        • System-attachments
        • Advanced-features
        • Set-check-invariant-risk
        • Numbers
        • Efficiency
        • Irrelevant-formals
        • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
        • Redefining-programs
        • Lists
        • Invariant-risk
        • Errors
        • Defabbrev
        • Conses
        • Alists
        • Set-register-invariant-risk
        • Strings
        • Program-wrapper
        • Get-internal-time
        • Basics
        • Packages
        • Oracle-eval
        • Defmacro-untouchable
        • <<
        • Primitive
        • Revert-world
        • Unmemoize
        • Set-duplicate-keys-action
        • Symbols
        • Def-list-constructor
        • Easy-simplify-term
        • Defiteration
        • Fake-oracle-eval
        • Defopen
        • Sleep
      • Operational-semantics
      • Real
      • Start-here
      • Debugging
      • Miscellaneous
      • Output-controls
      • Macros
      • Interfacing-tools
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
    • Testing-utilities
  • Std
  • Io
  • Interfacing-tools

Std/io

A library for reasoning about file input/output operations.

Introduction

The std/io library provides:

  • Basic lemmas about low-level, built-in ACL2 io operations like open-input-channel, read-byte$, close-output-channel, and so on. (These are especially useful for guard proofs about IO functions.)
  • A file-measure for proving the termination of functions that read from files.
  • Extended low-level file input operations such as read-bytes$, which lets you efficiently read 16-, 32-, and 64-bits from a file at once.
  • High-level operations for reading whole files, such as read-file-bytes, read-file-characters, and read-file-objects.

Some basic information about low-level i/o facilities in ACL2 can be found in io, and for some and also logical-story-of-io.

Loading the Library

If you just want to load the whole IO library, you can include the top book, e.g.,

(include-book "std/io/top" :dir :system)

But this may be more than you need. The library is split up into sensible books that can generally be loaded individually.

Subtopics

Open-channel-lemmas
Lemmas about when various state-modifying functions do and don't affect the list of open channels.
Std/io/read-char$
Read one character from an open :character stream.
Std/io/read-object
Read one object from an open :object stream.
Std/io/open-output-channel
Open a file for writing.
Unsound-read
A faster alternative to serialize-read, which is unsound in general, but may be fine in many common cases.
Read-string
Parse a string into s-expressions, by using Common Lisp's read under the hood. (requires a ttag)
Read-bytes$
Flexible macro for reading and combining 1, 2, 4, or 8 bytes from an open :byte input stream into a single value.
File-measure
A measure for admitting functions that read from files.
Read-bytes$-n
Flexible macro for reading whole lists of n 1-, 2-, 4-, or 8-byte values from an open :byte input stream.
Std/io/read-byte$
Read one byte from an open :byte stream.
Std/io/open-input-channel
Open an file for reading.
Read-file-lines-no-newlines
Read an entire file into a list of lines (strings), omitting newline characters from the resuting strings
Print-compressed
Wrapper for print-object$ that ensures serialize compression is enabled (if supported).
Nthcdr-bytes
Skip past some number of bytes in an open file.
Read-file-lines
Read an entire file into a list of lines (strings).
Std/io/close-output-channel
Close an output channel.
Read-file-characters
Read an entire file into a character-listp.
Read-file-bytes
Read an entire file into a list of (unsigned) bytes.
Print-legibly
Wrapper for print-object$ that ensures serialize compression is disabled.
Std/io/close-input-channel
Close an input channel.
Read-file-objects
Read an entire file into a list of ACL2 objects.
Logical-story-of-io
How file reading operations are modeled in the ACL2 logic.
Take-bytes
Read the first n bytes from an open file.
Std/io/peek-char$
Inspect the next character that will be read from an open :character input stream.
Read-file-characters-rev
Read an entire file into a character-listp, but in reverse order!
Read-file-as-string
Std/io/write-byte$
Write one byte to an open :byte output stream.
Std/io/set-serialize-character
Control the use of serialize in print-object$.
Std/io/print-object$
Print a Lisp object to an :object output stream.
Std/io/princ$
Print an atom to a :character output stream.
Std/io/read-file-into-string
*file-types*
Different ways to open files for reading and writing.