Enhanced variant of number-of-results.
(number-of-results+ fn wrld) → n
This returns the same result as number-of-results,
but it includes a run-time check (which should always succeed)
on the result
that allows us to prove a tighter return type theorem
than number-of-results
without strengthening the guard on
The function must not be in
Function:
(defun number-of-results+ (fn wrld) (declare (xargs :guard (and (symbolp fn) (plist-worldp wrld)))) (declare (xargs :guard (not (member-eq fn *stobjs-out-invalid*)))) (let ((__function__ 'number-of-results+)) (declare (ignorable __function__)) (cond ((not (function-symbolp fn wrld)) (prog2$ (raise "The symbol ~x0 does not name a function." fn) 1)) (t (b* ((result (number-of-results fn wrld))) (if (posp result) result (prog2$ (raise "Internal error: ~ the STOBJS-OUT property of ~x0 is empty." fn) 1)))))))
Theorem:
(defthm posp-of-number-of-results+ (b* ((n (number-of-results+ fn wrld))) (posp n)) :rule-classes :rewrite)