• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
      • Std/lists
        • Std/lists/abstract
        • Rev
        • Defsort
        • List-fix
        • Std/lists/nth
        • Hons-remove-duplicates
        • Std/lists/update-nth
        • Set-equiv
        • Duplicity
        • Prefixp
        • Std/lists/take
        • Std/lists/intersection$
        • Nats-equiv
        • Repeat
        • Index-of
        • All-equalp
        • Sublistp
        • Std/lists/nthcdr
        • Std/lists/append
        • Listpos
        • List-equiv
        • Final-cdr
        • Std/lists/remove
        • Subseq-list
        • Rcons
        • Std/lists/revappend
        • Std/lists/remove-duplicates-equal
        • Std/lists/last
        • Std/lists/reverse
          • Std/lists/resize-list
          • Flatten
          • Suffixp
          • Std/lists/set-difference
          • Std/lists/butlast
          • Std/lists/len
          • Std/lists/intersectp
          • Std/lists/true-listp
          • Intersectp-witness
          • Subsetp-witness
          • Std/lists/remove1-equal
          • Rest-n
          • First-n
          • Std/lists/union
          • Append-without-guard
          • Std/lists/subsetp
          • Std/lists/member
        • Std/alists
        • Obags
        • Std/util
        • Std/strings
        • Std/io
        • Std/osets
        • Std/system
        • Std/basic
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
        • Std-extensions
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Std/lists
    • Reverse

    Std/lists/reverse

    Lemmas about reverse available in the std/lists library.

    The built-in reverse function is overly complex because it can operate on either lists or strings. To reverse a list, it is generally preferable to use rev, which has a very simple definition.

    We ordinarily expect reverse to be enabled, in which case it expands (in the list case) to (revappend x nil), which we generally expect to be rewritten to (rev x) due to the revappend-removal theorem.

    Because of this, we do not expect these lemmas to be very useful unless, for some reason, you have disabled reverse itself.

    Definitions and Theorems

    Theorem: stringp-of-reverse

    (defthm stringp-of-reverse
            (equal (stringp (reverse x))
                   (stringp x)))

    Theorem: true-listp-of-reverse

    (defthm true-listp-of-reverse
            (equal (true-listp (reverse x))
                   (not (stringp x))))

    Theorem: equal-of-reverses

    (defthm equal-of-reverses
            (equal (equal (reverse x) (reverse y))
                   (if (or (stringp x) (stringp y))
                       (and (stringp x)
                            (stringp y)
                            (equal x y))
                       (equal (list-fix x) (list-fix y)))))