Why is this proof that $f(A-B)\subseteq f(A)-f(B)$ wrong? Consider this part of Exercise 2.9 of Apostol's Mathematical Analysis:

Let $f:S\to T$ be a function. Prove that d) $\to$ e), where:
d) For all disjoint subsets of $A$ and $B$ of $S$, the images $f(A)$ and $f(B)$ are disjoint.
e) For all subsets $A$ and $B$ of $S$ such that $B\subseteq A$, $f(A-B)=f(A)-f(B)$.

To prove e) we must show that

*

*$f(A-B)\subseteq f(A)-f(B)$, and

*$f(A)-f(B)\subseteq f(A-B)$.

In trying to show $1.$ I wrote the following:

The set $f(A-B)$ consists of the $f(x)$ such that $x\in A-B$. This means that $x\in A$ and $x\notin B$, so $f(x)\in f(A)$ and $f(x)\notin f(B)$. Hence, $f(x)\in f(A)-f(B)$, and $f(A-B)\subseteq f(A)-f(B)$.

After proving $2.$ without having used d) or the fact that $B\subseteq A$, I realized that something was wrong. A proof of $1.$ involving both facts occurred to me after a while. The answer and some comments to this question, point to my mistake. However, I can't, for the life of me, understand what is my mistake.
What did I do wrong? How could I avoid this kind of mistake?
 A: 
What did I do wrong?

$x \notin B$ does not mean $f(x) \notin f(B)$.
For example, take $f : [2, 4) \to [4, 16)$ to be $f(x) = x^2$.
Then $-2 \notin [2,4)$ but $f(-2) = 4 \in f([2,4)) = [4,16)$.
EDIT:  For similar reasons, it's also not generally true that "$f(A-B)$ consists of the $f(x)$ such that $x \in A - B$."  If you view $f(A-B)$ as a set, then it contains the (set of all) $f(x)$ such that $x \in A-B$, but to say it consists of such $f(x)$ can be interpreted as meaning it consists only of such $f(x)$, which isn't necessarily true.
I think you were on the right track and thinking of the right tools to use, but it's possible the notation/naming caused confusion.  That's just my guess and maybe I'm wrong.

How could I avoid this kind of mistake?

Practice, practice, more practice.  Making mistakes is an essential part of the learning process.

If there's any confusion in this problem in general I think it may arise from the fact that the $A$ and $B$ in (d) aren't the same as the $A$ and $B$ in (e).  Here's a complete rough draft of a proof.  Will need cleaning up in some areas.
We want to prove (d) implies (e).  So, suppose we have $B \subseteq A \subseteq S$.  We want to show that $f(A) \setminus f(B) = f(A \setminus B)$.
Let $y \in f(A) \setminus f(B)$.  Then $y \in f(A)$ and $y \notin f(B)$.  Thus there is some $x \in A$ such that $f(x) = y$.  Also, since $y \notin f(B)$ then we must have $x \notin B$.  So $x \in A$ and $x \notin B$, which means $x \in A \setminus B$.  Thus, $f(x) \in f(A \setminus B)$.  This shows one set inclusion.
For the other set inclusion, let $z \in f(A \setminus B)$.  Then there is some $w \in A \setminus B$ such that $f(w) = z$.  Since $A \setminus B$ and $B$ are disjoint, then by part (d) we must have  that $f(A \setminus B)$ and $f(B)$ are disjoint.  Combining this with the fact that $f(w) \in f(A \setminus B)$ therefore tells us that $f(w) \notin f(B)$.  Furthermore, since $w \in A \setminus B$, then $w \in A$.  Thus, $f(w) \in f(A)$.  So $f(w) \in f(A)$ and $f(w) \notin f(B)$, giving us $f(w) \in f(A) \setminus f(B)$.  This shows the other set inclusion.
A: It's not generally true that $f(A-B)=f(A)-f(B)$. Consider the unique function $f\colon\{1,2\}\to\{0\}$ and take $A=\{1,2\}$, $B=\{2\}$.
Then $f(A-B)=f(\{1\})=\{0\}$, whereas $f(A)-f(B)=\{0\}-\{0\}=\emptyset$.
This fails exactly where your mistake is: we can indeed have $f(A-B)\nsubseteq f(A)-f(B)$.
Saying that $y\in f(A-B)$ means $y=f(x)$, for some $x\in A$, $x\notin B$. Thus $y\in f(A)$, but this does not exclude $y\in f(B)$. 
It would if the function is injective, but unfortunately this is not among the hypotheses.
Note that the example function does not satisfy property d, because $f(\{1\})=f(\{2\})=\{0\}$, but $\{1\}$ and $\{2\}$ are disjoint.
