• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
      • Std/lists
      • Std/alists
      • Obags
      • Std/util
      • Std/strings
        • Pretty-printing
        • Printtree
        • Base64
        • Charset-p
        • Strtok!
        • Cases
        • Concatenation
        • Html-encoding
        • Character-kinds
        • Substrings
        • Strtok
          • Strtok-aux
          • Equivalences
          • Url-encoding
          • Lines
          • Explode-implode-equalities
          • Ordering
          • Numbers
          • Pad-trim
          • Coercion
          • Std/strings/digit-to-char
          • Substitution
          • Symbols
        • Std/osets
        • Std/io
        • Std/basic
        • Std/system
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Strtok

    Strtok-aux

    Fast implementation of strtok.

    Definitions and Theorems

    Function: strtok-aux

    (defun strtok-aux (x n xl delimiters curr acc)
      (declare (type string x)
               (type (integer 0 *) n xl)
               (xargs :guard (and (stringp x)
                                  (natp xl)
                                  (natp n)
                                  (<= xl (length x))
                                  (<= n xl)
                                  (character-listp delimiters)
                                  (character-listp curr)
                                  (string-listp acc))))
      (if (mbe :logic (zp (- (nfix xl) (nfix n)))
               :exec (int= n xl))
          (if curr (cons (rchars-to-string curr) acc)
            acc)
        (let* ((char1 (char x n))
               (matchp (member char1 delimiters)))
          (strtok-aux (the string x)
                      (the (integer 0 *) (+ 1 (lnfix n)))
                      (the integer xl)
                      delimiters
                      (if matchp nil (cons char1 curr))
                      (if (and matchp curr)
                          (cons (rchars-to-string curr) acc)
                        acc)))))

    Theorem: true-listp-of-strtok-aux

    (defthm true-listp-of-strtok-aux
      (implies (true-listp acc)
               (true-listp (strtok-aux x n xl delimiters curr acc))))

    Theorem: string-listp-of-strtok-aux

    (defthm string-listp-of-strtok-aux
      (implies (string-listp acc)
               (string-listp (strtok-aux x n xl delimiters curr acc))))

    Theorem: streqv-implies-equal-strtok-aux-1

    (defthm streqv-implies-equal-strtok-aux-1
      (implies (streqv x x-equiv)
               (equal (strtok-aux x n xl delimiters curr acc)
                      (strtok-aux x-equiv n xl delimiters curr acc)))
      :rule-classes (:congruence))