Which sets occur as boundaries of other sets in topological spaces? This question was originally asked on MathStackExchange and is migrated here with opinion from MO meta. I am integrating the inputs from users Daniel Fischer and Emil Jerabek there into this post.
Which sets occur as boundaries of other sets in topological spaces?
Of course the boundary of a set is closed. But not every closed set in a topological space is the boundary of some set in that space; only the empty set occurs as a boundary in a discrete space.
More generally, boundaries cannot contain isolated points of the ambient space (but can well have isolated points of itself).
It is tempting to assert that boundaries have empty interiors, but this is not true, as is shown by the fact that the boundary of Q in R is R. In fact it can be seen in general that the boundary of a dense set with empty interior is the whole space. Thus the only boundary in an indiscrete space is the whole set, just as the only boundary in a discrete space is the empty set.
However the intuitive feeling comes right for open sets (and then for closed sets as well): The boundary of an open set cannot contain an open set.
This question concerns all subsets of a topological space.
An alternative/related question shall be to characterise all topological spaces in which every closed set occurs as a boundary.
Being a perfect space (i.e., one without isolated points) is a necessary condition, as a previous remark above about isolated points shows.
Emil Jerabek has conjectured on meta that this (being perfect) is sufficient too, for $T_0$ second countable spaces.
 A: The spaces in which every closed set is a boundary are precisely the resolvable spaces. A topological space is said to be resolvable if it can be partitioned into two dense subspaces.
$\mathbf{Proposition}$ A space is resolvable if and only if every closed set is the boundary of some set.
$\leftarrow$ If $X$ is a topological space such that every closed subspace of $X$ is a boundary of some set, then the set $X$ is the boundary of some set $A$. However, if
$X=\partial A=\overline{A}\setminus(A^{\circ})$, then $A^{\circ}=\emptyset$, so
$\overline{A^{c}}=(A^{\circ})^{c}=X$. Therefore $A$ and $A^{c}$ are two disjoint dense subsets of $X$, so $X$ is resolvable.
$\rightarrow$ Suppose that $X$ is resolvable. Then there is a partition $A,B$ of $X$ into two dense subspaces. Let $C\subseteq X$ be a closed subspace. Then
I claim that $C=\partial (\partial C\cup(C^{\circ}\cap A))$.
Clearly $\partial C\cup(C^{\circ}\cap A)\subseteq C$, so
$\overline{\partial C\cup(C^{\circ}\cap A)}\subseteq C$.
Clearly $\partial C\subseteq\overline{\partial C\cup(C^{\circ}\cap A)}$.
On the other hand, if $x\in C^{\circ}$, then for each open neighborhood $U$ of $x$, the set $U\cap C^{\circ}$ is also an open neighborhood of $x$. Therefore the set $A\cap U\cap C^{\circ}$ is non-empty since $A$ is a dense set. We therefore conclude that $x\in\overline{C^{\circ}\cap A}\subseteq\overline{\partial C\cup(C^{\circ}\cap A)}$. We therefore conclude that $C^{\circ}\subseteq\overline{\partial C\cup(C^{\circ}\cap A)}$. Therefore, we have
$C=C^{\circ}\cup\partial C\subseteq\overline{\partial C\cup(C^{\circ}\cap A)}$.
Therefore $C=\overline{\partial C\cup(C^{\circ}\cap A)}$.
On the other hand, if $U\subseteq\partial C\cup(C^{\circ}\cap A)$ is open, then $U\subseteq C^{\circ}\cap A$. However, since $B$ is dense, $U$ must be empty. Therefore, $(\partial C\cup(C^{\circ}\cap A))^{\circ}=\emptyset$.
We conclude that $C=\partial(\partial C\cup(C^{\circ}\cap A))$. $\mathbf{QED}$
As was pointed out by Will Sawin, a closed subset of a topological space is a boundary of some space if and only if its interior is resolvable.
Since the notion of resolvability has not appeared on this website before, let me state a few facts about resolvability.
Most spaces with no isolated points that one deals with in topology are resolvable (and much more ).
Let's call a space $X$ $\kappa$-resolvable if $X$ can be partitioned into $\kappa$ many dense subsets. The dispersion character $\Delta(X)$ of a topological space $X$ is the minimal cardinality of a non-empty open subspace of $X$. A topological space $X$ is said to be maximally resolvable if it is $\Delta(X)$-resolvable.
Every compact Hausdorff space and every metric space is maximally resolvable. Furthermore, assuming $V=L$, there every Baire space with no isolated points is $\aleph_{0}$-resolvable. In fact, the existence of a Baire irresolvable space with no isolated points is equiconsistent with the existence of a measurable cardinal. Also, every countably compact regular space is $\omega_{1}$-resolvable. 
Also, resolvability is equivalent to a seemingly weaker condition. A space $X$ is resolvable if and only if it can be partitioned into finitely many subsets with empty interiors.
A: Building on Joseph Van Name's answer
A closed set is a boundary if and only if its interior is a resolvable topological space
Proof: 
$\leftarrow$ If $A$ is a subset of $X$ whose interior $A^o$ is resolvable, i.e., $A^o=B\cup (A^o-B)$ where $B$ and $A^o-B$ are dense in $A^o$, let $C$ be the union of the complement of the set and one of the two dense parts of the interior,
$C=B\cup A^c$.
The interior of this union is just the complement of the set,
$C^o=(B\cup A^c)^o=A^c$,
as $B$ cannot contain interior points if $A^o-B$ has to be dense in $A^o$.
The closure of this union, $\overline{C}=\overline{B\cup A^c} $ includes the interior $A^o$ and the complement $A^c$ of $A$, and is closed, so is the whole space, i.e., $\overline{C}=X$. 
Hence, $\partial C=\overline{C}-C^o=X-A^c=A.$
$\rightarrow$ For this part, note that the property of a set being a boundary is preserved by restriction to open subsets, and use Joesph Van Name's answer.
