Maximum member in a list of naturals.
(max-nats x) → *
Typically you would only use this on non-empty lists, but as a
reasonable default we say the maximum member of the empty list is
Function:
(defun max-nats (x) (declare (xargs :guard (nat-listp x))) (let ((__function__ 'max-nats)) (declare (ignorable __function__)) (if (atom x) 0 (max (lnfix (car x)) (max-nats (cdr x))))))
Theorem:
(defthm max-nats-when-atom (implies (atom x) (equal (max-nats x) 0)))
Theorem:
(defthm max-nats-of-cons (equal (max-nats (cons a x)) (max (nfix a) (max-nats x))))
Theorem:
(defthm natp-of-max-nats (natp (max-nats x)) :rule-classes :type-prescription)
Theorem:
(defthm max-nats-of-append (equal (max-nats (append x y)) (max (max-nats x) (max-nats y))))
Theorem:
(defthm max-nats-of-rev (equal (max-nats (rev x)) (max-nats x)))
Theorem:
(defthm max-nats-of-revappend (equal (max-nats (revappend x y)) (max (max-nats x) (max-nats y))))