From axiom of replacement: I have given a set $S$ and have relation $R(x,y)$ such that $x \in S$, then there exist unique $y \in T$ which is image of set $S$ where $T$ is also a set.
But I can use Axiom schema of comprehension where I have $P(y)$ as predicate, then there exist a subset $T \subset S$ such that it consist of exactly those $y \in S $ for which $P(y)$ is true. In symbols I have: $$T = \{y\in S|P(y)\}$$ Then it says that axiom schema of comprehension is a consequence of axiom of replacement as:
$\bullet\,$ $\,\lnot(\exists y\in S : P(y))$ then define $T = \phi$
$\bullet\,$ $\, \exists \,\hat{y}\in S : P(y)$ then by definition I have $$\text{when } P(x) \text{ is true, then } R(x)=y$$ $$\text{when } P(x) \text{ is false, then } R(\hat{y})=y$$ From all of this $T$ is image is image of set $S$ under relation $R(x,y)$
My confusion is:
$ \color{red}{\text{ how }y\in S \text{ and axiom schema of comprehension is a consequence of axiom of replacement}}$ Please provide me one example also. Thanks in advance!
note: I searched on internet and it didn't help and I am physics person and started learning set theory.