hcju/stacksqa huggingface dataset:
By Theorem \ref{theorem-fully-faithful} it suffices to show that $(g, g^\sharp)$ is a morphism of locally ringed topoi. By Modules on Sites, Lemma \ref{sites-modules-lemma-locally-ringed-morphism} (and since the site $X_\etale$ has enough points) it suffices to check that the map $\mathcal{O}_{Y, q} \to \mathcal{O}_{X, p}$ induced by $g^\sharp$ is a local ring map where $q = f \circ p$ and $p$ is any point of $X_\etale$. As it is an isomorphism this is clear.
Note that $\mathcal{O}_{X, \overline{x}} = \mathcal{O}_{U, u}^{sh}$ by Lemma \ref{lemma-describe-etale-local-ring} hence the tensor product makes sense. Moreover, from Definition \ref{definition-stalk} it is clear that $$ \mathcal{F}_{\overline{u}} = \colim (\varphi^*\mathcal{F})_u $$ where the colimit is over $\varphi : (U, \overline{u}) \to (X, \overline{x})$ as in the lemma. Hence there is a canonical map from left to right in the statement of the lemma. We have a similar colimit description for $\mathcal{O}_{X, \overline{x}}$ and by Lemma \ref{lemma-characterize-quasi-coherent-small-etale} we have $$ ((\varphi')^*\mathcal{F})_{u'} = (\varphi^*\mathcal{F})_u \otimes_{\mathcal{O}_{U, u}} \mathcal{O}_{U', u'} $$ whenever $(U', \overline{u}') \to (U, \overline{u})$ is a morphism of \'etale neighbourhoods. To complete the proof we use that $\otimes$ commutes with colimits.
Since $f^*\mathcal{G} = f_{small}^{-1}\mathcal{G} \otimes_{f_{small}^{-1}\mathcal{O}_Y} \mathcal{O}_X$ this follows from the description of stalks of pullbacks in Lemma \ref{lemma-stalk-pullback} and the fact that taking stalks commutes with tensor products. A more direct way to see this is as follows. Choose a commutative diagram $$ \xymatrix{ U \ar[d]_p \ar[r]_\alpha  & V \ar[d]^q \\ X \ar[r]^a & Y } $$ where $U$ and $V$ are schemes, and $p$ and $q$ are surjective \'etale. By Lemma \ref{lemma-geometric-lift-to-usual} we can choose a geometric point $\overline{u}$ of $U$ such that $\overline{x} = p \circ \overline{u}$. Set $\overline{v} = \alpha \circ \overline{u}$. Then we see that \begin{align*} (f^*\mathcal{G})_{\overline{x}} & = (p^*f^*\mathcal{G})_u \otimes_{\mathcal{O}_{U, u}} \mathcal{O}_{X, \overline{x}} \\ & = (\alpha^*q^*\mathcal{G})_u \otimes_{\mathcal{O}_{U, u}} \mathcal{O}_{X, \overline{x}} \\ & = (q^*\mathcal{G})_v \otimes_{\mathcal{O}_{V, v}} \mathcal{O}_{U, u} \otimes_{\mathcal{O}_{U, u}} \mathcal{O}_{X, \overline{x}} \\ & = (q^*\mathcal{G})_v \otimes_{\mathcal{O}_{V, v}} \mathcal{O}_{X, \overline{x}} \\ & = (q^*\mathcal{G})_v \otimes_{\mathcal{O}_{V, v}} \mathcal{O}_{Y, \overline{y}} \otimes_{\mathcal{O}_{Y, \overline{y}}} \mathcal{O}_{X, \overline{x}} \\ & = \mathcal{G}_{\overline{y}} \otimes_{\mathcal{O}_{Y, \overline{y}}} \mathcal{O}_{X, \overline{x}} \end{align*} Here we have used Lemma \ref{lemma-stalk-quasi-coherent} (twice) and the corresponding result for pullbacks of quasi-coherent sheaves on schemes, see Sheaves, Lemma \ref{sheaves-lemma-stalk-pullback-modules}.
It is clear that (1) implies (2) by considering $\text{id}_X$. Assume $f : Y \to X$ is as in (2), and let $V \to Y$ be a surjective \'etale morphism from a scheme towards $Y$. Then the composition $V \to X$ is surjective \'etale as well and by Lemma \ref{lemma-pullback-quasi-coherent} the pullback of $\mathcal{F}$ to $V$ is quasi-coherent as well. Hence we see that (2) implies (3). \medskip\noindent Let $U \to X$ be as in (3). Let us use the abuse of notation introduced in Equation (\ref{equation-restrict-modules}). As $\mathcal{F}|_{U_\etale}$ is quasi-coherent there exists an \'etale covering $\{U_i \to U\}$ such that $\mathcal{F}|_{U_{i, \etale}}$ has a global presentation, see Modules on Sites, Definition \ref{sites-modules-definition-global} and Lemma \ref{sites-modules-lemma-local-final-object}. Let $V \to X$ be an object of $X_\etale$. Since $U \to X$ is surjective and \'etale, the family of maps $\{U_i \times_X V \to V\}$ is an \'etale covering of $V$. Via the morphisms $U_i \times_X V \to U_i$ we can restrict the global presentations of $\mathcal{F}|_{U_{i, \etale}}$ to get a global presentation of $\mathcal{F}|_{(U_i \times_X V)_\etale}$ Hence the sheaf $\mathcal{F}$ on $X_\etale$ satisfies the condition of Modules on Sites, Definition \ref{sites-modules-definition-site-local} and hence is quasi-coherent. \medskip\noindent The equivalence of (3) and (4) comes from the fact that any scheme has an affine open covering.
Note that we have the corresponding result for quasi-coherent modules on schemes, see Schemes, Section \ref{schemes-section-quasi-coherent}. We will reduce the lemma to this case by \'etale localization. Choose a scheme $U$ and a surjective \'etale morphism $\varphi : U \to X$. In order to formulate this proof correctly, we temporarily go back to making the (pedantic) distinction between a quasi-coherent sheaf $\mathcal{G}$ on the scheme $U$ and the associated quasi-coherent sheaf $\mathcal{G}^a$ (see Descent, Definition \ref{descent-definition-structure-sheaf}) on $U_\etale$ We have a commutative diagram $$ \xymatrix{ \QCoh(\mathcal{O}_X) \ar[r] \ar[d] & \QCoh(\mathcal{O}_U) \ar[d] \\ \textit{Mod}(\mathcal{O}_X) \ar[r] & \textit{Mod}(\mathcal{O}_U) } $$ The bottom horizontal arrow is the restriction functor (\ref{equation-restrict-modules}) $\mathcal{G} \mapsto \mathcal{G}|_{U_\etale}$. This functor has both a left adjoint and a right adjoint, see Modules on Sites, Section \ref{sites-modules-section-localize}, hence commutes with all limits and colimits. Moreover, we know that an object of $\textit{Mod}(\mathcal{O}_X)$ is in $\QCoh(\mathcal{O}_X)$ if and only if its restriction to $U$ is in $\QCoh(\mathcal{O}_U)$, see Lemma \ref{lemma-characterize-quasi-coherent}. Let $\mathcal{F}_i$ be a family of quasi-coherent $\mathcal{O}_X$-modules. Then $\bigoplus \mathcal{F}_i$ is an $\mathcal{O}_X$-module whose restriction to $U$ is the direct sum of the restrictions. Let $\mathcal{G}_i$ be a quasi-coherent sheaf on $U$ with $\mathcal{F}_i|_{U_\etale} = \mathcal{G}_i^a$. Combining the above with Descent, Lemma \ref{descent-lemma-equivalence-quasi-coherent-limits} we see that $$ \Big(\bigoplus \mathcal{F}_i\Big)|_{U_\etale} = \bigoplus \mathcal{F}_i|_{U_\etale} = \bigoplus \mathcal{G}_i^a = \Big(\bigoplus \mathcal{G}_i\Big)^a $$ hence $\bigoplus \mathcal{F}_i$ is quasi-coherent and (1) follows. The other statements are proved just so (using the same references).
Let $U \to X$ be as in (1) and let $V \to X$ be \'etale where $V$ is a scheme. Then $\{U \times_X V \to V\}$ is an fppf covering of schemes. Hence if $\mathcal{F}|_U$ is locally projective, then $\mathcal{F}|_{U \times_X V}$ is locally projective (see Properties, Lemma \ref{properties-lemma-locally-projective-pullback}) and hence $\mathcal{F}|_V$ is locally projective, see Descent, Lemma \ref{descent-lemma-locally-projective-descends}.
Choose a surjective \'etale morphism $V \to Y$ with $V$ a scheme. Choose a surjective \'etale morphism $U \to V \times_Y X$ with $U$ a scheme. Denote $\psi : U \to V$ the induced morphism. Then $$ f^*\mathcal{G}|_U = \psi^*(\mathcal{G}|_V) $$ Hence the lemma follows from the definition and the result in the case of schemes, see Properties, Lemma \ref{properties-lemma-locally-projective-pullback}.
We construct the inverse of the map. Let $\varphi : \Gamma(T, \mathcal{O}_T) \to \Gamma(X, \mathcal{O}_X)$ be a ring map. Choose a presentation $X = U/R$, see Spaces, Definition \ref{spaces-definition-presentation}. By Schemes, Lemma \ref{schemes-lemma-morphism-into-affine} the composition $$ \Gamma(T, \mathcal{O}_T) \to \Gamma(X, \mathcal{O}_X) \to \Gamma(U, \mathcal{O}_U) $$ corresponds to a unique morphism of schemes $g : U \to T$. By the same lemma the two compositions $R \to U \to T$ are equal. Hence we obtain a morphism $f : X = U/R \to T$ such that $U \to X \to T$ equals $g$. By construction the diagram $$ \xymatrix{ \Gamma(U, \mathcal{O}_U) & \Gamma(X, \mathcal{O}_X) \ar[l]^{f^\sharp} \\ & \Gamma(T, \mathcal{O}_T) \ar[lu]^{g^\sharp} \ar[u]^\varphi } $$ commutes. Hence $f^\sharp$ equals $\varphi$ because $U \to X$ is an \'etale covering and $\mathcal{O}_X$ is a sheaf on $X_\etale$. The uniqueness of $f$ follows from the uniqueness of $g$.
The statement means that the sheaf $F$ associated to the presheaf $$ T \longmapsto X(T)/G $$ is an algebraic space. To see this we will construct a presentation. Namely, choose a scheme $U$ and a surjective \'etale morphism $\varphi : U \to X$. Set $V = \coprod_{g \in G} U$ and set $\psi : V \to X$ equal to $a(g) \circ \varphi$ on the component corresponding to $g \in G$. Let $G$ act on $V$ by permuting the components, i.e., $g_0 \in G$ maps the component corresponding to $g$ to the component corresponding to $g_0g$ via the identity morphism of $U$. Then $\psi$ is a $G$-equivariant morphism, i.e., we reduce to the case dealt with in the next paragraph. \medskip\noindent Assume that there exists a $G$-action on $U$ and that $U \to X$ is surjective, \'etale and $G$-equivariant. In this case there is an induced action of $G$ on $R = U \times_X U$ compatible with the projection mappings $t, s : R \to U$. Now we claim that $$ X/G = U/\coprod\nolimits_{g \in G} R $$ where the map $$ j : \coprod\nolimits_{g \in G} R \longrightarrow U \times_S U $$ is given by $(r, g) \mapsto (t(r), g(s(r)))$. Note that $j$ is a monomorphism: If $(t(r), g(s(r))) = (t(r'), g'(s(r')))$, then $t(r) = t(r')$, hence $r$ and $r'$ have the same image in $X$ under both $s$ and $t$, hence $g = g'$ (as $G$ acts freely on $X$), hence $s(r) = s(r')$, hence $r = r'$ (as $R$ is an equivalence relation on $U$). Moreover $j$ is an equivalence relation (details omitted). Both projections $\coprod\nolimits_{g \in G} R \to U$ are \'etale, as $s$ and $t$ are \'etale. Thus $j$ is an \'etale equivalence relation and $U/\coprod\nolimits_{g \in G} R$ is an algebraic space by Spaces, Theorem \ref{spaces-theorem-presentation}. There is a map $$ U/\coprod\nolimits_{g \in G} R \longrightarrow X/G $$ induced by the map $U \to X$. We omit the proof that it is an isomorphism of sheaves.
The question is local on $X$ by Lemma \ref{lemma-subscheme}. Thus by Lemma \ref{lemma-quasi-separated-quasi-compact-pieces} we may assume that there exists an affine scheme $U$ and a surjective, quasi-compact, \'etale morphism $U \to X$. Moreover $U \to X$ is separated (Lemma \ref{lemma-separated-cover}). Set $R = U \times_X U$ and denote $s, t : R \to U$ the projections as usual. Then $s, t$ are surjective, quasi-compact, separated, and \'etale. Hence $s, t$ are also quasi-finite and have finite fibres (Morphisms, Lemmas \ref{morphisms-lemma-etale-locally-quasi-finite}, \ref{morphisms-lemma-quasi-finite-locally-quasi-compact}, and \ref{morphisms-lemma-quasi-finite}). By Morphisms, Lemma \ref{morphisms-lemma-generically-finite} for every $\eta \in U$ which is the generic point of an irreducible component of $U$, there exists an open neighbourhood $V \subset U$ of $\eta$ such that $s^{-1}(V) \to V$ is finite. By Descent, Lemma \ref{descent-lemma-descending-property-finite} being finite is fpqc (and in particular \'etale) local on the target. Hence we may apply More on Groupoids, Lemma \ref{more-groupoids-lemma-property-invariant} which says that the largest open $W \subset U$ over which $s$ is finite is $R$-invariant. By the above $W$ contains every generic point of an irreducible component of $U$. The restriction $R_W$ of $R$ to $W$ equals $R_W = s^{-1}(W) = t^{-1}(W)$ (see Groupoids, Definition \ref{groupoids-definition-invariant-open} and discussion following it). By construction $s_W, t_W : R_W \to W$ are finite \'etale. Consider the open subspace $X' = W/R_W \subset X$ (see Spaces, Lemma \ref{spaces-lemma-finding-opens}). By construction the inclusion map $X' \to X$ induces a bijection on points of codimension $0$. This reduces us to Lemma \ref{lemma-quasi-separated-finite-etale-cover-dense-open-scheme}.
By assumption (3) and Groupoids, Lemma \ref{groupoids-lemma-find-invariant-affine} we can find an open covering $U = \bigcup U_i$ such that each $U_i$ is an $R$-invariant affine open of $U$. Set $R_i = R|_{U_i}$. Consider the fppf sheaves $F = U/R$ and $F_i = U_i/R_i$. By Spaces, Lemma \ref{spaces-lemma-finding-opens} the morphisms $F_i \to F$ are representable and open immersions. By Groupoids, Proposition \ref{groupoids-proposition-finite-flat-equivalence} the sheaves $F_i$ are representable by affine schemes. If $T$ is a scheme and $T \to F$ is a morphism, then $V_i = F_i \times_F T$ is open in $T$ and we claim that $T = \bigcup V_i$. Namely, fppf locally on $T$ we can lift $T \to F$ to a morphism $f : T \to U$ and in that case $f^{-1}(U_i) \subset V_i$. Hence we conclude that $F$ is representable by a scheme, see Schemes, Lemma \ref{schemes-lemma-glue-functors}.
In the statement of the proposition, and in this proof we think of a quasi-coherent sheaf on a scheme as a quasi-coherent sheaf on the small \'etale site of that scheme. This is permissible by the results of Descent, Section \ref{descent-section-quasi-coherent-sheaves}. \medskip\noindent The existence of $\alpha$ comes from the fact that $\varphi \circ t = \varphi \circ s$ and that pullback is functorial in the morphism, see discussion surrounding Equation (\ref{equation-push-pull}). In exactly the same way, i.e., by functoriality of pullback, we see that the isomorphism $\alpha$ satisfies condition (1) of Groupoids, Definition \ref{groupoids-definition-groupoid-module}. To see condition (2) of the definition it suffices to see that $\alpha$ is an isomorphism which is clear. The construction $\mathcal{F} \mapsto (\varphi^*\mathcal{F}, \alpha)$ is clearly functorial in the quasi-coherent sheaf $\mathcal{F}$. Hence we obtain the functor from left to right in the displayed formula of the lemma. \medskip\noindent Conversely, suppose that $(\mathcal{F}, \alpha)$ is a quasi-coherent sheaf on $(U, R, s, t, c)$. Let $V \to X$ be an object of $X_\etale$. In this case the morphism $V' = U \times_X V \to V$ is a surjective \'etale morphism of schemes, and hence $\{V' \to V\}$ is an \'etale covering of $V$. Moreover, the quasi-coherent sheaf $\mathcal{F}$ pulls back to a quasi-coherent sheaf $\mathcal{F}'$ on $V'$. Since $R = U \times_X U$ with $t = \text{pr}_0$ and $s = \text{pr}_0$ we see that $V' \times_V V' = R \times_X V$ with projection maps $V' \times_V V' \to V'$ equal to the pullbacks of $t$ and $s$. Hence $\alpha$ pulls back to an isomorphism $\alpha' : \text{pr}_0^*\mathcal{F}' \to \text{pr}_1^*\mathcal{F}'$, and the pair $(\mathcal{F}', \alpha')$ is a descend datum for quasi-coherent sheaves with respect to $\{V' \to V\}$. By Descent, Proposition \ref{descent-proposition-fpqc-descent-quasi-coherent} this descent datum is effective, and we obtain a quasi-coherent $\mathcal{O}_V$-module $\mathcal{F}_V$ on $V_\etale$. To see that this gives a quasi-coherent sheaf on $X_\etale$ we have to show (by Lemma \ref{lemma-characterize-quasi-coherent-small-etale}) that for any morphism $f : V_1 \to V_2$ in $X_\etale$ there is a canonical isomorphism $c_f : \mathcal{F}_{V_1} \to \mathcal{F}_{V_2}$ compatible with compositions of morphisms. We omit the verification. We also omit the verification that this defines a functor from the category on the right to the category on the left which is inverse to the functor described above.
This proof is a repeat of the proof in the case of schemes, see Properties, Proposition \ref{properties-proposition-coherator}. We advise the reader to read that proof first. \medskip\noindent Part (1) means $\QCoh(\mathcal{O}_X)$ (a) has all colimits, (b) filtered colimits are exact, and (c) has a generator, see Injectives, Section \ref{injectives-section-grothendieck-conditions}. By Lemma \ref{lemma-properties-quasi-coherent} colimits in $\QCoh(\mathcal{O}_X)$ exist and agree with colimits in $\textit{Mod}(\mathcal{O}_X)$. By Modules on Sites, Lemma \ref{sites-modules-lemma-limits-colimits} filtered colimits are exact. Hence (a) and (b) hold. \medskip\noindent To construct a generator, choose a presentation $X = U/R$ so that $(U, R, s, t, c)$ is an \'etale groupoid scheme and in particular $s$ and $t$ are flat morphisms of schemes. Pick a cardinal $\kappa$ as in Groupoids, Lemma \ref{groupoids-lemma-colimit-kappa}. Pick a collection $(\mathcal{E}_t, \alpha_t)_{t \in T}$ of $\kappa$-generated quasi-coherent modules on $(U, R, s, t, c)$ as in Groupoids, Lemma \ref{groupoids-lemma-set-of-iso-classes}. Let $\mathcal{F}_t$ be the quasi-coherent module on $X$ which corresponds to the quasi-coherent module $(\mathcal{E}_t, \alpha_t)$ via the equivalence of categories of Proposition \ref{proposition-quasi-coherent}. Then we see that every quasi-coherent module $\mathcal{H}$ is the directed colimit of its quasi-coherent submodules which are isomorphic to one of the $\mathcal{F}_t$. Thus $\bigoplus_t \mathcal{F}_t$ is a generator of $\QCoh(\mathcal{O}_X)$ and we conclude that (c) holds. The assertions on limits and injectives hold in any Grothendieck abelian category, see Injectives, Theorem \ref{injectives-theorem-injective-embedding-grothendieck} and Lemma \ref{injectives-lemma-grothendieck-products}. \medskip\noindent Proof of (2). To construct $Q$ we use the following general procedure. Given an object $\mathcal{F}$ of $\textit{Mod}(\mathcal{O}_X)$ we consider the functor $$ \QCoh(\mathcal{O}_X)^{opp} \longrightarrow \textit{Sets},\quad \mathcal{G} \longmapsto \Hom_X(\mathcal{G}, \mathcal{F}) $$ This functor transforms colimits into limits, hence is representable, see Injectives, Lemma \ref{injectives-lemma-grothendieck-brown}. Thus there exists a quasi-coherent sheaf $Q(\mathcal{F})$ and a functorial isomorphism $\Hom_X(\mathcal{G}, \mathcal{F}) = \Hom_X(\mathcal{G}, Q(\mathcal{F}))$ for $\mathcal{G}$ in $\QCoh(\mathcal{O}_X)$. By the Yoneda lemma (Categories, Lemma \ref{categories-lemma-yoneda}) the construction $\mathcal{F} \leadsto Q(\mathcal{F})$ is functorial in $\mathcal{F}$. By construction $Q$ is a right adjoint to the inclusion functor. The fact that $Q(\mathcal{F}) \to \mathcal{F}$ is an isomorphism when $\mathcal{F}$ is quasi-coherent is a formal consequence of the fact that the inclusion functor $\QCoh(\mathcal{O}_X) \to \textit{Mod}(\mathcal{O}_X)$ is fully faithful.
Let us change the Koszul complex $K_\bullet(f_1, \ldots, f_r)$ into a cochain complex $K^\bullet$ by setting $K^n = K_{-n}(f_1, \ldots, f_r)$. Then $K^\bullet$ is sitting in degrees $-r, \ldots, 0$ and $H^i(K^\bullet \otimes_A M) = H_{-i}(K_\bullet(f_1, \ldots, f_r) \otimes_A M)$. The statement of the theorem makes sense as the modules $H^i(K^\bullet \otimes M)$ are annihilated by $f_1, \ldots, f_r$ (More on Algebra, Lemma \ref{more-algebra-lemma-homotopy-koszul}) hence have finite length. Define a filtration on the complex $K^\bullet$ by setting $$ F^p(K^n \otimes_A M) = I^{\max(0, p + n)}(K^n \otimes_A M),\quad p \in \mathbf{Z} $$ Since $f_i I^p \subset I^{p + 1}$ this is a filtration by subcomplexes. Thus we have a filtered complex and we obtain a spectral sequence, see Homology, Section \ref{homology-section-filtered-complex}. We have $$ E_0 = \bigoplus\nolimits_{p, q} E_0^{p, q} = \bigoplus\nolimits_{p, q} \text{gr}^p(K^{p + q} \otimes_A M) = \text{Gr}_I(K^\bullet \otimes_A M) $$ Since $K^n$ is finite free we have $$ \text{Gr}_I(K^\bullet \otimes_A M) = \text{Gr}_I(K^\bullet) \otimes_{\text{Gr}_I(A)} \text{Gr}_I(M) $$ Note that $\text{Gr}_I(K^\bullet)$ is the Koszul complex over $\text{Gr}_I(A)$ on the elements $\overline{f}_1, \ldots, \overline{f}_r \in I/I^2$. A simple calculation (omitted) shows that the differential $d_0$ on $E_0$ agrees with the differential coming from the Koszul complex. Since $\text{Gr}_I(M)$ is a finite $\text{Gr}_I(A)$-module and since $\text{Gr}_I(A)$ is Noetherian (as a quotient of $A/I[x_1, \ldots, x_r]$ with $x_i \mapsto \overline{f}_i$), the cohomology module $E_1 = \bigoplus E_1^{p, q}$ is a finite $\text{Gr}_I(A)$-module. However, as above $E_1$ is annihilated by $\overline{f}_1, \ldots, \overline{f}_r$. We conclude $E_1$ has finite length. In particular we find that $\text{Gr}^p_F(K^\bullet \otimes M)$ is acyclic for $p \gg 0$. \medskip\noindent Next, we check that the spectral sequence above converges using Homology, Lemma \ref{homology-lemma-filtered-complex-ss-converges}. The required equalities follow easily from the Artin-Rees lemma in the form stated in Algebra, Lemma \ref{algebra-lemma-map-AR}. Thus we see that \begin{align*} \sum (-1)^i\text{length}_A(H^i(K^\bullet \otimes_A M)) & = \sum (-1)^{p + q} \text{length}_A(E_\infty^{p, q}) \\ & = \sum (-1)^{p + q} \text{length}_A(E_1^{p, q}) \end{align*} because as we've seen above the length of $E_1$ is finite (of course this uses additivity of lengths). Pick $t$ so large that $\text{Gr}^p_F(K^\bullet \otimes M)$ is acyclic for $p \geq t$ (see above). Using additivity again we see that $$ \sum (-1)^{p + q} \text{length}_A(E_1^{p, q}) = \sum\nolimits_n \sum\nolimits_{p \leq t} (-1)^n \text{length}_A(\text{gr}^p(K^n \otimes_A M)) $$ This is equal to $$ \sum\nolimits_{n = -r, \ldots, 0} (-1)^n{r \choose |n|} \chi_{I, M}(t + n) $$ by our choice of filtration above and the definition of $\chi_{I, M}$ in Algebra, Section \ref{algebra-section-Noetherian-local}. The lemma follows from Lemma \ref{lemma-leading-coefficient} and the definition of $e_I(M, r)$.
The first assertion follows from Chow Homology, Lemma \ref{chow-lemma-rational-function}. More precisely, let $W' \subset X \times \mathbf{P}^1$ be the closure of the graph of $f$. Then $\text{div}_W(f) = [W'_0]_k - [W'_\infty]$ in $Z_k(W) \subset Z_k(X)$, see part (6) of Chow Homology, Lemma \ref{chow-lemma-rational-function}. \medskip\noindent For the second, let $W' \subset X \times \mathbf{P}^1$ be a closed subvariety of dimension $k + 1$ which dominates $\mathbf{P}^1$. We will show that $[W'_0]_k - [W'_\infty]_k$ is a principal divisor which will finish the proof. Let $W \subset X$ be the image of $W'$ under the projection to $X$. Then $W' \to W$ is proper and generically finite\footnote{If $W' \to W$ is birational, then the result follows from Chow Homology, Lemma \ref{chow-lemma-rational-function}. Our task is to show that even if $W' \to W$ has degree $> 1$ the basic rational equivalence $[W'_0]_k \sim_{rat} [W'_\infty]_k$ comes from a principal divisor on a subvariety of $X$.}. Let $f$ denote the projection $W' \to \mathbf{P}^1$ viewed as an element of $\mathbf{C}(W')^*$. Let $g = \text{Nm}(f) \in \mathbf{C}(W)^*$ be the norm. By Chow Homology, Lemma \ref{chow-lemma-proper-pushforward-alteration} we have $$ \text{div}_W(g) = \text{pr}_{X, *}\text{div}_{W'}(f) $$ Since $\text{div}_{W'}(f) = [W'_0]_k - [W'_\infty]_k$  by Chow Homology, Lemma \ref{chow-lemma-rational-function} the proof is complete.
Proof of (1). We may work locally, hence we may assume that $Y = \Spec(A)$ and $X = V(f_1, \ldots, f_c)$ where $f_1, \ldots, f_c$ is a regular sequence in $A$. If $Z = \Spec(A/\mathfrak p)$, then we see that $f^{-1}(Z) = \Spec(A/\mathfrak p + (f_1, \ldots, f_c))$. If $V$ is an irreducible component of $f^{-1}(Z)$, then we can choose a closed point $v \in V$ not contained in any other irreducible component of $f^{-1}(Z)$. Then $$ \dim(Z) = \dim \mathcal{O}_{Z, v} \quad\text{and}\quad \dim(V) = \dim \mathcal{O}_{V, v} = \dim \mathcal{O}_{Z, v}/(f_1, \ldots, f_c) $$ The first equality for example by Algebra, Lemma \ref{algebra-lemma-dimension-prime-polynomial-ring} and the second equality by our choice of closed point. The result now follows from the fact that dividing by one element in the maximal ideal decreases the dimension by at most $1$, see Algebra, Lemma \ref{algebra-lemma-one-equation}. \medskip\noindent Proof of (2). Choose a factorization as in the definition of a local complete intersection and apply (1). Some details omitted.