Check if a function definition (at the top level) is statically well-formed.
(check-function-definition fundef ctxt) → (mv err? obligs)
We augment the context with the header and call the more general ACL2 function. Thus, we allow the function to be (singly) recursive.
For now we allow any recursion, but we will extend this code to only allow certain forms, or to generate more explicit termination obligations.
Function:
(defun check-function-definition (fundef ctxt) (declare (xargs :guard (and (function-definitionp fundef) (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-function-definition)) (declare (ignorable __function__)) (b* ((header (function-definition->header fundef)) (ctxt (change-context ctxt :functions (list header)))) (check-function-definition-top/nontop fundef ctxt))))
Theorem:
(defthm proof-obligation-listp-of-check-function-definition.obligs (b* (((mv ?err? ?obligs) (check-function-definition fundef ctxt))) (proof-obligation-listp obligs)) :rule-classes :rewrite)
Theorem:
(defthm check-function-definition-of-function-definition-fix-fundef (equal (check-function-definition (function-definition-fix fundef) ctxt) (check-function-definition fundef ctxt)))
Theorem:
(defthm check-function-definition-function-definition-equiv-congruence-on-fundef (implies (function-definition-equiv fundef fundef-equiv) (equal (check-function-definition fundef ctxt) (check-function-definition fundef-equiv ctxt))) :rule-classes :congruence)
Theorem:
(defthm check-function-definition-of-context-fix-ctxt (equal (check-function-definition fundef (context-fix ctxt)) (check-function-definition fundef ctxt)))
Theorem:
(defthm check-function-definition-context-equiv-congruence-on-ctxt (implies (context-equiv ctxt ctxt-equiv) (equal (check-function-definition fundef ctxt) (check-function-definition fundef ctxt-equiv))) :rule-classes :congruence)