Pillay's Introduction to Stability Theory has in Chapter 1 the following exercise: if $T$ is stable, and $M \prec N$ are models, then for all $N$-definable $X \subset N$, the set $X \cap M$ is an $M$-definable subset of $M$. He also says that this is just another way of saying that all types are definable.
(The above is not a verbatim statement of the exercise; I might replace it with a verbatim copy later.)
I have been trying to do the exercise by following his hint, but I do not understand the relationship between definable types and definable subsets. The following are my thoughts: If $\phi(x, \bar n)$ is an $L(N)$-formula defining $X$ in $N$, for each $x$ in $X$ we have $\bar m_x$ in $M$ such that $\models \phi(x, \bar m_x)$ by elementarity. Since $\bar m_x$ are, at least prima facie, infinitely many parameters, so we have an infinite set of $L(M)$ formulas, i.e., an incomplete $M$-type. However, this seems useless. The right interpretation of the set of formulas is an infinite disjunction, where as a type usually is an infinite conjunction, so to speak. In addition, even though a type is definable, the defining schema $d$ does not have to be "definable" (in an informal sense), I do not know how $d$ helps us remove those infinite conjunctions or disjunction.
What is the relationship between definable types and definable sets that is useful here?
Can you use that in a stable theory types over models are definable? If the answer is yes, here is how you can do it:
Suppose $X\subseteq N^n$ is definable by the formula $\phi(\overline{x},\overline{b})$ for some tuple $\overline{b}$ from $N$, and consider the type $p=tp(\overline{b}/M)$ and consider the formula $\phi^*(\overline{y};\overline{x})=\phi(\overline{x};\overline{y})$.
The fact that $p$ is definable over $M$ means that there is a formula $\psi(\overline{x})=d_p\phi^*(\overline{x})$ with parameters in $M$ such that, for every $\overline{a}\in M^{n}$, $\phi^*(\overline{y},\overline{a})\in p$ if and only if $M\models \psi(\overline{a})$.
Then, for $\overline{a}\in M^{n}$ we have
\begin{align*} M\models \psi(\overline{a}) &\Leftrightarrow \phi^*(\overline{y};\overline{a})\in p\\ &\Leftrightarrow \phi(\overline{a},\overline{y})\in tp(\overline{b}/M)\\ &\Leftrightarrow N\models \phi(\overline{a},\overline{b})\\ &\Leftrightarrow \overline{a}\in X \end{align*}
This shows that $X\cap M$ is defined precisely by the formula $\psi(\overline{x})$, with parameters from $M$.