# The Stacks Project

## Tag 01JA

### 25.14. Glueing schemes

Let $I$ be a set. For each $i \in I$ let $(X_i, \mathcal{O}_i)$ be a locally ringed space. (Actually the construction that follows works equally well for ringed spaces.) For each pair $i, j \in I$ let $U_{ij} \subset X_i$ be an open subspace. For each pair $i, j \in I$, let $$\varphi_{ij} : U_{ij} \to U_{ji}$$ be an isomorphism of locally ringed spaces. For convenience we assume that $U_{ii} = X_i$ and $\varphi_{ii} = \text{id}_{X_i}$. For each triple $i, j, k \in I$ assume that

1. we have $\varphi_{ij}^{-1}(U_{ji} \cap U_{jk}) = U_{ij} \cap U_{ik}$, and
2. the diagram $$\xymatrix{ U_{ij} \cap U_{ik} \ar[rr]_{\varphi_{ik}} \ar[rd]_{\varphi_{ij}} & & U_{ki} \cap U_{kj} \\ & U_{ji} \cap U_{jk} \ar[ru]_{\varphi_{jk}} }$$ is commutative.

Let us call a collection $(I, (X_i)_{i\in I}, (U_{ij})_{i, j\in I}, (\varphi_{ij})_{i, j\in I})$ satisfying the conditions above a glueing data.

Lemma 25.14.1. Given any glueing data of locally ringed spaces there exists a locally ringed space $X$ and open subspaces $U_i \subset X$ together with isomorphisms $\varphi_i : X_i \to U_i$ of locally ringed spaces such that

1. $\varphi_i(U_{ij}) = U_i \cap U_j$, and
2. $\varphi_{ij} = \varphi_j^{-1}|_{U_i \cap U_j} \circ \varphi_i|_{U_{ij}}$.

The locally ringed space $X$ is characterized by the following mapping properties: Given a locally ringed space $Y$ we have \begin{eqnarray*} \mathop{\rm Mor}\nolimits(X, Y) & = & \{ (f_i)_{i\in I} \mid f_i : X_i \to Y, ~f_j \circ \varphi_{ij} = f_i|_{U_{ij}}\} \\ f & \mapsto & (f|_{U_i} \circ \varphi_i)_{i \in I} \\ \mathop{\rm Mor}\nolimits(Y, X) & = & \left\{ \begin{matrix} \text{open covering }Y = \bigcup\nolimits_{i \in I} V_i\text{ and } (g_i : V_i \to X_i)_{i \in I} \text{ such that}\\ g_i^{-1}(U_{ij}) = V_i \cap V_j \text{ and } g_j|_{V_i \cap V_j} = \varphi_{ij} \circ g_i|_{V_i \cap V_j} \end{matrix} \right\} \\ g & \mapsto & V_i = g^{-1}(U_i), ~g_i = \varphi_i^{-1} \circ g|_{V_i} \end{eqnarray*}

Proof. We construct $X$ in stages. As a set we take $$X = (\coprod X_i) / \sim.$$ Here given $x \in X_i$ and $x' \in X_j$ we say $x \sim x'$ if and only if $x \in U_{ij}$, $x' \in U_{ji}$ and $\varphi_{ij}(x) = x'$. This is an equivalence relation since if $x \in X_i$, $x' \in X_j$, $x'' \in X_k$, and $x \sim x'$ and $x' \sim x''$, then $x' \in U_{ji} \cap U_{jk}$, hence by condition (1) of a glueing data also $x \in U_{ij} \cap U_{ik}$ and $x'' \in U_{ki} \cap U_{kj}$ and by condition (2) we see that $\varphi_{ik}(x) = x''$. (Reflexivity and symmetry follows from our assumptions that $U_{ii} = X_i$ and $\varphi_{ii} = \text{id}_{X_i}$.) Denote $\varphi_i : X_i \to X$ the natural maps. Denote $U_i = \varphi_i(X_i) \subset X$. Note that $\varphi_i : X_i \to U_i$ is a bijection.

