(ints-from a b) enumerates the integers from
Function:
(defun ints-from (a b) (declare (xargs :guard (and (integerp a) (integerp b)))) (declare (xargs :guard (<= a b))) (let ((__function__ 'ints-from)) (declare (ignorable __function__)) (let ((a (lifix a)) (b (lifix b))) (if (mbe :logic (zp (- b a)) :exec (= a b)) nil (cons a (ints-from (+ 1 a) b))))))
Theorem:
(defthm true-listp-of-ints-from (true-listp (ints-from a b)) :rule-classes :type-prescription)
Theorem:
(defthm integer-listp-of-ints-from (integer-listp (ints-from a b)))
Theorem:
(defthm consp-of-ints-from (equal (consp (ints-from a b)) (< (ifix a) (ifix b))))
Theorem:
(defthm ints-from-self (equal (ints-from a a) nil))
Theorem:
(defthm member-equal-ints-from (iff (member-equal x (ints-from a b)) (and (integerp x) (<= (ifix a) x) (< x (ifix b)))))
Theorem:
(defthm no-duplicatesp-equal-of-ints-from (no-duplicatesp-equal (ints-from a b)))
Theorem:
(defthm ints-from-of-ifix-a (equal (ints-from (ifix a) b) (ints-from a b)))
Theorem:
(defthm ints-from-int-equiv-congruence-on-a (implies (acl2::int-equiv a a-equiv) (equal (ints-from a b) (ints-from a-equiv b))) :rule-classes :congruence)
Theorem:
(defthm ints-from-of-ifix-b (equal (ints-from a (ifix b)) (ints-from a b)))
Theorem:
(defthm ints-from-int-equiv-congruence-on-b (implies (acl2::int-equiv b b-equiv) (equal (ints-from a b) (ints-from a b-equiv))) :rule-classes :congruence)
Theorem:
(defthm take-of-ints-from (equal (take k (ints-from a b)) (if (< (ifix k) (nfix (- (ifix b) (ifix a)))) (ints-from a (+ (ifix a) (ifix k))) (append (ints-from a b) (replicate (- (ifix k) (nfix (- (ifix b) (ifix a)))) nil)))))
Theorem:
(defthm nthcdr-of-ints-from (equal (nthcdr k (ints-from a b)) (if (< (nfix k) (nfix (- (ifix b) (ifix a)))) (ints-from (+ (ifix a) (nfix k)) b) nil)))
Theorem:
(defthm len-of-ints-from (equal (len (ints-from a b)) (nfix (- (ifix b) (ifix a)))))
Theorem:
(defthm car-of-ints-from (equal (car (ints-from a b)) (if (< (ifix a) (ifix b)) (ifix a) nil)))
Theorem:
(defthm nth-of-ints-from (equal (nth n (ints-from a b)) (if (< (nfix n) (nfix (- (ifix b) (ifix a)))) (+ (ifix a) (nfix n)) nil)))
Theorem:
(defthm setp-of-ints-from (setp (ints-from a b)))