(nats-from a b) enumerates the naturals from
Function:
(defun nats-from (a b) (declare (xargs :guard (and (natp a) (natp b)))) (declare (xargs :guard (<= a b))) (let ((__function__ 'nats-from)) (declare (ignorable __function__)) (let ((a (lnfix a)) (b (lnfix b))) (if (mbe :logic (zp (- b a)) :exec (= a b)) nil (cons a (nats-from (+ 1 a) b))))))
Theorem:
(defthm true-listp-of-nats-from (true-listp (nats-from a b)) :rule-classes :type-prescription)
Theorem:
(defthm nat-listp-of-nats-from (nat-listp (nats-from a b)))
Theorem:
(defthm consp-of-nats-from (equal (consp (nats-from a b)) (< (nfix a) (nfix b))))
Theorem:
(defthm nats-from-self (equal (nats-from a a) nil))
Theorem:
(defthm member-equal-nats-from (iff (member-equal x (nats-from a b)) (and (natp x) (<= (nfix a) x) (< x (nfix b)))))
Theorem:
(defthm no-duplicatesp-equal-of-nats-from (no-duplicatesp-equal (nats-from a b)))
Theorem:
(defthm take-of-nats-from (equal (take k (nats-from a b)) (if (< (nfix k) (nfix (- (nfix b) (nfix a)))) (nats-from a (+ (nfix a) (nfix k))) (append (nats-from a b) (replicate (- (nfix k) (nfix (- (nfix b) (nfix a)))) nil)))))
Theorem:
(defthm nthcdr-of-nats-from (equal (nthcdr k (nats-from a b)) (if (< (nfix k) (nfix (- (nfix b) (nfix a)))) (nats-from (+ (nfix a) (nfix k)) b) nil)))
Theorem:
(defthm len-of-nats-from (equal (len (nats-from a b)) (nfix (- (nfix b) (nfix a)))))
Theorem:
(defthm car-of-nats-from (equal (car (nats-from a b)) (if (< (nfix a) (nfix b)) (nfix a) nil)))
Theorem:
(defthm nth-of-nats-from (equal (nth n (nats-from a b)) (if (< (nfix n) (nfix (- (nfix b) (nfix a)))) (+ (nfix a) (nfix n)) nil)))
Theorem:
(defthm setp-of-nats-from (setp (nats-from a b)))