Shift a sparseint by some amount, positive or negative
(sparseint-ash x shift) → ash
Function:
(defun sparseint-ash (x shift) (declare (xargs :guard (and (sparseint-p x) (integerp shift)))) (let ((__function__ 'sparseint-ash)) (declare (ignorable __function__)) (b* ((shift (lifix shift))) (cond ((eql shift 0) (sparseint-fix x)) ((< shift 0) (sparseint-rightshift (- shift) x)) (t (sparseint-concatenate shift 0 x))))))
Theorem:
(defthm sparseint-p-of-sparseint-ash (b* ((ash (sparseint-ash x shift))) (sparseint-p ash)) :rule-classes :rewrite)
Theorem:
(defthm sparseint-ash-correct (b* ((common-lisp::?ash (sparseint-ash x shift))) (equal (sparseint-val ash) (ash (sparseint-val x) shift))))
Theorem:
(defthm sparseint-ash-of-sparseint-fix-x (equal (sparseint-ash (sparseint-fix x) shift) (sparseint-ash x shift)))
Theorem:
(defthm sparseint-ash-sparseint-equiv-congruence-on-x (implies (sparseint-equiv x x-equiv) (equal (sparseint-ash x shift) (sparseint-ash x-equiv shift))) :rule-classes :congruence)
Theorem:
(defthm sparseint-ash-of-ifix-shift (equal (sparseint-ash x (ifix shift)) (sparseint-ash x shift)))
Theorem:
(defthm sparseint-ash-int-equiv-congruence-on-shift (implies (int-equiv shift shift-equiv) (equal (sparseint-ash x shift) (sparseint-ash x shift-equiv))) :rule-classes :congruence)