For which morphisms of schemes $f : X\rightarrow Y$ do we have $f^{-1}\mathcal{O}\_Y = \mathcal{O}\_X$? (note that I don't mean $f^\*$, I really just mean the basic inverse image sheaf as a sheaf of rings/abelian groups/sets)


This is obviously true if $f$ is an open immersion, and intuitively I feel like this is the only time when it is true. Is this correct? (If not, is it possible to completely characterize the morphisms $f$ for which this is true?)


I was led to think about this when I read [here](https://stacks.math.columbia.edu/tag/06TU) that for a morphism of stacks $f : \mathcal{X}\rightarrow\mathcal{Y}$ (say over $(\textbf{Sch}/S)\_{et}$, there is a canonical identification $f^{-1}\mathcal{O}\_\mathcal{Y} = \mathcal{O}\_\mathcal{X}$, which I feel is somewhat strange. I suppose this is just a peculiarity of working with big sites?



When is the inverse image of the structure sheaf the structure sheaf?
Here is a trivial lemma.



> 
> **Lemma.** Let $f \colon X \to Y$ be a morphism of schemes. Then the natural map $f^{-1}\mathcal O\_Y \to \mathcal O\_X$ is an isomorphism if and only if for each $x \in X$ the natural map $\mathcal O\_{Y,f(x)} \to \mathcal O\_{X,x}$ is an isomorphism.
> 
> 
> 


*Proof.* A morphism of sheaves on $X$ is an isomorphism if and only if it is so at the stalk of every $x \in X$. The stalk of a sheaf $\mathscr F$ at $\iota \colon \{x\} \to X$ is given by $\iota^{-1}\mathscr F$, so $(f^{-1}\mathcal O\_Y)\_x = \mathcal O\_{Y,f(x)}$ since $\iota^{-1}f^{-1} = (f \circ \iota)^{-1}$. $\square$


Under reasonable finiteness assumptions, this gives a local isomorphism as Simon Henry suggested:



> 
> **Lemma.** Let $f \colon X \to Y$ be a morphism of schemes that is locally of finite presentation. Then $f^{-1}\mathcal O\_Y = \mathcal O\_X$ is and only if for every point $x \in X$, there exists an open neighbourhood $U \subseteq X$ of $x$ and an open neighbourhood $V \subseteq Y$ of $f(x)$ such that $f$ induces an isomorphism $U \stackrel\sim\to V$.
> 
> 
> 


*Proof.* Suppose $f^{-1}\mathcal O\_Y = \mathcal O\_X$, and let $x \in X$. By the lemma above, we get $\mathcal O\_{Y,f(x)} \stackrel\sim\to \mathcal O\_{X,x}$. Let $V \subseteq Y$ be an affine open neighbourhood of $f(x)$ and $U \subseteq f^{-1}(V)$ an affine open neighbourhood of $x$. If $V = \operatorname{Spec} A$ and $U = \operatorname{Spec} B$, then the map $g \colon A \to B$ is of finite presentation ([Tag 01TQ](https://stacks.math.columbia.edu/tag/01TQ)).


Letting $\mathfrak p \subseteq A$ and $\mathfrak q \subseteq B$ be the primes corresponding to $f(x) \in V$ and $x \in U$ respectively, we conclude that $g^{-1}(\mathfrak q) = \mathfrak p$, and the map $A\_\mathfrak p \to B\_\mathfrak q$ is an isomorphism. By [Tag 00QS](https://stacks.math.columbia.edu/tag/00QS), this implies that there exist $a \in A\setminus \mathfrak p$ and $b \in B\setminus \mathfrak q$ such that $A\_a \cong B\_b$.


Replacing $U$ by $D(b)$ and $V$ by $D(a)$ gives open neighbourhoods $U \subseteq X$ of $x$ and $V \subseteq Y$ of $f(x)$ such that $f$ induces an isomorphism $U \stackrel \sim \to V$. The converse is trivial. $\square$


Examples include open immersions, disjoint unions, but also the map from a line with double origin to the line with a single origin.


However, if we drop the finite presentation assumption, we get all sorts of examples:


**Example.** Let $Y$ be any scheme, and consider the map
$$X = \coprod\_{y \in Y} \operatorname{Spec} \mathcal O\_{Y,y} \to Y.$$
For a point $x \in X$ in the component $\operatorname{Spec} \mathcal O\_{Y,y}$, we get an isomorphism $(\mathcal O\_{Y,y})\_x \to \mathcal O\_{Y,f(x)}$, as can be seen easily by passing to an affine open neighbourhood of $y$ in $Y$ and using standard properties of localisation of rings.


