Relation between flatness and integrability of an algebraic connection Long time listener, first time caller!
Suppose that I have a locally free sheaf $\mathcal{E}$ on an smooth algebraic variety $X/k$. Let $\Delta^{(1)}\subset X\times X$ denote the first-order neighbourhood of the diagonal, with projection maps $p_1,p_2:\Delta^{(1)}\to X$. Then there are a few different ways one can describe a connection on $\mathcal{E}$:

*

*As a $k$-linear map $D:\mathcal{E}\to\mathcal{E}\otimes\Omega^1_X$ that satisfies the Leibniz rule.


*As an $\mathcal{O}_X$-linear splitting $s$ of the first jet bundle exact sequence $0 \to \mathcal{E}\otimes\Omega^1_X \to J^1(\mathcal{E})\to \mathcal{E}\to 0$. (Recall that $J^1(\mathcal{E}) = p_{1\ast}p_2^\ast\mathcal{E}$.)


*As an isomorphism $\phi:p_1^\ast\mathcal{E}\simeq p_2^\ast\mathcal{E}$ which restricts to the identity map on the diagonal $\Delta\subset X\times X$.
Passing between these different descriptions of a connection is fairly straightforward: given $D$ one obtains a splitting $s$ by taking $s = D+ j^1$ where $j^1$ is the $k$-linear "jet prolongation" splitting of the jet bundle exact sequence; given a splitting $s$ one obtains an isomorphism $\phi$ by pulling back along $p_1$ and applying the counit of the $(p_1^\ast,p_{1\ast})$ adjunction. So far, so good.
Now, there are various types of "integrability" conditions one might be interested in for a connection:

*

*Flatness: The connection is flat if the curvature $F(D)\in\Omega_X^2(End(\mathcal{E}))$ vanishes.

*Integrability: Let $\Delta^{(1)}_3\subset X\times X\times X$ be the first order neighbourhood of the small diagonal with projections $q_1,q_2,q_3$, and let $\phi_{ij}:q_i^\ast\mathcal{E}\simeq q_j^\ast\mathcal{E}$ be the isomorphisms induced by $\phi$. Then the connection is integrable if it satisfies the cocycle condition $\phi_{23}\circ\phi_{12} = \phi_{13}$.

*Formal lifting: The connection can be lifted to as isomorphism $p_1^\ast\mathcal{E}\simeq p_2^\ast\mathcal{E}$ on every finite order neighbourhood of the diagonal $\Delta^{(n)}$.

My question is as follows: What is the relation between these three integrability conditions?

*

*I believe I was once told that integrability $\Rightarrow$ formal lifting in characteristic zero, although I've never seen a proof (and have thus far failed to cook one up myself).

*I naively thought that there would be a straightforward relation between flatness and integrability, but if my calculations are correct the connection $D=d_{dR} + t^1dt^2$ on $\mathbb{A}_k^2$ provides a simple example of an integrable nonflat connection. (Of course, my calculations could always be wrong!)

*The curvature of a connection lies in $\Omega_X^2(End(\mathcal{E}))$, while the obstruction to lifting from the first- to second-order neighbourhood of the diagonal lives in $H^1(X;\text{Sym}^2(\Omega_X^1)\otimes\mathcal{E}nd(\mathcal{E}))$ (to get the obstruction to lifting from $\Delta^{(n)}$ to $\Delta^{(n+1)}$ replace $\text{Sym}^2$ with $\text{Sym}^{n+1}$). Should I take this as a hint that flatness and formal lifting are unrelated, or is there some sort of relation between the curvature and this lifting obstruction?


