# Dense set

In topology and related areas of mathematics, a subset A of a topological space X is said to be dense in X if every point of X either belongs to A or else is arbitrarily "close" to a member of A — for instance, the rational numbers are a dense subset of the real numbers because every real number either is a rational number or has a rational number arbitrarily close to it (see Diophantine approximation). Formally, $\displaystyle{ A }$ is dense in $\displaystyle{ X }$ if the smallest closed subset of $\displaystyle{ X }$ containing $\displaystyle{ A }$ is $\displaystyle{ X }$ itself.

The density of a topological space $\displaystyle{ X }$ is the least cardinality of a dense subset of $\displaystyle{ X. }$

## Definition

A subset $\displaystyle{ A }$ of a topological space $\displaystyle{ X }$ is said to be a dense subset of $\displaystyle{ X }$ if any of the following equivalent conditions are satisfied:

1. The smallest closed subset of $\displaystyle{ X }$ containing $\displaystyle{ A }$ is $\displaystyle{ X }$ itself.
2. The closure of $\displaystyle{ A }$ in $\displaystyle{ X }$ is equal to $\displaystyle{ X. }$ That is, $\displaystyle{ \operatorname{cl}_X A = X. }$
3. The interior of the complement of $\displaystyle{ A }$ is empty. That is, $\displaystyle{ \operatorname{int}_X (X \setminus A) = \varnothing. }$
4. Every point in $\displaystyle{ X }$ either belongs to $\displaystyle{ A }$ or is a limit point of $\displaystyle{ A. }$
5. For every $\displaystyle{ x \in X, }$ every neighborhood $\displaystyle{ U }$ of $\displaystyle{ x }$ intersects $\displaystyle{ A; }$ that is, $\displaystyle{ U \cap A \neq \varnothing. }$
6. $\displaystyle{ A }$ intersects every non-empty open subset of $\displaystyle{ X. }$

and if $\displaystyle{ \mathcal{B} }$ is a basis of open sets for the topology on $\displaystyle{ X }$ then this list can be extended to include:

1. For every $\displaystyle{ x \in X, }$ every basic neighborhood $\displaystyle{ B \in \mathcal{B} }$ of $\displaystyle{ x }$ intersects $\displaystyle{ A. }$
2. $\displaystyle{ A }$ intersects every non-empty $\displaystyle{ B \in \mathcal{B}. }$

### Density in metric spaces

An alternative definition of dense set in the case of metric spaces is the following. When the topology of $\displaystyle{ X }$ is given by a metric, the closure $\displaystyle{ \overline{A} }$ of $\displaystyle{ A }$ in $\displaystyle{ X }$ is the union of $\displaystyle{ A }$ and the set of all limits of sequences of elements in $\displaystyle{ A }$ (its limit points), $\displaystyle{ \overline{A} = A \cup \left\{\lim_{n \to \infty} a_n : a_n \in A \text{ for all } n \in \N\right\} }$

Then $\displaystyle{ A }$ is dense in $\displaystyle{ X }$ if $\displaystyle{ \overline{A} = X. }$

If $\displaystyle{ \left\{U_n\right\} }$ is a sequence of dense open sets in a complete metric space, $\displaystyle{ X, }$ then $\displaystyle{ \bigcap^{\infty}_{n=1} U_n }$ is also dense in $\displaystyle{ X. }$ This fact is one of the equivalent forms of the Baire category theorem.

## Examples

