Proof of "the continuous image of a connected set is connected"

$f^{-1}(A) \cup f^{-1}(B)$ may be larger than $E$, but it must contain $E$: if $x \in E$, $f(x) \in f(E) = A \cup B$. Then either $f(x) \in A$ or $f(x) \in B$. In the first case, $x \in f^{-1}(A)$, and in the second $x \in f^{-1}(B)$. (The fact that $f^{-1}(A) \cup f^{-1}(B)$ may be larger than $E$ is the reason for intersecting with $E$ when defining $G$ and $H$.)


If $e \in E$, then $f(e) \in f(E) = A \cup B$.
So, $f(e) \in A$ or $f(e) \in B$.
So, $e \in f^{-1}(A)$ or $e \in f^{-1}(B)$.
So, $e \in f^{-1}(A) \cup f^{-1}(B)$.
So, $E \subset f^{-1}(A) \cup f^{-1}(B)$.

So, $E = E \cap (f^{-1}(A) \cup f^{-1}(B)) = (E \cap f^{-1}(A)) \cup (E \cap f^{-1}(B)) = G \cup H$.

$A \cap B = \emptyset$.
So, $f^{-1}(A) \cap f^{-1}(B) = \emptyset$.
So, $\emptyset = E \cap \emptyset = E \cap (f^{-1}(A) \cap f^{-1}(B)) = (E \cap f^{-1}(A)) \cap (E \cap f^{-1}(B)) = G \cap H$