• 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

    Col-after-nthcdr

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

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

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

    Definitions and Theorems

    Function: col-after-nthcdr

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

    Theorem: natp-of-col-after-nthcdr

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

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

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

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

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

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

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

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

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