Difference betwwen $(\sqrt{2}, \pi)\cap \mathbb Q$ and $[\sqrt{2}, \pi]\cap \mathbb Q$ in $\mathbb Q$

Consider two metric spaces $$X,Y$$ such as $$Y\subseteq X$$. Let $$A\subseteq Y$$. $$A$$ is open in $$Y$$ $$\iff$$ $$\exists B\subseteq X$$ open in $$X$$ such that $$A=B\cap Y$$

According to this theorem, the set $$(\sqrt{2} , \pi) \cap \mathbb Q$$ must be open in $$\mathbb Q$$.

However, as $$\sqrt{2}$$ and $$\pi$$ are irrationals, we are excluding boundaries that do not exist in $$\mathbb Q$$, so I think the set $$(\sqrt{2} , \pi) \cap \mathbb Q$$ is closed.

The problem is that I see no differences (in terms of openness / closedness) between $$(\sqrt{2} , \pi) \cap \mathbb Q$$ and $$[\sqrt{2} , \pi] \cap \mathbb Q$$. Could it be that they are both open and closed ?

• Yes, $(\sqrt 2, \pi) \cap \mathbb{Q}$ is both open and closed in $\mathbb{Q}$. Commented Apr 4, 2023 at 8:50
• @Lemmon Isn't the intersection of two sets always included in both of the sets ? Commented Apr 4, 2023 at 8:51
• @niobium Of course, disregard my comment. Zoe's answer is correct. Commented Apr 4, 2023 at 8:52

Indeed. There's more, actually: $$(\sqrt{2} , \pi) \cap \mathbb Q$$ is literally equal to $$[\sqrt{2} , \pi] \cap \mathbb Q$$. So there's no difference between them at all, not only in terms of open/closed.
You are correct that they are both open and closed; and you are also correct in that $$(\sqrt{2},\pi)\cap\mathbb{Q}=[\sqrt{2},\pi]\cap\mathbb{Q}$$. The stated theorem is in fact still true if you replace each instant of the word "open" with "closed". This is easy to show noting that the complement of an open set is closed.
In this specific case, applying just your theorem and the fact you spotted that $$(\sqrt{2},\pi)\cap\mathbb{Q}=[\sqrt{2},\pi]\cap\mathbb{Q}$$, you can take the complement of $$[\sqrt{2},\pi]\cap\mathbb{Q}$$ and easily see this is open in $$\mathbb{Q}$$. Thus $$(\sqrt{2},\pi)\cap\mathbb{Q}$$ is closed in $$\mathbb{Q}$$.