Is there a largest open interval for an open set (not necessarily bounded)? If $G$ is an open subset of $R$, and if $x\in G$, show that there exists a largest open interval $I_x$ containing $x$ s.t $I_x$ is the subset of $G$.
My idea:
Let $x\in (a_x,b_x)$ where 
$a_x=\inf\{a<x|(a,x)\subset G \}$ and 
$b_x=\sup\{b>x|(x,b)\subset G \}$.
Let $I_x=(a_x,b_x)$.
I want to show $a_x$, $b_x$ can not belong to G, hence $I_x$ is the largest interval.
Assume $a_x\in G$, this contradicts the fact that $a_x$ was $\inf$. so $a_x$ is not in $G$. Likewise for $b_x$. 
I think if it was said that $G$ is bounded, I could confidently use the proof idea above. But it is NOT. So what if G is unbounded? Then I may not have finite $a_x$ and $b_x$. Or do I need to be worried about this at all?
 A: You could change your approach to defining $a_x$ and $b_x$ ever so slightly, to make your proof correct. 


*

*If the set $\{a<x \mid (a,x)\subset G \}$ is bounded below, then let $a_x$ be the infimum of that set. Otherwise let $a_x = -\infty$.

*If the set $\{b>x \mid (x,b)\subset G \}$ is bounded above, then let $b_x$ be the supremum of that set. Otherwise let $b_x = +\infty$.


Now you should go through the remainder of your proof and check carefully for any changes that are required by having changed the definitions of $a_x$ and $b_x$.
A: One way to think about this is use the following fact.  
Every open set in $\mathbf{R}$ can be written as a countable union of pairwise disjoint open intervals.
So we get $$G=\bigcup_{i=1}^{\infty}I_i$$
Let $x \in G \implies \exists! n\in\mathbf{N} $ so that $x\in I_n$
Now you can check that this interval will be your maximal interval containing $x$  that's contained in $G$.
A: You can just say that as $G$ is open, it means that there exists an open interval included in $G$ around each of its points, thus there exists at least $a_0$ and $b_0$ such that $x \in (a_0, b_0) \subset G$.
And then you can consider the set of all the intervals in $G$ including $x$, and take the biggest.
A: Your proof is fine when situated in the appropriate framework.
Although it might not be accepted in the context of a class, I think the best way to handle this problem is to use the extended real line $\bar{\mathbb R} = \mathbb R \cup \{-\infty,\infty\}$ where we can order this set in the obvious way and define infimum and supremum from the order - and likewise, can define open intervals as usual, with the observation that $(-\infty,x)$ are honest intervals in this view that coincide with the usual definitions. The importance of this change is that every set has a supremum and infimum in the extended reals - so you do not need to worry about boundedness at all.
Basically, with this change of context, you just say that you have some subset of $\mathbb R$ and let $a_x$ and $b_x$ be the infimum and supremum of that set in $\bar{\mathbb R}$, and then just finish your argument exactly as you did - except that you might, for completeness, observe that if $a_x$ and $b_x$ are real, they are not in the set for the reasons you observe, and if they are not, they are not in the set because the set is a subset of $\mathbb R$.
One often finds that analysis questions such as this one are much clearer if you work with $\pm \infty$ within the domain of mathematics, rather than, as is common, saying that every expression involving $\infty$ is specially defined and requires casework - because often the extended reals unify the theory with no need for extra work.
