# Hammersley–Clifford theorem

The Hammersley–Clifford theorem is a result in probability theory, mathematical statistics and statistical mechanics that gives necessary and sufficient conditions under which a strictly positive probability distribution (of events in a probability space)[clarification needed] can be represented as events generated by a Markov network (also known as a Markov random field). It is the fundamental theorem of random fields. It states that a probability distribution that has a strictly positive mass or density satisfies one of the Markov properties with respect to an undirected graph G if and only if it is a Gibbs random field, that is, its density can be factorized over the cliques (or complete subgraphs) of the graph.

The relationship between Markov and Gibbs random fields was initiated by Roland Dobrushin and Frank Spitzer in the context of statistical mechanics. The theorem is named after John Hammersley and Peter Clifford, who proved the equivalence in an unpublished paper in 1971. Simpler proofs using the inclusion–exclusion principle were given independently by Geoffrey Grimmett, Preston and Sherman in 1973, with a further proof by Julian Besag in 1974.

## Proof Outline

A simple Markov network for demonstrating that any Gibbs random field satisfies every Markov property.

It is a trivial matter to show that a Gibbs random field satisfies every Markov property. As an example of this fact, see the following:

In the image to the right, a Gibbs random field over the provided graph has the form $\Pr(A,B,C,D,E,F)\propto f_{1}(A,B,D)f_{2}(A,C,D)f_{3}(C,D,F)f_{4}(C,E,F)$ . If variables $C$  and $D$  are fixed, then the global Markov property requires that: $A,B\perp E,F|C,D$  (see conditional independence), since $C,D$  forms a barrier between $A,B$  and $E,F$ .

With $C$  and $D$  constant, $\Pr(A,B,E,F|C=c,D=d)\propto [f_{1}(A,B,d)f_{2}(A,c,d)]\cdot [f_{3}(c,d,F)f_{4}(c,E,F)]=g_{1}(A,B)g_{2}(E,F)$  where $g_{1}(A,B)=f_{1}(A,B,d)f_{2}(A,c,d)$  and $g_{2}(E,F)=f_{3}(c,d,F)f_{4}(c,E,F)$ . This implies that $A,B\perp E,F|C,D$ .

To establish that every positive probability distribution that satisfies the local Markov property is also a Gibbs random field, the following lemma, which provides a means for combining different factorizations, needs to be proven:

Lemma 1 provides a means for combining factorizations as shown in this diagram. Note that in this image, the overlap between sets is ignored.

Lemma 1

Let $U$  denote the set of all random variables under consideration, and let $\Theta ,\Phi _{1},\Phi _{2},\dots ,\Phi _{n}\subseteq U$  and $\Psi _{1},\Psi _{2},\dots ,\Psi _{m}\subseteq U$  denote arbitrary sets of variables. (Here, given an arbitrary set of variables $X$ , $X$  will also denote an arbitrary assignment to the variables from $X$ .)

If

$\Pr(U)=f(\Theta )\prod _{i=1}^{n}g_{i}(\Phi _{i})=\prod _{j=1}^{m}h_{j}(\Psi _{j})$

for functions $f,g_{1},g_{2},\dots g_{n}$  and $h_{1},h_{2},\dots ,h_{m}$ , then there exist functions $h'_{1},h'_{2},\dots ,h'_{m}$  and $g'_{1},g'_{2},\dots ,g'_{n}$  such that

$\Pr(U)={\bigg (}\prod _{j=1}^{m}h'_{j}(\Theta \cap \Psi _{j}){\bigg )}{\bigg (}\prod _{i=1}^{n}g'_{i}(\Phi _{i}){\bigg )}$

In other words, $\prod _{j=1}^{m}h_{j}(\Psi _{j})$  provides a template for further factorization of $f(\Theta )$ .

Proof of Lemma 1

In order to use $\prod _{j=1}^{m}h_{j}(\Psi _{j})$  as a template to further factorize $f(\Theta )$ , all variables outside of $\Theta$  need to be fixed. To this end, let ${\bar {\theta }}$  be an arbitrary fixed assignment to the variables from $U\setminus \Theta$  (the variables not in $\Theta$ ). For an arbitrary set of variables $X$ , let ${\bar {\theta }}[X]$  denote the assignment ${\bar {\theta }}$  restricted to the variables from $X\setminus \Theta$  (the variables from $X$ , excluding the variables from $\Theta$ ).

