Enhanced variant of well-founded-relation.
This returns the same result as well-founded-relation,
but it is guard-verified
and includes a run-time check (which should always succeed) on the result
that allows us to prove the return type theorem
without strengthening the guard on
(defun well-founded-relation+ (fn wrld) (declare (xargs :guard (and (symbolp fn) (plist-worldp wrld)))) (let ((__function__ 'well-founded-relation+)) (declare (ignorable __function__)) (if (not (irecursivep+ fn wrld)) (raise "The function ~x0 is not recursive." fn) (b* ((justification (getpropc fn 'justification nil wrld)) ((unless (weak-justification-p justification)) (raise "Internal error: ~ the justification ~x0 of ~x1 is not well-formed." justification fn)) (well-founded-relation (access justification justification :rel)) ((unless (symbolp well-founded-relation)) (raise "Internal error: ~ the well-founded relation ~x0 of ~x1 is not a symbol." well-founded-relation fn))) well-founded-relation))))
(defthm symbolp-of-well-founded-relation+ (b* ((well-founded-relation (well-founded-relation+ fn wrld))) (symbolp well-founded-relation)) :rule-classes :rewrite)