• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • 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

    Rcons

    Cons onto the back of a list.

    (rcons a x) is like cons, except that instead of putting a onto front of the list x, it puts it at the end. To borrow ML notation, we compute x@[a] instead of a::x. This is obviously quite inefficient: we have to copy the whole list just to add one element!

    Definitions and Theorems

    Function: rcons

    (defun rcons (a x)
           (declare (xargs :guard t))
           (append-without-guard x (list a)))

    Theorem: type-of-rcons

    (defthm type-of-rcons
            (and (consp (rcons a x))
                 (true-listp (rcons a x)))
            :rule-classes :type-prescription)

    Theorem: rcons-of-list-fix

    (defthm rcons-of-list-fix
            (equal (rcons a (list-fix x))
                   (rcons a x)))

    Theorem: list-equiv-implies-equal-rcons-2

    (defthm list-equiv-implies-equal-rcons-2
            (implies (list-equiv x x-equiv)
                     (equal (rcons a x) (rcons a x-equiv)))
            :rule-classes (:congruence))

    Theorem: list-equiv-of-rcons-and-rcons

    (defthm list-equiv-of-rcons-and-rcons
            (equal (list-equiv (rcons a x) (rcons a y))
                   (list-equiv x y)))

    Theorem: len-of-rcons

    (defthm len-of-rcons
            (equal (len (rcons a x)) (+ 1 (len x))))

    Theorem: rev-of-rcons

    (defthm rev-of-rcons
            (equal (rev (rcons a x))
                   (cons a (rev x))))

    Theorem: append-of-rcons

    (defthm append-of-rcons
            (equal (append (rcons a x) y)
                   (append x (cons a y))))

    Theorem: rcons-of-append

    (defthm rcons-of-append
            (equal (rcons a (append x y))
                   (append x (rcons a y))))

    Theorem: revappend-of-rcons

    (defthm revappend-of-rcons
            (equal (revappend (rcons a x) y)
                   (cons a (revappend x y))))

    Theorem: element-list-p-of-rcons

    (defthm element-list-p-of-rcons
            (iff (element-list-p (rcons a x))
                 (and (element-p a)
                      (element-list-p (list-fix x))))
            :rule-classes :rewrite)