The paper spatial interaction and the statistical analysis of lattice systems by Besag (1974) presents an alternative proof for the Hammersley-Clifford theorem.


In order to prove the HM theorem, Besag says that that under the following assumptions


1. The number of possible values at each site/vertex is finite.
2. $0$ is a possible value at every site.


the following expansion holds for every cdf $\mathbb{P}(\mathbf{x})$ and is unique on the sample space $\Omega$,
$$
\begin{align}
Q(\textbf{x}) &= \mathbb{P}(\mathbf{x})/\mathbb{P}(\mathbf{0})
\\ 
&= \sum\_{1 \leq i \leq n} x\_iG\_i(x\_i)
 +\sum\_{1 \leq i \leq j \leq n}x\_ix\_jG\_{i,j}(x\_i,x\_j)\\ &+ \sum\_{1 \leq i \leq j \leq k \leq n} x\_ix\_jx\_kG\_{i,j,k}(x\_i,x\_j,x\_k)+\ldots + x\_1x\_2 \ldots x\_nG\_{1,2,\ldots,n}(x\_1,x\_2,\ldots,x\_n)
\end{align}
$$


This equality looks slightly related to the inclusion-exclusion principle and in fact Besag says that we can use it to prove a HM for some restricted classes of lattices. How did Besag arrived at this equality? I'm really clueless.


My question is related to this [question](https://mathoverflow.net/questions/406500/canonical-representation-of-the-a-probability-distribution-for-hammersley-cliffo) that remains unanswered.



Hammersley-Clifford theorem
$\newcommand{\x}{\mathbf x}\newcommand{\tx}{\tilde{\mathbf x}}\newcommand{\0}{\mathbf0}\newcommand{\R}{\mathbb R}$You are citing Besag's paper ([formulas (3.1) and (3.3) there](http://links.jstor.org/sici?sici=0035-9246%281974%2936%3A2%3C192%3ASIATSA%3E2.0.CO%3B2-3)) incorrectly. What the paper actually has is this:
\begin{equation\*}
 \begin{aligned}
Q(\x)&:=\ln\frac{P(\x)}{P(\0)}
\\ 
&= \sum\_{1\le i\le n} x\_iG\_i(x\_i)
 +\sum\_{1\le i<j\le n}x\_ix\_jG\_{i,j}(x\_i,x\_j)\\ 
 &+ \sum\_{1\le i<j<k\le n} x\_ix\_jx\_kG\_{i,j,k}(x\_i,x\_j,x\_k) +\cdots \\ 
 &+x\_1\cdots x\_nG\_{1,\dots,n}(x\_1,\ldots,x\_n). 
\end{aligned}
\tag{1}\label{1}
\end{equation\*}


This is indeed a version of the inclusion-exclusion formula. To show this, identify the vector $\x=(x\_1,\dots,x\_n)\in\R^n$ with the function $[n]\ni i\mapsto x\_i$, which will also be denoted by $\x$; here, as usual, $[n]:=\{1,\dots,n\}$. For each $J\subseteq[n]$, let $\tx\_J$ be the vector/function on $[n]$ such that $(\tx\_J)(i):=x\_i$ for $i\in J$ and $(\tx\_J)(i):=0$ for $i\notin J$. Let $\x\_J:=\x|\_J=(x\_i\colon i\in J)$, the restriction of the function $\x$ to $J$, so that $\tx\_J$ is the extension by zeroes of the the function $\x\_J$ from $J$ to $[n]$. Let $|J|$ denote the cardinality of $J$.
For any $K\subseteq[n]$, let
\begin{equation\*}
 H\_K(\x\_K):=\sum\_{J\subseteq K}(-1)^{|K|-|J|}Q(\tx\_J); 
\end{equation\*}
note that the last expression depends on $\x$ only through $\x\_K$, so that $H\_K(\x\_K)$ is well defined.


Then
\begin{equation\*}
 \begin{aligned}
 &\sum\_{K\subseteq[n]}H\_K(\x\_K) \\ 
 &=\sum\_{K\subseteq[n]}\sum\_{J\subseteq K}(-1)^{|K|-|J|}Q(\tx\_J) \\ 
 &=\sum\_{J\subseteq[n]}Q(\tx\_J)
 \sum\_{K: J\subseteq K\subseteq[n]}(-1)^{|K|-|J|} \\ 
 &=\sum\_{J\subseteq[n]}Q(\tx\_J)
 \sum\_{k=|J|}^n(-1)^{k-|J|}\binom{n-|J|}{k-|J|} \\ 
 &=\sum\_{J\subseteq[n]}Q(\tx\_J)
 \sum\_{m=0}^{n-|J|}(-1)^m\binom{n-|J|}m \\ 
 &=\sum\_{J\subseteq[n]}Q(\tx\_J)
 \,1(|J|=n) \\ 
 &=Q(\tx\_{[n]})=Q(\x). 
\end{aligned}
\tag{2}\label{2}
\end{equation\*}
Note also that $H\_K(\x\_K)=0$ if $x\_j=0$ for some $j\in K$; this follows in view of the natural bijection between the **(**set of all subsets $J$ of the -- necessarily nonempty -- set $K$ such that $J\ni j$**)** and **(**the set of all subsets $J$ of $K$ such that $J\not\ni j$**)**.
So, $H\_K(\x\_K)=0$ if $p\_K(\x)=0$, where
\begin{equation\*}
 p\_K(\x):=\prod\_{j\in K}x\_j. 
\end{equation\*}


So, letting $G\_K(\x\_K):=H\_K(\x\_K)/p\_K(\x)$ if $p\_K(\x)\ne0$ and $G\_K(\x\_K):=0$ if $p\_K(\x)=0$, we get $H\_K(\x\_K)=p\_K(\x)G\_K(\x\_K)$ for all $\x$ and all $K$. Thus, by \eqref{2},
\begin{equation\*}
 Q(\x)=\sum\_{K\subseteq[n]}p\_K(\x)G\_K(\x\_K), \tag{3}\label{3}
\end{equation\*}
which is just another, more compact way of writing \eqref{1}.


Of course, one may refer to $G\_K(\x\_K)$ as a partial divided difference (of the function $Q$) of order $|K|$ with respect to $\x\_K=(x\_i\colon i\in K)$. In particular,
\begin{equation\*}
 G\_{\{1\}}(x\_1)=\frac{Q(x\_1,0,\dots,0)-Q(0,0,\dots,0)}{x\_1}
 \Big(=\frac{Q(x\_1,0,\dots,0)}{x\_1}\Big)
\end{equation\*}
if $x\_1\ne0$ and
\begin{equation\*}
 G\_{\{1,2\}}(x\_1,x\_2)=\frac{Q(x\_1,x\_2,0,\dots,0)-Q(x\_1,0,0,\dots,0)
 -Q(0,x\_2,0,\dots,0)+Q(0,0,\dots,0)}{x\_1x\_2} 
\end{equation\*}
$x\_1x\_2\ne0$.


So, \eqref{1} and, equivalently, \eqref{3} may be considered difference analogues of the Maclaurin expansion for functions of $n$ variables.


Representations \eqref{1} and, equivalently, \eqref{3} are essentially unique: the values of $G\_K(\x\_K)$ are uniquely determined for all $\x$ and $K$ such that $p\_K(\x)\ne0$. This can be verified by reasoning quite similar to \eqref{2}; this is left as an exercise for now.


