Check if a top-level construct is statically well-formed.
(check-toplevel top ctxt) → (mv err? obligs new-ctxt)
Return the context updated with the top-level construct.
Function:
(defun check-toplevel (top ctxt) (declare (xargs :guard (and (toplevelp top) (contextp ctxt)))) (declare (xargs :guard (and (null (context->types ctxt)) (null (context->functions ctxt)) (omap::emptyp (context->variables ctxt)) (null (context->obligation-vars ctxt)) (null (context->obligation-hyps ctxt))))) (let ((__function__ 'check-toplevel)) (declare (ignorable __function__)) (b* (((mv err? obligs) (toplevel-case top :type (check-type-definition top.get ctxt) :types (check-type-recursion top.get ctxt) :function (check-function-definition top.get ctxt) :functions (check-function-recursion top.get ctxt) :specification (check-function-specification top.get ctxt) :theorem (check-theorem top.get ctxt) :transform (check-transform top.get ctxt))) ((when err?) (mv err? nil (context-fix ctxt))) (new-ctxt (context-add-toplevel top ctxt))) (mv nil obligs new-ctxt))))
Theorem:
(defthm proof-obligation-listp-of-check-toplevel.obligs (b* (((mv ?err? ?obligs ?new-ctxt) (check-toplevel top ctxt))) (proof-obligation-listp obligs)) :rule-classes :rewrite)
Theorem:
(defthm contextp-of-check-toplevel.new-ctxt (b* (((mv ?err? ?obligs ?new-ctxt) (check-toplevel top ctxt))) (contextp new-ctxt)) :rule-classes :rewrite)
Theorem:
(defthm not-of-check-toplevel-new-ctxt-types (implies (not (context->types ctxt)) (b* (((mv ?err? ?obligs ?new-ctxt) (check-toplevel top ctxt))) (not (context->types new-ctxt)))))
Theorem:
(defthm not-of-check-toplevel-new-ctxt-functions (implies (not (context->functions ctxt)) (b* (((mv ?err? ?obligs ?new-ctxt) (check-toplevel top ctxt))) (not (context->functions new-ctxt)))))
Theorem:
(defthm emptyp-of-check-toplevel-new-ctxt-variables (implies (omap::emptyp (context->variables ctxt)) (b* (((mv ?err? ?obligs ?new-ctxt) (check-toplevel top ctxt))) (omap::emptyp (context->variables new-ctxt)))))
Theorem:
(defthm not-of-check-toplevel-new-ctxt-obligation-vars (implies (not (context->obligation-vars ctxt)) (b* (((mv ?err? ?obligs ?new-ctxt) (check-toplevel top ctxt))) (not (context->obligation-vars new-ctxt)))))
Theorem:
(defthm not-of-check-toplevel-new-ctxt-obligation-hyps (implies (not (context->obligation-hyps ctxt)) (b* (((mv ?err? ?obligs ?new-ctxt) (check-toplevel top ctxt))) (not (context->obligation-hyps new-ctxt)))))
Theorem:
(defthm check-toplevel-of-toplevel-fix-top (equal (check-toplevel (toplevel-fix top) ctxt) (check-toplevel top ctxt)))
Theorem:
(defthm check-toplevel-toplevel-equiv-congruence-on-top (implies (toplevel-equiv top top-equiv) (equal (check-toplevel top ctxt) (check-toplevel top-equiv ctxt))) :rule-classes :congruence)
Theorem:
(defthm check-toplevel-of-context-fix-ctxt (equal (check-toplevel top (context-fix ctxt)) (check-toplevel top ctxt)))
Theorem:
(defthm check-toplevel-context-equiv-congruence-on-ctxt (implies (context-equiv ctxt ctxt-equiv) (equal (check-toplevel top ctxt) (check-toplevel top ctxt-equiv))) :rule-classes :congruence)