Measure for recurring over value structures.
Function:
(defun value-count (x) (declare (xargs :guard (valuep x))) (let ((__function__ 'value-count)) (declare (ignorable __function__)) (case (value-kind x) (:number 1) (:character 1) (:string 1) (:symbol 1) (:cons (+ 3 (value-count (value-cons->car x)) (value-count (value-cons->cdr x)))))))
Theorem:
(defthm natp-of-value-count (b* ((count (value-count x))) (natp count)) :rule-classes :type-prescription)
Theorem:
(defthm value-count-of-value-fix-x (equal (value-count (value-fix x)) (value-count x)))
Theorem:
(defthm value-count-value-equiv-congruence-on-x (implies (value-equiv x x-equiv) (equal (value-count x) (value-count x-equiv))) :rule-classes :congruence)
Theorem:
(defthm value-count-of-value-cons (implies t (< (+ (value-count car) (value-count cdr)) (value-count (value-cons car cdr)))) :rule-classes :linear)
Theorem:
(defthm value-count-of-value-cons->car (implies (equal (value-kind x) :cons) (< (value-count (value-cons->car x)) (value-count x))) :rule-classes :linear)
Theorem:
(defthm value-count-of-value-cons->cdr (implies (equal (value-kind x) :cons) (< (value-count (value-cons->cdr x)) (value-count x))) :rule-classes :linear)