Transform a vl-maybe-nat-listp by combining contiguous
sequences of indices into
For example:
(vl-merge-contiguous-indices '(1 2 3 5 6 7 8 9 10 15 17 18)) --> ((1 . 3) (5 . 10) 15 (17 . 18))
Function:
(defun vl-merge-contiguous-indices (x) (declare (xargs :guard (vl-maybe-nat-listp x))) (if (atom x) nil (mv-let (range-end rest) (vl-match-contiguous-indices (car x) (cdr x)) (if (equal (car x) range-end) (cons (car x) (vl-merge-contiguous-indices (cdr x))) (cons (cons (car x) range-end) (vl-merge-contiguous-indices rest))))))
Theorem:
(defthm vl-merged-index-list-p-of-vl-merge-contiguous-indices (implies (force (vl-maybe-nat-listp x)) (vl-merged-index-list-p (vl-merge-contiguous-indices x))))