This note proceeds from the previous note on the toposes of sheaves on topological spaces. The plan at the moment is not to introduce various results of Grothendieck toposes but to guide the reader on how this concept of Grothendieck topology and toposes generalizes the ordinary notion of sheaves on topological spaces. The purpose is to provide a stepping stone towards our next topic, which is about the Lawvere–Tierney topology.
So far we have used the structure of open sets $\mathcal{O}(X)$ to model the concept of locality. For each open $U \in \mathcal{O}(X)$, we attach a set of data locally to $U$ by defining a functor $\mathcal{O}(X)^{op} \to \mathbf{Set}$ where $\mathcal{O}(X)$ is regarded as a category. Hence, a straightforward generalization of the usual notion of topology is to replace $\mathcal{O}(X)$ with an arbitrary category $\mathcal{C}$ with some structure.
For an object $C$, we say $S$ a sieve on $C$ when $S$ is a collection of morphisms to $C$ such that \[ (f : X \to C) \in S \Rightarrow f \circ g \in S \] for any $g : Y \to X$. Note that it is equivalent to a subfunctor of $\mathbf{y}_C$. Given a morphism $h : D \to C$, define a mapping from the sieves on $C$ to the sieves on $D$ by \[ h^* : S \mapsto \{f \mid h\circ f \in S\}. \] Intuitively, seeing $C$ as an open set, a sieve on $C$ is a collection of opens in $C$ that is consistent in the sense that for any $U$ in the collection, all open subsets of $U$ are in the collection. A topology determines, amongst the sieves, which are open coverings. Following the analogy, a mapping $J$ is a Grothendieck topology if it maps each object $C$ to a collection of sieves on $C$ such that
A pair $(\mathcal{C}, J)$ of a small category and its Grothendieck topology is called a site. As the analogy between $\mathcal{O}(X)$ and $(\mathcal{C}, J)$ suggests, we call a sieve $S$ on $C$ a $J$-covering of $C$ when $S \in J(C)$.
There are some note-worthy topologies:
Having defined a notion of topology $J$ on a small category $C$, what remains is to define what are sheaves among all presehaves $$\mathbf{PSh}(C) = \mathbf{Set}^{C^{\mathrm{op}}}.$$ Recall that in the case of topological spaces, the condition for a presheaf to be a sheaf was that for any covering when a global data are distributed locally to each opens consistently on the overlaps and can be collated uniquely.
Using a more abstract notion of category theory, this can be stated as follows. On a site $(C, J)$ a presheave $P$ is a $J$-sheaf if for each object $C$ and its covering sieve $S \in J(C)$, seeing it as a subfunctor of $\mathbf{y}_C$, the maximal sieve, any $\mu : S \to P$, in the functor category, has a unique extension $\mathbf{y}_C \to P$ for the inclusion $\iota:S \to \mathbf{y}_C$:
$$\require{AMScd} \begin{CD} S @>\mu>> P\\ @VV{\iota}V {_{}\style{display: inline-block; transform: rotate(150deg)}{{\dashleftarrow{}}}}@. \\ \mathbf{y}_C @. \end{CD}$$
Intuitive meaning is that a presheave $P$ is a sheave if it sees all coverings indistinctly as if they were the maximal sieve.
Note that for the trivial topology, all presheaves are sheaves.
We call a topology subcanonical when all Yoneda embeddings are sheaves. We call the largest one canonical.
When the underlying category $C$ has pullbacks so that the intersections can be expressed more directly, the topology and the sheave conditions can be written in a more understandable form similarly to the topological sheave condition.
The category of sheaves on a site $\mathbf{Sh}(C, J)$ is the full subcategory of sheaves at $\mathbf{Psh}(C)$. A category that is equivalent to one is called Grothendieck topos. Of course, it is not trivial to show that this is actually a topos. We will only reveal the subobject classifier and logic operations for the topos structure of categories of sheaves.
For a site $(\mathbf{C}, J)$ and a sieve $S$ on $C$, $S$ covers $f : D \to C$ if $f^*S \in J(D)$. We call a sieve $S$ on $C$ closed if $S$ covers $f : D \to C$, $f$ is in $S$. Then we define $$\Omega(C) = \text{the set of closed sieves on $C$.}$$ The mapping $\Omega$ then yields a presheave where $$\Omega(f: B \to C)\ S = f^*S.$$
Leaving a proof of $\Omega$ being a sheaf as an exercise, with $$\mathrm{true} : 1 \to \Omega$$ where $\mathrm{true}(C) = \mathbf{y}_C$, $\Omega$ becomes a subobject classifier.