Given a set $X$ and $\mathcal{A} \subseteq \mathcal{P}(X)$, prove that there exists a unique smallest topology on $X$ that contains $\mathcal{A}$
My attempt:
Define $$\mathcal{B}:= \mathcal{A} \cup \{\emptyset, X\}$$ $$\mathcal{C} := \{\bigcap \mathcal{E}\mid \mathcal{E} \subseteq \mathcal{B}, \mathcal{E} \ \mathrm{finite}\}$$ $$\mathcal{D} := \{\bigcup \mathcal{F}\mid\mathcal{F} \subseteq \mathcal{C}\}$$
We now prove that $\mathcal{D}$ is the topology we look for.
Take $\mathcal{E}:= \{\emptyset\} \in \mathcal{B}$. Then $\bigcap \mathcal{E} = \emptyset \in \mathcal{C}$ and if we put $\mathcal{F}:= \{\emptyset\} \subseteq \mathcal{C}$, it follows that $\bigcup \mathcal{F} = \emptyset \in \mathcal{D}$
In the same way, we can prove that $X \in \mathcal{D}$.
Now, let $A,B \in \mathcal{D}$. Then, there exists families $\mathcal{F_1}:= (F_i^1)_{i \in I}, \mathcal{F_2}:= (F_j^2)_{j \in J} \subseteq \mathcal{C}$ such that $A = \bigcup \mathcal{F_1}, B = \bigcup \mathcal{F_2}$
Hence, $A \cap B = (\bigcup_{i \in I} F_i^1) \cap (\bigcup_{j \in J}F_j^2) = \bigcup_{i \in I, j \in J}F_i^1 \cap F_j^2$
and hence it suffices to prove that $F_i^1 \cap F_j^2 \in C$, for every $i$ and $j$.
To do this, we note that $F_i^1, F_j^2 \in \mathcal{C}$. Hence, there are finite collections $ \mathcal{E_1}:=(E_k^1)_{k \in K}, \mathcal{E_2}:=(E_l^2)_{l \in L} \subseteq \mathcal{B}$ with $F_i^1 := \bigcap \mathcal{E_1}, F_j^2 := \bigcap \mathcal{E_2}$
and hence $$F_i^1 \cap F_j^2 = \bigcap_{k \in K} E_k^1 \cap \bigcap_{l \in L} E_l^2$$
and this is a finite intersection of sets out of $\mathcal{B}$, so $F_i^1 \cap F_j^2 \in \mathcal{C}$
Now, let $\mathcal{G}:= (G_n)_{n \in N} \subseteq \mathcal{D}$. Then for each $n \in N$, there is a collection $\mathcal{F_n} := (F_m^n)_{m \in M} \subseteq \mathcal{C}$ with $G_n = \bigcup\mathcal{F_n}$
So, $$\bigcup \mathcal{G} = \bigcup_{n \in N} G_n =\bigcup_{n \in N}(\bigcup \mathcal{F_n}) =\bigcup_{n \in N}\bigcup_{m \in M} F_m^n = \bigcup_{(n,m) \in N\times M} F_m^n$$
which is a union of elements in $\mathcal{C}$, so it follows that $\bigcup \mathcal{G} \in \mathcal{D}$
and this shows that $\mathcal{D}$ is a topology.
It is clear that $\mathcal{A} \subseteq \mathcal{D}$, and if the topology $\mathcal{T}$ contains $\mathcal{A}$, then, because $\mathcal{T}$ contains $\emptyset, X$ as well (it's a topology), it follows that $\mathcal{B} \subseteq \mathcal{T}$ and because $\mathcal{T}$ is a topology, $\mathcal{C} \subseteq \mathcal{T}$ and also $\mathcal{D} \subseteq \mathcal{T}$
This shows that $\mathcal{D}$ is the smallest topology that contains $\mathcal{A}$ (and the uniqueness is evident).
Is this correct? Do you have any suggestions? I'm not entirely sure if the equality $\bigcup_{n \in N}\bigcup_{m \in M} F_m^n = \bigcup_{(n,m) \in N\times M} F_m^n$ is valid. In my proof, I also use that I can index collections of sets. Is this always possible? Thanks.
Your idea is correct (I haven't digested your whole answer yet) which is definitely the main thing here.
Actually you can start with $\mathcal A$ itself instead of $\mathcal B=\mathcal A\cup\{\varnothing,X\}$.
This under the convention that the empty (hence finite) intersection of elements of $\mathcal A$ is identified with $X$. Further $\varnothing$ can be identified with empty union so that $\varnothing\in\mathcal D$.
This setup provides a nice inductive definition of the topology that is generated by subbasis $\mathcal A$.
The collection $\{\bigcap\mathcal E\mid\mathcal E\subseteq\mathcal A,\mathcal E\text{ finite}\}$ is a basis for a topology according to this link.
The arbitrary unions of such a basis always form a topology.
Mostly the topology generated by $\mathcal A\subseteq\wp(X)$ is presented as the intersection of all topologies on $X$ that contain $\mathcal A$ as a subcollection. That is a correct route, but your route (inductive definition) gives a far better insight on the way the topology is constructed.
edit (my proof).
Let $\mathcal C:=\{\bigcap\mathcal E\mid\mathcal E\subseteq\mathcal A,\mathcal E\text{ finite}\}$. Then (by convention) $X=\bigcap\varnothing\in\mathcal C$ and secondly it is immediate that $\mathcal C$ is closed under finite intersections. This makes $\mathcal C$ a basis of a topology according to this link.
Let $\mathcal D:=\{\bigcup\mathcal F\mid\mathcal F\subseteq\mathcal C\}$ so that $\varnothing=\bigcup\varnothing\in\mathcal D$ and $X\in\mathcal C\subseteq\mathcal D$. Also it is immediate that $\mathcal D$ is closed under unions (a union of unions of elements of $\mathcal C$ is a union of elements of $\mathcal C$). Further for $\mathcal F_i\subseteq\mathcal C$ with $i=1,2$ we find: $(\bigcup\mathcal F_1)\cap(\bigcup\mathcal F_2)=\bigcup\{F_1\cap F_2\mid F_1\in\mathcal F_1, F_2\in\mathcal F_2\}$. From $F_i\in\mathcal F_i\subseteq\mathcal C$ for $i=1,2$ it follows that $F_1\cap F_2\in\mathcal C$ since $\mathcal C$ is closed under finite intersections. So $(\bigcup\mathcal F_1)\cap(\bigcup\mathcal F_2)\in\mathcal D$ and proved is now that $\mathcal D$ is closed under finite intersections.
Proved is now that $\mathcal D$ is a topology, and this with $\mathcal A\subseteq\mathcal D$. If conversely $\mathcal E$ is a topology with $\mathcal A\subseteq\mathcal E$ then it is evident that also $\mathcal C\subseteq\mathcal E$ and secondly that also $\mathcal D\subseteq\mathcal E$. So it is clear that $\mathcal D$ is the "smallest" topology that contains $\mathcal A$ as a subcollection. In this context $\mathcal A$ is a subbase of $\mathcal D$ and $\mathcal C$ is a base of $\mathcal A$.