The real numbers with the usual topology have the rational numbers as a countable dense subset which shows that the cardinality of a dense subset of a topological space may be strictly smaller than the cardinality of the space itself. The irrational numbers are another dense subset which shows that a topological space may have several disjoint dense subsets (in particular, two dense subsets may be each other's complements), and they need not even be of the same cardinality. Perhaps even more surprisingly, both the rationals and the irrationals have empty interiors, showing that dense sets need not contain any non-empty open set. The intersection of two dense open subsets of a topological space is again dense and open.[proof 1] The empty set is a dense subset of itself. But every dense subset of a non-empty space must also be non-empty.

By the Weierstrass approximation theorem, any given complex-valued continuous function defined on a closed interval $\displaystyle{ [a, b] }$ can be uniformly approximated as closely as desired by a polynomial function. In other words, the polynomial functions are dense in the space $\displaystyle{ C[a, b] }$ of continuous complex-valued functions on the interval $\displaystyle{ [a, b], }$ equipped with the supremum norm.

Every metric space is dense in its completion.

## Properties

Every topological space is a dense subset of itself. For a set $\displaystyle{ X }$ equipped with the discrete topology, the whole space is the only dense subset. Every non-empty subset of a set $\displaystyle{ X }$ equipped with the trivial topology is dense, and every topology for which every non-empty subset is dense must be trivial.

Denseness is transitive: Given three subsets $\displaystyle{ A, B }$ and $\displaystyle{ C }$ of a topological space $\displaystyle{ X }$ with $\displaystyle{ A \subseteq B \subseteq C \subseteq X }$ such that $\displaystyle{ A }$ is dense in $\displaystyle{ B }$ and $\displaystyle{ B }$ is dense in $\displaystyle{ C }$ (in the respective subspace topology) then $\displaystyle{ A }$ is also dense in $\displaystyle{ C. }$

The image of a dense subset under a surjective continuous function is again dense. The density of a topological space (the least of the cardinalities of its dense subsets) is a topological invariant.

A topological space with a connected dense subset is necessarily connected itself.

Continuous functions into Hausdorff spaces are determined by their values on dense subsets: if two continuous functions $\displaystyle{ f, g : X \to Y }$ into a Hausdorff space $\displaystyle{ Y }$ agree on a dense subset of $\displaystyle{ X }$ then they agree on all of $\displaystyle{ X. }$

For metric spaces there are universal spaces, into which all spaces of given density can be embedded: a metric space of density $\displaystyle{ \alpha }$ is isometric to a subspace of $\displaystyle{ C\left([0, 1]^{\alpha}, \R\right), }$ the space of real continuous functions on the product of $\displaystyle{ \alpha }$ copies of the unit interval. 

## Related notions

A point $\displaystyle{ x }$ of a subset $\displaystyle{ A }$ of a topological space $\displaystyle{ X }$ is called a limit point of $\displaystyle{ A }$ (in $\displaystyle{ X }$) if every neighbourhood of $\displaystyle{ x }$ also contains a point of $\displaystyle{ A }$ other than $\displaystyle{ x }$ itself, and an isolated point of $\displaystyle{ A }$ otherwise. A subset without isolated points is said to be dense-in-itself.

A subset $\displaystyle{ A }$ of a topological space $\displaystyle{ X }$ is called nowhere dense (in $\displaystyle{ X }$) if there is no neighborhood in $\displaystyle{ X }$ on which $\displaystyle{ A }$ is dense. Equivalently, a subset of a topological space is nowhere dense if and only if the interior of its closure is empty. The interior of the complement of a nowhere dense set is always dense. The complement of a closed nowhere dense set is a dense open set. Given a topological space $\displaystyle{ X, }$ a subset $\displaystyle{ A }$ of $\displaystyle{ X }$ that can be expressed as the union of countably many nowhere dense subsets of $\displaystyle{ X }$ is called meagre. The rational numbers, while dense in the real numbers, are meagre as a subset of the reals.

A topological space with a countable dense subset is called separable. A topological space is a Baire space if and only if the intersection of countably many dense open sets is always dense. A topological space is called resolvable if it is the union of two disjoint dense subsets. More generally, a topological space is called κ-resolvable for a cardinal κ if it contains κ pairwise disjoint dense sets.

An embedding of a topological space $\displaystyle{ X }$ as a dense subset of a compact space is called a compactification of $\displaystyle{ X. }$

A linear operator between topological vector spaces $\displaystyle{ X }$ and $\displaystyle{ Y }$ is said to be densely defined if its domain is a dense subset of $\displaystyle{ X }$ and if its range is contained within $\displaystyle{ Y. }$ See also Continuous linear extension.

A topological space $\displaystyle{ X }$ is hyperconnected if and only if every nonempty open set is dense in $\displaystyle{ X. }$ A topological space is submaximal if and only if every dense subset is open.

If $\displaystyle{ \left(X, d_X\right) }$ is a metric space, then a non-empty subset $\displaystyle{ Y }$ is said to be $\displaystyle{ \varepsilon }$-dense if $\displaystyle{ \forall x \in X, \; \exists y \in Y \text{ such that } d_X(x, y) \leq \varepsilon. }$

One can then show that $\displaystyle{ D }$ is dense in $\displaystyle{ \left(X, d_X\right) }$ if and only if it is ε-dense for every $\displaystyle{ \varepsilon \gt 0. }$