(sparseint$-height x) → height
Function:
(defun sparseint$-height (x) (declare (xargs :guard (sparseint$-p x))) (declare (xargs :guard (sparseint$-height-correctp x))) (let ((__function__ 'sparseint$-height)) (declare (ignorable __function__)) (sparseint$-case x :leaf 0 :concat (mbe :logic (+ 1 (max (sparseint$-height x.lsbs) (sparseint$-height x.msbs))) :exec (cond (x.lsbs-taller (+ 2 (sparseint$-height x.msbs))) (x.msbs-taller (+ 2 (sparseint$-height x.lsbs))) (t (+ 1 (sparseint$-height x.lsbs))))))))
Theorem:
(defthm natp-of-sparseint$-height (b* ((height (sparseint$-height x))) (natp height)) :rule-classes :type-prescription)
Theorem:
(defthm sparseint$-real-height-equals-sparseint$-height (b* ((?height (sparseint$-height x))) (equal (sparseint$-real-height x) height)))
Theorem:
(defthm sparseint$-height-equal-0 (b* ((?height (sparseint$-height x))) (equal (equal height 0) (sparseint$-case x :leaf))))
Theorem:
(defthm sparseint$-height-when-concat (implies (sparseint$-case x :concat) (equal (sparseint$-height x) (b* (((sparseint$-concat x))) (+ 1 (max (sparseint$-height x.lsbs) (sparseint$-height x.msbs)))))))
Theorem:
(defthm sparseint$-height-of-concat (equal (sparseint$-height (make-sparseint$-concat :width width :lsbs lsbs :msbs msbs :lsbs-taller lsbs-taller :msbs-taller msbs-taller)) (+ 1 (max (sparseint$-height lsbs) (sparseint$-height msbs)))))
Theorem:
(defthm sparseint$-height-when-leaf (implies (sparseint$-case x :leaf) (equal (sparseint$-height x) 0)) :rule-classes (:rewrite :forward-chaining))
Theorem:
(defthm sparseint$-height-posp-when-concat (b* ((?height (sparseint$-height x))) (iff (posp height) (equal (sparseint$-kind x) :concat))) :rule-classes ((:forward-chaining :trigger-terms ((sparseint$-height x)) :corollary (implies (posp (sparseint$-height x)) (equal (sparseint$-kind x) :concat))) (:forward-chaining :trigger-terms ((equal (sparseint$-kind x) :concat)) :corollary (implies (equal (sparseint$-kind x) :concat) (posp (sparseint$-height x))))))
Theorem:
(defthm sparseint$-height-gt-0-implies-concat (b* ((?height (sparseint$-height x))) (implies (< 0 height) (equal (sparseint$-kind x) :concat))) :rule-classes ((:forward-chaining :trigger-terms ((sparseint$-height x)))))
Theorem:
(defthm sparseint$-height-of-lsbs-upper-bound (implies (sparseint$-case x :concat) (<= (sparseint$-height (sparseint$-concat->lsbs x)) (+ -1 (sparseint$-height x)))) :rule-classes :linear)
Theorem:
(defthm sparseint$-height-of-msbs-upper-bound (implies (sparseint$-case x :concat) (<= (sparseint$-height (sparseint$-concat->msbs x)) (+ -1 (sparseint$-height x)))) :rule-classes :linear)
Theorem:
(defthm sparseint$-height-of-sparseint$-fix-x (equal (sparseint$-height (sparseint$-fix x)) (sparseint$-height x)))
Theorem:
(defthm sparseint$-height-sparseint$-equiv-congruence-on-x (implies (sparseint$-equiv x x-equiv) (equal (sparseint$-height x) (sparseint$-height x-equiv))) :rule-classes :congruence)