• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
      • X86isa
        • Program-execution
          • Dynamic-instrumentation
          • Initialize-x86-state
          • Binary-file-load-fn
          • Read-channel-into-memory
          • Setting-up-page-tables
          • Read-channel-into-byte-list
          • Init-zero-page
          • Linux-load
          • Read-file-into-memory
          • Read-file-into-byte-list
            • Init-sys-view
            • Load-elf-sections
            • Chars-to-c-str
            • String-to-c-str
            • Pack-u64
            • Pack-u32
            • Concrete-simulation-examples
            • Gdt-entry
          • Sdm-instruction-set-summary
          • Tlb
          • Running-linux
          • Introduction
          • Asmtest
          • X86isa-build-instructions
          • Publications
          • Contributors
          • Machine
          • Implemented-opcodes
          • To-do
          • Proof-utilities
          • Peripherals
          • Model-validation
          • Modelcalls
          • Concrete-simulation-examples
          • Utils
          • Debugging-code-proofs
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Program-execution

    Read-file-into-byte-list

    Signature
    (read-file-into-byte-list filename state) 
      → 
    (mv file-contents state)
    Arguments
    filename — Guard (stringp filename).
    Returns
    file-contents — Type (byte-listp file-contents), given (and (stringp filename) (state-p1 state)).
    state — Type (state-p1 state), given (and (stringp filename) (state-p1 state)).

    Definitions and Theorems

    Function: read-file-into-byte-list

    (defun read-file-into-byte-list (filename state)
      (declare (xargs :stobjs (state)))
      (declare (xargs :guard (stringp filename)))
      (let ((__function__ 'read-file-into-byte-list))
        (declare (ignorable __function__))
        (b* (((mv channel state)
              (open-input-channel filename
                                  :byte state))
             ((when (not channel)) (mv nil state))
             ((mv file-contents state)
              (read-channel-into-byte-list channel nil state))
             (state (close-input-channel channel state)))
          (mv (reverse file-contents) state))))

    Theorem: byte-listp-of-read-file-into-byte-list.file-contents

    (defthm byte-listp-of-read-file-into-byte-list.file-contents
      (implies (and (stringp filename)
                    (state-p1 state))
               (b* (((mv ?file-contents acl2::?state)
                     (read-file-into-byte-list filename state)))
                 (byte-listp file-contents)))
      :rule-classes :rewrite)

    Theorem: state-p1-of-read-file-into-byte-list.state

    (defthm state-p1-of-read-file-into-byte-list.state
      (implies (and (stringp filename)
                    (state-p1 state))
               (b* (((mv ?file-contents acl2::?state)
                     (read-file-into-byte-list filename state)))
                 (state-p1 state)))
      :rule-classes :rewrite)