• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Hons-and-memoization
      • Events
      • History
      • Parallelism
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Mutual-recursion
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Loop$-primer
        • Fast-alists
        • Defmacro
        • Defconst
        • Evaluation
        • Guard
        • Equality-variants
        • Compilation
        • Hons
        • ACL2-built-ins
        • System-attachments
        • Developers-guide
        • Advanced-features
        • Set-check-invariant-risk
        • Numbers
        • Irrelevant-formals
        • Efficiency
        • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
        • Redefining-programs
        • Lists
          • Member
          • Append
          • Nth
          • List
          • Len
          • True-listp
          • Symbol-listp
          • String-listp
          • Nat-listp
          • Character-listp
          • True-list-listp
          • Length
          • Search
          • Intersection$
          • Union$
          • Remove-duplicates
          • Position
          • Take
          • Update-nth
          • Set-difference$
          • Subsetp
          • No-duplicatesp
          • Concatenate
          • Remove
          • Nthcdr
          • Remove1
          • Intersectp
          • Endp
          • Keyword-value-listp
          • Reverse
          • List-utilities
          • Add-to-set
          • Set-size
          • Integer-listp
          • Revappend
          • Subseq
            • Subseq-list
          • Make-list
          • Lists-light
          • Butlast
          • Pairlis$
          • Substitute
          • Count
          • Boolean-listp
          • List*
          • Keyword-listp
          • Eqlable-listp
          • Last
          • Integer-range-listp
          • Pos-listp
          • Rational-listp
          • Evens
          • Atom-listp
          • ACL2-number-listp
          • Good-atom-listp
          • Typed-list-utilities
          • Listp
          • Odds
          • Standard-char-listp
          • Last-cdr
          • Pairlis
          • Proper-consp
          • Improper-consp
          • Pairlis-x2
          • Pairlis-x1
          • Merge-sort-lexorder
          • Fix-true-list
          • Real-listp
        • Invariant-risk
        • Errors
        • Defabbrev
        • Conses
        • Alists
        • Set-register-invariant-risk
        • Strings
        • Program-wrapper
        • Get-internal-time
        • Basics
        • Packages
        • Defmacro-untouchable
        • Primitive
        • <<
        • Revert-world
        • Set-duplicate-keys-action
        • Unmemoize
        • Symbols
        • Def-list-constructor
        • Easy-simplify-term
        • Defiteration
        • Defopen
        • Sleep
      • Start-here
      • Real
      • Debugging
      • Miscellaneous
      • Output-controls
      • Macros
      • Interfacing-tools
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Testing-utilities
    • Math
  • Lists
  • Strings
  • ACL2-built-ins

Subseq

Subsequence of a string or list

For any natural numbers start and end, where start <= end <= (length seq), (subseq seq start end) is the subsequence of seq from index start up to, but not including, index end. End may be nil, in which case it is treated as though it is (length seq), i.e., we obtain the subsequence of seq from index start all the way to the end.

The guard for (subseq seq start end) is that seq is a true list or a string, start and end are integers (except, end may be nil, in which case it is treated as (length seq) for the rest of this discussion), and 0 <= start <= end <= (length seq).

Subseq is a Common Lisp function. See any Common Lisp documentation for more information. Note: In Common Lisp the third argument of subseq is optional, but in ACL2 it is required, though it may be nil as explained above.

Function: subseq

(defun
     subseq (seq start end)
     (declare (xargs :guard (and (or (true-listp seq) (stringp seq))
                                 (integerp start)
                                 (<= 0 start)
                                 (or (null end)
                                     (and (integerp end)
                                          (<= end (length seq))))
                                 (<= start (or end (length seq))))))
     (if (stringp seq)
         (coerce (subseq-list (coerce seq 'list)
                              start (or end (length seq)))
                 'string)
         (subseq-list seq start (or end (length seq)))))

Subtopics

Subseq-list
Lemmas about subseq-list available in the std/lists library.