The topology on $X$ is defined by the rule that $U \subset X$ is open if and only if $\varphi_i^{-1}(U)$ is open for all $i$. We leave it to the reader to verify that this does indeed define a topology. Note that in particular $U_i$ is open since $\varphi_j^{-1}(U_i) = U_{ji}$ which is open in $X_j$ for all $j$. Moreover, for any open set $W \subset X_i$ the image $\varphi_i(W) \subset U_i$ is open because $\varphi_j^{-1}(\varphi_i(W)) = \varphi_{ji}^{-1}(W \cap U_{ij})$. Therefore $\varphi_i : X_i \to U_i$ is a homeomorphism.

To obtain a locally ringed space we have to construct the sheaf of rings $\mathcal{O}_X$. We do this by glueing the sheaves of rings $\mathcal{O}_{U_i} := \varphi_{i, *} \mathcal{O}_i$. Namely, in the commutative diagram $$\xymatrix{ U_{ij} \ar[rr]_{\varphi_{ij}} \ar[rd]_{\varphi_i|_{U_{ij}}} & & U_{ji} \ar[ld]^{\varphi_j|_{U_{ji}}} \\ & U_i \cap U_j & }$$ the arrow on top is an isomorphism of ringed spaces, and hence we get unique isomorphisms of sheaves of rings $$\mathcal{O}_{U_i}|_{U_i \cap U_j} \longrightarrow \mathcal{O}_{U_j}|_{U_i \cap U_j}.$$ These satisfy a cocycle condition as in Sheaves, Section 6.33. By the results of that section we obtain a sheaf of rings $\mathcal{O}_X$ on $X$ such that $\mathcal{O}_X|_{U_i}$ is isomorphic to $\mathcal{O}_{U_i}$ compatibly with the glueing maps displayed above. In particular $(X, \mathcal{O}_X)$ is a locally ringed space since the stalks of $\mathcal{O}_X$ are equal to the stalks of $\mathcal{O}_i$ at corresponding points.

The proof of the mapping properties is omitted. $\square$

Lemma 25.14.2. In Lemma 25.14.1 above, assume that all $X_i$ are schemes. Then the resulting locally ringed space $X$ is a scheme.

Proof. This is clear since each of the $U_i$ is a scheme and hence every $x \in X$ has an affine neighbourhood. $\square$

It is customary to think of $X_i$ as an open subspace of $X$ via the isomorphisms $\varphi_i$. We will do this in the next two examples.

Example 25.14.3 (Affine space with zero doubled). Let $k$ be a field. Let $n \geq 1$. Let $X_1 = \mathop{\rm Spec}(k[x_1, \ldots, x_n])$, let $X_2 = \mathop{\rm Spec}(k[y_1, \ldots, y_n])$. Let $0_1 \in X_1$ be the point corresponding to the maximal ideal $(x_1, \ldots, x_n) \subset k[x_1, \ldots, x_n]$. Let $0_2 \in X_2$ be the point corresponding to the maximal ideal $(y_1, \ldots, y_n) \subset k[y_1, \ldots, y_n]$. Let $U_{12} = X_1 \setminus \{0_1\}$ and let $U_{21} = X_2 \setminus \{0_2\}$. Let $\varphi_{12} : U_{12} \to U_{21}$ be the isomorphism coming from the isomorphism of $k$-algebras $k[y_1, \ldots, y_n] \to k[x_1, \ldots, x_n]$ mapping $y_i$ to $x_i$ (which induces $X_1 \cong X_2$ mapping $0_1$ to $0_2$). Let $X$ be the scheme obtained from the glueing data $(X_1, X_2, U_{12}, U_{21}, \varphi_{12}, \varphi_{21} = \varphi_{12}^{-1})$. Via the slight abuse of notation introduced above the example we think of $X_i \subset X$ as open subschemes. There is a morphism $f : X \to \mathop{\rm Spec}(k[t_1, \ldots, t_n])$ which on $X_i$ corresponds to $k$ algebra map $k[t_1, \ldots, t_n] \to k[x_1, \ldots, x_n]$ (resp. $k[t_1, \ldots, t_n] \to k[y_1, \ldots, y_n]$) mapping $t_i$ to $x_i$ (resp.  $t_i$ to $y_i$). It is easy to see that this morphism identifies $k[t_1, \ldots, t_n]$ with $\Gamma(X, \mathcal{O}_X)$. Since $f(0_1) = f(0_2)$ we see that $X$ is not affine.

