I'm now studying general topology. As stated in Intro. to Topology by Yan Min, if $A$ is dense in $B$, then $B \subset \overline{A}$. I'm not sure if the reverse is true (which my attempt assumes so). Please correct me, or suggest better ways to answer the following iff question:
Prove if $X$ is a union of open subsets $X_i$, then $A \subseteq X$ is dense iff $A$ is dense in each $X_i$.
My attempt:
$\underline{\Rightarrow}$: As (a) $A \subseteq X$ is dense & (b) each $X_i \subseteq X$ is open, $A \cap X_i$ is dense in each $X_i$. As $X_i \subset \overline{A \cap X_i} \subseteq \overline{A}$, $A$ is also dense in each $X_i$.
$\underline{\Leftarrow}$: $A$ is dense in each $X_i \Rightarrow X_i \subset \overline{A} \Rightarrow$ (for $i \neq j)$ $X_i \cup X_j \subset \overline{A} \Rightarrow \cup_i X_i = X \subset \overline{A} \Rightarrow A$ is dense in $X$. Also, $X = \cup$ open $X_i$ which is open. So $A \cap X = A$ is dense in $X$.
Many thanks.
There seems to be some confusing (see comments) about what "$A$ is dense in $B$", where $A,B \subseteq B$ means exactly. The OP seems to have the definition that
while the more standard definition states that in order for that statement to open make sense, we need $A \subseteq B$ and that moreover the closure of $A$ (in the subspace $B$) must equal $B$.
But (1) is in fact equivalent to
So $A$ is dense in $B$ then can be seen as "the part of $A$ that hits $B$ is close to all points of $B$", and then we could say that $\mathbb{Q}$ is dense in $\mathbb{Z}$ and also that the irrationals $\mathbb{P}$ are not dense in $\mathbb{Q}$ even though $\mathbb{Q} \subseteq \operatorname{Cl}_X(\mathbb{P})$.
So the reverse is not true, to come back to the OP's question.
If $D$ is dense in every $X_i$, then $D$ is dense in $X$: let $x \in X$ and $U$ open containing $x$. Then $U \cap X_i$ is open in $X_i$ so intersects $D \cap X_i$ which implies $U$ intersects $D$.
OTOH, if $D$ is dense in $X$, then $D$ dense in $X_i$ (in the second sense), for let $x \in X_i$ and $x \in O$ open in $X_i$, then $O$ open in $X$ (as $X_i$ is open in $X$) and $O \cap X_i$ thus intersects $D$ and we are done.