I've been pondering this old question Is the Subset Axiom Schema in ZF necessary? and seem to have an answer which didn't come up, but I'm wondering if there's a mistake in my reasoning.
Axiom of specification: given any set $x$ and formula $\phi(y)$ there exists a set $z$ whose members are exactly those members of $x$ which satisfy $\phi$: $$\forall \phi \forall x \exists z \forall y(y \in z \leftrightarrow y \in x \land \phi(y)).$$
So let $x$ be a set and $z \subseteq x$ a subcollection. Define the formula $\phi(y) = (y \in z)$. Then by the axiom of specification there exists a set $z'$ such that $\forall y(y \in z' \leftrightarrow y \in z)$. I thought about applying the axiom of extensionality here to deduce that $z = z'$, but obviously you can't do that because $z$ is not necessarily a set. Still, to every subcollection I've associated a set with exactly the same members. One of the answers https://math.stackexchange.com/q/2383 says it's possible there may be subsets which aren't expressible by a formula, but if I know that $z$ is a set then I seem to have a formula. Did I make a mistake? Maybe my $\phi$ isn't a proper formula because it refers to something which may not be a set?