Generate the new function definition.
(casesplit-gen-new-fn old$ conditions$ news new-name$ new-enable$ verify-guards$ appcond-thm-names wrld) → (mv local-event exported-event)
The macro used to introduce the new function is determined by whether the new function must be enabled or not.
The new function has the same formal arguments as the old function.
The body of the new function is obtained
as shown in the reference documentation.
Starting with the term
The new function has the same guard as the old function.
The guards are verified as shown in the template file.
The
Function:
(defun casesplit-gen-new-fn-body (k conditions$ news acc) (declare (xargs :guard (and (natp k) (pseudo-term-listp conditions$) (pseudo-term-listp news) (pseudo-termp acc)))) (let ((__function__ 'casesplit-gen-new-fn-body)) (declare (ignorable __function__)) (b* (((when (zp k)) acc) (condk (nth (1- k) conditions$)) (newk (nth (1- k) news)) (acc (cons 'if (cons condk (cons newk (cons acc 'nil)))))) (casesplit-gen-new-fn-body (1- k) conditions$ news acc))))
Theorem:
(defthm pseudo-termp-of-casesplit-gen-new-fn-body (implies (and (pseudo-termp acc) (pseudo-term-listp conditions$) (pseudo-term-listp news)) (b* ((term (casesplit-gen-new-fn-body k conditions$ news acc))) (pseudo-termp term))) :rule-classes :rewrite)
Function:
(defun casesplit-gen-new-fn (old$ conditions$ news new-name$ new-enable$ verify-guards$ appcond-thm-names wrld) (declare (xargs :guard (and (symbolp old$) (pseudo-term-listp conditions$) (pseudo-term-listp news) (symbolp new-name$) (booleanp new-enable$) (booleanp verify-guards$) (symbol-symbol-alistp appcond-thm-names) (plist-worldp wrld)))) (let ((__function__ 'casesplit-gen-new-fn)) (declare (ignorable __function__)) (evmac-generate-defun new-name$ :formals (formals old$ wrld) :guard (uguard old$ wrld) :body (b* ((new0 (car (last news))) (body (casesplit-gen-new-fn-body (len conditions$) conditions$ news new0))) (untranslate body nil wrld)) :guard-hints (b* ((guard-appcond-thm-names (nthcdr (len news) appcond-thm-names))) (cons (cons '"Goal" (cons ':in-theory (cons 'nil (cons ':use (cons (append (strip-cdrs guard-appcond-thm-names) (cons (cons ':guard-theorem (cons old$ 'nil)) 'nil)) 'nil))))) 'nil)) :guard-simplify :limited :verify-guards verify-guards$ :enable new-enable$)))