Note that $X_1$ and $X_2$ are affine opens of $X$. But, if $n = 2$, then $X_1 \cap X_2$ is the scheme described in Example 25.9.3 and hence not affine. Thus in general the intersection of affine opens of a scheme is not affine. (This fact holds more generally for any $n > 1$.)

Another curious feature of this example is the following. If $n > 1$ there are many irreducible closed subsets $T \subset X$ (take the closure of any non closed point in $X_1$ for example). But unless $T = \{0_1\}$, or $T = \{0_2\}$ we have $0_1 \in T \Leftrightarrow 0_2 \in T$. Proof omitted.

Example 25.14.4 (Projective line). Let $k$ be a field. Let $X_1 = \mathop{\rm Spec}(k[x])$, let $X_2 = \mathop{\rm Spec}(k[y])$. Let $0 \in X_1$ be the point corresponding to the maximal ideal $(x) \subset k[x]$. Let $\infty \in X_2$ be the point corresponding to the maximal ideal $(y) \subset k[y]$. Let $U_{12} = X_1 \setminus \{0\} = D(x) = \mathop{\rm Spec}(k[x, 1/x])$ and let $U_{21} = X_2 \setminus \{\infty\} = D(y) = \mathop{\rm Spec}(k[y, 1/y])$. Let $\varphi_{12} : U_{12} \to U_{21}$ be the isomorphism coming from the isomorphism of $k$-algebras $k[y, 1/y] \to k[x, 1/x]$ mapping $y$ to $1/x$. Let $\mathbf{P}^1_k$ be the scheme obtained from the glueing data $(X_1, X_2, U_{12}, U_{21}, \varphi_{12}, \varphi_{21} = \varphi_{12}^{-1})$. Via the slight abuse of notation introduced above the example we think of $X_i \subset \mathbf{P}^1_k$ as open subschemes. In this case we see that $\Gamma(\mathbf{P}^1_k, \mathcal{O}) = k$ because the only polynomials $g(x)$ in $x$ such that $g(1/y)$ is also a polynomial in $y$ are constant polynomials. Since $\mathbf{P}^1_k$ is infinite we see that $\mathbf{P}^1_k$ is not affine.

We claim that there exists an affine open $U \subset \mathbf{P}^1_k$ which contains both $0$ and $\infty$. Namely, let $U = \mathbf{P}^1_k \setminus \{1\}$, where $1$ is the point of $X_1$ corresponding to the maximal ideal $(x - 1)$ and also the point of $X_2$ corresponding to the maximal ideal $(y - 1)$. Then it is easy to see that $s = 1/(x - 1) = y/(1 - y) \in \Gamma(U, \mathcal{O}_U)$. In fact you can show that $\Gamma(U, \mathcal{O}_U)$ is equal to the polynomial ring $k[s]$ and that the corresponding morphism $U \to \mathop{\rm Spec}(k[s])$ is an isomorphism of schemes. Details omitted.

The code snippet corresponding to this tag is a part of the file schemes.tex and is located in lines 2353–2598 (see updates for more information).

\section{Glueing schemes}
\label{section-glueing-schemes}

\noindent
Let $I$ be a set.
For each $i \in I$ let $(X_i, \mathcal{O}_i)$ be
a locally ringed space. (Actually the construction that
follows works equally well for ringed spaces.)
For each pair $i, j \in I$ let $U_{ij} \subset X_i$
be an open subspace.
For each pair $i, j \in I$, let
$$\varphi_{ij} : U_{ij} \to U_{ji}$$
be an isomorphism of locally ringed spaces.
For convenience we assume that $U_{ii} = X_i$ and
$\varphi_{ii} = \text{id}_{X_i}$.
For each triple $i, j, k \in I$ assume that
\begin{enumerate}
\item we have
$\varphi_{ij}^{-1}(U_{ji} \cap U_{jk}) = U_{ij} \cap U_{ik}$, and
\item the diagram
$$\xymatrix{ U_{ij} \cap U_{ik} \ar[rr]_{\varphi_{ik}} \ar[rd]_{\varphi_{ij}} & & U_{ki} \cap U_{kj} \\ & U_{ji} \cap U_{jk} \ar[ru]_{\varphi_{jk}} }$$
is commutative.
\end{enumerate}
Let us call a collection
$(I, (X_i)_{i\in I}, (U_{ij})_{i, j\in I}, (\varphi_{ij})_{i, j\in I})$
satisfying the conditions above a glueing data.

