Let $T$ be a first order theory, $M$ a model of $T$ equipped with a topology with a definable basis (i.e. every basic open is definable with parameters). Let $F: M\rightarrow M$ be a partial function and $(f\_a)\_{a\in M^k}$ be a uniformly definable family of functions such that for any open set $U\subsetneq dom(F)$ there is $a\in M^k$ such that $F\upharpoonright U=f\_a\upharpoonright U$. Suppose in addition both $dom(F)$ and $rg(F)$ are $M$-definable. Can we say something about the definability of $F$ in $M$? What about if $F=f\_d\upharpoonright M$ for some $d$ in an elementary extension of $M$, i.e., $F$ is an externally definable function? If the exchange property is assumed I know in this later case that $F$ is indeed $M$-definable. Is it true without the exchange property? (NIP can be assumed if needed)



Approximating a function via definable functions
With your clarification (in a comment) that $U$ should be from the definable basis, the answer to your question seems to be negative. Notice first that the discrete topology on any model has a definable (with parameters, as you wrote in the question) basis, consisting of the singletons. Now you can uniformly define a family of functions $(f\_a)\_{a\in M}$ to be the family of constant functions, i.e., $f\_a$ is constant with value $a$. Then any $F:M\to M$ whatsoever will agree locally with this family, i.e., $F$ is constant on each singleton. So you can't conclude anything about definability of $F$ (unless your model $M$ is such that all functions on it are definable, which can only happen when either $M$ is finite or its language is bigger than the model itself).


