Measure for recurring over expression structures.
(expression-count x) → count
Function:
(defun expression-count (x) (declare (xargs :guard (expressionp x))) (let ((__function__ 'expression-count)) (declare (ignorable __function__)) (case (expression-kind x) (:const 1) (:var 1) (:add (+ 3 (expression-count (expression-add->arg1 x)) (expression-count (expression-add->arg2 x)))) (:mul (+ 3 (expression-count (expression-mul->arg1 x)) (expression-count (expression-mul->arg2 x)))))))
Theorem:
(defthm natp-of-expression-count (b* ((count (expression-count x))) (natp count)) :rule-classes :type-prescription)
Theorem:
(defthm expression-count-of-expression-fix-x (equal (expression-count (expression-fix x)) (expression-count x)))
Theorem:
(defthm expression-count-expression-equiv-congruence-on-x (implies (expression-equiv x x-equiv) (equal (expression-count x) (expression-count x-equiv))) :rule-classes :congruence)
Theorem:
(defthm expression-count-of-expression-add (implies t (< (+ (expression-count arg1) (expression-count arg2)) (expression-count (expression-add arg1 arg2)))) :rule-classes :linear)
Theorem:
(defthm expression-count-of-expression-add->arg1 (implies (equal (expression-kind x) :add) (< (expression-count (expression-add->arg1 x)) (expression-count x))) :rule-classes :linear)
Theorem:
(defthm expression-count-of-expression-add->arg2 (implies (equal (expression-kind x) :add) (< (expression-count (expression-add->arg2 x)) (expression-count x))) :rule-classes :linear)
Theorem:
(defthm expression-count-of-expression-mul (implies t (< (+ (expression-count arg1) (expression-count arg2)) (expression-count (expression-mul arg1 arg2)))) :rule-classes :linear)
Theorem:
(defthm expression-count-of-expression-mul->arg1 (implies (equal (expression-kind x) :mul) (< (expression-count (expression-mul->arg1 x)) (expression-count x))) :rule-classes :linear)
Theorem:
(defthm expression-count-of-expression-mul->arg2 (implies (equal (expression-kind x) :mul) (< (expression-count (expression-mul->arg2 x)) (expression-count x))) :rule-classes :linear)