Suppose $a\in\mathbb{R}$ and $S$ is a nonempty subset of $\mathbb{R}$ such that $S=\{q\in\mathbb{Q}, q<a\}$. Prove that $\sup(S)=a$. Here is my proof.
we argue by contradiction. Suppose $\sup(S)\neq a$. Then there exists a supremum $a'$ (because $S$ is nonempty bounded above subset of $\mathbb{R}$.) such that $a'<a$. By density of rational numbers, there exists $q$ such that $a'<q<a$. But this contradicts the fact that $a'$ is an upper bound of set $S$.
Is this proof legit?
Yes, it is correct, the clue is that the following holds: $$a,b\in \mathbb{R}: a < b \Rightarrow \exists q \in \mathbb{Q}: a < q < b $$ Which follows by the fact that $\mathbb{Q} \subseteq \mathbb{R}$ is a dense subset and thus has a nonempty intersection with the open set $(a,b)$.