A challenge in Prof.Terence Tao's book “Analysis”: Using axiom of specification to define image of a function On page 64 (3.4 Images and Inverse Images) of "Analysis I" by Terence Tao, it says:

Note that the set $f(S)$ ($f$ is a function) is well-defined thanks to the axiom of
  replacement (Axiom 3.6). One can also define $f(S)$ using the axiom of
  specification (Axiom 3.5) instead of replacement, but we leave this as
  a challenge to the reader.

right below the definition 3.4.1 (image of sets).
(In case any ambiguity caused by incompleteness of pre-knowledge, here is the definition of function given in the same book:

Definition 3.3.1 (Functions). Let $X$, $Y$ be sets, and let $P(x,y)$ be a
  property pertaining to an object $x\in X$ and an object $y \in Y$, such that
  for every $x\in X$, there is exactly one $y \in Y$ for which $P(x,y)$ is true
  (this is sometimes known as the vertical line test). Then we define
  the function $f:X\rightarrow Y$ defined by $P$ on the domain $X$ and range $Y$ to be
  the object which, given any input $x\in X$, assigns an output $f(x) \in Y$,
  defined to be the unique object $f(x)$ for which $P(x, f(x))$ is true.
  Thus, for any $x\in X$ and $y \in Y$, $$y=f(x) \Leftrightarrow P(x, y) \textrm{ is true.}$$

)
It is quite obvious for me to see how to define f(S) by using axiom of replacement. However, it bothers me for a bit too long to "beat off" the challenge left to the reader. 
My thinking so far is to somehow construct a property $P(y)\ $that just depends on $y \in Y$ and somehow relates to the domain $S \subseteq X$ (motivation is simply from the format of the set given by axiom of specification $ \lbrace x \in A\mid P(x) \rbrace $). I am not sure but I guess that I did not understand the dependence between the property and the variables very well. That means, I am not sure in which situation the appearance of two variables like ($x$ and $y$) would be allowed to construct a property $P(x)$ or $P(y)$, or even it's not possible to do this. I don't know...
So I wish I could get some useful hint or enlightenment. In fact, I would be more excited about the feeling of reading three lines then "Ah-Ha! That's how it's done", than a complete solution (though I accept it definitely).
By the way, I am a pre-service math teacher right now (not an undergrad student), thus this is not a question for any assignment.
I appreciate for any help on this question.
Zach
 A: Basically, by definition of function, the function $f\colon X\to Y$ is defined by a property $P$ such that $P(x,y)$ is true when $y=f(x)$.
We have $f(S):=\{f(x):x\in S\}$ defined by axiom of replacement. So, this is a short form to represent $\{y:y=f(x)\text{ for some } x\in S\}$ what is the same that $\{y:P(x,y)\text{ for some } x\in S\}$.
To use the axiom of specification, we need a reference set, we say $A$, to define a set like $\{x\in A:P(x)\}$ for some property $P$.
In this case, we can use the set $Y$ of $f\colon X\to Y$ as reference set. Thus, defining $Q(y):=P(x,y)\text{ for some } x\in S$, we can state $f(S):=\{y\in Y:Q(y)\}$, what use the axiom of specification.
Edit. The property $Q$ is only used for ilustrative purpose. So, the final definition of image is $$f(S):=\{y\in Y:P(x,y)\text{ for some } x\in S\}.$$
Note that the property $P(x,y)$ is already defined by the definition of function for $f\colon X\to Y$.
A: I’m just learning this so take it with a grain of salt, but here’s how I’d construct it.
First, a small picture of what we’re dealing with. We’re trying to define the inner set on the right.

To use the Axiom of Specification, we need two things:

*

*An original set $A$.

*A property $P(a)$ that specifies whether some $a$ should be included.

Since we're using the Axiom of Specification, we want to start with a wider set than $f(S)$ and find a way to “narrow it down”. By definition, $f(S)$ is a subset of $Y$. So let’s pick $Y$ as our original set.
Next, we need a property that would “filter out” any values in $Y$ that don’t belong in $f(S)$. We can write a condition for $y$ that says “include if there exists $x$ in $S$ such that $f(x) = y$”. Intuitively, this corresponds to the dots in the inner right circle—because are reachable from the red lines.
Now that we picked the original set and the condition, we can use Specification: $$f(S):=\{y\in Y: P(y) \text{ is  true}\}.$$
where $P(y) = \exists x\in S: f(x) = y$.
Hopefully this is right!
