This is an exercise (1.4.11) from Marker. Fix a language $\mathcal L$ and $\mathcal L$-structure $\mathcal M$. For a subset $A \subseteq M$, an element of $M$ is algebraic over $A$ if it is a member of a finite $A$-definable subset of $M$. Let $\bar A$ denote the set of algebraic elements over $A$. We would like to show that $\bar {\bar A} = \bar A$.
Here's a failed attempt to solve the problem. Let a formula $\psi(x, b)$ defines a finite set with a parameter $b$ from $\bar A$ and $\phi (y, a)$ defines a finite set with a parameter $a$ from $A$ (for simplicity we assume the number of parameters is one). Then, naively, the formula $\exists z (\psi(x, z) \wedge \phi(z, a))$ will do the job. However, this formula is not known to define a finite set a priori.
I'd be grateful if you could help me in this problem.