Edited to add:
Since it isn't explicit in the answer below or the comments that follow: the correct relation here is that for $X$ smooth and in characteristic zero, flatness is equivalent to formal lifting together with the cocycle condition.
 A: (In characteristic zero) Flatness implies the other two definitions; integrability and formal lifting are very weak conditions (in fact if I haven't made a mistake I think this notion of integrability is automatic. As such it seems like a weird definition to me; I usually use the words "integrable" and "flat" as synonyms.)
First of all, let me rephrase the notion of flatness a few times. Take $X$ affine for simplicity (to do the general case turn everything into a sheaf, with a little bit of care). Let $\mathcal{D}_X$ be the ring of differential operators on $X$. It can be presented as the universal envelopping algebroid (over $\mathcal{O}_X$) of the Lie algebroid $T_X$ of vector fields. Concretely, this means giving a $\mathcal{D}_X$-module $M$ is equivalent to giving a $k$-linear map $T_X\otimes M\rightarrow M,$ so that for two vector fields $v_1,v_2$ and $m\in M$, we have $v_1\cdot(v_2\cdot m)-v_2\cdot(v_1\cdot m)=[v_1,v_2]\cdot m,$ where $\cdot$ denotes the action of $T_X$ on $M$.
I claim that, if $M=\mathcal{E}$, this is exactly the data of a flat connection on $\mathcal{E}$. The map $T_X\otimes M\rightarrow M$ is equivalent to a map $M\rightarrow M\otimes\Omega^1_X$, aka the map defining our connection. The expression
$$v_1\cdot(v_2\cdot m)-v_2\cdot(v_1\cdot m)-[v_1,v_2]\cdot m$$
defines a map $T_X\otimes T_X\otimes M\rightarrow M$. It can be checked that this map is $\mathcal{O}_X$-multilinear and antisymmetric on the first two , so it actually lies in
$$\operatorname{Hom}_{\mathcal{O}_X}(\Lambda^2T_X\underset{{\mathcal{O}_X}}{\otimes}M,M)\cong\Omega^2_X(\operatorname{End}(M))$$
and you can check that this is the curvature of your connection. So the connection is flat exactly when this gives a $\mathcal{D}_X$-module structure.
Let $\hat{\Delta}$ and $\hat{\Delta}_3$ be the formal neighborhoods of $\Delta\subseteq X\times X$ and $\Delta_3\subseteq X\times X\times X$. Then a map $\mathcal{D}_X\underset{\mathcal{O}_X}{\otimes}M\rightarrow M$ is equivalent to the data of an isomorphism $\hat{\phi}:\hat{p}_1^*M\cong\hat{p}_2^*M$ over $\hat{\Delta}$. The action of $\mathcal{D}_X$ on $M$ is compatible with the algebra structure on $\mathcal{D}_X$ if and only if $\hat{\phi}$ satisfies a cocycle condition. In particular we see that flatness implies your other conditions.
To prove these statements, the key is the following. A map $\hat{p}_1^*M\rightarrow\hat{p}_2^*M$ is equivalent to a map $M\rightarrow\hat{p}_{1*}\hat{p}_2^*M\cong\mathcal{O}_{\hat{\Delta}}\otimes_{\mathcal{O}_X}M.$ (Note here that we have a left and a right $\mathcal{O}_X$ action on $\mathcal{O}_\hat{\Delta}$. The right one is absorbed into the tensor product, while the left one defines the $\mathcal{O}_X$-module structure on $\mathcal{O}_{\hat{\Delta}}\otimes_{\mathcal{O}_X}M$.) Furthermore, convolution defines a coalgebra structure on $\mathcal{O}_{\hat{\Delta}}.$ If one dualizes this coalgebra, one gets exactly $\mathcal{D}_X$, and you can use this to prove the above interpretation of $\mathcal{D}$-modules. (This is a little painful and has a number of details that need to be checked, so I am avoiding doing it...)
Now let me explain why the other conditions are very weak. For formal lifting, as you note, the obstruction lives in $H^1$, so it automatically vanishes if $X$ is affine. I believe it can be a nontrivial condition when $X$ is not affine.
On the other hand, here is an argument that all connections are integrable in your sense. We would like to check that the map $\phi_{31}\circ\phi_{23}\circ\phi_{12}$ is the identity over $\Delta_3^{(1)}$. This is true on the diagonal. It is also true on the image of any of the three natural embeddings of $\Delta^{(1)}\rightarrow\Delta_3^{(1)}$. I claim this is sufficient to see that it is the identity over all of $\Delta_3^{(1)}$.
Let $N_{123}$ be the normal bundle of $\Delta_3$ inside $X\times X\times X$. We let $N_{12}$ be the subbundle given by the normal vectors inside $\Delta\times X$. Define $N_{13}$ and $N_{23}$ similarly.
An endomorphism of the pullback of $\mathcal{E}$ over $\Delta_3^{(1)}$ which restricts to the identity on $\Delta_3$ can be identified with a map $N_{123}\otimes\mathcal{E}\rightarrow\mathcal{E}$, and the original endomorphism is the identity if and only if this resulting map is zero. So we see that the maps $N_{ij}\otimes\mathcal{E}\rightarrow\mathcal{E}$ must be trivial. As the map $N_{12}\oplus N_{23}\oplus N_{31}\rightarrow N_{123}$ is surjective, this implies that $N_{123}\otimes\mathcal{E}\rightarrow\mathcal{E}$ is trivial, as desired.
