• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Mutual-recursion
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Defconst
        • Fast-alists
        • Defmacro
        • Loop$-primer
        • Evaluation
        • Guard
        • Equality-variants
        • Compilation
        • Hons
        • ACL2-built-ins
        • Developers-guide
        • System-attachments
        • Advanced-features
        • Set-check-invariant-risk
        • Numbers
        • Efficiency
        • Irrelevant-formals
        • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
        • Redefining-programs
        • Lists
          • Member
          • Append
          • List
          • Nth
          • Len
          • True-listp
          • String-listp
          • Nat-listp
          • Character-listp
          • Symbol-listp
          • True-list-listp
          • Length
          • Search
          • Intersection$
          • Union$
          • Remove-duplicates
          • Position
          • Update-nth
          • Take
          • Set-difference$
          • Nthcdr
          • Subsetp
          • No-duplicatesp
          • Concatenate
          • Remove
          • Remove1
          • Intersectp
          • Endp
          • Keyword-value-listp
          • Integer-listp
          • Reverse
          • Add-to-set
          • List-utilities
          • Set-size
          • Revappend
          • Subseq
          • Make-list
          • Lists-light
          • Boolean-listp
          • Butlast
          • Pairlis$
          • Substitute
          • Count
          • Keyword-listp
          • List*
          • Last
            • Std/lists/last
              • Last-theorems
            • Eqlable-listp
            • Integer-range-listp
            • Rational-listp
            • Pos-listp
            • Evens
            • Atom-listp
            • ACL2-number-listp
            • Typed-list-utilities
            • Odds
            • List$
            • Listp
            • 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
          • Oracle-eval
          • Defmacro-untouchable
          • <<
          • Primitive
          • Revert-world
          • Unmemoize
          • Set-duplicate-keys-action
          • Symbols
          • Def-list-constructor
          • Easy-simplify-term
          • Defiteration
          • Fake-oracle-eval
          • Defopen
          • Sleep
        • Operational-semantics
        • Real
        • Start-here
        • Miscellaneous
        • Output-controls
        • Bdd
        • Macros
        • Installation
        • Mailing-lists
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Std/lists
    • Last

    Std/lists/last

    Lemmas about last available in the std/lists library.

    Definitions and Theorems

    Theorem: last-when-atom

    (defthm last-when-atom
      (implies (atom x) (equal (last x) x)))

    Theorem: last-when-atom-of-cdr

    (defthm last-when-atom-of-cdr
      (implies (atom (cdr x))
               (equal (last x) x)))

    Theorem: last-of-cons

    (defthm last-of-cons
      (equal (last (cons a x))
             (if (consp x) (last x) (cons a x))))

    Theorem: consp-of-last

    (defthm consp-of-last
      (equal (consp (last l)) (consp l)))

    Theorem: true-listp-of-last

    (defthm true-listp-of-last
      (equal (true-listp (last l))
             (true-listp l)))

    Theorem: len-of-last

    (defthm len-of-last
      (equal (len (last l))
             (if (consp l) 1 0)))

    Theorem: upper-bound-of-len-of-last

    (defthm upper-bound-of-len-of-last
      (< (len (last x)) 2)
      :rule-classes :linear)

    Theorem: member-of-car-of-last

    (defthm member-of-car-of-last
      (iff (member (car (last x)) x)
           (if (consp x) t nil)))

    Theorem: subsetp-of-last

    (defthm subsetp-of-last
      (subsetp (last x) x))

    Theorem: last-of-append

    (defthm last-of-append
      (equal (last (append x y))
             (if (consp y)
                 (last y)
               (append (last x) y))))

    Theorem: last-of-rev

    (defthm last-of-rev
      (equal (last (rev x))
             (if (consp x) (list (car x)) nil)))

    Theorem: last-of-revappend

    (defthm last-of-revappend
      (equal (last (revappend x y))
             (cond ((consp y) (last y))
                   ((consp x) (cons (car x) y))
                   (t y))))

    Theorem: element-list-p-of-last

    (defthm element-list-p-of-last
      (implies (element-list-p (double-rewrite x))
               (element-list-p (last x)))
      :rule-classes :rewrite)