Lemmas about len available in the std/lists library.
Theorem:
(defthm len-when-atom (implies (atom x) (equal (len x) 0)))
Theorem:
(defthm len-of-cons (equal (len (cons a x)) (+ 1 (len x))))
Theorem:
(defthm |(equal 0 (len x))| (equal (equal 0 (len x)) (atom x)))
Theorem:
(defthm |(< 0 (len x))| (equal (< 0 (len x)) (consp x)))
Theorem:
(defthm consp-by-len (implies (and (equal (len x) n) (syntaxp (quotep n))) (equal (consp x) (< 0 n))))
Theorem:
(defthm consp-of-cdr-by-len (implies (and (equal (len x) n) (syntaxp (quotep n))) (equal (consp (cdr x)) (< 1 n))))
Theorem:
(defthm consp-of-cddr-by-len (implies (and (equal (len x) n) (syntaxp (quotep n))) (equal (consp (cddr x)) (< 2 n))))
Theorem:
(defthm consp-of-cdddr-by-len (implies (and (equal (len x) n) (syntaxp (quotep n))) (equal (consp (cdddr x)) (< 3 n))))