\begin{lemma}
\label{lemma-glue}
\begin{slogan}
If you have two locally ringed spaces, and a subspace of the first one
is isomorphic to a subspace of the other, then you can glue them together
into one big locally ringed space.
\end{slogan}
Given any glueing data of locally ringed spaces there
exists a locally ringed space $X$ and open subspaces
$U_i \subset X$ together with isomorphisms
$\varphi_i : X_i \to U_i$ of locally ringed spaces such that
\begin{enumerate}
\item $\varphi_i(U_{ij}) = U_i \cap U_j$, and
\item $\varphi_{ij} = \varphi_j^{-1}|_{U_i \cap U_j} \circ \varphi_i|_{U_{ij}}$.
\end{enumerate}
The locally ringed space $X$ is characterized by the following
mapping properties: Given a locally ringed space $Y$ we have
\begin{eqnarray*}
\Mor(X, Y) & = & \{ (f_i)_{i\in I} \mid
f_i : X_i \to Y, \ f_j \circ \varphi_{ij} = f_i|_{U_{ij}}\} \\
f & \mapsto & (f|_{U_i} \circ \varphi_i)_{i \in I} \\
\Mor(Y, X) & = &
\left\{
\begin{matrix}
\text{open covering }Y = \bigcup\nolimits_{i \in I} V_i\text{ and }
(g_i : V_i \to X_i)_{i \in I}
\text{ such that}\\
g_i^{-1}(U_{ij}) = V_i \cap V_j
\text{ and }
g_j|_{V_i \cap V_j} = \varphi_{ij} \circ g_i|_{V_i \cap V_j}
\end{matrix}
\right\} \\
g & \mapsto &
V_i = g^{-1}(U_i), \ g_i = \varphi_i^{-1} \circ g|_{V_i}
\end{eqnarray*}
\end{lemma}

\begin{proof}
We construct $X$ in stages.
As a set we take
$$X = (\coprod X_i) / \sim.$$
Here given $x \in X_i$ and $x' \in X_j$ we say
$x \sim x'$ if and only if $x \in U_{ij}$, $x' \in U_{ji}$
and $\varphi_{ij}(x) = x'$. This is an equivalence relation
since if $x \in X_i$, $x' \in X_j$, $x'' \in X_k$, and $x \sim x'$ and
$x' \sim x''$, then $x' \in U_{ji} \cap U_{jk}$, hence by condition (1) of
a glueing data also $x \in U_{ij} \cap U_{ik}$ and
$x'' \in U_{ki} \cap U_{kj}$ and by condition (2)
we see that $\varphi_{ik}(x) = x''$. (Reflexivity and symmetry
follows from our assumptions that $U_{ii} = X_i$ and
$\varphi_{ii} = \text{id}_{X_i}$.)
Denote $\varphi_i : X_i \to X$
the natural maps. Denote $U_i = \varphi_i(X_i) \subset X$.
Note that $\varphi_i : X_i \to U_i$ is a bijection.

\medskip\noindent
The topology on $X$ is defined by the rule that
$U \subset X$ is open if and only if $\varphi_i^{-1}(U)$
is open for all $i$. We leave it to the reader to verify
that this does indeed define a topology.
Note that in particular $U_i$ is open since $\varphi_j^{-1}(U_i) = U_{ji}$ which is open in $X_j$ for all $j$.
Moreover, for any open set $W \subset X_i$ the image
$\varphi_i(W) \subset U_i$ is open because
$\varphi_j^{-1}(\varphi_i(W)) = \varphi_{ji}^{-1}(W \cap U_{ij})$.
Therefore $\varphi_i : X_i \to U_i$ is a homeomorphism.

