• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
      • Io
      • Defttag
      • Sys-call
      • Save-exec
      • Quicklisp
      • Oslib
      • Std/io
      • Bridge
      • Clex
        • Example-lexer
        • Sin
        • Matching-functions
          • Sin-match-until-lit
          • Sin-match-lit
          • Sin-match-charset*
            • Sin-match-some-lit
            • Sin-match-through-lit
            • Sin-match-everything
            • Def-match-thms
          • Def-sin-progress
        • Tshell
        • Unsound-eval
        • Hacker
        • Startup-banner
        • Command-line
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Matching-functions

    Sin-match-charset*

    Match all leading characters in some charset-p.

    Signature
    (sin-match-charset* set sin) → (mv match sin)
    Arguments
    set — Set of characters that should be matched.
        Guard (charset-p set).
    sin — The sin stobj.
    Returns
    match — The largest prefix of the input stream consisting entirely of matching characters, or nil if there are no matching characters.
        Type (or (stringp match) (not match)).
    sin — The remainder of the input stream, with the match removed, if applicable.

    Examples:

    (defcharset num (str::digitp x))
    
    (sin-match-charset* (num-chars) [apple123])
      -->
    (nil [apple123])
    
    (sin-match-charset* (num-chars) [123apple])
      -->
    ("123" [apple])

    Definitions and Theorems

    Function: sin-match-charset*

    (defun sin-match-charset* (set sin)
           (declare (xargs :stobjs (sin)))
           (declare (xargs :guard (charset-p set)))
           (let ((__function__ 'sin-match-charset*))
                (declare (ignorable __function__))
                (b* ((num-matches (sin-count-charset set sin))
                     ((when (zp num-matches)) (mv nil sin))
                     (match1 (sin-firstn num-matches sin))
                     (sin (sin-nthcdr num-matches sin)))
                    (mv match1 sin))))

    Theorem: return-type-of-sin-match-charset*.match

    (defthm return-type-of-sin-match-charset*.match
            (b* (((mv ?match ?sin)
                  (sin-match-charset* set sin)))
                (or (stringp match) (not match)))
            :rule-classes :type-prescription)

    Theorem: stringp-of-sin-match-charset*.match

    (defthm stringp-of-sin-match-charset*.match
            (b* (((mv ?match ?new-sin)
                  (sin-match-charset* set sin)))
                (equal (stringp match)
                       (if match t nil))))

    Theorem: non-empty-of-sin-match-charset*.match

    (defthm non-empty-of-sin-match-charset*.match
            (b* (((mv ?match ?new-sin)
                  (sin-match-charset* set sin)))
                (equal (equal match "") nil)))

    Theorem: sin-match-charset*-progress-weak

    (defthm sin-match-charset*-progress-weak
            (b* (((mv ?match ?new-sin)
                  (sin-match-charset* set sin)))
                (<= (len (strin-left new-sin))
                    (len (strin-left sin))))
            :rule-classes ((:rewrite) (:linear)))

    Theorem: sin-match-charset*-progress-strong

    (defthm sin-match-charset*-progress-strong
            (b* (((mv ?match ?new-sin)
                  (sin-match-charset* set sin)))
                (implies match
                         (< (len (strin-left new-sin))
                            (len (strin-left sin)))))
            :rule-classes ((:rewrite) (:linear)))

    Theorem: sin-match-charset*-reconstruction

    (defthm sin-match-charset*-reconstruction
            (b* (((mv ?match ?new-sin)
                  (sin-match-charset* set sin)))
                (equal (append (explode match)
                               (strin-left new-sin))
                       (strin-left sin))))

    Theorem: sin-match-charset*-graceful-failure

    (defthm sin-match-charset*-graceful-failure
            (b* (((mv ?match ?new-sin)
                  (sin-match-charset* set sin)))
                (implies (not match)
                         (equal new-sin sin))))

    Theorem: sin-match-charset*-reconstruction-free

    (defthm sin-match-charset*-reconstruction-free
            (b* (((mv ?match ?new-sin)
                  (sin-match-charset* set sin)))
                (implies (equal chars (explode match))
                         (equal (append chars (strin-left new-sin))
                                (strin-left sin)))))

    Theorem: sin-match-charset*.match-succeeds

    (defthm sin-match-charset*.match-succeeds
            (b* (((mv ?match ?new-sin)
                  (sin-match-charset* set sin)))
                (implies (char-in-charset-p (sin-car sin) set)
                         match)))

    Theorem: chars-in-charset-p-of-sin-match-charset*.match

    (defthm chars-in-charset-p-of-sin-match-charset*.match
            (b* (((mv ?match ?new-sin)
                  (sin-match-charset* set sin)))
                (chars-in-charset-p (explode match)
                                    set)))