Measure for recurring over vttree structures.
Function:
(defun vttree-count (x) (declare (xargs :guard (vttree-p x))) (let ((__function__ 'vttree-count)) (declare (ignorable __function__)) (common-lisp::case (vttree-kind x) (:none 1) (:warnings 1) (:constraints 1) (:context (+ 3 (vttree-count (vttree-context->subtree x)))) (:branch (+ 3 (vttree-count (vttree-branch->left x)) (vttree-count (vttree-branch->right x)))))))
Theorem:
(defthm natp-of-vttree-count (b* ((count (vttree-count x))) (natp count)) :rule-classes :type-prescription)
Theorem:
(defthm vttree-count-of-vttree-fix-x (equal (vttree-count (vttree-fix x)) (vttree-count x)))
Theorem:
(defthm vttree-count-vttree-equiv-congruence-on-x (implies (vttree-equiv x x-equiv) (equal (vttree-count x) (vttree-count x-equiv))) :rule-classes :congruence)
Theorem:
(defthm vttree-count-of-vttree-context (implies t (< (+ (vttree-count subtree)) (vttree-count (vttree-context ctx subtree)))) :rule-classes :linear)
Theorem:
(defthm vttree-count-of-vttree-context->subtree (implies (equal (vttree-kind x) :context) (< (vttree-count (vttree-context->subtree x)) (vttree-count x))) :rule-classes :linear)
Theorem:
(defthm vttree-count-of-vttree-branch (implies t (< (+ (vttree-count left) (vttree-count right)) (vttree-count (vttree-branch left right)))) :rule-classes :linear)
Theorem:
(defthm vttree-count-of-vttree-branch->left (implies (equal (vttree-kind x) :branch) (< (vttree-count (vttree-branch->left x)) (vttree-count x))) :rule-classes :linear)
Theorem:
(defthm vttree-count-of-vttree-branch->right (implies (equal (vttree-kind x) :branch) (< (vttree-count (vttree-branch->right x)) (vttree-count x))) :rule-classes :linear)