(sparseint$-plus-int-width width offset x x.height y cin) → (mv sum height cout)
Function:
(defun sparseint$-plus-int-width (width offset x x.height y cin) (declare (xargs :guard (and (posp width) (natp offset) (sparseint$-p x) (natp x.height) (integerp y) (bitp cin)))) (declare (xargs :guard (and (sparseint$-height-correctp x) (equal x.height (sparseint$-height x)) (< (integer-length y) width)))) (let ((__function__ 'sparseint$-plus-int-width)) (declare (ignorable __function__)) (b* ((width (lposfix width)) (offset (lnfix offset)) (y (mbe :logic (logext width y) :exec y)) (cin (lbfix cin)) (x.height (mbe :logic (sparseint$-height x) :exec x.height))) (sparseint$-case x :leaf (b* ((xval (bignum-logext width (logtail offset x.val))) (sum (bignum-logext width (sum-with-cin cin xval y))) (cout (carry-out-bit (logbit (1- width) xval) (logbit (1- width) y) (logbit (1- width) sum)))) (mv (sparseint$-leaf sum) 0 cout)) :concat (b* ((x.msbs.height (mbe :logic (sparseint$-height x.msbs) :exec (- x.height (if x.lsbs-taller 2 1)))) ((when (<= x.width offset)) (sparseint$-plus-int-width width (- offset x.width) x.msbs x.msbs.height y cin)) (width1 (- x.width offset)) (x.lsbs.height (mbe :logic (sparseint$-height x.lsbs) :exec (- x.height (if x.msbs-taller 2 1)))) ((when (<= width width1)) (sparseint$-plus-int-width width offset x.lsbs x.lsbs.height y cin)) ((mv lsbs-sum lsbs-sum-height lsbs-cout) (sparseint$-plus-int-width width1 offset x.lsbs x.lsbs.height (bignum-logext width1 y) cin)) ((mv msbs-sum msbs-sum-height msbs-cout) (sparseint$-plus-int-width (- width width1) 0 x.msbs x.msbs.height (logtail width1 y) lsbs-cout)) ((mv sum-concat sum-height) (sparseint$-concatenate-rebalance width1 lsbs-sum lsbs-sum-height msbs-sum msbs-sum-height))) (mv sum-concat sum-height msbs-cout))))))
Theorem:
(defthm sparseint$-p-of-sparseint$-plus-int-width.sum (b* (((mv ?sum ?height ?cout) (sparseint$-plus-int-width width offset x x.height y cin))) (sparseint$-p sum)) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-sparseint$-plus-int-width.height (b* (((mv ?sum ?height ?cout) (sparseint$-plus-int-width width offset x x.height y cin))) (equal height (sparseint$-height sum))) :rule-classes :rewrite)
Theorem:
(defthm bitp-of-sparseint$-plus-int-width.cout (b* (((mv ?sum ?height ?cout) (sparseint$-plus-int-width width offset x x.height y cin))) (bitp cout)) :rule-classes :type-prescription)
Theorem:
(defthm sparseint$-height-correctp-of-sparseint$-plus-int-width (b* (((mv ?sum ?height ?cout) (sparseint$-plus-int-width width offset x x.height y cin))) (implies (sparseint$-height-correctp x) (sparseint$-height-correctp sum))))
Theorem:
(defthm sparseint$-val-of-sparseint$-plus-int-width (b* (((mv ?sum ?height ?cout) (sparseint$-plus-int-width width offset x x.height y cin))) (and (equal (sparseint$-val sum) (logext width (sum-with-cin cin (logtail offset (sparseint$-val x)) y))) (equal cout (carry-out width cin (logtail offset (sparseint$-val x)) y)))))
Theorem:
(defthm sparseint$-plus-int-width-of-pos-fix-width (equal (sparseint$-plus-int-width (pos-fix width) offset x x.height y cin) (sparseint$-plus-int-width width offset x x.height y cin)))
Theorem:
(defthm sparseint$-plus-int-width-pos-equiv-congruence-on-width (implies (pos-equiv width width-equiv) (equal (sparseint$-plus-int-width width offset x x.height y cin) (sparseint$-plus-int-width width-equiv offset x x.height y cin))) :rule-classes :congruence)
Theorem:
(defthm sparseint$-plus-int-width-of-nfix-offset (equal (sparseint$-plus-int-width width (nfix offset) x x.height y cin) (sparseint$-plus-int-width width offset x x.height y cin)))
Theorem:
(defthm sparseint$-plus-int-width-nat-equiv-congruence-on-offset (implies (nat-equiv offset offset-equiv) (equal (sparseint$-plus-int-width width offset x x.height y cin) (sparseint$-plus-int-width width offset-equiv x x.height y cin))) :rule-classes :congruence)
Theorem:
(defthm sparseint$-plus-int-width-of-sparseint$-fix-x (equal (sparseint$-plus-int-width width offset (sparseint$-fix x) x.height y cin) (sparseint$-plus-int-width width offset x x.height y cin)))
Theorem:
(defthm sparseint$-plus-int-width-sparseint$-equiv-congruence-on-x (implies (sparseint$-equiv x x-equiv) (equal (sparseint$-plus-int-width width offset x x.height y cin) (sparseint$-plus-int-width width offset x-equiv x.height y cin))) :rule-classes :congruence)
Theorem:
(defthm sparseint$-plus-int-width-of-nfix-x.height (equal (sparseint$-plus-int-width width offset x (nfix x.height) y cin) (sparseint$-plus-int-width width offset x x.height y cin)))
Theorem:
(defthm sparseint$-plus-int-width-nat-equiv-congruence-on-x.height (implies (nat-equiv x.height x.height-equiv) (equal (sparseint$-plus-int-width width offset x x.height y cin) (sparseint$-plus-int-width width offset x x.height-equiv y cin))) :rule-classes :congruence)
Theorem:
(defthm sparseint$-plus-int-width-of-ifix-y (equal (sparseint$-plus-int-width width offset x x.height (ifix y) cin) (sparseint$-plus-int-width width offset x x.height y cin)))
Theorem:
(defthm sparseint$-plus-int-width-int-equiv-congruence-on-y (implies (int-equiv y y-equiv) (equal (sparseint$-plus-int-width width offset x x.height y cin) (sparseint$-plus-int-width width offset x x.height y-equiv cin))) :rule-classes :congruence)
Theorem:
(defthm sparseint$-plus-int-width-of-bfix-cin (equal (sparseint$-plus-int-width width offset x x.height y (bfix cin)) (sparseint$-plus-int-width width offset x x.height y cin)))
Theorem:
(defthm sparseint$-plus-int-width-bit-equiv-congruence-on-cin (implies (bit-equiv cin cin-equiv) (equal (sparseint$-plus-int-width width offset x x.height y cin) (sparseint$-plus-int-width width offset x x.height y cin-equiv))) :rule-classes :congruence)