This is a question whose motivation and framing seem to involve a lot of topology, but which I suspect comes down to some simple and standard combinatorics that's probably recorded in a book somewhere. To draw in the nLab people, I'll say that I also considered entitling this "categorifying Mobius inversion".


Let $X$ be a topological space, and let $U\_i$, $i \in I$, be a finite collection of open sets of $X$ such that


* $X = \bigcup U\_i$
* For any two sets $U\_i$ and $U\_j$ in the collection, $U\_i \cap U\_j$ is also in the collection.


Suppose that I know all of the $H^{\ast}(U\_i)$'s, and all of the restriction maps between them, and I would like to compute $H^{\ast}(X)$. 


One way is to compute $H^{\ast}(U\_1)$, then $H^{\ast}(U\_1 \cup U\_2)$, then $H^{\ast}(U\_1 \cup U\_2 \cup U\_3)$, and so forth, successively using Mayer-Vietoris to put in each new set.


I can also do it all in one go, by using the Mayer-Vietoris spectral sequence. Let $J \subseteq I$ be the set of indices $j$ such that $U\_j$ is not contained in any other $U\_i$. As explained [here](https://mathoverflow.net/questions/23175/mathematically-mature-way-to-think-about-mayervietoris/23179#23179), one way to think of this is that we have an exact complex of sheaves. 
$$0 \to \mathbb{Z}(X )\to \bigoplus\_{j \in J} \mathbb{Z}(U\_j) \to \bigoplus\_{j\_1, j\_2 \in J} \mathbb{Z}(U\_{j\_1} \cap U\_{j\_2}) \to \cdots \quad (\ast)$$
(See the comments on that question for issues about whether one should be using the extension by zero or the pushforward; which I'm not sure ever got resolved. I should probably get that right at some point, but it isn't what I want to focus on, so we can switch to covers by closed sets if that will avoid focusing on that point.)


It seems like sometimes one can use knowledge of the relations between the $U$'s to shorten the resolution $(\ast)$. For example, suppose that $U\_1 \cap U\_2 = U\_1 \cap U\_3 = U\_2 \cap U\_3 = U\_4$. Then the complex $(\ast)$ looks like
$$0 \to \mathbb{Z}(X) \to \mathbb{Z}(U\_1) \oplus \mathbb{Z}(U\_2) \oplus \mathbb{Z}(U\_3) \to \mathbb{Z}(U\_4)^{\oplus 3} \to \mathbb{Z}(U\_4) \to 0.$$
But there is a shorter resolution
$$0 \to \mathbb{Z}(X) \to \mathbb{Z}(U\_1) \oplus \mathbb{Z}(U\_2) \oplus \mathbb{Z}(U\_3) \to \mathbb{Z}(U\_4)^{\oplus 2} \to 0. \quad (\ast \ast)$$


Let $I$ be the poset of containment relations between the $U\_i$. (Since the collection $U\_i$ is closed under intersection, $I$ has joins and, if we adjoin an extra minimal element $0$ of $I$, then $I$ is a [lattice](http://en.wikipedia.org/wiki/Lattice_%2528order%2529).) I am looking for a recipe which would look at the poset $I$ and spit out the complex $(\ast \ast)$.


Mobius inversion tells me that the sheaf $\mathbb{Z}(U\_i)$ should be used "$\mu(0,i)$ times", where $\mu$ is the [Mobius function](http://en.wikipedia.org/wiki/Incidence_algebra) and the scare quotes are because using $U\_i$ in an odd cohomological degree counts negatively. For example, the double occurrence of $U\_4$ in $(\ast \ast)$ reflects that $\mu(0,2) = 2$ for this poset. So this is why I say that I want to "categorify Mobius inversion" -- I want to turn that number into a vector space (or collection of vector spaces).


Thanks!



Calculating Mayer-Vietoris efficiently
To be safe, let me assume the cohomologies are taken with coefficients in a field, like $\mathbf{C}$.


Let $I' \subset I$ be the indices for which $U\_i$ is nonempty. The incidence algebra of $I'$ is a finite-dimensional algebra that naturally acts on the vector space of $\mathbf{C}$-valued functions on $I'$. Your "categorified Mobius inversion" amounts to finding the minimal projective resolution of this module.


Let $f:X \to I'$ be the function that carries $x$ to the index of $\bigcap\_{i \in I \mid x \in U\_i} U\_i$. This function is continuous for topology on $I'$ whose open subsets are order ideals. The Mayer-Vietoris spectral sequence for the cover is also the Leray spectral sequence for the map $f$ and the constant sheaf .
$$
E\_2^{st} = H^s(I';R^t f\_\* \mathbf{C}) \implies H^{s+t}(X)
$$


A sheaf on a finite topological space like $I'$ is the same data as a functor out of $I'$ regarded as a poset, and is also the same data as a module over the incidence algebra of $I'$. If $\mathcal{F}$ is a sheaf, the corresponding functor $F$ is given by the formula
$$
F(i) = \Gamma(\text{minimal open neighborhood of $i$};\mathcal{F})
$$
The corresponding module $M$ is the direct sum of all the $F(i)$. Under this correspondence:


1. The sheaves $R^t f\_\* \mathbf{C}$ take the value $H^t(U\_i;\mathbf{C})$ at $i$.
2. Projective modules over finite dimensional algebras have a Krull-Schmidt property. In the case of the incidence algebra the indecomposable projectives are parametrized by $i \in I'$. The projective $P\_{i}$ is given by
$$
P\_i(j) = \begin{cases}
\mathbf{C} & \text{if $j \leq i$} \\
0 & \text{otherwise}
\end{cases}
$$
Homomorphisms out of $P\_i$ compute the value of the functor at $i$.
3. The constant sheaf on $I'$ is the module $\mathbf{C}^{I'}$.


As $H^s(I';-) = \mathrm{Ext}^s(\text{constant sheaf},-)$, a projective resolution of $\mathbf{C}^{I'}$ gives a chain complex computing $H^s(I';-)$ and the $E\_2$ page of the spectral sequence. The theory of finite-dimensional algebras says that there is a unique minimal resolution (it appears as a subquotient of any other projective resolution) of $\mathbf{C}^{I'}$, or of any other finite-dimensional module $M$. One computes it by taking the projective cover of $M$, call it $P\_M \to M$, next taking the projective cover of the kernel of $P\_M \to M$, and so on. 


