Cantor-Bernstein-Schröder Theorem/Lemma/Proof 3

Proof
Define $C = \{f^k(x) | k \in \N, x \in S \setminus T \}$.

Clearly, $C = C_0 \cup C_1$, where:

$C_0 = S \setminus T$, the difference between $S$ and $T$,

$C_1 = \{f^k(x) | k \in \N_{> 0}, x \in S \setminus T \}$.

Note, that $S \setminus C_0 = T$.

Obviously, $im(f|C) = C_1$.

Define a mapping $h: S \to S$ as follows:

$\map h x = \begin {cases} \map f x & : x \in C \\ x & : x \notin C \end {cases}$

Clearly, $h = f|C \cup id(S \setminus C)$, where $id(S \setminus C)$ is the identity function on the set $S \setminus C$. Note, that $dom(h) = S$;

$im(h) = im(f|C) \cup im(id(S \setminus C) =$ $C_1 \cup (S \setminus C) =$ $C_1 \cup (S \setminus (C_0 \cup C_1)) =$ $S \setminus C_0 =$ $T$.

Also, $h$ is an injection because $h$ is the union of the injections $f|C$ and $id(S \setminus C)$ and $dom(f|C) \cap dom(id(S \setminus C)) = \{\}$ and $im(f|C) \cap im(id(S \setminus C) = C_1 \cap (S \setminus C) = \{\}$ because $C_1 \subseteq C$.

Now $h$ is a bijection $S \to T$ because $dom(h) = S, im(h) = T$ and $h$ is an injection.