$\bigcup U_{i}$ and $\bigcup V_{j}$ are homeomorphic iff there are equally many $U_{i}$ and $V_{j}$ where $U_{i},V_{i}$ are open. Let $U$ and $V$ two open sets in $\mathbb{R}$.


*

*First, I proved that if $U$ is open, then $U = \bigsqcup_{i \in \mathbb{N}} U_{i}$ where $U_{i}$ is open and $"\bigsqcup"$ means disjoint union.

*Second, I proved that $U_{i}$ are uniquely determined by $U$, that is, $\bigsqcup_{i \in \mathbb{N}} U_{i}$ is unique, up to order of the factors.
Now, I want to prove that

If $U$ and $V$ are open, $U$ and $V$ are homeomorphic iff there are equally many $U_{i}$ and $V_{j}$.

This makes perfect sense for me, but I dont know how to write correctly.
Can someone help me?
I dont know if it helps, but I wrote $U = \bigsqcup I_{x}$ where $I_{x}$ is the largest interval containing $x$ and countained in $U$.
 A: Hints: your construction $U = \bigcup_x I_x$, where $I_x$ is a maximal interval containing $x \in U$, is a good way of describing the decomposition of $U$ into its  connected components, but you need to pick just one $x$ from each connected component to get a disjoint union. You are right that there will be at most countably many distinct connected components $I_x$, but there need not be infinitely many (e.g., take $U = \Bbb{R}$). So your first observation should be that $U = \bigsqcup_{j \in J}U_j$, where $J \subseteq \Bbb{N}$ and each $U_j$ is non-empty open interval. Now if you have $V = \bigsqcup_{k \in K}V_k$ where $K \subseteq \Bbb{N}$ and each $V_k$ is a non-empty open interval, then, if $J$ and $K$ have the same number of elements you can use a bijection between $J$ and $K$ and your favourite homeomomorphism between any two open intervals $(a, b)$ and $(c, d)$ ($a < b$ and $c < d)$ to construct a homeomorphism between $U$ and $V$. Conversely you can use a homeomorphism between $U$ and $V$ to construct a bijection between $J$ and $K$ (so $J$ and $K$ have "equally many elements").
