String-based version of lc-nthcdr.
(lc-nthcdr-str n x pos xl line col) → (mv new-pos new-line new-col)
Function:
(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:
(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:
(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:
(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)