Check if a function header is statically well-formed.
(check-function-header header ctxt) → err?
When checking a function header, no types are being defined, no variables are in scope, and no obligation variables and hypotheses are present. But there may be (other) function headers, which happens when checking mutually recursive functions.
The name must not be the name of an already defined function. Input and output types must be well-formed. Input and output names must be all distinct.
Function:
(defun check-function-header (header ctxt) (declare (xargs :guard (and (function-headerp header) (contextp ctxt)))) (declare (xargs :guard (and (null (context->types ctxt)) (omap::emptyp (context->variables ctxt)) (null (context->obligation-vars ctxt)) (null (context->obligation-hyps ctxt))))) (let ((__function__ 'check-function-header)) (declare (ignorable __function__)) (b* (((function-header header) header) ((when (get-function-definition header.name (context->tops ctxt))) (list :function-alread-defined header.name)) (input-types (typed-variable-list->type-list header.inputs)) ((when (not (check-type-list input-types ctxt))) (list :malformed-input-types header.name input-types)) (output-types (typed-variable-list->type-list header.outputs)) ((when (not (check-type-list output-types ctxt))) (list :malformed-output-types header.name output-types)) (input-output-names (append (typed-variable-list->name-list header.inputs) (typed-variable-list->name-list header.outputs))) ((unless (no-duplicatesp-equal input-output-names)) (list :duplicate-input/output-names header.name input-output-names))) nil)))
Theorem:
(defthm check-function-header-of-function-header-fix-header (equal (check-function-header (function-header-fix header) ctxt) (check-function-header header ctxt)))
Theorem:
(defthm check-function-header-function-header-equiv-congruence-on-header (implies (function-header-equiv header header-equiv) (equal (check-function-header header ctxt) (check-function-header header-equiv ctxt))) :rule-classes :congruence)
Theorem:
(defthm check-function-header-of-context-fix-ctxt (equal (check-function-header header (context-fix ctxt)) (check-function-header header ctxt)))
Theorem:
(defthm check-function-header-context-equiv-congruence-on-ctxt (implies (context-equiv ctxt ctxt-equiv) (equal (check-function-header header ctxt) (check-function-header header ctxt-equiv))) :rule-classes :congruence)