• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
      • Io
      • Defttag
      • Sys-call
      • Save-exec
      • Quicklisp
      • Std/io
      • Oslib
      • Bridge
      • Clex
        • Example-lexer
        • Sin
          • Strin-p
          • Sin$c
            • Line-and-column-tracking
              • Lc-nthcdr-str
                • Line-after-nthcdr
                • Col-after-nthcdr
                • Lc-nthcdr
                • Lc-nthcdr-str-fast
              • Sin$c-okp
              • Sin$c-init
              • Sin$c-nthcdr
              • Sin$c-cdr
              • Sin$c-firstn
              • Sin$c-count-charset
              • Sin$c-nth
              • Sin$c-matches-p
              • Sin$c-imatches-p
              • Sin$c-find
              • Sin$c-len
              • Sin$c-endp
              • Sin$c-car
              • Sin$corr
              • Sin$c-get-line
              • Sin$c-get-file
              • Sin$c-get-col
          • Matching-functions
          • Def-sin-progress
        • Tshell
        • Unsound-eval
        • Hacker
        • ACL2s-interface
        • Startup-banner
        • Command-line
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Line-and-column-tracking

    Lc-nthcdr-str

    String-based version of lc-nthcdr.

    Signature
    (lc-nthcdr-str n x pos xl line col) 
      → 
    (mv new-pos new-line new-col)
    Arguments
    n — How many characters to advance.
        Guard (natp n).
    x — String we're processing.
        Guard (stringp x).
    pos — Current index into x.
        Guard (natp pos).
    xl — Pre-computed length of x.
        Guard (equal xl (length x)).
    line — Current line number.
        Guard (natp line).
    col — Current column number.
        Guard (natp col).
    Returns
    new-pos — Type (natp new-pos).
    new-line — Type (natp new-line).
    new-col — Type (natp new-col).

    Definitions and Theorems

    Function: lc-nthcdr-str

    (defun lc-nthcdr-str (n x pos xl line col)
      (declare (xargs :guard (and (natp n)
                                  (stringp x)
                                  (natp pos)
                                  (natp line)
                                  (natp col)
                                  (equal xl (length x)))))
      (declare (type (integer 0 *) n pos xl line col)
               (type string x))
      (declare (xargs :guard (<= pos xl)))
      (let ((__function__ 'lc-nthcdr-str))
        (declare (ignorable __function__))
        (mbe :logic
             (let ((chars (nthcdr pos (coerce x 'list))))
               (mv (min (+ (nfix pos) (nfix n)) (nfix xl))
                   (line-after-nthcdr n chars line)
                   (col-after-nthcdr n chars col)))
             :exec
             (b* (((when (or (zp n) (eql pos xl)))
                   (mv pos line col))
                  ((the character char1) (char x pos))
                  ((the (integer 0 *) n) (- n 1))
                  ((the (integer 0 *) pos) (+ 1 pos)))
               (if (eql char1 #\Newline)
                   (lc-nthcdr-str n x pos xl (+ 1 line) 0)
                 (lc-nthcdr-str n x pos xl line (+ 1 col)))))))

    Theorem: natp-of-lc-nthcdr-str.new-pos

    (defthm natp-of-lc-nthcdr-str.new-pos
      (b* (((mv ?new-pos ?new-line ?new-col)
            (lc-nthcdr-str n x pos xl line col)))
        (natp new-pos))
      :rule-classes :type-prescription)

    Theorem: natp-of-lc-nthcdr-str.new-line

    (defthm natp-of-lc-nthcdr-str.new-line
      (b* (((mv ?new-pos ?new-line ?new-col)
            (lc-nthcdr-str n x pos xl line col)))
        (natp new-line))
      :rule-classes :type-prescription)

    Theorem: natp-of-lc-nthcdr-str.new-col

    (defthm natp-of-lc-nthcdr-str.new-col
      (b* (((mv ?new-pos ?new-line ?new-col)
            (lc-nthcdr-str n x pos xl line col)))
        (natp new-col))
      :rule-classes :type-prescription)