I am trying to prove that if $X \subset \mathbb{R}^{n}$ is semialgebraic, then $\operatorname{dim}X = \operatorname{dim}\overline{X}$, where the dimension of a semialgebraic set is the supremum of the dimensions of the elements of a finite semi-algebraic stratification of $X$. The reference is the book from Benedetti and Risler, Semialgebraic and Real Algebraic Sets.
For context, an stratification of a set $X$ is a partition of $X$ into locally closed analytic submanifolds of $\mathbb{R}^{n}$ s.t. $A_{i} \cap \overline{A_{j}} \neq \emptyset$, then $A_{i} \subset \overline{A_{j}}$ and $\operatorname{dim} A_{i} < \operatorname{dim} A_{j}$.
The stratification theorem says that given any finite family $\{P_{1},...,P_{k}\} \subset \mathbb{R}[X_{1},...,X_{n}]$, we can extend it to a family $\{P_{1},...,P_{R}\}$ s.t. the sets of the type $\displaystyle \bigcap_{j=1}^{R} \{x \in \mathbb{R}^{n}: P_{j}(x) s_{j} 0\}$ (called elementary sets) are connected, where $s_{j}$ is $<,=$ or $>$, and the closure of every such set is obtained by relaxing the inequalities. Also, elementary sets form a stratification of $\mathbb{R}^{n}$. By the first structure theorem for semialgebraic sets (where we can decompose it as graphs of maps and bands determined by these graphs), any semialgebraic set admits an stratification.
The book says that the proposition follows from the property about the closure of elementary sets, but I don't understand how.
I tried to analyse what happens with a stratification of $X$ when we take the closure of $X$, but the result is not a stratification of $\overline{X}$. I appreciate any help.
Let us prove the following lemma:
Now consider $X$ a semialgebraic subset of $\mathbb{R}^n$ and $\mathcal{S}$ a stratification of $\mathbb{R}^n$ compatible with $X$. By Theorem 2.4.4, we can assume that the strata of $\mathcal{S}$ are elementary sets satisfying a kind of Thom's Lemma, that is the closure of the strata are obtained by relaxing the inequalities. Now, $$ X = \bigcup_{S \in \mathcal{S}'} S\ \mbox{ and }\ \overline{X} = \bigcup_{S \in \mathcal{S}'} \overline{S},$$ for some subset $\mathcal{S}'$ of $\mathcal{S}$. Since we can obtain each stratum $S$ by relaxing inequalities, we have $\mathrm{dim}\, S = \mathrm{dim}\, \overline{S}$. We can conclude by the above lemma.