Lemmas about butlast available in the std/lists library.
The usual definition of
Theorem:
(defthm butlast-redefinition (equal (butlast x n) (if (>= (nfix n) (len x)) nil (cons (car x) (butlast (cdr x) n)))) :rule-classes ((:definition :clique (butlast) :controller-alist ((butlast t t)))))
Function:
(defun butlast-induction (x n) (if (>= (nfix n) (len x)) nil (cons (car x) (butlast-induction (cdr x) n))))
Theorem:
(defthm use-butlast-induction t :rule-classes ((:induction :pattern (butlast x n) :scheme (butlast-induction x n))))
For use with std::deflist:
Theorem:
(defthm element-list-p-of-butlast (implies (element-list-p (double-rewrite x)) (element-list-p (butlast x n))) :rule-classes :rewrite)