Apologies for the vagueness of question.


**Background**


[this thread](https://mathoverflow.net/a/45218/74739) has some nice examples of presheaves failing to be sheaves.


**Question**


Is there a generic way to measure "how badly" a presheaf fails at being a sheaf?


Something like an invariant that "counts", up to some notion of equivalence, sections that fail to glue or restrict properly?


**Discussion**


Can we do this by comparing some invariant of a presheaf $P$ and its sheafification $\tilde P$? The comments on [this old math SE thread](https://math.stackexchange.com/questions/803551/%C4%8Cech-cohomology-with-values-in-a-presheaf) makes an attempt to argue that the Cech cohomology (taking the cover refinement limit) of the two are equal. But is there something else that we can compare between $P$ and $\tilde P$?



Measuring a presheaf's failure to be a sheaf?
This answer is inspired by the Embedding Calculus (aka Manifold Calculus) of Weiss and Goodwillie. This is a framework for studying certain presheaves on manifolds. The idea is that sheafification of a presheaf is analogous to the linearization of a function. From this point of view, sheafification is just the first in a sequence of approximation - for each $n$ there is the universal approximation of degree $n$. What I am doing below is describe the difference between the quadratic and the linear approximation, which one may think of as the principal part of the difference between a presheaf and its sheafification. I am not sure if this approach is useful in the context of algebraic geometry, or for the applications that you have in mind. But let me put it out here, FWIIW.


Let ${\mathcal F}$ be a presheaf on $X$. Suppose $x$ and $y$ are two points in $X$ that can be separated by disjoint open sets. Let us define the "bi-stalk" of $\mathcal F$ at $(x,y)$ as ${\mathcal F}\_{(x,y)}=$colim$\_{U,V} \mathcal F(U\cup V)$, where $(U, V)$ range over pairs of disjoint neighborhoods of $x$ and $y$. There is a natural homomorphism from the bi-stalk to the product of stalks ${\mathcal F}\_{(x,y)}\to {\mathcal F}\_{x}\times {\mathcal F}\_{y}$. If $\mathcal F$ is a sheaf then this homomorphism is an isomorphism. So you have a homomorphism for each such pair that measures the failure of $\mathcal F$ to be a sheaf. 


Here is a perhaps slightly more sophisticated version of this idea. We can use $\mathcal F$ to define some new presheaves on $X\times X$. We will define them on basic sets of the form $U\times V$. There is an evident diagram of presheaves


$$\begin{array}{ccc}
{\mathcal F}(U \cup V) & \to & {\mathcal F}(U)\\
\downarrow & & \downarrow \\
{\mathcal F}(V) & \to & {\mathcal F}(U\cap V)
\end{array}$$


If $\mathcal F$ is a sheaf then this is a pullback square for every $U, V$. Define $\mathcal F\_2$ to be the  ~~total homotopy fiber of this square~~ homotopy fiber of the homomorphism from the initial corner to the pullback of the rest. We may want to think of $\mathcal F\_2$ as a presheaf of chain complexes on $X\times X$. The cohomology of the associated sheaf is an invariant that measures the deviation of $\mathcal F$ from being a sheaf (roughly speaking - see next paragraph). If this invariant vanishes, one can construct similar invariants of higher order by looking at higher "cross-effects" of $\mathcal F$.


In fact, the restriction of $\mathcal F\_2$ to the diagonal is trivial, we really want to consider cohomology relative to the diagonal. Also, there is a $\Sigma\_2$ symmetry to this set-up, and we probably want to consider equivariant cohomology.


