Identify one strictly increasing segment of a vl-maybe-nat-listp.
(vl-match-contiguous-indices n x) tries to consume the leading
portion of
(vl-match-contiguous-indices 1 '(2 3 4 5 10 11 12)) --> (mv 5 (10 11 12))
We use when collapsing emod names into Verilog-style names; see vl-merge-contiguous-indices.
Function:
(defun vl-match-contiguous-indices (n x) (declare (xargs :guard (and (maybe-natp n) (vl-maybe-nat-listp x)))) (if (or (not (natp n)) (atom x) (not (equal (car x) (+ n 1)))) (mv n x) (vl-match-contiguous-indices (+ n 1) (cdr x))))
Theorem:
(defthm maybe-natp-of-vl-match-contiguous-indices (implies (and (force (maybe-natp n)) (force (vl-maybe-nat-listp x))) (maybe-natp (mv-nth 0 (vl-match-contiguous-indices n x)))))
Theorem:
(defthm vl-maybe-nat-listp-of-vl-match-contiguous-indices (implies (and (force (maybe-natp n)) (force (vl-maybe-nat-listp x))) (vl-maybe-nat-listp (mv-nth 1 (vl-match-contiguous-indices n x)))))
Theorem:
(defthm len-of-vl-match-contiguous-indices (implies (not (equal n (mv-nth 0 (vl-match-contiguous-indices n x)))) (< (len (mv-nth 1 (vl-match-contiguous-indices n x))) (len x))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm vl-match-contiguous-indices-fails-on-nil (equal (mv-nth 0 (vl-match-contiguous-indices nil x)) nil))
Theorem:
(defthm vl-match-contiguous-indices-monotonic-on-success (implies (and (not (equal n (mv-nth 0 (vl-match-contiguous-indices n x)))) (force (maybe-natp n)) (force (vl-maybe-nat-listp x))) (< n (mv-nth 0 (vl-match-contiguous-indices n x)))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm vl-match-contiguous-indices-exists-on-success (implies (and (not (equal n (mv-nth 0 (vl-match-contiguous-indices n x)))) (force (maybe-natp n)) (force (vl-maybe-nat-listp x))) (natp (mv-nth 0 (vl-match-contiguous-indices n x)))))