\medskip\noindent
To obtain a locally ringed space we have to construct the
sheaf of rings $\mathcal{O}_X$. We do this by glueing the
sheaves of rings $\mathcal{O}_{U_i} := \varphi_{i, *} \mathcal{O}_i$.
Namely, in the commutative diagram
$$\xymatrix{ U_{ij} \ar[rr]_{\varphi_{ij}} \ar[rd]_{\varphi_i|_{U_{ij}}} & & U_{ji} \ar[ld]^{\varphi_j|_{U_{ji}}} \\ & U_i \cap U_j & }$$
the arrow on top is an isomorphism of ringed spaces,
and hence we get unique isomorphisms of sheaves of rings
$$\mathcal{O}_{U_i}|_{U_i \cap U_j} \longrightarrow \mathcal{O}_{U_j}|_{U_i \cap U_j}.$$
These satisfy a cocycle condition as in Sheaves,
Section \ref{sheaves-section-glueing-sheaves}.
By the results of that section we obtain a sheaf of rings
$\mathcal{O}_X$ on $X$ such that $\mathcal{O}_X|_{U_i}$
is isomorphic to $\mathcal{O}_{U_i}$ compatibly with
the glueing maps displayed above.
In particular $(X, \mathcal{O}_X)$ is a locally ringed
space since the stalks of $\mathcal{O}_X$ are equal
to the stalks of $\mathcal{O}_i$ at corresponding
points.

\medskip\noindent
The proof of the mapping properties is omitted.
\end{proof}

\begin{lemma}
\label{lemma-glue-schemes}
\begin{slogan}
Schemes can be glued to give new schemes.
\end{slogan}
In Lemma \ref{lemma-glue} above, assume that all
$X_i$ are schemes. Then the resulting locally ringed
space $X$ is a scheme.
\end{lemma}

\begin{proof}
This is clear since each of the $U_i$ is a scheme
and hence every $x \in X$ has an affine neighbourhood.
\end{proof}

\noindent
It is customary to think of $X_i$ as an open subspace of
$X$ via the isomorphisms $\varphi_i$. We will do this in
the next two examples.

\begin{example}[Affine space with zero doubled]
\label{example-affine-space-zero-doubled}
Let $k$ be a field. Let $n \geq 1$.
Let $X_1 = \Spec(k[x_1, \ldots, x_n])$,
let $X_2 = \Spec(k[y_1, \ldots, y_n])$.
Let $0_1 \in X_1$ be the point corresponding to the maximal ideal
$(x_1, \ldots, x_n) \subset k[x_1, \ldots, x_n]$.
Let $0_2 \in X_2$ be the point corresponding to the maximal ideal
$(y_1, \ldots, y_n) \subset k[y_1, \ldots, y_n]$.
Let $U_{12} = X_1 \setminus \{0_1\}$ and
let $U_{21} = X_2 \setminus \{0_2\}$. Let
$\varphi_{12} : U_{12} \to U_{21}$ be the isomorphism
coming from the isomorphism of $k$-algebras
$k[y_1, \ldots, y_n] \to k[x_1, \ldots, x_n]$
mapping $y_i$ to $x_i$ (which induces $X_1 \cong X_2$ mapping
$0_1$ to $0_2$).
Let $X$ be the scheme obtained from the glueing data
$(X_1, X_2, U_{12}, U_{21}, \varphi_{12}, \varphi_{21} = \varphi_{12}^{-1})$. Via the slight abuse
of notation introduced above the example we think of
$X_i \subset X$ as open subschemes.
There is a morphism $f : X \to \Spec(k[t_1, \ldots, t_n])$
which on $X_i$ corresponds to $k$ algebra map
$k[t_1, \ldots, t_n] \to k[x_1, \ldots, x_n]$
(resp.\ $k[t_1, \ldots, t_n] \to k[y_1, \ldots, y_n]$)
mapping $t_i$ to $x_i$ (resp.\  $t_i$ to $y_i$).
It is easy to see that this morphism identifies
$k[t_1, \ldots, t_n]$ with $\Gamma(X, \mathcal{O}_X)$. Since
$f(0_1) = f(0_2)$ we see that $X$ is not affine.

\medskip\noindent
Note that $X_1$ and $X_2$ are affine opens of $X$.
But, if $n = 2$, then $X_1 \cap X_2$ is the scheme
described in Example \ref{example-not-affine} and hence not affine.
Thus in general the intersection of affine opens of a scheme
is not affine. (This fact holds more generally for any $n > 1$.)

\medskip\noindent
Another curious feature of this example is the following.
If $n > 1$ there are many irreducible closed subsets $T \subset X$
(take the closure of any non closed point in $X_1$ for example).
But unless $T = \{0_1\}$, or $T = \{0_2\}$ we have
$0_1 \in T \Leftrightarrow 0_2 \in T$. Proof omitted.
\end{example}

