• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Fgl
      • Vl
        • Syntax
        • Loader
        • Warnings
        • Getting-started
        • Utilities
          • Name-database
          • Vl-gc
          • Symbol-list-names
          • Ints-from
          • Nats-from
          • Make-lookup-alist
          • Redundant-mergesort
          • Longest-common-prefix
          • Vl-remove-keys
          • Vl-plural-p
          • Vl-merge-contiguous-indices
            • Vl-match-contiguous-indices
            • Vl-merged-index-list-p
            • Vl-merged-index-p
          • Sum-nats
          • Vl-edition-p
          • Vl-maybe-integer-listp
          • Fast-memberp
          • Nat-listp
          • Max-nats
          • Longest-common-prefix-list
          • Character-list-listp
          • Vl-character-list-list-values-p
          • Remove-from-alist
          • Prefix-of-eachp
          • Vl-string-keys-p
          • Vl-maybe-nat-listp
          • Vl-string-list-values-p
          • String-list-listp
          • Vl-string-values-p
          • Explode-list
          • True-list-listp
          • Symbol-list-listp
          • All-have-len
          • Pos-listp
          • Min-nats
          • Debuggable-and
          • Vl-starname
          • Remove-equal-without-guard
          • String-fix
          • Anyp
          • Vl-maybe-string-list
          • Longer-than-p
          • Fast-alist-free-each-alist-val
          • Not*
          • Free-list-of-fast-alists
          • *nls*
        • Printer
        • Kit
        • Mlib
        • Transforms
      • X86isa
      • Svl
      • Rtl
    • Software-verification
    • Testing-utilities
    • Math
  • Utilities

Vl-merge-contiguous-indices

Transform a vl-maybe-integer-listp by combining contiguous sequences of indices into (low . high) pairs.

Signature
(vl-merge-contiguous-indices x) → indices
Arguments
x — Guard (vl-maybe-integer-listp x).
Returns
indices — Type (vl-merged-index-list-p indices), given the guard.

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))

Definitions and Theorems

Function: vl-merge-contiguous-indices

(defun vl-merge-contiguous-indices (x)
       (declare (xargs :guard (vl-maybe-integer-listp x)))
       (let ((__function__ 'vl-merge-contiguous-indices))
            (declare (ignorable __function__))
            (b* (((when (atom x)) nil)
                 ((mv range-end rest)
                  (vl-match-contiguous-indices (car x)
                                               (cdr x)))
                 ((when (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: vl-merged-index-list-p-of-vl-merge-contiguous-indices

(defthm vl-merged-index-list-p-of-vl-merge-contiguous-indices
        (implies (and (force (vl-maybe-integer-listp x)))
                 (b* ((indices (vl-merge-contiguous-indices x)))
                     (vl-merged-index-list-p indices)))
        :rule-classes :rewrite)

Subtopics

Vl-match-contiguous-indices
Identify one strictly increasing segment of a vl-maybe-integer-listp.
Vl-merged-index-list-p
(vl-merged-index-list-p x) recognizes lists where every element satisfies vl-merged-index-p.
Vl-merged-index-p