Existence of a function on the Euclidean space which differs by constants from locally defined functions Let $\{U_\lambda\}_{\lambda\in\Lambda}$ be an open covering of $\mathbb{R}^n$.
Given a family of functions $f_\lambda:U_\lambda\rightarrow \mathbb{R}\,(\lambda\in\Lambda)$ such that $f_\lambda-f_\mu: U_\lambda\cap U_\mu\rightarrow\mathbb{R}$ is constant for any $\lambda,\mu\in\Lambda$, is there a function $f:\mathbb{R}^n\rightarrow \mathbb{R}$ such that for each $\lambda\in\Lambda$, the function $f-f_\lambda$ is constant on $U_\lambda$?
It seems like that this assertion is true, but I don't have any proof.
 A: This doesn't work if the $U_\lambda$ are not connected, for example we can take $U_1=(-\infty,0)\cup(1,\infty)$, $U_2=(-1,1)$ and $U_3=(0,2)$ and the functions $f_1$ defined by $f_1(x)=x$ if $x<0$ and $x+1$ if $x>0$, and $f_2(x)=f_3(x)=x$.
But if the $U_\lambda$ are connected, it is true. The relationship of this with homology can be seen using homology of small simplices (Hatcher proposition 2.21).
As in Hatcher's book let $C_n(\mathbb{R}^n)$ be the group of $n$-chains in $\mathbb{R}^n$ generated by the singular $n$-simplices. Now we can take the cover $\mathcal{U}=\{U_\lambda\}_\lambda$ and let $C_n^\mathcal{U}(\mathbb{R}^n)$ be the subgroup of $C_n(\mathbb{R}^n)$ generated by simplices which are contained in some element of $\mathcal{U}$.
We can define a homomorphism $\alpha:C_1^\mathcal{U}(\mathbb{R}^n)\to\mathbb{R}$ which assigns to each $1$-simplex $\gamma:[0,1]\to\mathbb{R}^n$ the value $f_\lambda(\gamma(1))-f_\lambda(\gamma(0))$, for some $\lambda$ such that $\gamma([0,1])\subseteq U_\lambda$.
This is well defined and it is $0$ in boundaries (as the $2$-simplices are also contained in some $U_\lambda$), so it gives you a homomorphism $\overline{\alpha}:H_1^\mathcal{U}(\mathbb{R}^n)\to\mathbb{R}$. But by Hatcher proposition 2.21, $H_1^\mathcal{U}(\mathbb{R}^n)\cong H_1(\mathbb{R}^n)=0$, so $\alpha$ is $0$ in cycles.
So you can define your function $f$ by $f(0)=0$, and for any other $x\in\mathbb{R}^n$, $f(x)=\alpha(\gamma)$, where $\gamma$ is a path (sum of small segments) from $0$ to $x$. By the previous paragraph, $f$ is well defined, and $f-f_\lambda$ is constant because for $x,y\in U_\lambda$, we can take a sequence of segments $[x_0,x_1],[x_1,x_2],\dots,[x_{n-1},x_n]$ contained in $U_\lambda$ going from $x=x_0$ to $y=x_n$, so that $f_\lambda(y)-f_\lambda(x)=\sum_{i=1}^n(f_\lambda(x_i)-f_\lambda(x_{i-1}))$, which also coincides with $f(y)-f(x)$.
A: Yes. It is easy to show that there is such a function $f$ when each $f_U$ is smooth.
Observation: Suppose that $(f_U)_{U\in\mathcal{U}}$ is a system of smooth mappings
$f_U:U\rightarrow\mathbb{R}$ and where $f_U-f_V$ is locally constant on $U\cap V$ whenever $U,V\in\mathcal{U}$. Then there is some smooth $f:\mathbb{R}^n\rightarrow\mathbb{R}$ where $f|_U-f_U$ is locally constant for each $U\in\mathcal{U}$.
Proof: The system of 1-forms $(df_U)_{U\in\mathcal{U}}$ is coherent in the sense that $df_U=df_V$ on $U\cap V$. Therefore, there is a 1-form $w$ such that
$w|_U=df_U$ for each $U\in\mathcal{U}$. Observe that $dw|_U=d^2f_U=0$ for each $U\in\mathcal{U}$, so $dw=0$. Therefore, there is a smooth function $f:\mathbb{R}^{n}\rightarrow\mathbb{R}$ with $df=w$. In this case, we have $df=df_U$ for each $U\in\mathcal{U}$, so $f-f_U$ is locally constant. $\square$
We can actually say much more. We can actually reconstruct the first de Rham cohomology and the first singular cohomology groups from groups of functions
$(f_U)_{U\in\mathcal{U}}$ where $f_U-f_V$ is locally constant when we replace $\mathbb{R}^n$ with a smooth manifold or at least a nice topological space. In this case, the fact that we can always find an $f$ where each $f-f_U$ is locally constant is equivalent to the fact that the first cohomology group is trivial, and the complexity of the first cohomology group measures how close one is to being able to find an $f$ where each $f-f_U$ is locally constant.
de Rham cohomology
Let $X$ be a smooth manifold. Then for each open cover $\mathcal{U}$, let
$C_\mathcal{U}$ be the abelian group of all $\mathcal{F}=(f_U)_{U\in\mathcal{U}}$ where each $f_U:U\rightarrow\mathbb{R}$ is smooth and where $f_{U}-f_{V}$ is locally constant on the set $U\cap V$. Then the 1-form $df_{U}$ coincides with the 1-form $df_{V}$ on $U\cap V$. Therefore,  there is a $1$-form $w$ where $w|_{U}=df_{U}$ for each $U\in\mathcal{U}$. Observe that $dw|_{U}=d^{2}f_{U}=0$ for each $U\in\mathcal{U}$, so $dw=0$. Let $H_{\text{dR}}^{n}(Z)$ denote the $n$-th de Rham cohomology group of a smooth manifold $Z$. Define a mapping $\Gamma_\mathcal{U}:C_{\mathcal{U}}\rightarrow H^1_{\text{dR}}(X)$ by letting $\Gamma_\mathcal{U}((f_U)_{U\in\mathcal{U}})=w/\text{Im}(d)$.
Let $A_\mathcal{U},B_\mathcal{U}$ be the subgroups of $C_\mathcal{U}$ where
$A_\mathcal{U}$ is the group of all mappings $(f|_U)_{U\in\mathcal{U}}$ where $f:X\rightarrow\mathbb{R}$ is smooth and where $B_\mathcal{U}$ is the group of all $(f_{U})_{U\in\mathcal{U}}$ where each $f_U$ is a locally constant function. Then
$A_\mathcal{U}+B_\mathcal{U}\subseteq\ker(\Gamma_\mathcal{U})$. Let $H_{U}=C_{\mathcal{U}}/(A_{\mathcal{U}}+B_{\mathcal{U}})$. Define a mapping $\Xi_\mathcal{U}:H_\mathcal{U}\rightarrow H_\text{dR}^1(X)$ by letting $\Xi_\mathcal{U}((f_U)_{U\in\mathcal{U}}/(A_\mathcal{U}+B_\mathcal{U})=\Gamma((f_U)_{U\in\mathcal{U}}).$
Suppose now that $\mathcal{U},\mathcal{V}$ are covers where $\mathcal{U}\preceq\mathcal{V}$. Then define a mapping $\phi_{\mathcal{V},\mathcal{U}}:H_{\mathcal{V}}\rightarrow H_{\mathcal{U}}$ by letting $\phi_{\mathcal{V},\mathcal{U}}([(f_U)_{U\in\mathcal{U}}])=([g_V])_{V\in\mathcal{V}}$ where if $V\in\mathcal{V},U\in\mathcal{U},V\subseteq U$, then $g_{V}-f_{U}$ is locally constant. Let $H_{X}$ be the direct limit of all groups $H_\mathcal{U}$, and let $\phi_\mathcal{U}:H_\mathcal{U}\rightarrow H_X$ be the canonical mapping.
Define a mapping $\Xi_X:H_X\rightarrow H_\text{dR}^1(X)$ by letting
$\Xi(\Phi_\mathcal{U}(\mathcal{F}))=\Xi_\mathcal{U}(\mathcal{F})$ whenever
$\mathcal{F}\in H_\mathcal{U}$.
Proposition: The mapping $\Xi_X:H_X\rightarrow H_\text{dR}^1(X)$ is a vector space isomorphism.
Proof: We shall first show that the mapping $\Xi_X$ is injective.
Suppose that $\Xi_X(\mathcal{F})=0$. Then there exists some cover $\mathcal{U}$ along with some $(f_U)_{U\in\mathcal{U}}$ with
$\mathcal{F}=\Phi_\mathcal{U}((f_U)_{U\in\mathcal{U}}/(A_\mathcal{U}+B_\mathcal{U}))$.
$0=\Xi_X(\mathcal{F})=\Xi_\mathcal{U}((f_U)_{U\in\mathcal{U}}/(A_\mathcal{U}+B_\mathcal{U}))=\Gamma((f_U)_{U\in\mathcal{U}})=w/\text{Im}(d)$ where $w|_U=df_U$ for each $U\in\mathcal{U}$.
Therefore, we have $w\in\text{Im}(d)$, so there is some smooth function $f:X\rightarrow\mathbb{R}$ with $df=w$. In this case, if $U\in\mathcal{U}$, since
$df_U=w|_U=df|_U$, we know that $f_U$ and $f|_U$ differ locally by a constant. Therefore, we conclude that $(f_U)_{U\in\mathcal{U}}/(A_\mathcal{U}+B_\mathcal{U})=0$, so $\mathcal{F}=0$ as well.
Now, for surjectivity, suppose that $w$ is a 1-form with $dw=0$. Then there is a cover $\mathcal{U}$ of $X$ where each $U\in\mathcal{U}$ is homeomorphic to some Euclidean space. In this case, for each $U\in\mathcal{U}$,$dw| _{U}=0$, so there is some smooth $f_U:U\rightarrow\mathbb{R}$ where $df_U=w|_{U}$. Here, $f_U-f_V$ is locally constant on $U\cap V$. Thus, $(f_U)_{U\in\mathcal{U}}\in C_{\mathcal{U}}$. Therefore,
$$w/\text{Im}(d)=\Gamma((f_U)_{U\in\mathcal{U}})=\Xi_U((f_U)_{U\in\mathcal{U}}/(A_\mathcal{U}+B_\mathcal{U})=\Xi_X(\Phi_\mathcal{U}((f_U)_{U\in\mathcal{U}}/(A_\mathcal{U}+B_\mathcal{U})).$$ Therefore, $\Xi_X$ is also surjective. $\square$
Singular cohomology
Let $X$ be a completely regular space. Let $G$ be an abelian group. Then let $C_{\mathcal{U}}^{G}$ be the group of all $(f_U)_{U\in\mathcal{U}}$ where $f_U:U\rightarrow G$ for each $U\in\mathcal{U}$ and where $f_U-f_V$ is locally constant on $U\cap V$. As before, let $A_\mathcal{U}^G,B_\mathcal{U}^G$ be the subgroups of $C_\mathcal{U}^G$ where $A_\mathcal{U}^G$ consists of all systems $(f|_U)_{U\in\mathcal{U}}$ for some $f:X\rightarrow G$ and where
$B_\mathcal{U}^G$ consists of all systems $(f_U)_{U\in\mathcal{U}}$ where each $f_U$ is locally constant. Let $H_{\mathcal{U}}^G=C_\mathcal{U}^G/(A_\mathcal{U}^G+B_\mathcal{U}^G)$.
Suppose now that $(f_U)_{U\in\mathcal{U}}\in C_\mathcal{U}^G$. Then whenever
$\ell:[0,1]\rightarrow X$ is a $1$-simplex, there is some partition $0=r_0<\dots<r_n=1$ such that for all $i$, there is some $U_i\in\mathcal{U}$ where
$\ell[r_i,r_{i+1}]\subseteq U_i$. Therefore, define
$$\alpha(\ell)=f_{U_0}(r_1)-f_{U_0}(r_0)+\dots+f_{U_{n-1}}(r_n)-f_{U_{n-1}}(r_{n-1}).$$
Extend $\alpha$ to a mapping $\alpha:C_{1}(X)\rightarrow G$ by linearity. Observe that if $\ell_0,\ell_1$ are homotopic, then $\alpha(\ell_0)=\alpha(\ell_1)$. If $\ell$ is a singular 2-simpliex, then $(d\alpha)(\ell)=\alpha(\delta\ell)=0$. Therefore, $d\alpha=0$. We conclude that $\alpha/\text{Im}(d)\in H^1(X,G).$ Therefore, define a homomorphism $\Gamma_\mathcal{U}^G:C_{\mathcal{U}}^{G}\rightarrow H^1(X,G)$ by letting
$\Gamma_\mathcal{U}^G((f_U)_{U\in\mathcal{U}})=\alpha/\text{Im}(d)$.
Suppose that $f:X\rightarrow G$ is a function. Let $\overline{f}:C_0(X)\rightarrow G$ be the 0-chain that extends $f$. Let $f_U=f|_U$ for each $U\in\mathcal{U}$, and let $\alpha$ be as before. Then for each path $\ell:[0,1]\rightarrow X$, we have
$$(d\overline{f})(\ell)=\overline{f}(\delta\ell)=\overline{f}(\ell(1)-\ell(0))=f(\ell(1))-f(\ell(0))=\alpha(\ell).$$
Therefore, $d\overline{f}=\alpha\in\text{Im}(d)$. Thus,
$\Gamma_\mathcal{U}^G((f_U)_{U\in\mathcal{U}})=0$ whenever $(f_U)_{U\in\mathcal{U}}\in A_\mathcal{U}^G$.
Furthermore, if $(f_U)_{U\in\mathcal{U}}\in B_\mathcal{U}^G$, then $\Gamma_\mathcal{U}^G((f_U)_{U\in\mathcal{U}})=0$ as well. We conclude that
$\Gamma_\mathcal{U}^G[A_\mathcal{U}^G+B_\mathcal{U}^G]=0$. Therefore, define a mapping
$\Xi_\mathcal{U}^G:H_\mathcal{U}^G\rightarrow H^1(C_0(X),G)$ by letting
$\Xi_\mathcal{U}^G(\mathcal{F}/(A_\mathcal{U}^G+B_\mathcal{U}^G))=\Gamma_\mathcal{U}^G(\mathcal{F})$.
Proposition: Let $X$ be a locally path connected space. The mapping $\Xi_\mathcal{U}^G$ is an injective group homomorphism. Furthermore, if $H^1(U,G)=0$ for each $U\in\mathcal{U}$, then $\Xi_\mathcal{U}^G$ is bijective.
Proof: We shall first prove injectivity. Let $(f_U)_{U\in\mathcal{U}}$ and let $\alpha$ be as before. Suppose that $\Xi_\mathcal{U}^G((f_U)_{U\in\mathcal{U}}/(A_\mathcal{U}^G+B_\mathcal{U}^G))=0$.
Then $\alpha\in\text{Im}(d)$. Therefore, there is some $\beta:C_0(X)\rightarrow G$ where $\alpha=d\beta$. Let $g:X\rightarrow G$ be the restriction of $\beta$ to $X$.
Suppose now that $U\in\mathcal{U}$. Then by local path connectedness, for each $x\in U$, there is a path connected open set $O$ with $x\in O\subseteq U$. Now, suppose that $y\in O$. Then let $\ell:[0,1]\rightarrow O$ be a path with $\ell(1)=y,\ell(0)=x$.
Then $\alpha(\ell)=f_U(y)-f_U(x)$. Furthermore,
$$\alpha(\ell)=d\beta(\ell)=\beta(\delta(\ell))=\beta(\ell(1)-\ell(0))
=g(\ell(1))-g(\ell(0))=g(y)-g(x).$$ Therefore, $f_U(y)-f_U(x)=g(y)-g(x)$, so
$f_U-g$ is constant on the open set $O$. Therefore, since each $f_U-g$ is locally constant, we know that $(f_U)_{U\in\mathcal{U}}\in A_\mathcal{U}^G+B_\mathcal{U}^G$.
Therefore, $(f_U)_{U\in\mathcal{U}}/(A_\mathcal{U}^G+B_\mathcal{U}^G)$, so the mapping $\Xi_\mathcal{U}^G$ is injective.
For surjectivity, suppose that $\gamma:C_1(X)\rightarrow G$ is a group homomorphism with $d\gamma=0$. Then $\gamma|_U:C_1(U)\rightarrow G$ is a group homomorphism. For each $\ell\in C_2(U)$, we have $d\gamma|_U(\ell)=\gamma|_U(\delta\ell)=\gamma(\delta\ell)=0$, so $d\gamma|_U=0$. Therefore, since $H^1(U,G)=0$, we have $\gamma|_U=d\beta_U$ for some $\beta_U:C_0(U)\rightarrow G$. Let $f_U$ be the restriction of $\beta_U$ to $U$.
Suppose now that $x\in U\cap V$. Then $x\in O\subseteq U\cap V$ for some path connected open set $O$. Now let $y\in O$. Let $\ell$ be a path in $O$ from $x$ to $y$. Then $\ell\in C_1(O)\subseteq C_1(U)\cap C_1(V)$. Therefore,
$$\gamma(\ell)=\gamma|_U(\ell)=d\beta_U(\ell)=\beta_U(\delta(\ell))=\beta_U(\ell(1)-\ell(0))=f_U(\ell(1))-f_U(\ell(0))=f_U(y)-f_U(x).$$
For the same reason, $\gamma(\ell)=f_V(y)-f_V(x)$, so $f_U(y)-f_U(x)=f_V(y)-f_V(x)$ whenever $y\in O$. Therefore, $f_U(y)-f_V(y)=f_U(x)-f_V(x)$. Therefore, $f_U-f_V$ is constant on $O$. Since the point $x\in U\cap V$ was arbitrary, the function $f_U-f_V$ is locally constant on $U\cap V$.
Therefore $(f_U)_{U\in\mathcal{U}}\in C_\mathcal{U}^G$. Now, let $\alpha$ be the usual mapping. Then suppose that $\ell:[0,1]\rightarrow U$ is a path for some $U\in\mathcal{U}$. Then
$\alpha(\ell)=f_U(\ell(1))-f_U(\ell(0))$. On the other hand,
$$\gamma(\ell)=\gamma|_U(\ell)=d\beta_U(\ell)=\beta_U(\delta\ell)=\beta_U(\ell(1))-\beta_U(\ell(0))=f_U(\ell(1))-f_U(\ell(0)).$$ Therefore, $\alpha(\ell)=\gamma(\ell)$. Since $d\alpha=d\gamma=0$, we conclude that $\alpha(\ell)=\gamma(\ell)$ for all paths $\ell:[0,1]\rightarrow X$, so $\alpha=\gamma$. Therefore,
$$\Xi_\mathcal{U}^G\big((f_U)_{U\in\mathcal{U}}/(A_\mathcal{U}^G+B_\mathcal{U}^G)\big)=\alpha/\text{Im}(d)=\gamma/\text{Im}(d).$$ $\square.$
Recall that $H^1(X,G)\simeq\text{Hom}(H_1(X),G)$. I will leave it to the reader to obtain a more isomorphism from $H_\mathcal{U}^G$ to $\text{Hom}(H_1(X),G)$ and to relate $H_\mathcal{U}^G$ to different cohomologies.
