Question about proof that every open set in $\Bbb R$ can be written as disjoint union of intervals. I have a question about the proof in Stein and Shakarski's measure theory book. The argument goes as follows. Let $O$ be open in $\Bbb R$. Given $x \in O$, we define $I_x$ (the maximal interval in $O$ which contains x). Let $I_x=(a_x,b_x)$ where $a_x= \inf[a<x: (a,x)\subset O]$, $b_x= \sup[x<b: (x,b)\subset O]$. Then $O= \cup_{x\in O} I_x$.
Now I want to show this last claim holds but I am unsure of the details. First of all, to show $O\subset \cup_{x\in O} I_x$, I said let $x\in O$, then $x\in I_x$ since $a_x \leq a < x $ for all a for which $(a,x)\in O$. Similarly for the other side. Since this works for any element of $O$, we have the desired result. Is my proof for this side of the containment correct?
Now for the other side, how do we show that $\cup_{x\in O} I_x \subset O$ ? How do we know $(a_x,b_x)$ is necessarily in O? Is it the case that the infimum of a set has to obey the same condition the elements of that set obey (i.e. $(a,x)$ and $(x,b)$ in $O$)? Thanks!
 A: If $y\in(a_x,b_x)$ then by definition $a_x<y<b_x$. If $y<x$ then choose $a$ with $a_x<a<y$, so that by definition $y\in(a,x)\subset O$. A similar argument shows $y\in O$ if $y>x$.
A: Let $x \in O$.  Let $a_x = \inf\{a|a < x; (a,x) \subset O\}$[#].  If $(a_x, x) \not \subset O$ then there is a $b; a_x < b < x$ so that $b \not \in O$ so $(\frac {a_x + b}2, x) \not \subset O$ and for all $c \le \frac {a_x + b}2$, $(c, x) \not \subset O$.  So $\frac {a_x + b}2$ is lower bound of  $\{a|a < x; (a,x) \subset O\}$ which is a contradiction as $\frac {a_x + b}2 > a_x =\inf\{a|a < x; (a,x) \subset O\}$
So $(a_x, x) \subset O$.  $x \in O$ so $(a_x, x] \subset O$.
The exact same argument holds that $[x, b_x) \subset O$.  So $I_x = (a_x, b_x) \subset O$.
[#] Of course to assume the infinum actually exist the set needs to be bounded below.  Which if $O$ isn't, the set may not be.  
Complete proof:  Let $O \subset \mathbb R$ be open.  We'll assume $O$ is non-empty as this is vacuously true if $O$ is empty.  The empty set is the empty union of any sets.
For each $x \in O$ define  an interval $I_x$ with $x\in I_x$ via the following:
Let $A_x = \{y \in O|(y,x) \subset O\}$ and let $B_x= \{y \in O|(x,y) \subset O\}$.  We know $A_x$ is not empty as $O$ is open so there must exist an $\epsilon >0$ so that $(a-\epsilon,a+\epsilon) \subset O$ so $a-\epsilon \in A_x$.  Likewise $B_x$ is non-empty.
If $A_x$ is non-empty and bounded below let $a_x = \inf A_x$; if $A_x$ is not bounded below  let $a_x = -\infty$.    If $B_x$ is bounded above let $b_x = \sup A$; otherwise let $b_x = \infty$.  
If $w \in (a_x, b_x)$ then either $w=x; w<x; w>x$.  i) If $w=x$ then $w \in O$.  ii) If $w < x$ then $w > a_x$ so $w$ is not a lower bound of $A_x$. So there is an element $a \in A_x; a_x  \le a < w < x$.  $a \in A_x$ so $(a,x) \subset O$ and $w \in (a,x) \subset O$. iii) by exact same argument if $w > x$ then there is a $b\in B_x$ so that $w \in (x,b) \subset O$.  So in all three cases $w \in O$ so $(a_x,b_x) \subset I_x$.  So $I_x \subset O$.  (Note: $a_x$ and/or $b_x$ could have been equal to $\pm \infty$.)
For each $y\in O$ $y \in I_y \subset \cup_x\in O I_x$ so $O \subset \cup_x\in O I_x$.  And if $y \in \subset \cup_x\in O I_x$ then $y \in I_w \subset O$ for some $w\in O$ so $ \cup_x\in O I_x \subset O$.  So $O =  \cup_x\in O I_x$.
Remains to show the $I_x$ are disjoint.  If $I_x \cap I_w \ne \emptyset$ then if $v \in I_x \cap I_w$, The $a_x < v < b_x$ and $a_w < v < b_w$ so $(\min(v,x),\max(v,x))$ and $(\min(v,w),\max(v,w))$ are both subsets of $O$ so $a_w=a_x=a_v$ and $b_w=b_x=b_v$ so $I_x = I_w = I_v$.  So the $I_x$ are disjoint  or equal.
The harder part is proving if we remove the redundencies, that this is a countable union.
