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