Dimension of irreducible affine variety is same as any open subset Let $X$ be an irreducible affine variety. Let $U \subset X$ be a nonempty open subset. Show that dim $U=$ dim $X$.

Since $U \subset X$, dim $U \leq$ dim $X$ is immediate. I also know that the result is not true if $X$ is any irreducible topological space, so somehow the properties of an affine variety have to come in. I have tried assuming $U=X$ \ $V(f_1,...,f_k)$ but I don't know how to continue on.

Any help is appreciated!
Let $X=\operatorname{Spec} A$, and pick some nonzero $f\in A$ with $\operatorname{Spec} A_f = D(f) \subset U$.  Then we can lift chains of closed sets to see that $\dim D(f) \leq \dim U 
\leq \dim X$.

But as shown here, we have $\dim D(f) = \dim A_f = \dim A = \dim X$.  We can also see this quite quickly by noting that $A$ and $A_f$ have the same fraction fields, and therefore the same transcendence degree over $k$.



Note that this is false for general rings $A$, even if $A$ is assumed to be a noetherian domain.  In fact, any DVR is a counterexample.
You should note that any nonempty open subset of an irreducible variety (or topological space) is dense : https://en.wikipedia.org/wiki/Hyperconnected_space.
Then you can use the definition of the dimension to conclude.