• 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

    Line-after-nthcdr

    Determine what the new line number should be after we advance n characters.

    Signature
    (line-after-nthcdr n x line) → new-line
    Arguments
    n — How many characters to cdr.
        Guard (natp n).
    x — Characters we're processing.
        Guard (character-listp x).
    line — Current line number.
        Guard (natp line).
    Returns
    new-line — Type (natp new-line).

    This is a logically simple way to express how the line number gets updated. It isn't really meant to be executed.

    Definitions and Theorems

    Function: line-after-nthcdr

    (defun line-after-nthcdr (n x line)
      (declare (xargs :guard (and (natp n)
                                  (character-listp x)
                                  (natp line))))
      (let ((__function__ 'line-after-nthcdr))
        (declare (ignorable __function__))
        (if (or (zp n) (atom x))
            (lnfix line)
          (line-after-nthcdr (- n 1)
                             (cdr x)
                             (if (eql (car x) #\Newline)
                                 (+ 1 (lnfix line))
                               (lnfix line))))))

    Theorem: natp-of-line-after-nthcdr

    (defthm natp-of-line-after-nthcdr
      (b* ((new-line (line-after-nthcdr n x line)))
        (natp new-line))
      :rule-classes :type-prescription)

    Theorem: nat-equiv-implies-equal-line-after-nthcdr-1

    (defthm nat-equiv-implies-equal-line-after-nthcdr-1
      (implies (nat-equiv n n-equiv)
               (equal (line-after-nthcdr n x line)
                      (line-after-nthcdr n-equiv x line)))
      :rule-classes (:congruence))

    Theorem: nat-equiv-implies-equal-line-after-nthcdr-3

    (defthm nat-equiv-implies-equal-line-after-nthcdr-3
      (implies (nat-equiv line line-equiv)
               (equal (line-after-nthcdr n x line)
                      (line-after-nthcdr n x line-equiv)))
      :rule-classes (:congruence))

    Theorem: lower-bound-of-line-after-nthcdr

    (defthm lower-bound-of-line-after-nthcdr
      (<= (nfix line)
          (line-after-nthcdr n x line))
      :rule-classes ((:rewrite) (:linear)))

    Theorem: upper-bound-1-of-line-after-nthcdr

    (defthm upper-bound-1-of-line-after-nthcdr
      (<= (line-after-nthcdr n x line)
          (+ (nfix line) (nfix n)))
      :rule-classes ((:rewrite) (:linear)))

    Theorem: upper-bound-2-of-line-after-nthcdr

    (defthm upper-bound-2-of-line-after-nthcdr
      (<= (line-after-nthcdr n x line)
          (+ (nfix line) (len x)))
      :rule-classes ((:rewrite) (:linear)))