hcju/stacksqa huggingface dataset:
Choose a scheme $V$ and a surjective smooth morphism $V \to \mathcal{Y}$. By Lemma \ref{lemma-cover-upstairs} we may replace $\mathcal{Y}$ by $V$. Thus it suffices to show that if $X \to \mathcal{X}$ is a morphism from a scheme to an algebraic stack, then the scheme theoretic image exists. Choose a scheme $U$ and a surjective smooth morphism $U \to \mathcal{X}$. Set $R = U \times_\mathcal{X} U$. We have $\mathcal{X} = [U/R]$ by Algebraic Stacks, Lemma \ref{algebraic-lemma-stack-presentation}. By Properties of Stacks, Lemma \ref{stacks-properties-lemma-substacks-presentation} the closed substacks $\mathcal{Z}$ of $\mathcal{X}$ are in $1$-to-$1$ correspondence with $R$-invariant closed subschemes $Z \subset U$. Let $Z_1 \subset U$ be the scheme theoretic image of $X \times_\mathcal{X} U \to U$. Observe that $X \to \mathcal{X}$ factors through $\mathcal{Z}$ if and only if $X \times_\mathcal{X} U \to U$ factors through the corresponding $R$-invariant closed subscheme $Z$ (details omitted; hint: this follows because $X \times_\mathcal{X} U \to X$ is surjective and smooth). Thus we have to show that there exists a smallest $R$-invariant closed subscheme $Z \subset U$ containing $Z_1$. \medskip\noindent Let $\mathcal{I}_1 \subset \mathcal{O}_U$ be the quasi-coherent ideal sheaf corresponding to the closed subscheme $Z_1 \subset U$. Let $Z_\alpha$, $\alpha \in A$ be the set of all $R$-invariant closed subschemes of $U$ containing $Z_1$. For $\alpha \in A$, let $\mathcal{I}_\alpha \subset \mathcal{O}_U$ be the quasi-coherent ideal sheaf corresponding to the closed subscheme $Z_\alpha \subset U$. The containment $Z_1 \subset Z_\alpha$ means $\mathcal{I}_\alpha \subset \mathcal{I}_1$. The $R$-invariance of $Z_\alpha$ means that $$ s^{-1}\mathcal{I}_\alpha \cdot \mathcal{O}_R = t^{-1}\mathcal{I}_\alpha \cdot \mathcal{O}_R $$ as (quasi-coherent) ideal sheaves on (the algebraic space) $R$. Consider the image $$ \mathcal{I} = \Im\left( \bigoplus\nolimits_{\alpha \in A} \mathcal{I}_\alpha \to \mathcal{I}_1 \right) = \Im\left( \bigoplus\nolimits_{\alpha \in A} \mathcal{I}_\alpha \to \mathcal{O}_X \right) $$ Since direct sums of quasi-coherent sheaves are quasi-coherent and since images of maps between quasi-coherent sheaves are quasi-coherent, we find that $\mathcal{I}$ is quasi-coherent. Since pull back is exact and commutes with direct sums we find $$ s^{-1}\mathcal{I} \cdot \mathcal{O}_R = t^{-1}\mathcal{I} \cdot \mathcal{O}_R $$ Hence $\mathcal{I}$ defines an $R$-invariant closed subscheme $Z \subset U$ which is contained in every $Z_\alpha$ and containes $Z_1$ as desired.
Let $z \in |\mathcal{Z}|$ be a point. Choose an affine scheme $V$, a point $v \in V$, and a smooth morphism $V \to \mathcal{Y}$ mapping $v$ to $z$. Then $\mathcal{X} \times_\mathcal{Y} V$ is a quasi-compact algebraic stack. Hence we can find an affine scheme $W$ and a surjective smooth morphism $W \to \mathcal{X} \times_\mathcal{Y} V$. By Lemma \ref{lemma-existence-plus-flat-base-change} the scheme theoretic image of $\mathcal{X} \times_\mathcal{Y} V \to V$ is $Z = \mathcal{Z} \times_\mathcal{Y} V$. Hence the inverse image of $|\mathcal{Z}|$ in $|V|$ is $|Z|$ by Properties of Stacks, Lemma \ref{stacks-properties-lemma-points-cartesian}. By Lemma \ref{lemma-cover-upstairs} $Z$ is the scheme theoretic image of $W \to V$. By Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-quasi-compact-scheme-theoretic-image} we see that the image of $|W| \to |Z|$ is dense. Hence the image of $|\mathcal{X} \times_\mathcal{Y} V| \to |Z|$ is dense. Observe that $v \in Z$. Since $|V| \to |\mathcal{Y}|$ is open, a topology argument tells us that $z$ is in the closure of the image of $|f|$ as desired.
By Lemma \ref{lemma-quasi-compact-permanence} the morphism $s : \mathcal{V} \to \mathcal{Y}$ is quasi-compact. Hence the construction of the scheme theoretic image $\mathcal{Y}'$ of $s$ commutes with flat base change by Lemma \ref{lemma-existence-plus-flat-base-change}. Thus to prove the lemma we may assume $\mathcal{Y}$ is representable by an algebraic space and we reduce to the case of algebraic spaces which is Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-scheme-theoretic-image-of-partial-section}.
Since $2$-arrows are invertible it is clear that the category of dotted arrows is a groupoid. Given a dotted arrow $(a, \alpha, \beta)$ an automorphism of $(a, \alpha, \beta)$ is a $2$-morphism $\theta : a \to a$ satisfying two conditions. The first condition $\beta = (\text{id}_f \star \theta) \circ \beta$ signifies that $\theta$ defines a morphism $(a, \theta) : \Spec(A) \to \mathcal{I}_{\mathcal{X}/\mathcal{Y}}$. The second condition $\alpha = \alpha \circ (\theta \star \text{id}_j)$ implies that the restriction of $(a, \theta)$ to $\Spec(K)$ is the identity. Picture $$ \xymatrix{ \mathcal{I}_{\mathcal{X}/\mathcal{Y}} \ar[d] & & \Spec(K) \ar[d]^j \ar[ll]_{(a \circ j, \text{id})} \\ \mathcal{X} & & \Spec(A) \ar[ll]_a \ar[llu]_{(a, \theta)} } $$ In other words, if $G \to \Spec(A)$ is the group algebraic space we get by pulling back the relative inertia by $a$, then $\theta$ defines a point $\theta \in G(A)$ whose image in $G(K)$ is trivial. Certainly, if the identity $e : \Spec(A) \to G$ is a closed immersion, then this can happen only if $\theta$ is the identity. Looking at Lemma \ref{lemma-diagonal-diagonal} we obtain the result we want.
Let $\gamma, \gamma' : y \circ j \longrightarrow f \circ x$ be two $2$-morphisms. Then $\gamma^{-1} \circ \gamma'$ is an automorphism of $y$ over $\Spec(K)$. Hence if $\mathit{Isom}_\mathcal{Y}(y, y) \to \Spec(A)$ is proper, then by the valuative criterion of properness (Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-characterize-proper}) we can find $\delta : y \to y$ whose restriction to $\Spec(K)$ is $\gamma^{-1} \circ \gamma'$. Then we can use $\delta$ to define an equivalence between the category of dotted arrows for $\gamma$ to the category of dotted arrows for $\gamma'$ by sending $(a, \alpha, \beta)$ to $(a, \alpha, \beta \circ \delta)$. The final statement is clear.
This lemma, although a bit of a brain teaser, is straightforward. (We do not know how to prove the analogue of this lemma if instead of the category of dotted arrows we look at the set of isomorphism classes of morphisms producing two $2$-commutative triangles as in Lemma \ref{lemma-cat-dotted-arrows-independent}; in fact this analogue may very well be wrong.) To prove the lemma we are allowed to replace $\mathcal{X}'$ by the $2$-fibre product $\mathcal{Y}' \times_\mathcal{Y} \mathcal{X}$ as described in Categories, Lemma \ref{categories-lemma-2-product-categories-over-C}. Then the object $x'$ becomes the triple $(y' \circ j, x, \gamma)$. Then we can go from a dotted arrow $(a, \alpha, \beta)$ for the outer rectangle to a dotted arrow $(a', \alpha', \beta')$ for the left square by taking $a' = (y', a, \beta)$ and $\alpha' = (\text{id}_{y' \circ j}, \alpha)$ and $\beta' = \text{id}_{y'}$. Details omitted.
We are going to write out a detailed proof, but we strongly urge the reader to find their own proof, inspired by reading the argument given in the proof of Lemma \ref{lemma-cat-dotted-arrows}. \medskip\noindent Assume $\Delta_f$ is quasi-separated and for every diagram (\ref{equation-diagram}) and choice of $\gamma$ as in Definition \ref{definition-fill-in-diagram} the category of dotted arrows is a setoid. By Lemma \ref{lemma-diagonal-diagonal} it suffices to show that $e : \mathcal{X} \to \mathcal{I}_{\mathcal{X}/\mathcal{Y}}$ is a closed immersion. By Lemma \ref{lemma-first-diagonal-separated-second-diagonal-closed} it in fact suffices to show that $e = \Delta_{f, 2}$ is universally closed. Either of these lemmas tells us that $e = \Delta_{f, 2}$ is quasi-compact by our assumption that $\Delta_f$ is quasi-separated. \medskip\noindent In this paragraph we will show that $e$ satisfies the existence part of the valuative criterion. Consider a $2$-commutative solid diagram $$ \xymatrix{ \Spec(K) \ar[r]_x \ar[d]_j & \mathcal{X} \ar[d]^e \\ \Spec(A) \ar[r]^{(a, \theta)} & \mathcal{I}_{\mathcal{X}/\mathcal{Y}} } $$ and let $\alpha : (a, \theta) \circ j \to e \circ x$ be any $2$-morphism witnessing the $2$-commutativity of the diagram (we use $\alpha$ instead of the letter $\gamma$ used in Definition \ref{definition-fill-in-diagram}). Note that $f \circ \theta = \text{id}$; we will use this below. Observe that $e \circ x = (x, \text{id}_x)$ and $(a, \theta) \circ j = (a \circ j, \theta \star \text{id}_j)$. Thus we see that $\alpha$ is a $2$-arrow $\alpha : a \circ j \to x$ compatible with $\theta \star \text{id}_j$ and $\text{id}_x$. Set $y = f \circ x$ and $\beta = \text{id}_{f \circ a}$. Reading the arguments given in the proof of Lemma \ref{lemma-cat-dotted-arrows} backwards, we see that $\theta$ is an automorphism of the dotted arrow $(a, \alpha, \beta)$ with $$ \gamma : y \circ j \to f \circ x \quad\text{equal to}\quad \text{id}_f \star \alpha : f \circ a \circ j \to f \circ x $$ On the other hand, $\text{id}_a$ is an automorphism too, hence we conclude $\theta = \text{id}_a$ from the assumption on $f$. Then we can take as dotted arrow for the displayed diagram above the morphism $a : \Spec(A) \to \mathcal{X}$ with $2$-morphisms $(a, \text{id}_a) \circ j \to (x, \text{id}_x)$ given by $\alpha$ and $(a, \theta) \to e \circ a$ given by $\text{id}_a$. \medskip\noindent By Lemma \ref{lemma-base-change-existence} any base change of $e$ satisfies the existence part of the valuative criterion. Since $e$ is representable by algebraic spaces, it suffices to show that $e$ is universally closed after a base change by a morphism $I \to \mathcal{I}_{\mathcal{X}/\mathcal{Y}}$ which is surjective and smooth and with $I$ an algebraic space (see Properties of Stacks, Section \ref{stacks-properties-section-properties-morphisms}). This base change $e' : X' \to I'$ is a quasi-compact morphism of algebraic spaces which satisfies the existence part of the valuative criterion and hence is universally closed by Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-quasi-compact-existence-universally-closed}.
The assumption on $f$ means that $\Delta_f$ is quasi-compact and quasi-separated (Definition \ref{definition-separated}). We have to show that $\Delta_f$ is proper. Lemma \ref{lemma-setoids-and-diagonal} says that $\Delta_f$ is separated. By Lemma \ref{lemma-properties-diagonal} we know that $\Delta_f$ is locally of finite type. To finish the proof we have to show that $\Delta_f$ is universally closed. A formal argument (see Lemma \ref{lemma-helper-diagonal}) shows that the uniqueness part of the valuative criterion implies that we have the existence of a dotted arrow in any solid diagram like so: $$ \xymatrix{ \Spec(K) \ar[d] \ar[r] & \mathcal{X} \ar[d]^{\Delta_f} \\ \Spec(A) \ar[r] \ar@{..>}[ru] & \mathcal{X} \times_\mathcal{Y} \mathcal{X} } $$ Using that this property is preserved by any base change we conclude that any base change by $\Delta_f$ by an algebraic space mapping into $\mathcal{X} \times_\mathcal{Y} \mathcal{X}$ has the existence part of the valuative criterion and we conclude is universally closed by the valuative criterion for morphisms of algebraic spaces, see Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-quasi-compact-existence-universally-closed}.
Since $f$ is separated we see that all categories of dotted arrows are setoids by Lemma \ref{lemma-cat-dotted-arrows}. Consider a diagram $$ \xymatrix{ \Spec(K) \ar[r]_-x \ar[d]_j & \mathcal{X} \ar[d]^f \\ \Spec(A) \ar[r]^-y \ar@{..>}[ru] & \mathcal{Y} } $$ and a $2$-morphism $\gamma : y \circ j \to f \circ x$ as in Definition \ref{definition-fill-in-diagram}. Consider two objects $(a, \alpha, \beta)$ and $(a', \beta', \alpha')$ of the category of dotted arrows. To finish the proof we have to show these objects are isomorphic. The isomorphism $$ f \circ a \xrightarrow{\beta^{-1}} y \xrightarrow{\beta'} f \circ a' $$ means that $(a, a', \beta' \circ \beta^{-1})$ is a morphism $\Spec(A) \to \mathcal{X} \times_\mathcal{Y} \mathcal{X}$. On the other hand, $\alpha$ and $\alpha'$ define a $2$-arrow $$ (a, a', \beta' \circ \beta^{-1}) \circ j = (a \circ j, a' \circ j, (\beta' \star \text{id}_j) \circ (\beta \star \text{id}_j)^{-1}) \xrightarrow{(\alpha, \alpha')} (x, x, \text{id}) = \Delta_f \circ x $$ Here we use that both $(a, \alpha, \beta)$ and $(a', \alpha', \beta')$ are dotted arrows with respect to $\gamma$. We obtain a commutative diagram $$ \xymatrix{ \Spec(K) \ar[d]_j \ar[rr]_x & & \mathcal{X} \ar[d]^{\Delta_f} \\ \Spec(A) \ar[rr]^{(a, a', \beta' \circ \beta^{-1})} & & \mathcal{X} \times_\mathcal{Y} \mathcal{X} } $$ with $2$-commutativity witnessed by $(\alpha, \alpha')$. Now $\Delta_f$ is representable by algebraic spaces (Lemma \ref{lemma-properties-diagonal}) and proper as $f$ is separated. Hence by Lemma \ref{lemma-existence-representable} and the valuative criterion for properness for algebraic spaces (Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-characterize-proper}) we see that there exists a dotted arrow. Unwinding the construction, we see that this means $(a, \alpha, \beta)$ and $(a', \alpha', \beta')$ are isomorphic in the category of dotted arrows as desired.
By Lemmas \ref{lemma-base-change-quasi-compact} and \ref{lemma-base-change-existence} properties (1) and (2) are preserved under any base change. By Lemma \ref{lemma-universally-closed-local} we only have to show that $|T \times_\mathcal{Y} \mathcal{X}| \to |T|$ is closed, whenever $T$ is an affine scheme mapping into $\mathcal{Y}$. Hence it suffices to show: if $f : \mathcal{X} \to Y$ is a quasi-compact morphism from an algebraic stack to an affine scheme satisfying the existence part of the valuative criterion, then $|f|$ is closed. Let $T \subset |\mathcal{X}|$ be a closed subset. We have to show that $f(T)$ is closed to finish the proof. \medskip\noindent Let $\mathcal{Z} \subset \mathcal{X}$ be the reduced induced algebraic stack structure on $T$ (Properties of Stacks, Definition \ref{stacks-properties-definition-reduced-induced-stack}). Then $i : \mathcal{Z} \to \mathcal{X}$ is a closed immersion and we have to show that the image of $|\mathcal{Z}| \to |Y|$ is closed. Since closed immersions are quasi-compact (Lemma \ref{lemma-closed-immersion-quasi-compact}) and satisfies the existence part of the valuative criterion (Lemma \ref{lemma-closed-immersion-valuative-criteria}) and since compositions of quasi-compact morphisms are quasi-compact (Lemma \ref{lemma-composition-quasi-compact}) and since compositions preserve the property of satisfying the existence part of the valuative criterion (Lemma \ref{lemma-composition-existence}) we conclude that it suffices to show: if $f : \mathcal{X} \to Y$ is a quasi-compact morphism from an algebraic stack to an affine scheme satisfying the existence part of the valuative criterion, then $|f|(|\mathcal{X}|)$ is closed. \medskip\noindent Since $\mathcal{X}$ is quasi-compact (being quasi-compact over the affine $Y$), we can choose an affine scheme $U$ and a surjective smooth morphism $U \to \mathcal{X}$ (Properties of Stacks, Lemma \ref{stacks-properties-lemma-quasi-compact-stack}). Suppose that $y \in Y$ is in the closure of the image of $U \to Y$ (in other words, in the closure of the image of $|f|$). Then by Morphisms, Lemma \ref{morphisms-lemma-reach-points-scheme-theoretic-image} we can find a valuation ring $A$ with fraction field $K$ and a commutative diagram $$ \xymatrix{ \Spec(K) \ar[r] \ar[d] & U \ar[d] \\ \Spec(A) \ar[r] & Y } $$ such that the closed point of $\Spec(A)$ maps to $y$. By assumption we get an extension $K'/K$ and a valuation ring $A' \subset K'$ dominating $A$ and the dotted arrow in the following diagram $$ \xymatrix{ \Spec(K') \ar[r] \ar[d] & \Spec(K) \ar[r] \ar[d] & U \ar[d] \ar[r] & \mathcal{X} \ar[d]^f \\ \Spec(A') \ar[r] \ar@{..>}[rrru] & \Spec(A) \ar[r] & Y  \ar@{=}[r] & Y } $$ Thus $y$ is in the image of $|f|$ and we win.
Consider a solid diagram $$ \xymatrix{ \Spec(K) \ar[r]_-x \ar[d]_j & \mathcal{X} \ar[d]^f \\ \Spec(A) \ar[r]^-y \ar@{..>}[ru] & \mathcal{Y} } $$ where $A$ is a valuation ring with field of fractions $K$ and $\gamma : y \circ j \longrightarrow f \circ x$ as in Definition \ref{definition-fill-in-diagram}. By Lemma \ref{lemma-cat-dotted-arrows-base-change} in order to find a dotted arrow (after possibly replacing $K$ by an extension and $A$ by a valuation ring dominating it) we may replace $\mathcal{Y}$ by $\Spec(A)$ and $\mathcal{X}$ by $\Spec(A) \times_\mathcal{Y} \mathcal{X}$. Of course we use here that being quasi-separated and universally closed are preserved under base change. Thus we reduce to the case discussed in the next paragraph. \medskip\noindent Consider a solid diagram $$ \xymatrix{ \Spec(K) \ar[r]_-x \ar[d]_j & \mathcal{X} \ar[d]^f \\ \Spec(A) \ar@{=}[r] \ar@{..>}[ru] & \Spec(A) } $$ where $A$ is a valuation ring with field of fractions $K$ as in Definition \ref{definition-fill-in-diagram}. By Lemma \ref{lemma-quasi-compact-permanence} and the fact that $f$ is quasi-separated we have that the morphism $x$ is quasi-compact. Since $f$ is universally closed, we have in particular that $|f|(\overline{\{x\}})$ is closed in $\Spec(A)$. Since this image contains the generic point of $\Spec(A)$ there exists a point $x' \in |\mathcal{X}|$ in the closure of $x$ mapping to the closed point of $\Spec(A)$. By Lemma \ref{lemma-reach-points-scheme-theoretic-image} we can find a commutative diagram $$ \xymatrix{ \Spec(K') \ar[r] \ar[d] & \Spec(K) \ar[d] \\ \Spec(A') \ar[r] & \mathcal{X} } $$ such that the closed point of $\Spec(A')$ maps to $x' \in |\mathcal{X}|$. It follows that $\Spec(A') \to \Spec(A)$ maps the closed point to the closed point, i.e., $A'$ dominates $A$ and this finishes the proof.
Choose a scheme $W$ and a surjective smooth morphism $W \to \mathcal{Z}$. Choose a scheme $V$ and a surjective smooth morphism $V \to W \times_\mathcal{Z} \mathcal{Y}$. Choose a scheme $U$ and a surjective smooth morphism $U \to V \times_\mathcal{Y} \mathcal{X}$. Then $U \to W$ is a local complete intersection morphism of schemes and $V \to W$ is a smooth morphism of schemes. By the result for schemes (More on Morphisms, Lemma \ref{more-morphisms-lemma-lci-permanence}) we conclude that $U \to V$ is a local complete intersection morphism. By definition this means that $f$ is a local complete intersection morphism.
Choose a scheme $U$ and a surjective smooth morphism $U \to \mathcal{X}$. Denote $G \to H$ the pullback of the morphism $\mathcal{I}_\mathcal{X} \to \mathcal{X} \times_\mathcal{Y} \mathcal{I}_\mathcal{Y}$ to $U$. By Remark \ref{remark-get-property-auts-from-diagonal} and Lemma \ref{lemma-characterize-unramified} the morphism $G \to H$ is \'etale. Condition (1) is equivalent to the condition that $G \to H$ is an isomorphism (this follows for example by applying Properties of Stacks, Lemma \ref{stacks-properties-lemma-check-property-covering}). Condition (2) is equivalent to the condition that for every $u \in U$ the morphism $G_u \to H_u$ of fibres is an isomorphism. Thus (1) $\Rightarrow$ (2) is trivial. If (2) holds, then $G \to H$ is a surjective, universally injective, \'etale morphism of algebraic spaces. Such a morphism is an isomorphism by Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-etale-universally-injective-open}.
Choose a scheme $U$ and a surjective smooth morphism $U \to \mathcal{X}$. Denote $G \to H$ the pullback of the morphism $\mathcal{I}_\mathcal{X} \to \mathcal{X} \times_\mathcal{Y} \mathcal{I}_\mathcal{Y}$ to $U$. By Remark \ref{remark-get-property-auts-from-diagonal} and Lemma \ref{lemma-characterize-unramified} the morphism $G \to H$ is \'etale. Since $f$ is representable by algebraic spaces, we see that $G \to H$ is a monomorphism. Hence $G \to H$ is an open immersion, see Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-etale-universally-injective-open}. By assumption $H \to U$ is proper. \medskip\noindent With these preparations out of the way, we can prove the lemma as follows. The inverse image of the subset of $|\mathcal{X}|$ of the lemma is clearly the set of $u \in U$ such that $G_u \to H_u$ is an isomorphism (since after all $G_u$ is an open sub group algebraic space of $H_u$). This is an open subset because the complement is the image of the closed subset $|H| \setminus |G|$ and $|H| \to |U|$ is closed. By Properties of Stacks, Lemma \ref{stacks-properties-lemma-open-substacks} we can consider the corresponding open substack $\mathcal{U}$ of $\mathcal{X}$. The final statement of the lemma follows from applying Lemma \ref{lemma-aut-iso-unramified} to $\mathcal{U} \to \mathcal{Y}$.
By Lemma \ref{lemma-universally-injective} we see that $f$ is universally injective. Combining Lemmas \ref{lemma-stabilizer-preserving} and \ref{lemma-aut-iso-unramified} we see that $f$ is representable by algebraic spaces. Hence $f$ is an open immersion by Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-etale-universally-injective-open}. To finish we remark that the condition in the lemma also guarantees that $f$ is surjective.
The implication (1) $\Rightarrow$ (2) follows from Lemmas \ref{lemma-gerbe-fppf} and \ref{lemma-gerbe-isom-fppf}. \medskip\noindent Assume (2). It suffices to prove (1) for the base change of $f$ by a surjective, flat, and locally finitely presented morphism $\mathcal{Y}' \to \mathcal{Y}$, see Lemma \ref{lemma-gerbe-descent} (note that the base change of the diagonal of $f$ is the diagonal of the base change).  Thus we may assume $\mathcal{Y}$ is a scheme $Y$. In this case $\mathcal{I}_\mathcal{X} \to \mathcal{X}$ is a base change of $\Delta$ and we conclude that $\mathcal{X}$ is a gerbe by Proposition \ref{proposition-when-gerbe}. We still have to show that $\mathcal{X}$ is a gerbe over $Y$. Let $\mathcal{X} \to X$ be the morphism of Lemma \ref{lemma-gerbe-over-iso-classes} turning $\mathcal{X}$ into a gerbe over the algebraic space $X$ classifying isomorphism classes of objects of $\mathcal{X}$. It is clear that $f : \mathcal{X} \to Y$ factors as $\mathcal{X} \to X \to Y$. Since $f$ is surjective, flat, and locally of finite presentation, we conclude that $X \to Y$ is surjective as a map of fppf sheaves (for example use Lemma \ref{lemma-surjective-flat-locally-finite-presentation}). On the other hand, $X \to Y$ is injective too: for any scheme $T$ and any two $T$-valued points $x_1, x_2$ of $X$ which map to the same point of $Y$, we can first fppf locally on $T$ lift $x_1, x_2$ to objects $\xi_1, \xi_2$ of $\mathcal{X}$ over $T$ and second deduce that $\xi_1$ and $\xi_2$ are fppf locally isomorphic by our assumption that $\Delta : \mathcal{X} \to \mathcal{X} \times_Y \mathcal{X}$ is surjective, flat, and locally of finite presentation. Whence $x_1 = x_2$ by construction of $X$. Thus $X = Y$ and the proof is complete.