hcju/stacksqa huggingface dataset:
More on Algebra, Lemma \ref{more-algebra-lemma-geometrically-unibranch} shows that (1) implies that the punctured spectra in (2) are irreducible and in particular connected. \medskip\noindent Assume (2). Let $x \in X$. We have to show that $\mathcal{O}_{X, x}$ is geometrically unibranch. By induction on $\dim(\mathcal{O}_{X, x})$ we may assume that the result holds for every nontrivial generalization of $x$. We may replace $X$ by $\Spec(\mathcal{O}_{X, x})$. In other words, we may assume that $X = \Spec(A)$ with $A$ local and that $A_\mathfrak p$ is geometrically unibranch for each nonmaximal prime $\mathfrak p \subset A$. \medskip\noindent Let $A^{sh}$ be the strict henselization of $A$. If $\mathfrak q \subset A^{sh}$ is a prime lying over $\mathfrak p \subset A$, then $A_\mathfrak p \to A^{sh}_\mathfrak q$ is a filtered colimit of \'etale algebras. Hence the strict henselizations of $A_\mathfrak p$ and $A^{sh}_\mathfrak q$ are isomorphic. Thus by More on Algebra, Lemma \ref{more-algebra-lemma-geometrically-unibranch} we conclude that $A^{sh}_\mathfrak q$ has a unique minimal prime ideal for every nonmaximal prime $\mathfrak q$ of $A^{sh}$. \medskip\noindent Let $\mathfrak q_1, \ldots, \mathfrak q_r$ be the minimal primes of $A^{sh}$. We have to show that $r = 1$. By the above we see that $V(\mathfrak q_1) \cap V(\mathfrak q_j) = \{\mathfrak m^{sh}\}$ for $j = 2, \ldots, r$. Hence $V(\mathfrak q_1) \setminus \{\mathfrak m^{sh}\}$ is an open and closed subset of the punctured spectrum of $A^{sh}$ which is a contradiction with the assumption that this punctured spectrum is connected unless $r = 1$.
We view the $X_i$ as integral closed subschemes of $X$, see Schemes, Definition \ref{schemes-definition-reduced-induced-scheme} and Lemma \ref{lemma-characterize-integral}. Observe that the number of (geometric) branches of $X_i$ at $x$ is at least $1$ for all $i$ (essentially by definition). Recall that the $X_i$ correspond $1$-to-$1$ with the minimal prime ideals $\mathfrak p_i \subset \mathcal{O}_{X, x}$, see Algebra, Lemma \ref{algebra-lemma-irreducible-components-containing-x}. Thus, if $I$ is infinite, then $\mathcal{O}_{X, x}$ has infinitely many minimal primes, whence both $\mathcal{O}_{X, x}^h$ and $\mathcal{O}_{X, x}^{sh}$ have infinitely many minimal primes (combine Algebra, Lemmas \ref{algebra-lemma-injective-minimal-primes-in-image} and \ref{algebra-lemma-minimal-prime-image-minimal-prime} and the injectivity of the maps $\mathcal{O}_{X, x} \to  \mathcal{O}_{X, x}^h \to \mathcal{O}_{X, x}^{sh}$). In this case the number of (geometric) branches of $X$ at $x$ is defined to be $\infty$ which is also true for the sum. Thus we may assume $I$ is finite. Let $A'$ be the integral closure of $\mathcal{O}_{X, x}$ in the total ring of fractions $Q$ of $(\mathcal{O}_{X, x})_{red}$. Let $A'_i$ be the  integral closure of $\mathcal{O}_{X, x}/\mathfrak p_i$ in the total ring of fractions $Q_i$ of $\mathcal{O}_{X, x}/\mathfrak p_i$. By Algebra, Lemma \ref{algebra-lemma-total-ring-fractions-no-embedded-points} we have $Q = \prod_{i \in I} Q_i$. Thus $A' = \prod A'_i$. Then the equality of the lemma follows from More on Algebra, Lemma \ref{more-algebra-lemma-number-of-branches-1} which expresses the number of (geometric) branches in terms of the maximal ideals of $A'$.
Assume $\widetilde M$ is a finite type $\mathcal{O}_X$-module. This means there exists an open covering of $X$ such that $\widetilde M$ restricted to the members of this covering is globally generated by finitely many sections. Thus there also exists a standard open covering $X = \bigcup_{i = 1, \ldots, n} D(f_i)$ such that $\widetilde M|_{D(f_i)}$ is generated by finitely many sections. Thus $M_{f_i}$ is finitely generated for each $i$. Hence we conclude by Algebra, Lemma \ref{algebra-lemma-cover}.
Assume $\widetilde M$ is an $\mathcal{O}_X$-module of finite presentation. By Lemma \ref{lemma-finite-type-module} we see that $M$ is a finite $R$-module. Choose a surjection $R^n \to M$ with kernel $K$. By Schemes, Lemma \ref{schemes-lemma-spec-sheaves} there is a short exact sequence $$ 0 \to \widetilde{K} \to \bigoplus \mathcal{O}_X^{\oplus n} \to \widetilde{M} \to 0 $$ By Modules, Lemma \ref{modules-lemma-kernel-surjection-finite-free-onto-finite-presentation} we see that $\widetilde{K}$ is a finite type $\mathcal{O}_X$-module. Hence by Lemma \ref{lemma-finite-type-module} again we see that $K$ is a finite $R$-module. Hence $M$ is an $R$-module of finite presentation.
Write $R = \Gamma(X, \mathcal{O}_X)$. Consider the canonical morphism $$ \varphi : X \longrightarrow \Spec(R) $$ of schemes, see Schemes, Lemma \ref{schemes-lemma-morphism-into-affine}. Then the inverse image of the standard open $D(f)$ on the right hand side is $X_f$ on the left hand side. Moreover, since $X$ is assumed quasi-compact and quasi-separated the morphism $\varphi$ is quasi-compact and quasi-separated, see Schemes, Lemma \ref{schemes-lemma-quasi-compact-affine} and \ref{schemes-lemma-compose-after-separated}. Hence by Schemes, Lemma \ref{schemes-lemma-push-forward-quasi-coherent} we see that $\varphi_*\mathcal{F}$ is quasi-coherent. Hence we see that $\varphi_*\mathcal{F} = \widetilde M$ with $M = \Gamma(X, \mathcal{F})$ as an $R$-module. Thus we see that $$ \Gamma(X_f, \mathcal{F}) = \Gamma(D(f), \varphi_*\mathcal{F}) = \Gamma(D(f), \widetilde M) = M_f $$ which is exactly the content of the lemma. The first displayed isomorphism of the lemma follows by taking $\mathcal{F} = \mathcal{O}_X$.
Assume $X$ is quasi-compact. Choose a finite affine open covering $X = U_1 \cup \ldots \cup U_m$ with $U_j$ affine and $\mathcal{L}|_{U_j} \cong \mathcal{O}_{U_j}$. Via this isomorphism, the image $s|_{U_j}$ corresponds to some $f_j \in \Gamma(U_j, \mathcal{O}_{U_j})$. Then $X_s \cap U_j = D(f_j)$. \medskip\noindent Proof of (1). Let $t/s^n$ be an element in the kernel of (\ref{equation-module-invert-s}). Then $t|_{X_s} = 0$. Hence $(t|_{U_j})|_{D(f_j)} = 0$. By Lemma \ref{lemma-invert-f-sections} we conclude that $f_j^{e_j} t|_{U_j} = 0$ for some $e_j \geq 0$. Let $e = \max(e_j)$. Then we see that $t \otimes s^e$ restricts to zero on $U_j$ for all $j$, hence is zero. Since $t/s^n$ is equal to $t \otimes s^e/s^{n + e}$ in $\Gamma_*(X, \mathcal{L}, \mathcal{F})_{(s)}$ we conclude that $t/s^n = 0$ as desired. \medskip\noindent Proof of (2). Assume $X$ is quasi-compact and quasi-separated. Then $U_j \cap U_{j'}$ is quasi-compact for all pairs $j, j'$, see Schemes, Lemma \ref{schemes-lemma-characterize-quasi-separated}. By part (1) we know (\ref{equation-module-invert-s}) is injective. Let $t' \in \Gamma(X_s, \mathcal{F}|_{X_s})$. For every $j$, there exist an integer $e_j \geq 0$ and $t'_j \in \Gamma(U_j, \mathcal{F}|_{U_j})$ such that $t'|_{D(f_j)}$ corresponds to $t'_j/f_j^{e_j}$ via the isomorphism of Lemma \ref{lemma-invert-f-sections}. Set $e = \max(e_j)$ and $$ t_j = f_j^{e - e_j} t'_j \otimes q_j^e \in \Gamma(U_j, (\mathcal{F} \otimes_{\mathcal{O}_X} \mathcal{L}^{\otimes e})|_{U_j}) $$ where $q_j \in \Gamma(U_j, \mathcal{L}|_{U_j})$ is the trivializing section coming from the isomorphism $\mathcal{L}|_{U_j} \cong \mathcal{O}_{U_j}$. In particular we have $s|_{U_j} = f_j q_j$. Using this a calculation shows that $t_j|_{U_j \cap U_{j'}}$ and $t_{j'}|_{U_j \cap U_{j'}}$ map to the same section of $\mathcal{F}$ over $U_j \cap U_{j'} \cap X_s$. By quasi-compactness of $U_j \cap U_{j'}$ and part (1) there exists an integer $e' \geq 0$ such that $$ t_j|_{U_j \cap U_{j'}} \otimes s^{e'}|_{U_j \cap U_{j'}} = t_{j'}|_{U_j \cap U_{j'}} \otimes s^{e'}|_{U_j \cap U_{j'}} $$ as sections of $\mathcal{F} \otimes \mathcal{L}^{\otimes e + e'}$ over $U_j \cap U_{j'}$. We may choose the same $e'$ to work for all pairs $j, j'$. Then the sheaf conditions implies there is a section $t \in \Gamma(X, \mathcal{F} \otimes \mathcal{L}^{\otimes e + e'})$ whose restriction to $U_j$ is $t_j \otimes s^{e'}|_{U_j}$. A simple computation shows that $t/s^{e + e'}$ maps to $t'$ as desired.
We first prove the lemma in case $X = \Spec(A)$ is affine and $\mathcal{L} = \mathcal{O}_X$. In this case $s$ corresponds to an element $f \in A$. Say $\mathcal{F} = \widetilde{M}$ and $\mathcal{G} = \widetilde{N}$ for some $A$-modules $M$ and $N$. Then the lemma translates (via Lemmas \ref{lemma-finite-type-module} and \ref{lemma-finite-presentation-module}) into the following algebra statements \begin{enumerate} \item If $M$ is a finite $A$-module and $\varphi : M \to N$ is an $A$-module map such that the induced map $M_f \to N_f$ is zero, then $f^n\varphi = 0$ for some $n$. \item If $M$ is a finitely presented $A$-module, then $\Hom_A(M, N)_f = \Hom_{A_f}(M_f, N_f)$. \end{enumerate} The second statement is Algebra, Lemma \ref{algebra-lemma-hom-from-finitely-presented} and we omit the proof of the first statement. \medskip\noindent Next, we prove (1) for general $X$. Assume $X$ is quasi-compact and hoose a finite affine open covering $X = U_1 \cup \ldots \cup U_m$ with $U_j$ affine and $\mathcal{L}|_{U_j} \cong \mathcal{O}_{U_j}$. Via this isomorphism, the image $s|_{U_j}$ corresponds to some $f_j \in \Gamma(U_j, \mathcal{O}_{U_j})$. Then $X_s \cap U_j = D(f_j)$. Let $\alpha/s^n$ be an element in the kernel of (\ref{equation-hom-invert-s}). Then $\alpha|_{X_s} = 0$. Hence $(\alpha|_{U_j})|_{D(f_j)} = 0$. By the affine case treated above we conclude that $f_j^{e_j} \alpha|_{U_j} = 0$ for some $e_j \geq 0$. Let $e = \max(e_j)$. Then we see that $\alpha \otimes s^e$ restricts to zero on $U_j$ for all $j$, hence is zero. Since $\alpha/s^n$ is equal to $\alpha \otimes s^e/s^{n + e}$ in $M_{(s)}$ we conclude that $\alpha/s^n = 0$ as desired. \medskip\noindent Proof of (2). Since $\mathcal{F}$ is of finite presentation, the sheaf $\SheafHom_{\mathcal{O}_X}(\mathcal{F}, \mathcal{G})$ is quasi-coherent, see Schemes, Section \ref{schemes-section-quasi-coherent}. Moreover, it is clear that $$ \SheafHom_{\mathcal{O}_X}(\mathcal{F}, \mathcal{G} \otimes_{\mathcal{O}_X} \mathcal{L}^{\otimes n}) = \SheafHom_{\mathcal{O}_X}(\mathcal{F}, \mathcal{G}) \otimes_{\mathcal{O}_X} \mathcal{L}^{\otimes n} $$ for all $n$. Hence in this case the statement follows from Lemma \ref{lemma-invert-s-sections} applied to $\SheafHom_{\mathcal{O}_X}(\mathcal{F}, \mathcal{G})$.
Denote $j : U \to \Spec(A)$ the inclusion morphism. Then $H^0(U, \mathcal{F}) = H^0(\Spec(A), j_*\mathcal{F})$ and $j_*\mathcal{F}$ is quasi-coherent by Schemes, Lemma \ref{schemes-lemma-push-forward-quasi-coherent}. Hence $j_*\mathcal{F} = \widetilde{H^0(U, \mathcal{F})}$ by Schemes, Lemma \ref{schemes-lemma-equivalence-quasi-coherent}. Restricting back to $U$ we get the lemma.
If the displayed morphism is a quasi-compact open immersion then $X$ is isomorphic to a quasi-compact open subscheme of $\Spec(\Gamma(X, \mathcal{O}_X))$ and clearly $X$ is quasi-affine. \medskip\noindent Assume $X$ is quasi-affine, say $X \subset \Spec(R)$ is quasi-compact open. This in particular implies that $X$ is separated, see Schemes, Lemma \ref{schemes-lemma-subscheme-of-separated-scheme}. Let $A = \Gamma(X, \mathcal{O}_X)$. Consider the ring map $R \to A$ coming from $R = \Gamma(\Spec(R), \mathcal{O}_{\Spec(R)})$ and the restriction mapping of the sheaf $\mathcal{O}_{\Spec(R)}$. By Schemes, Lemma \ref{schemes-lemma-morphism-into-affine} we obtain a factorization: $$ X \longrightarrow \Spec(A) \longrightarrow \Spec(R) $$ of the inclusion morphism. Let $x \in X$. Choose $r \in R$ such that $x \in D(r)$ and $D(r) \subset X$. Denote $f \in A$ the image of $r$ in $A$. The open $X_f$ of Lemma \ref{lemma-invert-f-sections} above is equal to $D(r) \subset X$ and hence $A_f \cong R_r$ by the conclusion of that lemma. Hence $D(r) \to \Spec(A)$ is an isomorphism onto the standard affine open $D(f)$ of $\Spec(A)$. Since $X$ can be covered by such affine opens $D(f)$ we win.
The diagram is commutative by Schemes, Lemma \ref{schemes-lemma-morphism-into-affine}. Write $A = \Gamma(U, \mathcal{O}_U)$ and $B = \Gamma(V, \mathcal{O}_V)$. Let $g \in B$ be such that $V_g$ is affine and contained in $U$. This means that if $f$ is the image of $g$ in $A$, then $U_f = V_g$. By Lemma \ref{lemma-invert-f-affine} we see that $j'$ induces an isomorphism of $V_g$ with the standard open $D(g)$ of $\Spec(B)$. Thus $V_g \times_{\Spec(B)} \Spec(A) \to \Spec(A)$ is an isomorphism onto $D(f) \subset \Spec(A)$. By Lemma \ref{lemma-invert-f-affine} again $j$ maps $U_f$ isomorphically to $D(f)$. Thus we see that $U_f = U_f \times_{\Spec(B)} \Spec(A)$. Since by Lemma \ref{lemma-quasi-affine} we can cover $U$ by $V_g = U_f$ as above, we see that $U \to U \times_{\Spec(B)} \Spec(A)$ is an isomorphism.
Flatness of $\mathcal{F}$ may be checked on the stalks, see Modules, Lemma \ref{modules-lemma-flat-stalks-flat}. The same is true in the case of modules over a ring, see Algebra, Lemma \ref{algebra-lemma-flat-localization}. And since $\mathcal{F}_x = M_{\mathfrak p}$ if $x$ corresponds to $\mathfrak p$ the lemma is true.
First, note that if $M$ is a projective $A$-module and $A \to B$ is a ring map, then $M \otimes_A B$ is a projective $B$-module, see Algebra, Lemma \ref{algebra-lemma-ascend-properties-modules}. Hence if $U$ is an affine open such that $\mathcal{F}(U)$ is a projective $\mathcal{O}_X(U)$-module, then the standard open $D(f)$ is an affine open such that $\mathcal{F}(D(f))$ is a projective $\mathcal{O}_X(D(f))$-module for all $f \in \mathcal{O}_X(U)$. Assume (2) holds. Let $U \subset X$ be an arbitrary affine open. We can find an open covering $U = \bigcup_{j = 1, \ldots, m} D(f_j)$ by finitely many standard opens $D(f_j)$ such that for each $j$ the open $D(f_j)$ is a standard open of some $U_i$, see Schemes, Lemma \ref{schemes-lemma-standard-open-two-affines}. Hence, if we set $A = \mathcal{O}_X(U)$ and if $M$ is an $A$-module such that $\mathcal{F}|_U$ corresponds to $M$, then we see that $M_{f_j}$ is a projective $A_{f_j}$-module. It follows that $A \to B = \prod A_{f_j}$ is a faithfully flat ring map such that $M \times_A B$ is a projective $B$-module. Hence $M$ is projective by Algebra, Theorem \ref{algebra-theorem-ffdescent-projectivity}.
An immersion is separated (see Schemes, Lemma \ref{schemes-lemma-immersions-monomorphisms}) and $j$ is quasi-compact by assumption. Hence for any quasi-coherent sheaf $\mathcal{G}$ on $U$ the sheaf $j_*\mathcal{G}$ is an extension to $X$. See Schemes, Lemma \ref{schemes-lemma-push-forward-quasi-coherent} and Sheaves, Section \ref{sheaves-section-open-immersions}. \medskip\noindent Assume $\mathcal{F}$, $\mathcal{G}$ are as in (2). Then $j_*\mathcal{G}$ is a quasi-coherent sheaf on $X$ (see above). It is a subsheaf of $j_*j^*\mathcal{F}$. Hence the kernel $$ \mathcal{H} = \Ker(\mathcal{F} \oplus j_* \mathcal{G} \longrightarrow j_*j^*\mathcal{F}) $$ is quasi-coherent as well, see Schemes, Section \ref{schemes-section-quasi-coherent}. It is formal to check that $\mathcal{H} \subset \mathcal{F}$ and that $\mathcal{H}|_U = \mathcal{G}$ (using the material in Sheaves, Section \ref{sheaves-section-open-immersions} again). \medskip\noindent Part (3) is proved in the same manner as (2). Just take $\mathcal{H} = \Ker(\mathcal{F} \oplus j_* \mathcal{G} \to j_*j^*\mathcal{F})$ with its obvious map to $\mathcal{F}$ and its obvious identification with $\mathcal{G}$ over $U$.
Let $n$ be the minimal number of affine opens $U_i \subset X$, $i = 1, \ldots , n$ such that $X = U \cup \bigcup U_i$. (Here we use that $X$ is quasi-compact.) Suppose we can prove the lemma for the case $n = 1$. Then we can successively extend $\mathcal{G}$ to a $\mathcal{G}_1$ over $U \cup U_1$ to a $\mathcal{G}_2$ over $U \cup U_1 \cup U_2$ to a $\mathcal{G}_3$ over $U \cup U_1 \cup U_2 \cup U_3$, and so on. Thus we reduce to the case $n = 1$. \medskip\noindent Thus we may assume that $X = U \cup V$ with $V$ affine. Since $X$ is quasi-separated and $U$, $V$ are quasi-compact open, we see that $U \cap V$ is a quasi-compact open. It suffices to prove the lemma for the system $(V, U \cap V, \mathcal{F}|_V, \mathcal{G}|_{U \cap V})$ since we can glue the resulting sheaf $\mathcal{G}'$ over $V$ to the given sheaf $\mathcal{G}$ over $U$ along the common value over $U \cap V$. Thus we reduce to the case where $X$ is affine. \medskip\noindent Assume $X = \Spec(R)$. Write $\mathcal{F} = \widetilde M$ for some $R$-module $M$. By Lemma \ref{lemma-extend-trivial} above we may find a quasi-coherent subsheaf $\mathcal{H} \subset \mathcal{F}$ which restricts to $\mathcal{G}$ over $U$. Write $\mathcal{H} = \widetilde N$ for some $R$-module $N$. For every $u \in U$ there exists an $f \in R$ such that $u \in D(f) \subset U$ and such that $N_f$ is finitely generated, see Lemma \ref{lemma-finite-type-module}. Since $U$ is quasi-compact we can cover it by finitely many $D(f_i)$ such that $N_{f_i}$ is generated by finitely many elements, say $x_{i, 1}/f_i^N, \ldots, x_{i, r_i}/f_i^N$. Let $N' \subset N$ be the submodule generated by the elements $x_{i, j}$. Then the subsheaf $\mathcal{G}' = \widetilde{N'} \subset \mathcal{H} \subset \mathcal{F}$ works.
The colimit is directed because if $\mathcal{G}_1$, $\mathcal{G}_2$ are quasi-coherent subsheaves of finite type, then the image of $\mathcal{G}_1 \oplus \mathcal{G}_2 \to \mathcal{F}$ is a quasi-coherent submodule of finite type. Let $U \subset X$ be any affine open, and let $s \in \Gamma(U, \mathcal{F})$ be any section. Let $\mathcal{G} \subset \mathcal{F}|_U$ be the subsheaf generated by $s$. Then clearly $\mathcal{G}$ is quasi-coherent and has finite type as an $\mathcal{O}_U$-module. By Lemma \ref{lemma-extend} we see that $\mathcal{G}$ is the restriction of a quasi-coherent subsheaf $\mathcal{G}' \subset \mathcal{F}$ which has finite type. Since $X$ has a basis for the topology consisting of affine opens we conclude that every local section of $\mathcal{F}$ is locally contained in a quasi-coherent submodule of finite type. Thus we win.
The beginning of the proof is a repeat of the beginning of the proof of Lemma \ref{lemma-extend}. We write it out carefuly anyway. \medskip\noindent Let $n$ be the minimal number of affine opens $U_i \subset X$, $i = 1, \ldots , n$ such that $X = U \cup \bigcup U_i$. (Here we use that $X$ is quasi-compact.) Suppose we can prove the lemma for the case $n = 1$. Then we can successively extend the pair $(\mathcal{G}, \varphi)$ to a pair $(\mathcal{G}_1, \varphi_1)$ over $U \cup U_1$ to a pair $(\mathcal{G}_2, \varphi_2)$ over $U \cup U_1 \cup U_2$ to a pair $(\mathcal{G}_3, \varphi_3)$ over $U \cup U_1 \cup U_2 \cup U_3$, and so on. Thus we reduce to the case $n = 1$. \medskip\noindent Thus we may assume that $X = U \cup V$ with $V$ affine. Since $X$ is quasi-separated and $U$ quasi-compact, we see that $U \cap V \subset V$ is quasi-compact. Suppose we prove the lemma for the system $(V, U \cap V, \mathcal{F}|_V, \mathcal{G}|_{U \cap V}, \varphi|_{U \cap V})$ thereby producing $(\mathcal{G}', \varphi')$ over $V$. Then we can glue $\mathcal{G}'$ over $V$ to the given sheaf $\mathcal{G}$ over $U$ along the common value over $U \cap V$, and similarly we can glue the map $\varphi'$ to the map $\varphi$ along the common value over $U \cap V$. Thus we reduce to the case where $X$ is affine. \medskip\noindent Assume $X = \Spec(R)$. By Lemma \ref{lemma-extend-trivial} above we may find a quasi-coherent sheaf $\mathcal{H}$ with a map $\psi : \mathcal{H} \to \mathcal{F}$ over $X$ which restricts to $\mathcal{G}$ and $\varphi$ over $U$. By Lemma \ref{lemma-extend} we can find a finite type quasi-coherent $\mathcal{O}_X$-submodule $\mathcal{H}' \subset \mathcal{H}$ such that $\mathcal{H}'|_U = \mathcal{G}$. Thus after replacing $\mathcal{H}$ by $\mathcal{H}'$ and $\psi$ by the restriction of $\psi$ to $\mathcal{H}'$ we may assume that $\mathcal{H}$ is of finite type. By Lemma \ref{lemma-finite-presentation-module} we conclude that $\mathcal{H} = \widetilde{N}$ with $N$ a finitely generated $R$-module. Hence there exists a surjection as in the following short exact sequence of quasi-coherent $\mathcal{O}_X$-modules $$ 0 \to \mathcal{K} \to \mathcal{O}_X^{\oplus n} \to \mathcal{H} \to 0 $$ where $\mathcal{K}$ is defined as the kernel. Since $\mathcal{G}$ is of finite presentation and $\mathcal{H}|_U = \mathcal{G}$ by Modules, Lemma \ref{modules-lemma-kernel-surjection-finite-free-onto-finite-presentation} the restriction $\mathcal{K}|_U$ is an $\mathcal{O}_U$-module of finite type. Hence by Lemma \ref{lemma-extend} again we see that there exists a finite type quasi-coherent $\mathcal{O}_X$-submodule $\mathcal{K}' \subset \mathcal{K}$ such that $\mathcal{K}'|_U = \mathcal{K}|_U$. The solution to the problem posed in the lemma is to set $$ \mathcal{G}' = \mathcal{O}_X^{\oplus n}/\mathcal{K}' $$ which is clearly of finite presentation and restricts to give $\mathcal{G}$ on $U$ with $\varphi'$ equal to the composition $$ \mathcal{G}' = \mathcal{O}_X^{\oplus n}/\mathcal{K}' \to \mathcal{O}_X^{\oplus n}/\mathcal{K} = \mathcal{H} \xrightarrow{\psi} \mathcal{F}. $$ This finishes the proof of the lemma.
Part (2) is the special case of Lemma \ref{lemma-extend-finite-presentation} where $\mathcal{F} = 0$. For part (1) we first write $\mathcal{G} = \mathcal{F}|_U$ for some quasi-coherent $\mathcal{O}_X$-module by Lemma \ref{lemma-extend-trivial} and then we apply Lemma \ref{lemma-extend} with $\mathcal{G} = \mathcal{F}|_U$.
Write $\mathcal{F} = \colim \mathcal{G}_i$ as a filtered colimit of finitely presented $\mathcal{O}_X$-modules (Lemma \ref{lemma-directed-colimit-finite-presentation}). We claim that $\mathcal{G}_i \to \mathcal{F}$ is surjective for some $i$. Namely, choose a finite affine open covering $X = U_1 \cup \ldots \cup U_m$. Choose sections $s_{jl} \in \mathcal{F}(U_j)$ generating $\mathcal{F}|_{U_j}$, see Lemma \ref{lemma-finite-type-module}. By Sheaves, Lemma \ref{sheaves-lemma-directed-colimits-sections} we see that $s_{jl}$ is in the image of $\mathcal{G}_i \to \mathcal{F}$ for $i$ large enough. Hence $\mathcal{G}_i \to \mathcal{F}$ is surjective for $i$ large enough. Choose such an $i$ and let $\mathcal{K} \subset \mathcal{G}_i$ be the kernel of the map $\mathcal{G}_i \to \mathcal{F}$. Write $\mathcal{K} = \colim \mathcal{K}_a$ as the filtered colimit of its finite type quasi-coherent submodules (Lemma \ref{lemma-quasi-coherent-colimit-finite-type}). Then $\mathcal{F} = \colim \mathcal{G}_i/\mathcal{K}_a$ is a solution to the problem posed by the lemma.
Write $\mathcal{F} = \colim \mathcal{F}_i$ as a directed colimit with each $\mathcal{F}_i$ of finite presentation, see Lemma \ref{lemma-directed-colimit-finite-presentation}. Choose a finite affine open covering $X = \bigcup V_j$ and choose finitely many sections $s_{jl} \in \mathcal{F}(V_j)$ generating $\mathcal{F}|_{V_j}$, see Lemma \ref{lemma-finite-type-module}. By Sheaves, Lemma \ref{sheaves-lemma-directed-colimits-sections} we see that $s_{jl}$ is in the image of $\mathcal{F}_i \to \mathcal{F}$ for $i$ large enough. Hence $\mathcal{F}_i \to \mathcal{F}$ is surjective for $i$ large enough. Choose such an $i$ and let $\mathcal{K} \subset \mathcal{F}_i$ be the kernel of the map $\mathcal{F}_i \to \mathcal{F}$. Since $\mathcal{F}_U$ is of finite presentation, we see that $\mathcal{K}|_U$ is of finite type, see Modules, Lemma \ref{modules-lemma-kernel-surjection-finite-free-onto-finite-presentation}. Hence we can find a finite type quasi-coherent submodule $\mathcal{K}' \subset \mathcal{K}$ with $\mathcal{K}'|_U = \mathcal{K}|_U$, see Lemma \ref{lemma-extend}. Then $\mathcal{G} = \mathcal{F}_i/\mathcal{K}'$ with the given map $\mathcal{G} \to \mathcal{F}$ is a solution.