\begin{example}[Projective line]
\label{example-projective-line}
Let $k$ be a field.
Let $X_1 = \Spec(k[x])$,
let $X_2 = \Spec(k[y])$.
Let $0 \in X_1$ be the point corresponding to the maximal ideal
$(x) \subset k[x]$.
Let $\infty \in X_2$ be the point corresponding to the maximal ideal
$(y) \subset k[y]$.
Let $U_{12} = X_1 \setminus \{0\} = D(x) = \Spec(k[x, 1/x])$ and
let $U_{21} = X_2 \setminus \{\infty\} = D(y) = \Spec(k[y, 1/y])$.
Let $\varphi_{12} : U_{12} \to U_{21}$ be the isomorphism
coming from the isomorphism of $k$-algebras
$k[y, 1/y] \to k[x, 1/x]$ mapping $y$ to $1/x$.
Let $\mathbf{P}^1_k$ be the scheme obtained from the glueing data
$(X_1, X_2, U_{12}, U_{21}, \varphi_{12}, \varphi_{21} = \varphi_{12}^{-1})$. Via the slight abuse
of notation introduced above the example we think of
$X_i \subset \mathbf{P}^1_k$ as open subschemes. In this case
we see that $\Gamma(\mathbf{P}^1_k, \mathcal{O}) = k$ because the
only polynomials $g(x)$ in $x$ such that $g(1/y)$ is
also a polynomial in $y$ are constant polynomials.
Since $\mathbf{P}^1_k$ is infinite we see that $\mathbf{P}^1_k$ is not affine.

\medskip\noindent
We claim that there exists an affine open $U \subset \mathbf{P}^1_k$
which contains both $0$ and $\infty$. Namely, let
$U = \mathbf{P}^1_k \setminus \{1\}$, where $1$ is the point
of $X_1$ corresponding to the maximal ideal $(x - 1)$
and also the point of $X_2$ corresponding to the
maximal ideal $(y - 1)$. Then it is easy to see that
$s = 1/(x - 1) = y/(1 - y) \in \Gamma(U, \mathcal{O}_U)$.
In fact you can show that $\Gamma(U, \mathcal{O}_U)$
is equal to the polynomial ring $k[s]$ and that the
corresponding morphism $U \to \Spec(k[s])$ is
an isomorphism of schemes. Details omitted.
\end{example}

Comment #1261 by Lau on January 17, 2015 a 6:30 pm UTC

In the proof of Lemma 25.14.1, the author writes that because $\varphi_{ij}$ is an isomorphism of ringed spaces, we get an isomorphism of ringed spaces $\mathcal{O}_{U_i}|_{U_i \cap U_j} \longrightarrow \mathcal{O}_{U_j}|_{U_i \cap U_j}$. Can someone explain how this morphism is defined?

Comment #1262 by Lau on January 18, 2015 a 10:52 am UTC

Another little thing: In the proof of this Lemma, right before the line "Namely, in the commutative diagram", the structure sheaf of $X_i$ is refered to as $\mathcal{O}_{X_i}$, while in the description of a gluing data, it's called $\mathcal{O}_{i}$.

Comment #1264 by Johan (site) on January 22, 2015 a 7:40 pm UTC

The answer to your first question is that you take $\varphi_{ij}^\sharp : \varphi_{ij}^{-1}\mathcal{O}_{U_{ji}} \to \mathcal{O}_{U_{ij}}$ and push it down with $\varphi_{i, *}$ to $\varphi_i(U_{ij}) = U_i \cap U_j$. The second comment I fixed here. Thanks!

Comment #2438 by Dmitrii Pedchenko on February 25, 2017 a 10:10 pm UTC

The characterization of $Mor(Y,X)$ by the rule $g \mapsto V_i=g^{-1} (U_i), g_i=g|_{V_i}$ seems to produce a map $g_i: V_i \to U_i$. If we want it to land in $X_i$ we have to compose with $\phi_i^{-1}$ - $g_i := \phi_i^{-1} \circ g|_{V_i}$.

Comment #2481 by Johan (site) on April 13, 2017 a 10:27 pm UTC

Thanks. Fixed here.

## Add a comment on tag 01JA

In your comment you can use Markdown and LaTeX style mathematics (enclose it like $\pi$). A preview option is available if you wish to see how it works out (just click on the eye in the lower-right corner).