Look up a function in a set, by name.
(function-lookup name functions) → function?
We return the first function in the set with the given name, if any.
If there is none, we return
When a set of functions represents all the function definitions in an ACL2 environment, the list will have unique function names; this will be formalized elsewhere. Under this condition, returning the first function found is as good as returning any function with that name in the set, since there can be at most one.
Function:
(defun function-lookup (name functions) (declare (xargs :guard (and (symbol-valuep name) (function-setp functions)))) (let ((__function__ 'function-lookup)) (declare (ignorable __function__)) (b* (((when (or (not (mbt (function-setp functions))) (emptyp functions))) nil) (function (head functions)) ((when (symbol-value-equiv name (function->name function))) function)) (function-lookup name (tail functions)))))
Theorem:
(defthm function-optionp-of-function-lookup (b* ((function? (function-lookup name functions))) (function-optionp function?)) :rule-classes :rewrite)
Theorem:
(defthm function-lookup-of-symbol-value-fix-name (equal (function-lookup (symbol-value-fix name) functions) (function-lookup name functions)))
Theorem:
(defthm function-lookup-symbol-value-equiv-congruence-on-name (implies (symbol-value-equiv name name-equiv) (equal (function-lookup name functions) (function-lookup name-equiv functions))) :rule-classes :congruence)
Theorem:
(defthm function-lookup-of-function-set-fix-functions (equal (function-lookup name (function-set-fix functions)) (function-lookup name functions)))
Theorem:
(defthm function-lookup-function-set-equiv-congruence-on-functions (implies (function-set-equiv functions functions-equiv) (equal (function-lookup name functions) (function-lookup name functions-equiv))) :rule-classes :congruence)