Apply a function substitution to an individual function.
(fun-subst-function fsbs fun wrld) → new-fun
Applying an instantiation to a term involves replacing
not only the function variables that are keys of the instantiation
and that occur explicitly in the term,
but also the ones that occur implicitly in the term
via occurrences of second-order functions that depend on
those function variables.
For example, if
When an instantiation is applied
to the body of a recursive second-order function
The following code applies a function substitution to an individual function, in the manner explained above. It is used by fun-subst-term, which applies a function substitution to a term. If a needed second-order function instance does not exist, an error occurs.
Function:
(defun fun-subst-function (fsbs fun wrld) (declare (xargs :guard (and (fun-substp fsbs) (symbolp fun) (plist-worldp wrld)))) (let ((__function__ 'fun-subst-function)) (declare (ignorable __function__)) (let ((pair (assoc-eq fun fsbs))) (if pair (cdr pair) (if (sofunp fun wrld) (let* ((funvars (sofun-funvars fun wrld)) (subfsbs (restrict-alist funvars fsbs))) (if (null subfsbs) fun (let* ((instmap (sof-instances fun wrld)) (new-fun (get-sof-instance subfsbs instmap wrld))) (if new-fun new-fun (raise "~x0 has no instance for ~x1." fun fsbs))))) fun)))))