• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
      • X86isa
      • Execloader
        • Elf-reader
        • Mach-o-reader
        • Merge-first-split-bytes
        • Split-bytes
        • Charlist->bytes
        • Take-till-zero
          • Merge-bytes
          • Bytes->charlist
          • Bytes->string
          • String->bytes
        • Axe
      • Testing-utilities
      • Math
    • Execloader

    Take-till-zero

    Return all initial elements of bytes until a 0 element is encountered or the end of bytes is reached, whichever happens first.

    Signature
    (take-till-zero bytes) → bs
    Arguments
    bytes — Guard (byte-listp bytes).
    Returns
    bs — Type (byte-listp bs), given the guard.

    Definitions and Theorems

    Function: take-till-zero

    (defun take-till-zero (bytes)
           (declare (xargs :guard (byte-listp bytes)))
           (let ((__function__ 'take-till-zero))
                (declare (ignorable __function__))
                (if (endp bytes)
                    nil
                    (if (equal (car bytes) 0)
                        nil
                        (cons (car bytes)
                              (take-till-zero (cdr bytes)))))))

    Theorem: byte-listp-of-take-till-zero

    (defthm byte-listp-of-take-till-zero
            (implies (and (byte-listp bytes))
                     (b* ((bs (take-till-zero bytes)))
                         (byte-listp bs)))
            :rule-classes :rewrite)