• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Bitcoin
      • Riscv
      • Des
      • Ethereum
      • X86isa
      • Sha-2
      • Yul
      • Zcash
      • Proof-checker-itp13
      • Regex
      • ACL2-programming-language
      • Json
      • Jfkr
      • Equational
      • Cryptography
      • Poseidon
      • Where-do-i-place-my-book
      • Axe
      • Bigmems
      • Builtins
      • 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
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • 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)