Moreover, to factorize only $f(\Theta )$ , the other factors $g_{1}(\Phi _{1}),g_{2}(\Phi _{2}),...,g_{n}(\Phi _{n})$  need to be rendered moot for the variables from $\Theta$ . To do this, the factorization

$\Pr(U)=f(\Theta )\prod _{i=1}^{n}g_{i}(\Phi _{i})$

will be re-expressed as

$\Pr(U)={\bigg (}f(\Theta )\prod _{i=1}^{n}g_{i}(\Phi _{i}\cap \Theta ,{\bar {\theta }}[\Phi _{i}]){\bigg )}{\bigg (}\prod _{i=1}^{n}{\frac {g_{i}(\Phi _{i})}{g_{i}(\Phi _{i}\cap \Theta ,{\bar {\theta }}[\Phi _{i}])}}{\bigg )}$

For each $i=1,2,...,n$ : $g_{i}(\Phi _{i}\cap \Theta ,{\bar {\theta }}[\Phi _{i}])$  is $g_{i}(\Phi _{i})$  where all variables outside of $\Theta$  have been fixed to the values prescribed by ${\bar {\theta }}$ .

Let $f'(\Theta )=f(\Theta )\prod _{i=1}^{n}g_{i}(\Phi _{i}\cap \Theta ,{\bar {\theta }}[\Phi _{i}])$  and $g'_{i}(\Phi _{i})={\frac {g_{i}(\Phi _{i})}{g_{i}(\Phi _{i}\cap \Theta ,{\bar {\theta }}[\Phi _{i}])}}$  for each $i=1,2,\dots ,n$  so

$\Pr(U)=f'(\Theta )\prod _{i=1}^{n}g'_{i}(\Phi _{i})=\prod _{j=1}^{m}h_{j}(\Psi _{j})$

What is most important is that $g'_{i}(\Phi _{i})={\frac {g_{i}(\Phi _{i})}{g_{i}(\Phi _{i}\cap \Theta ,{\bar {\theta }}[\Phi _{i}])}}=1$  when the values assigned to $\Phi _{i}$  do not conflict with the values prescribed by ${\bar {\theta }}$ , making $g'_{i}(\Phi _{i})$  "disappear" when all variables not in $\Theta$  are fixed to the values from ${\bar {\theta }}$ .

Fixing all variables not in $\Theta$  to the values from ${\bar {\theta }}$  gives

$\Pr(\Theta ,{\bar {\theta }})=f'(\Theta )\prod _{i=1}^{n}g'_{i}(\Phi _{i}\cap \Theta ,{\bar {\theta }}[\Phi _{i}])=\prod _{j=1}^{m}h_{j}(\Psi _{j}\cap \Theta ,{\bar {\theta }}[\Psi _{j}])$

Since $g'_{i}(\Phi _{i}\cap \Theta ,{\bar {\theta }}[\Phi _{i}])=1$ ,

$f'(\Theta )=\prod _{j=1}^{m}h_{j}(\Psi _{j}\cap \Theta ,{\bar {\theta }}[\Psi _{j}])$

Letting $h'_{j}(\Theta \cap \Psi _{j})=h_{j}(\Psi _{j}\cap \Theta ,{\bar {\theta }}[\Psi _{j}])$  gives:

$f'(\Theta )=\prod _{j=1}^{m}h'_{j}(\Theta \cap \Psi _{j})$  which finally gives:

$\Pr(U)={\bigg (}\prod _{j=1}^{m}h'_{j}(\Theta \cap \Psi _{j}){\bigg )}{\bigg (}\prod _{i=1}^{n}g'_{i}(\Phi _{i}){\bigg )}$

The clique formed by vertices $x_{1}$ , $x_{2}$ , and $x_{3}$ , is the intersection of $\{x_{1}\}\cup \partial x_{1}$ , $\{x_{2}\}\cup \partial x_{2}$ , and $\{x_{3}\}\cup \partial x_{3}$ .

Lemma 1 provides a means of combining two different factorizations of $\Pr(U)$ . The local Markov property implies that for any random variable $x\in U$ , that there exists factors $f_{x}$  and $f_{-x}$  such that:

$\Pr(U)=f_{x}(x,\partial x)f_{-x}(U\setminus \{x\})$

where $\partial x$  are the neighbors of node $x$ . Applying Lemma 1 repeatedly eventually factors $\Pr(U)$  into a product of clique potentials (see the image on the right).

End of Proof