• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • ACL2
    • Macro-libraries
    • 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-channel-into-memory

    Signature
    (read-channel-into-memory channel ptr bytes-read x86 state) 
      → 
    (mv bytes-read x86 state)
    Arguments
    channel — Guard (symbolp channel).
    ptr — Guard (canonical-address-p ptr).
    bytes-read — Guard (natp bytes-read).
    Returns
    bytes-read — Type (natp bytes-read), given (and (state-p1 state) (symbolp channel) (open-input-channel-p channel :byte state)) .
    x86 — Type (x86p x86), given (x86p x86).
    state — Type (state-p1 state), given (and (state-p1 state) (symbolp channel) (open-input-channel-p1 channel :byte state)) .

    Definitions and Theorems

    Function: read-channel-into-memory

    (defun read-channel-into-memory (channel ptr bytes-read x86 state)
     (declare (xargs :stobjs (x86 state)))
     (declare (xargs :guard (and (symbolp channel)
                                 (canonical-address-p ptr)
                                 (natp bytes-read))))
     (declare
          (xargs :guard (and (open-input-channel-p channel
                                                   :byte state)
                             (canonical-address-p (+ ptr bytes-read)))))
     (let ((__function__ 'read-channel-into-memory))
      (declare (ignorable __function__))
      (b* ((bytes-read (nfix bytes-read))
           ((mv current-byte state)
            (read-byte$ channel state))
           ((when (not current-byte))
            (mv bytes-read x86 state))
           ((mv flg x86)
            (wml08 (+ ptr bytes-read)
                   current-byte x86))
           ((when (or flg
                      (not (canonical-address-p (+ ptr bytes-read 1)))))
            (mv bytes-read x86 state)))
        (read-channel-into-memory channel ptr (1+ bytes-read)
                                  x86 state))))

    Theorem: natp-of-read-channel-into-memory.bytes-read

    (defthm natp-of-read-channel-into-memory.bytes-read
     (implies
       (and (state-p1 state)
            (symbolp channel)
            (open-input-channel-p channel
                                  :byte state))
       (b*
         (((mv ?bytes-read ?x86 acl2::?state)
           (read-channel-into-memory channel ptr bytes-read x86 state)))
         (natp bytes-read)))
     :rule-classes :rewrite)

    Theorem: x86p-of-read-channel-into-memory.x86

    (defthm x86p-of-read-channel-into-memory.x86
     (implies
       (x86p x86)
       (b*
         (((mv ?bytes-read ?x86 acl2::?state)
           (read-channel-into-memory channel ptr bytes-read x86 state)))
         (x86p x86)))
     :rule-classes :rewrite)

    Theorem: state-p1-of-read-channel-into-memory.state

    (defthm state-p1-of-read-channel-into-memory.state
     (implies
       (and (state-p1 state)
            (symbolp channel)
            (open-input-channel-p1 channel
                                   :byte state))
       (b*
         (((mv ?bytes-read ?x86 acl2::?state)
           (read-channel-into-memory channel ptr bytes-read x86 state)))
         (state-p1 state)))
     :rule-classes :rewrite)

    Theorem: read-channel-into-memory-leaves-channel-open

    (defthm read-channel-into-memory-leaves-channel-open
     (implies
      (open-input-channel-p1 channel
                             :byte state)
      (open-input-channel-p1
       channel
       :byte
       (mv-nth
         2
         (read-channel-into-memory channel ptr bytes-read x86 state)))))