Determine what the new column number should be after we advance
(col-after-nthcdr n x col) → new-col
This is a logically simple way to express how the column number gets updated. It isn't really meant to be executed.
Function:
(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:
(defthm natp-of-col-after-nthcdr (b* ((new-col (col-after-nthcdr n x col))) (natp new-col)) :rule-classes :type-prescription)
Theorem:
(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:
(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:
(defthm upper-bound-1-of-col-after-nthcdr (<= (col-after-nthcdr n x col) (+ (nfix col) (nfix n))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm upper-bound-2-of-col-after-nthcdr (<= (col-after-nthcdr n x col) (+ (nfix col) (len x))) :rule-classes ((:rewrite) (:linear)))