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