Skip to main content
NIHPA Author Manuscripts logoLink to NIHPA Author Manuscripts
. Author manuscript; available in PMC: 2016 Jun 6.
Published in final edited form as: Adv Neural Inf Process Syst. 2015 Dec;28:3079–3087.

Rapidly Mixing Gibbs Sampling for a Class of Factor Graphs Using Hierarchy Width

Christopher De Sa 1, Ce Zhang 1, Kunle Olukotun 1, Christopher Ré 1
PMCID: PMC4894721  NIHMSID: NIHMS771630  PMID: 27279724

Abstract

Gibbs sampling on factor graphs is a widely used inference technique, which often produces good empirical results. Theoretical guarantees for its performance are weak: even for tree structured graphs, the mixing time of Gibbs may be exponential in the number of variables. To help understand the behavior of Gibbs sampling, we introduce a new (hyper)graph property, called hierarchy width. We show that under suitable conditions on the weights, bounded hierarchy width ensures polynomial mixing time. Our study of hierarchy width is in part motivated by a class of factor graph templates, hierarchical templates, which have bounded hierarchy width—regardless of the data used to instantiate them. We demonstrate a rich application from natural language processing in which Gibbs sampling provably mixes rapidly and achieves accuracy that exceeds human volunteers.

1 Introduction

We study inference on factor graphs using Gibbs sampling, the de facto Markov Chain Monte Carlo (MCMC) method [8, p. 505]. Specifically, our goal is to compute the marginal distribution of some query variables using Gibbs sampling, given evidence about some other variables and a set of factor weights. We focus on the case where all variables are discrete. In this situation, a Gibbs sampler randomly updates a single variable at each iteration by sampling from its conditional distribution given the values of all the other variables in the model. Many systems—such as Factorie [14], OpenBugs [12], PGibbs [5], DimmWitted [28], and others [15, 22, 25]—use Gibbs sampling for inference because it is fast to run, simple to implement, and often produces high quality empirical results. However, theoretical guarantees about Gibbs are lacking. The aim of the technical result of this paper is to provide new cases in which one can guarantee that Gibbs gives accurate results.

For an MCMC sampler like Gibbs sampling, the standard measure of efficiency is the mixing time of the underlying Markov chain. We say that a Gibbs sampler mixes rapidly over a class of models if its mixing time is at most polynomial in the number of variables in the model. Gibbs sampling is known to mix rapidly for some models. For example, Gibbs sampling on the Ising model on a graph with bounded degree is known to mix in quasilinear time for high temperatures [10, p. 201]. Recent work has outlined conditions under which Gibbs sampling of Markov Random Fields mixes rapidly [11]. Continuous-valued Gibbs sampling over models with exponential-family distributions is also known to mix rapidly [2, 3]. Each of these celebrated results still leaves a gap: there are many classes of factor graphs on which Gibbs sampling seems to work very well—including as part of systems that have won quality competitions [24]—for which there are no theoretical guarantees of rapid mixing.

Many graph algorithms that take exponential time in general can be shown to run in polynomial time as long as some graph property is bounded. For inference on factor graphs, the most commonly used property is hypertree width, which bounds the complexity of dynamic programming algorithms on the graph. Many problems, including variable elimination for exact inference, can be solved in polynomial time on graphs with bounded hypertree width [8, p. 1000]. In some sense, bounded hypertree width is a necessary and sufficient condition for tractability of inference in graphical models [1,9]. Unfortunately, it is not hard to construct examples of factor graphs with bounded weights and hypertree width 1 for which Gibbs sampling takes exponential time to mix. Therefore, bounding hypertree width is insufficient to ensure rapid mixing of Gibbs sampling. To analyze the behavior of Gibbs sampling, we define a new graph property, called the hierarchy width. This is a stronger condition than hypertree width; the hierarchy width of a graph will always be larger than its hypertree width. We show that for graphs with bounded hierarchy width and bounded weights, Gibbs sampling mixes rapidly.

Our interest in hierarchy width is motivated by so-called factor graph templates, which are common in practice [8, p. 213]. Several types of models, such as Markov Logic Networks (MLN) and Relational Markov Networks (RMN) can be represented as factor graph templates. Many state-of-the-art systems use Gibbs sampling on factor graph templates and achieve better results than competitors using other algorithms [14, 27]. We exhibit a class of factor graph templates, called hierarchical templates, which, when instantiated, have a hierarchy width that is bounded independently of the dataset used; Gibbs sampling on models instantiated from these factor graph templates will mix in polynomial time. This is a kind of sampling analog to tractable Markov logic [4] or so-called “safe plans” in probabilistic databases [23]. We exhibit a real-world templated program that outperforms human annotators at a complex text extraction task—and provably mixes in polynomial time.

In summary, this work makes the following contributions:

  • We introduce a new notion of width, hierarchy width, and show that Gibbs sampling mixes in polynomial time for all factor graphs with bounded hierarchy width and factor weight.

  • We describe a new class of factor graph templates, hierarchical factor graph templates, such that Gibbs sampling on instantiations of these templates mixes in polynomial time.

  • We validate our results experimentally and exhibit factor graph templates that achieve high quality on tasks but for which our new theory is able to provide mixing time guarantees.

1.1 Related Work

Gibbs sampling is just one of several algorithms proposed for use in factor graph inference. The variable elimination algorithm [8] is an exact inference method that runs in polynomial time for graphs of bounded hypertree width. Belief propagation is another widely-used inference algorithm that produces an exact result for trees and, although it does not converge in all cases, converges to a good approximation under known conditions [7]. Lifted inference [18] is one way to take advantage of the structural symmetry of factor graphs that are instantiated from a template; there are lifted versions of many common algorithms, such as variable elimination [16], belief propagation [21], and Gibbs sampling [26]. It is also possible to leverage a template for fast computation: Venugopal et al. [27] achieve orders of magnitude of speedup of Gibbs sampling on MLNs. Compared with Gibbs sampling, these inference algorithms typically have better theoretical results; despite this, Gibbs sampling is a ubiquitous algorithm that performs practically well—far outstripping its guarantees.

Our approach of characterizing runtime in terms of a graph property is typical for the analysis of graph algorithms. Many algorithms are known to run in polynomial time on graphs of bounded treewidth [19], despite being otherwise NP-hard. Sometimes, using a stronger or weaker property than treewidth will produce a better result; for example, the submodular width used for constraint satisfaction problems [13].

2 Main Result

In this section, we describe our main contribution. We analyze some simple example graphs, and use them to show that bounded hypertree width is not sufficient to guarantee rapid mixing of Gibbs sampling. Drawing intuition from this, we define the hierarchy width graph property, and prove that Gibbs sampling mixes in polynomial time for graphs with bounded hierarchy width.

First, we state some basic definitions. A factor graph G is a graphical model that consists of a set of variables V and factors Φ, and determines a distribution over those variables. If I is a world for G (an assignment of a value to each variable in V), then ε, the energy of the world, is defined as

ε(I)=ϕΦϕ(I). (1)

The probability of world I is π(I)=1Zexp(ε(I)), where Z is the normalization constant necessary for this to be a distribution. Typically, each ϕ depends only on a subset of the variables; we can draw G as a bipartite graph where a variable υ ∈ V is connected to a factor ϕ ∈ Φ if ϕ depends on υ.

Definition 1 (Mixing Time)

The mixing time of a Markov chain is the first time t at which the estimated distribution μt is within statistical distance 14 of the true distribution [10, p. 55]. That is,

tmix=min {t: maxAΩ|μt(A)π(A)|14}.

2.1 Voting Example

We start by considering a simple example model [20], called the voting model, that models the sign of a particular “query” variable Q ∈ {−1, 1} in the presence of other “voter” variables Ti ∈ {0, 1} and Fi ∈ {0, 1}, for i ∈ {1, …, n}, that suggest that Q is positive and negative (true and false), respectively. We consider three versions of this model. The first, the voting model with linear semantics, has energy function

ε(Q,T,F)=wQi=1nTiwQi=1nFi+i=1nwTiTi+i=1nwFiFi,

where wTi, wFi, and w > 0 are constant weights. This model has a factor connecting each voter variable to the query, which represents the value of that vote, and an additional factor that gives a prior for each voter. It corresponds to the factor graph in Figure 1(a). The second version, the voting model with logical semantics, has energy function

ε(Q,T,F)=wQ maxiTiwQ maxiFi+i=1nwTiTi+i=1nwFiFi.

Figure 1.

Figure 1

Factor graph diagrams for the voting model; single-variable prior factors are omitted.

Here, in addition to the prior factors, there are only two other factors, one of which (which we call ϕT) connects all the true-voters to the query, and the other of which (ϕF) connects all the false-voters to the query. The third version, the voting model with ratio semantics, is an intermediate between these two models, and has energy function

ε(Q,T,F)=wQ log (1+i=1nTi)wQ log (1+i=1nFi)+i=1nwTiTi+i=1nwFiFi.

With either logical or ratio semantics, this model can be drawn as the factor graph in Figure 1(b).

These three cases model different distributions and therefore different ways of representing the power of a vote; the choice of names is motivated by considering the marginal odds of Q given the other variables. For linear semantics, the odds of Q depend linearly on the difference between the number of nonzero positive-voters Ti and nonzero negative-voters Fi. For ratio semantics, the odds of Q depend roughly on their ratio. For logical semantics, only the presence of nonzero voters matters, not the number of voters.

We instantiated this model with random weights WTi and wFi, ran Gibbs sampling on it, and computed the variance of the estimated marginal probability of Q for the different models (Figure 2). The results show that the models with logical and ratio semantics produce much lower-variance estimates than the model with linear semantics. This experiment motivates us to try to prove a bound on the mixing time of Gibbs sampling on this model.

Figure 2.

Figure 2

Convergence for the voting model with w = 0.5, and random prior weights in (−1,0).

Theorem 1

Fix any constant ω > 0, and run Gibbs sampling on the voting model with bounded factor weights {wTi, wFi, w} ⊂ [−ω, ω]. For the voting model with linear semantics, the largest possible mixing time tmix of any suck model is tmix = 2Θ(n). For the voting model with either logical or ratio semantics, the largest possible mixing time is tmix = Θ(n log n).

This result validates our observation that linear semantics mix poorly compared to logical and ratio semantics. Intuitively, the reason why linear semantics performs worse is that the Gibbs sampler will switch the state of Q only very infrequently—in fact exponentially so. This is because the energy roughly depends linearly on the number of voters n, and therefore the probability of switching Q depends exponentially on n. This does not happen in either the logical or ratio models.

2.2 Hypertree Width

In this section, we describe the commonly-used graph property of hypertree width, and show using the voting example that bounding it is insufficient to ensure rapid Gibbs sampling. Hypertree width is typically used to bound the complexity of dynamic programming algorithms on a graph; in particular, variable elimination for exact inference runs in polynomial time on factor graphs with bounded hypertree width [8, p. 1000]. The hypertree width of a hypergraph, which we denote tw(G), is a generalization of the notion of acyclicity; since the definition of hypertree width is technical, we instead state the definition of an acyclic hypergraph, which is sufficient for our analysis. In order to apply these notions to factor graphs, we can represent a factor graph as a hypergraph that has one vertex for each node of the factor graph, and one hyperedge for each factor, where that hyperedge contains all variables the factor depends on.

Definition 2 (Acyclic Factor Graph [6])

A join tree, also called a junction tree, of a factor graph G is a tree T such that the nodes of T are the factors of G and, if two factors ϕ and ρ both depend on the same variable x in G, then every factor on the unique path between ϕ and ρ in T also depends on x. A factor graph is acyclic if it has a join tree. All acyclic graphs have hypertree width tw(G) = 1.

Note that all trees are acyclic; in particular the voting model (with any semantics) has hypertree width 1. Since the voting model with linear semantics and bounded weights mixes in exponential time (Theorem 1), this means that bounding the hypertree width and the factor weights is insufficient to ensure rapid mixing of Gibbs sampling.

2.3 Hierarchy Width

Since the hypertree width is insufficient, we define a new graph property, the hierarchy width, which, when bounded, ensures rapid mixing of Gibbs sampling. This result is our main contribution.

Definition 3 (Hierarchy Width)

The hierarchy width hw(G) of a factor graph G is defined recursively such that, for any connected factor graph G = 〈V, Φ〉,

hw(G)=1+minϕ*Φhw(V,Φ{ϕ*}), (2)

and for any disconnected factor graph G with connected components G1, G2, …,

hw(G)=maxihw(Gi). (3)

As a base case, all factor graphs G with no factors have

hw(V,)=0. (4)

To develop some intuition about how to use the definition of hierarchy width, we derive the hierarchy width of the path graph drawn in Figure 3.

Figure 3.

Figure 3

Factor graph diagram for an n-variable path graph.

Lemma 1

The path graph model has hierarchy width hw(G) = ⌈log2 n⌉.

Proof

Let Gn denote the path graph with n variables. For n = 1, the lemma follows from (4). For n > 1, Gn is connected, so we must compute its hierarchy width by applying (2). It turns out that the factor that minimizes this expression is the factor in the middle, and so applying (2) followed by (3) shows that hw(Gn)=1+hw(Gn2). Applying this inductively proves the lemma.

Similarly, we are able to compute the hierarchy width of the voting model factor graphs.

Lemma 2

The voting model with logical or ratio semantics has hierarchy width hw(G) = 3.

Lemma 3

The voting model with linear semantics has hierarchy width hw(G) = 2n + 1.

These results are promising, since they separate our polynomially-mixing examples from our exponentially-mixing examples. However, the hierarchy width of a factor graph says nothing about the factors themselves and the functions they compute. This means that it, alone, tells us nothing about the model; for example, any distribution can be represented by a trivial factor graph with a single factor that contains all the variables. Therefore, in order to use hierarchy width to produce a result about the mixing time of Gibbs sampling, we constrain the maximum weight of the factors.

Definition 4 (Maximum Factor Weight)

A factor graph has maximum factor weight M, where

M=maxϕΦ(maxIϕ(I)minIϕ(I)).

For example, the maximum factor weight of the voting example with linear semantics is M = 2w; with logical semantics, it is M = 2w; and with ratio semantics, it is M = 2w log(n + 1). We now show that graphs with bounded hierarchy width and maximum factor weight mix rapidly.

Theorem 2 (Polynomial Mixing Time)

If G is a factor graph with n variables, at most s states per variable, e factors, maximum factor weight M, and hierarchy width h, then

tmix(log(4)+n log(s)+eM)n exp(3hM).

In particular, if e is polynomial in n, the number of values for each variable is bounded, and hM = O(log n), then tmix (ε) = O(nO(1)).

To show why bounding the hierarchy width is necessary for this result, we outline the proof of Theorem 2. Our technique involves bounding the absolute spectral gap γ(G) of the transition matrix of Gibbs sampling on graph G; there are standard results that use the absolute spectral gap to bound the mixing time of a process [10, p. 155]. Our proof proceeds via induction using the definition of hierarchy width and the following three lemmas.

Lemma 4 (Connected Case)

Let G and Ḡ be two factor graphs with maximum factor weight M, which differ only inasmuch as G contains a single additional factor ϕ*. Then,

γ(G)γ() exp (3M).

Lemma 5 (Disconnected Case)

Let G be a disconnected factor graph with n variables and m connected components G1, G2, …, Gm with n1, n2, … nm variables, respectively. Then,

γ(G)minimninγ(Gi).

Lemma 6 (Base Case)

Let G be a factor graph with one variable and no factors. The absolute spectral gap of Gibbs sampling running on G will be γ(G) = 1.

Using these Lemmas inductively, it is not hard to show that, under the conditions of Theorem 2,

γ(G)1nexp (3hM);

converting this to a bound on the mixing time produces the result of Theorem 2.

To gain more intuition about the hierarchy width, we compare its properties to those of the hypertree width. First, we note that, when the hierarchy width is bounded, the hypertree width is also bounded.

Statement 1

For any factor graph G, tw(G) ≤ hw(G).

One of the useful properties of the hypertree width is that, for any fixed k, computing whether a graph G has hypertree width tw(G) ≤ k can be done in polynomial time in the size of G. We show the same is true for the hierarchy width.

Statement 2

For any fixed k, computing whether hw(G) ≤ k can be done in time polynomial in the number of factors of G.

Finally, we note that we can also bound the hierarchy width using the degree of the factor graph. Notice that a graph with unbounded node degree contains the voting program with linear semantics as a subgraph. This statement shows that bounding the hierarchy width disallows such graphs.

Statement 3

Let d be the maximum degree of a variable in factor graph G. Then, hw(G) ≥ d.

3 Factor Graph Templates

Our study of hierarchy width is in part motivated by the desire to analyze the behavior of Gibbs sampling on factor graph templates, which are common in practice and used by many state-of-the-art systems. A factor graph template is an abstract model that can be instantiated on a dataset to produce a factor graph. The dataset consists of objects, each of which represents a thing we want to reason about, which are divided into classes. For example, the object Bart could have class Person and the object Twilight could have class Movie. (There are many ways to define templates; here, we follow the formulation in Koller and Friedman [8, p. 213].)

A factor graph template consists of a set of template variables and template factors. A template variable represents a property of a tuple of zero or more objects of particular classes. For example, we could have an IsPopular(x) template, which takes a single argument of class Movie. In the instantiated graph, this would take the form of multiple variables like IsPopular(Twilight) or IsPopular(Avengers). Template factors are replicated similarly to produce multiple factors in the instantiated graph. For example, we can have a template factor

ϕ(TweetedAbout(x,y),IsPopular(x))

for some factor function ϕ. This would be instantiated to factors like

ϕ(TweetedAbout(Avengers,Bart),IsPopular(Avengers)).

We call the x and y in a template factor object symbols. For an instantiated factor graph with template factors Φ, if we let Aϕ denote the set of possible assignments to the object symbols in a template factor ϕ, and let ϕ (a, I) denote the value of its factor function in world I under the object symbol assignment a, then the standard way to define the energy function is with

ε(I)=ϕΦaAϕwϕϕ(a,I), (5)

where wϕ is the weight of template factor ϕ. This energy function results from the creation of a single factor ϕa(I) = ϕ (a, I) for each object symbol assignment a of ϕ. Unfortunately, this standard energy definition is not suitable for all applications. To deal with this, Shin et al. [20] introduce the notion of a semantic function g, which counts the of energy of instances of the factor template in a non-standard way. In order to do this, they first divide the object symbols of each template factor into two groups, the head symbols and the body symbols. When writing out factor templates, we distinguish head symbols by writing them with a hat (like ). If we let Hϕ denote the set of possible assignments to the head symbols, let Bϕ denote the set of possible assignments to the body symbols, and let ϕ(h, b, I) denote the value of its factor function in world I under the assignment (h, b), then the energy of a world is defined as

ε(I)=ϕΦhHϕwϕ(h)g(bBϕϕ(h,b,I)). (6)

This results in the creation of a single factor ϕh(I) = g (∑b ϕ(h, b, I)) for each assignment of the template’s head symbols. We focus on three semantic functions in particular [20]. For the first, linear semantics, g(x) = x. This is identical to the standard semantics in (5). For the second, logical semantics, g(x) = sgn(x). For the third, ratio semantics, g(x) = sgn(x) log(l + |x|). These semantics are analogous to the different semantics used in our voting example. Shin et al. [20] exhibit several classification problems where using logical or ratio semantics gives better F1 scores.

3.1 Hierarchical Factor Graphs

In this section, we outline a class of templates, hierarchical templates, that have bounded hierarchy width. We focus on models that have hierarchical structure in their template factors; for example,

ϕ(A(x^,ŷ,z),B(x^,ŷ),Q(x^,ŷ)) (7)

should have hierarchical structure, while

ϕ(A(z),B(x^),Q(x^,y)) (8)

should not. Armed with this intuition, we give the following definitions.

Definition 5 (Hierarchy Depth)

A template factor ϕ has hierarchy depth d if the first d object symbols that appear in each of its terms are the same. We call these symbols hierarchical symbols. For example, (7) has hierarchy depth 2, and and ŷ are hierarchical symbols; also, (8) has hierarchy depth 0, and no hierarchical symbols.

Definition 6 (Hierarchical)

We say that a template factor is hierarchical if all of its head symbols are hierarchical symbols. For example, (7) is hierarchical, while (8) is not. We say that a factor graph template is hierarchical if all its template factors are hierarchical.

We can explicitly bound the hierarchy width of instances of hierarchical factor graphs.

Lemma 7

If G is an instance of a hierarchical template with E template factors, then hw(G) ≤ E.

We would now like to use Theorem 2 to prove a bound on the mixing time; this requires us to bound the maximum factor weight of the graph. Unfortunately, for linear semantics, the maximum factor weight of a graph is potentially O(n), so applying Theorem 2 won’t get us useful results. Fortunately, for logical or ratio semantics, hierarchical factor graphs do mix in polynomial time.

Statement 4

For any fixed hierarchical factor graph template 𝒢, if G is an instance of 𝒢 with bounded weights using either logical or ratio semantics, then the mixing time of Gibbs sampling on G is polynomial in the number of objects n in its dataset. That is, tmix = O (nO(1)).

So, if we want to construct models with Gibbs samplers that mix rapidly, one way to do it is with hierarchical factor graph templates using logical or ratio semantics.

4 Experiments

Synthetic Data

We constructed a synthetic dataset by using an ensemble of Ising model graphs each with 360 nodes, 359 edges, and treewidth 1, but with different hierarchy widths. These graphs ranged from the star graph (like in Figure 1 (a)) to the path graph; and each had different hierarchy width. For each graph, we were able to calculate the exact true marginal of each variable because of the small tree-width. We then ran Gibbs sampling on each graph, and calculated the error of the marginal estimate of a single arbitrarily-chosen query variable. Figure 5(a) shows the result with different weights and hierarchy width. It shows that, even for tree graphs with the same number of nodes and edges, the mixing time can still vary depending on the hierarchy width of the model.

Figure 5.

Figure 5

Experiments illustrate how convergence is affected by hierarchy width and semantics.

Real-World Applications

We observed that the hierarchical templates that we focus on in this work appear frequently in real applications. For example, alt five knowledge base population (KBP) systems illustrated by Shin el ad. [20] contain subgraphs that are grounded by hierarchical templates. Moreover, sometimes a factor graph is solely grounded by hierarchical templates, and thus provably mixes rapidly by our theorem while achieving high quality. To validate this, we constructed a hierarchical template for the Paleontology application used by Shanan ct al. [17]. We found that when using the ratio semantic, we were able to get an F1 score of 0.86 with precision of 0.96. On the same task, this quality is actually higher than professional human volunteers [17]. For comparison, the linear semantic achieved an F1 score of 0.76 and lhe logical achieved 0.73.

The factor graph we used in this Paleontology application is large enough that it is intractable, using exact inference, to estimate the true marginal to investigate the mixing behavior. Therefore, we chose a subgraph of a KBP system used by Shin et al. [20] that can be grounded by a hierarchical template and chose a setting of the weight such that the true marginal was 0.5 for all variables. We then ran Gibbs sampling on this subgraph and report the average error of the marginal estimation in Figure 5(b). Our results illustrate the effect of changing the semantic on a more complicated model from a real application, and show similar behavior to our simple voting example.

5 Conclusion

This paper showed that for a class of factor graph templates, hierarchical templates, Gibbs sampling mixes in polynomial time. It also introduced the graph property hierarchy width, and showed that for graphs of bounded factor weight and hierarchy width, Gibbs sampling converges rapidly. These results may aid in better understanding the behavior of Gibbs sampling for both template and general factor graphs.

Figure 4.

Figure 4

Subset relationships among classes of factor graphs, and locations of examples.

Acknowledgments

Thanks to Stefano Ermon and Percy Liang for helpful conversations.

The authors acknowledge the support of: DARPA FA8750-12-2-0335; NSF IIS-1247701; NSF CCF-1111943; DOE 108845; NSF CCF-1337375; DARPA FA8750-13-2-0039; NSF IIS-1353606; ONR N000141210041 and N000141310129: NIH U54EB020405; Oracle; NVIDIA; Huawei; SAP Labs; Sloan Research Fellowship; Moore Foundation; American Family Insurance; Google; and Toshiba.

A Proof of Voting Program Rates

Here, we prove the convergence rates stated in Theorem 1. The strategy for the upper bound proofs involves constructing a coupling between the Gibbs sampler and another process that attains the equilibrium distribution at each step. First, we restate the definition of mixing time in terms of the total variation distance, a quantity which we will use in the proofs in this section.

Definition 7 (Total Variation Distance)

The total variation distance [10, p. 48] is a distance metric between two probability measures μ and ν over probability space Ω defined as

μνTV=maxAΩ|μ(A)ν(A)|,

that is, the maximum difference between the probabilities that μ and ν assign to a single event.

Definition 8 (Mixing Time)

The mixing time of a Markov chain is the first time t at which the estimated distribution μt is within total variation distance 14 of the true distribution [10, p. 55]. That is,

tmix=min {t:μtπTV14}.

Next, we define a coupling [30].

Definition 9 (Coupling)

A coupling of two random variables X and X′ defined on some separate probability spaces ℙ and ℙ′ is any new probability space ℙ̂ over which there are two random variables and ′ such that X has the same distribution as and X′ has the same distribution as ′.

Given a coupling of two Markov processes Xk and Xk with the same transition matrix, the coupling time is defined as the first time T when X^k=X^k. The following theorem lets us bound the total variance distance in terms of the coupling time.

Theorem 3 (Theorem 5.2 in Levin et al. [10])

For any coupling (k, X^k) with coupling time T, if we let νk and νk denote the distributions of Xk and Xk respectively, then

νkνktvP(T>k).

All of the coupling examples in this section use a correlated flip coupler, which consists of two Gibbs samplers and ′, each of which is running with the same random inputs. Specifically, both samplers choose to sample the same variable at each timestep. Then, if we define p as the probability of sampling 1 for , and p′ similarly, it assigns both variables to 1 with probability min(p, p′), assigns both variables to 0 with probability min(1 − p, 1 − p′), and assigns different values with probability |pp′|. If we initialize with an arbitrary distribution ν and ′ with the stationary distribution π, it is trivial to check that k has distribution Pkν, and X^k always has distribution π. Applying Theorem 3 results in

PkνπtvP(T>k).

Now, we prove the bounds stated in Theorem 1 as a collection of four statements about the upper and lower bounds of the mixing time.

Statement 5 (UB for Voting: Logical and Ratio)

For the voting example, assume that all the weights on the variables are bounded by |w| ≤ M, |wTx| ≤ M and |wFx| ≤ M. Then for either the logical or ratio semantics, for sufficiently small constant ε,

tmix(ε)=O(n log(n)).

Proof

Recall that, for the voting program, the weight of a world is

W(q,t,f)=wqg(t1)wqg(f1)+x=1nwT(x)tx+x=1nwF(x)fx,

where q ∈ {−1,1} and {tx, fx} ⊆ {0,1}.

Consider a correlated-flip coupler running on this Markov process, producing two chains X and . For either chain, if we sample a variable T(x) at time k, and let u denote the number of T(y) variables for yx that are true, then

P(T(x)(k+1)=1)=(1+exp (wq(g(u)g(u+1))wT(x)))1.

Since g(x + 1) − g(x) ≤ 1 for any x, it follows that

P(T(x)(k+1)=1)(1+exp(2M))1.

We now define the constant

pM=(1+exp(2M))1.

Also, if u non-T(x) variables are true in the X process, and ū variables are true in the process, then the probability of the processes X and not producing the same value for Yi is

pD=|P(T(x)(k+1)=1)P(T¯(x)(k+1)=1)|=|(1+exp (wq(g(u)g(u+1))wT(x)))1(1+exp (wq¯(g(ū)g(ū+1))wT(x)))1|,

where the last statement follows from continuous differentiability of the function h(x) = (1 + exp(−x))−1. Notice that, if u = Ω(n), then

pD=O(n1)

for both logical and ratio semantics.

The same logic will show that, if we sample any F(x), then

P(F(x)(k+1)=1)pM,

and

pD=O(g(υ+1)g(υ)+g(υ¯+1)g(υ¯)),

where υ and ῡ are the number of non-F(x) variables that are true in the X and processes respectively. Again as above, if υ = Ω(n), then

pD=O(n1).

Next, consider the situation if we sample Q. In this case,

P(Q(k+1)=1)=(1+exp (2w(g(t1)g(f1))))1.

Therefore, of we let u denote the number of true T(x) variables and υ denote the number of true F(x) variables, and similarly for ū and ῡ, then the probability of the processes X and not producing the same value for Q is

pD=|P(Q(k+1)=1)P(Q¯(k+1)=1)|=|(1+exp (2w(f(υ)f(u))))1·(1+exp (2w(f(υ¯)f(ū))))1.|=O(|f(υ)f(u)f(υ¯)+f(ū),|)

where as before, the last statement follows from continuous differentiability of the function g(x) = (1 + exp(−x))−1. Furthermore, if all of u, υ, ū, and ῡ are Ω(n), then

pD=O(1).

Now, assume that our correlated-flip coupler runs for 8n log n steps on the Gibbs sampler. Let E1 be the event that, after the first 4n log n steps, each of the variables has been sampled at least once. This will have probability at least 12 by the coupon collector’s problem.

Next, let E2 be the event that, after the first 4n log n steps, min(u,υ,ū,υ)pMn2 for the next 4n log n steps for both samplers. After all the entries have been sampled, u, υ, ū, and ῡ will each be bounded from below by a binomial random variable with parameter pM at each timestep, so from Hoeffding’s inequality, the probability that this constraint will be violated by a sampler at any particular step is less than exp (12pMn). Therefore,

P(E2|E1)(1exp (12pMn))4n log n=Ω(1).

Let E3 be the event that all the variables are resampled at least once between time 2n log n and 4n log n. Again this event has probability at least 12.

Finally, let C be the event that coupling occurs at time 4n log n. Given E1, E2, and E3, this probability is equal to the probability that each variable coupled individually the last time it was sampled. For all the Yi, our analysis above showed that this probability is

1pD=1O(n1),

and for Q, this probability is

1pD=Ω(1).

Therefore,

P(C|E1,E2,E3)Ω(1)(1O(n1))2n=Ω(1),

and since

P(C)=P(C|E1,E2,E3)P(E3)P(E2|E1)P(E1),

and all these quantities are Ω(1), we can conclude that ℙ̂(C) = Ω(1).

Therefore, this process couples with at least some constant probability P independent of n after 8n log n steps. Since we can run this coupling argument independently an arbitrary number of times, it follows that, after 8Ln log n steps, the probability of coupling will be at least 1 − (1 − P)L. Therefore, by Theorem 3, for any initial distribution ν,

P8Ln log nνπtv^(T>8Ln log n)(1P)L.

For any ε, this will be less than ε when

Llog(ε)log(1pC);

which occurs when t8n log nlog(ε)log(1pC). Letting ε=14,

tmix=8n log nlog(4)log(1pC)

produces the desired result.

Statement 6 (LB for Voting: Logical and Ratio)

For the voting example using either the logical or ratio semantics, a lower bound for the mixing time for sufficiently small constant values of ε is Ω(n log n).

Proof

At a minimum, in order to converge, we must sample all the variables. From the coupon collector’s problem, this requires Ω(n log n) time.

Statement 7 (UB for Voting: Linear)

For the voting example, assume that all the weights on the variables are bounded by |w| ≤ M, |wT(x)| ≤ M and |wF(x)| ≤ M. Then for linear semantics,

tmix=2O(n).

Proof

From our algebra above in the proof of Statement 5, we know that at any timestep, the probability of not coupling the sampled variable is bounded; that is

pD=O(1).

Therefore, if we run a correlated-flip coupler for 2n log n timesteps, the probability that coupling will have occurred is greater than the probability that all variables have been sampled (which is Ω(1)) times the probability that all variables coupled the last time they were sampled. Thus if C is the event that coupling occurs,

P(C)Ω(1)(1O(1))2n+1=exp(O(n)).

Therefore, if we run for some t = 2O(n) timesteps, coupling will have occurred at least once with high probability. It follows that the mixing time is

tmix=2O(n),

as desired.

Statement 8 (LB for Voting: Linear)

For the voting example using linear semantics and bounded weights, a lower bound for the mixing time of a worst-case model is 2Ω(n).

Proof

Consider a sampler with unary weights wT(x) = wF(x) = 0. Assume that it starts in a state where Q = 1, all the T(x) = 1, and all the F(x) = 0. We will show that it takes an exponential amount of time until Q = −1. From above, the probability of flipping Q will be

P(Q(k+1)=1)=(1+exp (2w(t1)f1))))1.

Meanwhile, the probability to flip any T(x) while Q = 1 is

P(T(x)(k+1)=0)=(1+exp(w))1=p,

for constant p, and the probability of flipping any F(x) is similarly

P(F(x)(k+1)=1)=p.

Now, consider the following events which could happen at any timestep. While Q = 1, let ET be the event that ‖t1 ≤ (1 − 2p)n, and let EF be the event that ‖f1 ≥ 2pn. Since ‖t1 and ‖f1 are both bounded by binomial random variables with parameters 1 − p and p respectively, Hoeffding’s inequality states that, at any timestep,

P(ET)=P(t1(12p)n)exp(2p2n),

and similarly

P(EF)=P(f12pn)exp(2p2n).

Now, while these bounds are satisfied, let EQ be the event that Q = − 1. This will be bounded by

P(EQ)=(1+exp (2w(14p)n))1exp(2w(14p)n).

It follows that at any timestep,

P(ETEFEQ)=exp(O(n)),

so, at any timestep k,

P(Q(k)=1)=k exp(O(n)).

However, by symmetry, under the stationary distribution π, this probability must be 12. Therefore, the total variation distance is bounded by

Ptνπtv12t exp(O(n)).

So, for convergence to less than ε=14, for example, we must require at least 2O(a) steps. This proves the statement.

B Proof of Theorem 2

In this section, we prove the main result of the paper, Theorem 2. First, we state some basic lemmas we will need for the proof in Section B. 1. Then, we prove the main result inductively in Section B.2. Finally, we prove the lemmas in Section B.3.

B.1 Statement of Lemmas

Note that some of these lemmas are restated from the body of the paper.

Definition 10 (Absolute Spectral Gap)

Let P be the transition matrix of a Markov process. Since it is a Markov process, one of its eigenvalues, the dominant eigenvalue, must be 1. The absolute spectral gap of the Markov process is the value

γ=1maxλ|λ|,

where the maximum is taken over all non-dominant eigenvalues of P.

Lemma 5 (Disconnected Case)

Let G be a disconnected factor graph with n variables and m connected components G1, G2, …, Gm with n1, n2, …, nm variables, respectively. Then,

γ(G)minimninγ(Gi).

Lemma 4 (Connected Case)

Let G and Ḡ be two factor graphs with maximum factor weight M, which differ only in as much as G contains a single additional factor ϕ*. Then,

γ(G)γ() exp (3M).

Lemma 6 (Base Case)

Let G be a factor graph with one variable and no factors. The absolute spectral gap of Gibbs sampling running on G will be γ(G) = 1.

Lemma 8

Let P be the transition matrix of a reversible, irreducible Markov chain with state space Ω and absolute spectral gap γ, and let πmin = minx∈π π(x). Then

tmix(ε)log (επmin)1γ.
Proof

This is Theorem 12.3 from Markov Chains and Mixing Times [10, p. 155], and a complete proof can be found in that book.

B.2 Main Proof

We achieve the proof of Theorem 2 in two steps. First we inductively bound the absolute spectral gap of Gibbs sampling on factor graphs in terms of the hierarchy width. Then, we use the bound on the spectral gap to bound the mixing time.

Lemma 9

If G is a factor graph with n variables, maximum factor weight M and hierarchy width h, then Gibbs sampling running on G will have absolute spectral gap γ, where

γ1nexp (3hM).
Proof

We will prove this result by multiple induction on the number of variables and number of factors of G. In what follows, we assume that the statement holds for all graphs with either fewer variables and no more factors than G, or fewer factors and no more variables than G.

Consider the connectedness of G. There are three possibilities:

  1. G has one variable and no factors.

  2. G is connected and has at least one factor.

  3. G is disconnected.

We consider these cases separately.

Case 1

If G has no factors and one variable, then by Lemma 6, its spectral gap will be

γ=1.

Also, if G has no factors, by (4), its hierarchy width is h = 0. Therefore,

γ=11exp(0)=1nexp(3hM),

which is the desired result.

Case 2

Next, we consider the case where G is connected and has at least one factor. In this case, by (2), its hierarchy width is

hw(G)=1+mineEhw(N,E{e}).

Let e be an edge that minimizes this quantity, and let denote the factor graph that results from removing the corresponding factor from G. Clearly,

hw(G)=1+hw().

Since G and differ by only one factor, by Lemma 4,

γγ¯ exp (3M).

Furthermore, since has fewer factors than G, by the inductive hypothesis,

γ¯1nexp (3Mhw()).

Therefore,

γγ¯ exp (M)1nexp (3Mhw()) exp (3M)=1nexp (3M(1+hw()))=1nexp (3Mhw(G)),

which is the desired result.

Case 3

Finally, consider the case where G is disconnected. Let G1, G2, …, Gm be the connected components of G for some m ≥ 2. In this case, by (3), its hierarchy width is

hw(G)=maxihw(Gi).

By Lemma 5,

γ=minimninγi,

where ni are the sizes of the Gi and γi are their absolute spectral gaps. We further know that each of the Gi has fewer nodes than G, so by the inductive hypothesis,

γi1niexp (3Mhw(Gi)).

Therefore,

γ=minimninγiminimnin1niexp (3Mhw(Gi))=minim1nexp (3Mhw(Gi))=1nexp (3Mmaximhw(Gi))=1nexp (3Mhw(G)),

which is the desired result.

Since the statement holds in all three cases, by induction it will hold for all factor graphs. This completes the proof.

Now, we restate and prove the main theorem.

Theorem 2 (Polynomial Mixing Time)

If G is a factor graph with n variables, at most s states per variable, e factors, maximum factor weight M, and hierarchy width h, then

tmix(log(4)+n log(s)+eM)n exp(3hM).

In particular, if e is polynomial in n, the number of values for each variable is bounded, and hM = O(log n), then tmix(ε) = O(nO(1)).

Proof

From Lemma 8, we have that

tmix(ε)log (επmin)1γ.

For our factor graph G,

πmin=minIπ(I)=minI exp(W(I))Jexp(W(J)).

Since there are only at most sn worlds, it follows that

πminminI exp(W(I))snmaxJ exp(W(J))=sn exp (minIW(I)maxJW(J)).

Expanding the world weight in terms of the factors,

πminsn exp (minIϕΦϕ(I)maxJϕΦϕ(J))sn exp (ϕΦ(minIϕ(I)maxJϕ(J))).

Applying our maximum factor weight bound,

πminsn exp (ϕΦM)=sn exp (eM).

Substituting this into the expression from Lemma 8 produces

tmix(ε)log (εsnexp (eM))1γ=(n log(s)+eMlog(ε))1γ,

and substituting the result from Lemma 9 gives

tmix(ε)(n log(s)+eMlog(ε))n exp(3hM).

Substituting ε=14 gives the desired result.

B.3 Proofs of Lemmas

In this statement, we will restate and prove the lemmas stated above in Section B.I.

Lemma 5 (Disconnected Case)

Let G be a disconnected factor graph with n variables and m connected components G1, G2, …, Gm with n1, n2, … nm variables, respectively. Then,

γ(G)minimninγ(Gi).
Proof

Lemma 5 follows directly from Corollary 12.12 in Markov Chains and Mixing Times [10, p. 161]. For completeness, we restate the proof here.

Since G is disconnected, Gibbs sampling on G is equivalent to running m independent Gibbs samplers on the Gi, where at each timestep, the Gibbs sampler of Gi is updated if a variable in Gi is chosen; this occurs with probability nin. Therefore, if we let Pi denote the Markov transition matrix of Gibbs sampling on Gi, we can write the transition matrix P of Gibbs sampling on G as

P(x,y)=i=1mninPi(xi,yi)jiI(xj,yj),

where x and y are worlds on G, where xi and yi are subsets of the variables of x and y respectively that correspond to the graph Gi, and I is the identity matrix (I(x, y) = 1 if x = y, and I(x, y) = 0 otherwise).

Now, we, for each i, we let fi be some eigenvector of Pi with eigenvalue λi, and define

f(x)=i=1mfi(xi).

It follows that

(Pf)(y)=xf(x)P(x,y)=xf(x)i=1mninPi(xi,yi)jiI(xj,yj)=xi=1mninfi(xi)Pi(xi,yi)jifj(xj)I(xj,yj)=i=1mninxifi(xi)Pi(xi,yi)jixjfj(xj)I(xj,yj)=i=1mninλifi(yi)jifj(yi)=f(y)i=1mninλi;

if follows that f is an eigenvector of P with eigenvalue

λ=i=1mninλi. (9)

Furthermore, it is clear that such eigenvectors will form a basis for the space of possible distributions on the worlds of G. Therefore, all eigenvalues of P will be of the form (9), and so

|λ|i=1mnin|λi|.

Therefore,

γ=minλ1(1|λ|)minλ1i=1mnin(1|λi|)miniminλi1nin(1|λi|)=minininγi,

which is the desired result.

To prove Lemma 4, we will need to first prove two other lemmas.

Lemma 10

Let G and Ḡ be two factor graphs, which differ only in as much as G contains a single additional factor ϕ* with maximum factor weight M. Then, if π and π̄ denote the distributions on worlds for these graphs,

exp(M)π¯(x)π(x)exp(M)π¯(x).
Proof

From the definition of the distribution function,

π(x)=exp(W(x))zΩexp(W(z))=exp(W¯(x)+ϕ*(x))zΩexp(W¯(z)+ϕ*(z))exp(W¯(x)+minIϕ*(I))zΩexp(W¯(z)+maxIϕ*(I))=exp(W¯(x))zΩexp(W¯(z))exp (minIϕ*(I)maxIϕ*(I))=exp(M)π¯(x).

In the other direction,

π(x)=exp(W¯(x)+ϕ*(x))zΩexp(W¯(z)+ϕ*(z))exp(W¯(x)+maxIϕ*(I))zΩexp(W¯(z)+minIϕ*(I))=exp(W¯(x))zΩexp(W¯(z))exp (maxIϕ*(I)minIϕ*(I))=exp(M)π¯(x).

This proves the lemma.

Lemma 11

Let G and Ḡ be two factor graphs, which differ only in as much as G contains a single additional factor ϕ* with maximum factor weight M. Then, if P and P̄ denote the transition matrices for Gibbs sampling on these graphs, for all xy,

exp(M)P¯(x,y)P(x,y)exp(M)P¯(x,y).
Proof

For Gibbs sampling on G, we know that, if worlds x and y differ in the value of only one variable, and L is the set of worlds that only differ from x and y in the same variable, then

P(x,y)=1nexp(W(y))lLexp(W(l))

If is the transition matrix for Gibbs sampling on , then the same argument will show that

P¯(x,y)=1nexp(W¯(y))lLexp(W¯(l)).

Therefore,

P(x,y)=1nexp(W¯(y)+ϕ*(y))lLexp(W¯(l)+ϕ*(y))1nexp(W¯(y)+minIϕ*(I))lLexp(W¯(l)+maxIϕ*(I))=1nexp(W¯(y))lLexp(W¯(l))exp (minIϕ*(I)maxIϕ*(I))=exp(M)P¯(x,y).

Similarly,

P(x,y)=1nexp(W¯(y)+ϕ*(y))lLexp(W¯(l)+ϕ*(y))1nexp(W¯(y)+maxIϕ*(I))lLexp(W¯(l)+minIϕ*(I))=1nexp(W¯(y))lLexp(W¯(l))exp (maxIϕ*(I)minIϕ*(I))=exp(M)P¯(x,y).

On the other hand, if x and y differ in more than one variable, then

P(x,y)=P¯(x,y)=0.

Therefore, the lemma holds for any xy.

Now, we restate and prove Lemma 4.

Lemma 4 (Connected Case)

Let G and Ḡ be two factor graphs with maximum factor weight M, which differ only in as much as G contains a single additional factor ϕ*. Then,

γ(G)γ() exp (3M).
Proof

The proof is similar to proofs using the Dirichlet form to bound the spectral gap [10, p. 181].

Recall that Gibbs sampling is a reversible Markov chain. That is, if P is the transition matrix associated with Gibbs sampling on G, and π is its stationary distribution,

π(x)P(x,y)=π(y)P(y,x).

If we let Π be the diagonal matrix such that Π(x, x) = π(x), then we can write this as

PΠ=ΠPT;

that is, A = PΠ is a symmetric matrix. Now, consider the form

α(f)=12x,y(f(x)f(y))2π(x)P(x,y).

Expanding this produces

α(f)=12x,yf(x)2π(x)P(x,y)x,yf(x)f(y)π(x)P(x,y)+12x,yf(y)2π(x)P(x,y).

By reversibility of the chain,

α(f)=12x,yf(x)2π(x)P(x,y)x,yf(x)f(y)π(x)P(x,y)+12x,yf(y)2π(y)P(y,x)=x,yf(x)2π(x)P(x,y)x,yf(x)f(y)π(x)P(x,y)=xf(x)2π(x)yP(x,y)x,yf(x)f(y)π(x)P(x,y)=xπ(x)f(x)2x,yf(x)f(y)A(x,y)=fTΠffTAf=fT(IP)Πf.

Similarly, if we define

β(f)=12x,y(f(x)+f(y))2π(x)P(x,y),

then the same logic will show that

β(f)=fT(I+P)Πf.

We define Ā, ᾱ and β̄ similarly for Gibbs sampling on .

Now, by Lemmas 10 and 11,

α(f)=12x,y(f(x)f(y))2π(x)P(x,y)12x,y(f(x)f(y))2 exp(2M)π¯(x)P¯(x,y)=exp(2M)α¯(f).

It follows that

fT(IP)Πfexp(2M)fT(IP¯)Π¯f.

We also notice that, by Lemma 10,

fT(ΠππT)f=fTΠf(πTf)2=xf(x)2π(x)(yf(y)π(y))2=x(f(x)yf(y)π(y))2π(x)x(f(x)yf(y)π¯(y))2π(x)exp(M)x(f(x)yf(y)π¯(y))2π¯(x)=exp(M)(xf(x)2π¯(x)(yf(y)π¯(y))2)=exp(M)fT(Π¯π¯π¯T)f

Therefore,

fT(IP)ΠffT(ΠππT)fexp(3M)fT(IP¯)Π¯ffT(Π¯π¯π¯T)f. (10)

Now, let’s explore the quantity

minffT(IP)ΠffT(ΠππT)f. (11)

First, we notice that

(IP)Π1=(IP)π=ππ=0,

so 1 is an eigenvector of (IP)Π with eigenvalue 0. Furthermore,

(ΠππT)1=(πππT1)=ππ=0,

so 1 is also an eigenvector of (IP)Π with eigenvalue 0. It follows that (11) is invariant to additions of the vector 1 to f, and in particular we can therefore choose to minimize over only those vectors for which πT f = 0. Therefore,

minffT(IP)ΠffT(ΠππT)f=minπTg=0gT(IP)ΠggTΠg=minπTg=0gTΠ12Π12(IP)Π12Π12ggTΠg.

If we let h=Π12g, then

minffT(IP)ΠffT(ΠππT)f=min1TΠ12h=0hTΠ12(IP)Π12hhTh.

Notice that Π12(IP)Π12 is similar to IP, and so it must have the same eigenvalues. Since it is symmetric, it has an orthogonal complement of eigenvectors, and the eigenvector that corresponds to λ = 0 is

(Π12(IP)Π12)(Π121)=Π12(IP)π=Π12(ππ)=0.

The expression above is minimizing over all vectors orthogonal to this eigenvector; it follows that the minimum will be the second smallest eigenvalue of IP. This eigenvalue will be 1 − λ2, where λ2 is the second-largest eigenvalue of P. So,

minffT(IP)ΠffT(ΠππT)f=1λ2.

The same argument will show that

minffT(IP¯)Π¯ffT(Π¯π¯π¯T)f=1λ¯2.

Therefore, minimizing both sides in (10) produces

1λ2exp(3M)(1λ¯2).

And applying the definition of absolute spectral gap,

1λ2exp(3M)γ¯

Now, a similar argument to the above will show that

fT(I+P)ΠffTΠfexp(3M)fT(I+P¯)Π¯ffTΠ¯f.

And we will be able to conclude that

minffT(I+P)ΠffTΠf=1λn,

where λn is the (algebraically) smallest eigenvalue of P, and similarly for λ̄n. Therefore, we can conclude that

1+λnexp(3M)(1+λ¯n),

and from the definition of absolute spectral gap,

1+λnexp(3M)γ¯.

Therefore,

γmin(1λ2,1+λn)exp(3M)γ¯.

This proves the lemma.

Next, we restate and prove Lemma 6

Lemma 6 (Base Case)

Let G be a factor graph with one variable and no factors. The absolute spectral gap of Gibbs sampling running on G will be γ(G) = 1.

Proof

Gibbs sampling on a factor graph with one variable and no factors will have transition matrix

P=π1T,

where π is the stationary distribution, and 1 is the vector of all 1s. That is, the process achieves the stationary distribution in a single step. The only eigenvalues of this matrix are 0 and 1, so the absolute spectral gap will be 1, as desired.

C Proofs of Other Results

In this section, we will prove the other results about hierarchy decomposition stated in Section 2.3. First, we express it in terms of a hypergraph decomposition; this is how hypertree width is defined so it is useful for comparison.

Definition 11 (Hierarchy Decomposition)

A hierarchy decomposition of a hypergraph G = 〈N, E〉 is a rooted tree T where each node υ of T is labeled with a set χ(υ) of edges of G, that satisfies the following conditions: (1) for each edge eE, there is some node υ of T such that e ∈ χ(υ); (2) if for two nodes u and υ of T and for some edge eE, both e ∈ χ(u) and e ∈ χ(υ), then for all nodes w on the (unique) path between u and υ in T, e ∈ χ(w); (3) for every pair of edges eE and fE, if ef ≠ ∅, then there exists a node υ of T such that {e, f} ⊆ χ(υ); and (4) if node u is the parent of node υ in T, then u ⊆ υ.

The width of a hierarchy decomposition is the size of the largest node in T, that is, maxυ |χ(υ)|.

Statement 9

The hierarchy width of a hypergraph G is equal to the minimum width of a hierarchy decomposition of G.

In this section, we denote the width of a hierarchy decomposition T as w(T).

Lemma 12

Let T be a hierarchy decomposition of a hypergraph G. Let u be a node of T that has exactly one child υ, and let e be the edge connecting u and υ. Let T̄ be the graph minor of T that is formed by removing u from T and, if applicable, connecting υ with the parent of u; assume that the nodes T̄ have the same labeling as the corresponding nodes in T. Then T̄ is a hierarchy decomposition of G, and

w(T)=w(T¯).

Proof

We validate the conditions of the definition of hierarchy decomposition individually.

  1. Since T is a hierarchy decomposition of G, by condition (1), for any hyperedge e of G, there exists a node x of T such that e ∈ χT(x). If xu, then e ∈ χ(x). Otherwise, by condition (4) of T, it will hold that χT(u) ⊆ χT(υ) = χ(υ), so e ∈ χ(υ). Since this is true for any hyperedge e, the condition holds.

  2. Since we constructed by removing a node from T and connecting its neighbors, it follows that if the path from node x to node y in passes through a node z, then the path from x to y in T also passes through z. The condition then follows directly from condition (2) of T.

  3. The argument here is the same as the argument for condition (1).

  4. This condition follows directly from transitivity of the subset relation.

Therefore, is a hierarchy decomposition of G. To show that w(T) = w(), it suffices to notice that removing node u from T can’t change its width, since node υ has at least as many hyperedges in its labeling as u. This proves the lemma.

Lemma 13

Let T be a hierarchy decomposition of a hypergraph G. Let u be a node of T, and let υ be a child of T such that χT(u) = χT(υ). Let T̄ be the graph minor of T that is formed by identifying u and υ by contracting along their connecting edge. Assume that the nodes T̄ have the same labeling as the corresponding nodes in T, and that the new node, w, has χ(w) = χT(u) = χT(υ). Then T is a hierarchy decomposition of G, and

w(T)=w(T¯).

Proof

We validate the conditions of the definition of hierarchy decomposition individually.

  1. The set of labelings of is exactly the same as the set of labelings of T. Since T is a hierarchy decomposition of G, the condition follows directly from condition (1) of T.

  2. Similarly, the set of labelings of any path in is the same as the set of labeling of the corresponding path in T. The condition then follows directly from condition (2) of T.

  3. The argument here is the same as the argument for condition (1).

  4. The labeling of every node’s parent in will be the same as the labeling of that node’s parent in T. Therefore, the condition follows from condition (3) of T.

Therefore, is a hierarchy decomposition of G. To show that w(T) = w(), it suffices to notice the set of labelings of nodes of is the same as the set of labelings of nodes of T; therefore they must have the same width.

Lemma 14

For any factor graph G and for any hierarchy decomposition T of G,

w(T)hw(G).

Proof

As in the proof of Lemma 9, we will prove this result by multiple induction. In what follows, we assume that the statement holds for all graphs with either fewer vertexes and no more hyperedges than G, or fewer hyperedges and no more vertexes than G. We also assume that for a particular G, the statement holds for all hierarchy decompositions of G that have fewer nodes than T.

There are five possibilities:

  1. The root r of T is labeled with χ(r) = ∅, and r has no children.

  2. The root r of T is labeled with χ(r) = ∅, and r has one child.

  3. The root r of T is labeled with χ(r) = ∅, and r has two or more children, at least one of which, x, is also labeled with χ(x) = ∅.

  4. The root r of T is labeled with χ(r) = ∅, and r has two or more children, none of which are labeled with the empty set.

  5. The root r of T is labeled with χ(r) ≠ ∅.

We consider these cases separately.

Case 1

If r is labeled with the empty set and has no children, then it follows from condition (1) that there are no hyperedges in G. Therefore, hw(G) = 0. Also, since r is labeled with the empty set, w(T) = 0. So, the statement holds in this case.

Case 2

If r has exactly one child, then by Lemma 12, there is a hierarchy decomposition of G such that has fewer nodes than T and w(T) = W(). By the inductive hypothesis,

w(T¯)hw(G).

So, the statement holds in this case.

Case 3

If r is labeled with the empty set and has two or more children, at least one of which is also labeled with the empty set, then by Lemma 13, there is a hierarchy decomposition of G such that has fewer nodes than T and w(T) = w(). By the inductive hypothesis,

w(T¯)hw(G).

So, the statement holds in this case.

Case 4

Consider the case where r is labeled with the empty set and has two or more children, none of which are labeled with the empty set. Let T1, T2, …, Tl be the labeled subtrees rooted at the children of r. Notice that if a hyperedge e appears in the labeling of some node of Ti, then it can’t appear in the labeling of any node of Tj for ij, since otherwise by condition (2) it must appear in the labeling of the root node r, and r has an empty labeling. Therefore, the hyperedges of G are partitioned among the subtrees Ti. Furthermore, condition (3) implies that hyperedges associated with different subtrees are disconnected, and therefore that graph G is disconnected. Therefore, if we let Gi denote the m connected components of G.

hw(G)=maximhw(Gi).

Now, let i, for il, denote the subgraph of G that consists of the nodes that are connected to a hyperedge in a labeling of a node of Ti. Clearly, the i, will be disconnected, so

hw(G)=maxilhw(i).

Each i will also have fewer vertexes and hyperedges than G, so by the inductive hypothesis,

w(Ti)hw(i).

Therefore,

w(T)=maxilw(Ti)maxilhw(i)=hw(G);

so the statement holds in this case.

Case 5

Finally, consider the case where the root node r is labeled with some hyperedge e. Let be the graph that results from removing e from G, and let be the hierarchy decomposition that results from removing e from all the labellings of T. Clearly, will be a hierarchy decomposition of . Furthermore, has fewer hyperedges and the same number of vertexes as G, so by the inductive hypothesis,

w(T¯)hw().

Furthermore, since removing e decreases the size of each of the labelings of by 1,

w(T¯)=w(T)1.

Therefore,

w(T¯)hw()+1hw(G),

so the statement holds in this case.

Therefore, the statement holds in all cases, so the lemma follows from induction on all hypergraphs and all hierarchy decompositions.

Lemma 15

For any factor graph G, there exists a hierarchy decomposition T of G such that

w(T)=hw(G).

Proof

As in the proof of Lemma 9, we will prove this result by multiple induction. In what follows, we assume that the statement holds for all graphs with either fewer vertexes and no more hyperedges than G, or fewer hyperedges and no more vertexes than G.

There are three possibilities:

  1. G has no hyperedges.

  2. G is disconnected.

  3. G is connected.

We consider these cases separately.

Case 1

If G has no hyperedges, then the tree T with a single node labeled with the empty set is a hierarchy decomposition for G. It will satisfy

w(T)=0.

Also, by (4), for the case with no hyperedges,

hw(G)=0.

so the statement holds in this case.

Case 2

Assume that G is disconnected, and its connected components are Gi. Then by (3),

hw(G)=maxihw(Gi).

Since each Gi has fewer nodes and hyperedges than G, by the inductive hypothesis there exists a hierarchy decomposition Ti for each Gi, such that

w(Ti)=hw(Gi).

Let T be the tree that has a root node labeled with the empty set, and where the subtrees rooted at its children are exactly the Ti above. We now show that T is a hierarchy decomposition for G by validating the conditions.

  1. Any hyperedge e of G must be a hyperedge of exactly one Gi. Since Ti is a hierarchy decomposition of Gi, by condition (1) it follows that e appears in the labeling of some node of Gi. Therefore, e will appear in the labeling of the corresponding node of G, and the condition holds.

  2. Again, any hyperedge e of G must be a hyperedge of exactly one Gi. Therefore, if e appears in two nodes of T, those two nodes must both be part of the same subtree Ti. The condition follows from the corresponding condition of Ti.

  3. Since G is disconnected, any pair of hyperedges in G that share a vertex must both be part of exactly one Gi. The condition then follows from the corresponding condition of Ti.

  4. This condition follows directly from the fact that for any X, θ ⊆ X, and from the corresponding condition for the subgraphs Ti.

Therefore T is a hierarchy decomposition for G. Furthermore, since the labelings of nodes of T are the union of the labelings of nodes of Ti,

w(T)=maxiw(Ti).

Therefore,

hw(G)=maxihw(Gi)=maxiw(Ti)=w(T),

so the statement holds in this case.

Case 3

Assume that G is connected. Then by (2),

hw(G)=1+mineEhw(N,E{e}).

Let b be a hyperedge that minimizes this quantity, and let be the graph that results from removing this hyperedge from G. Then,

hw(G)=1+hw(G¯).

Now, has fewer hyperedges than G, so by the inductive hypothesis, there exists a hierarchy decomposition of such that

hw(G¯)=w(T¯).

Let T be the tree that results from adding edge b to every labeling of a node of . Clearly,

w(T)=w(T¯)+1.

We now show that T is a hierarchy decomposition for G by validating the conditions.

  1. Any hyperedge e of G is either hyperedge b or some hyperedge in . If it is b, then it must appear in a labeling of a node of T since it appears in all such labelings. Otherwise, the condition follows from the corresponding condition of .

  2. Again, any hyperedge e of G is either hyperedge b or some hyperedge in . If it is b, then the condition follows from the fact that all node labelings of T contain b. Otherwise, the condition follows from the corresponding condition of .

  3. For any pair of edges (e, f) of G, either b ∉ {e, f}, or b ∈ {e, f}. If b ∈ {e, f}, then the condition follows from condition (1) of and the fact that all node labelings of T contain b; otherwise, the condition follows from the corresponding condition of .

  4. This condition follows directly from the fact that for any X and Y, if XY, then X ∪ {b} ⊆ Y ∪ {b}.

Therefore T is a hierarchy decomposition for G, and

w(T)=w(T¯)+1=hw(G¯)+1=hw(G),

so the statement holds in this case.

Therefore the statement holds in all cases, so the lemma follows from induction over all factor graphs.

Next, we restate and prove Statement 9.

Statement 9

The hierarchy width of a hypergraph G is equal to the minimum width of a hierarchy decomposition of G.

Proof

This statement follows directly from Lemmas 14 and 15.

Now, we provide a definition for hypertree width, and prove the comparison statements from the body of the paper.

Definition 12 (Hypertree Decomposition [6])

A hypertree decomposition of a hypergraph G is a structure 〈T, ρ, χ〉, where 〈T, ρ〉 is a tree decomposition for the primal graph of G, χ is a labeling of the nodes of T with hyperedges of χ and the following conditions are satisfied: (1) for any node u of T, and for all vertices x ∈ ρ(u), there exists an edge e ∈ χ(u) such that xe; and (2) for any node u of T, for any edge e ∈ χ(u), and for any descendant ν of u in T, e ∩ ρ(ν) ⊆ ρ(u).

The width of a hypertree decomposition, denoted w(T), is defined (as in the hierarchy decomposition case) to be the cardinality of the largest hyperedge-labeling of a node of T. That is,

w(T)=maxu|χ(u)|.

The hypertree width tw(G) of a graph G is the minimum width among all hypertree decompositions of G.

We restate and prove Statement 1.

Statement 1

For any factor graph G, tw(G) ≤ hw(G).

Proof

Consider the hierarchy decomposition T of G that satisfies w(T) = hw(G). Assume that we augment T with an additional node labeling ρ(ν) that consists of the vertexes of G that are part of at least one edge of χ(ν) (that is, ρ(ν) = ∪χ(ν)). We show that T is a hypertree decomposition of G.

First, we must show that 〈T, ρ〉 is a tree decomposition for the primal graph of G; we do so by verifying the conditions independently.

  1. Each vertex of G must appear in the labeling of some node of T, since (by assumption) it must appear in some hyperedge of G, and each hyperedge appears in the labeling of some node of T because T is a hierarchy decomposition of G.

  2. Similarly, any two vertexes (x, y) that are connected by an edge in the primal graph of G must appear together in some hyperedge of G. Since each hyperedge of G appears in the edge-labeling of some node of T, it follows that x and y must both appear in the vertex-labeling of that node.

  3. Finally, assume that vertex x appears in the labeling of two different nodes u and ν of T. Since x ∈ ρ(u), there must exist an edge e ∈ χ(u) such that xe; similarly, there must be an edge f ∈ χ(ν) such that xf. By condition (3) of the definition of hierarchy decomposition, there must exist a node w of T such that {e, f} ⊆ χ(w). By condition (2) of the definition of hierarchy decomposition, for all nodes z on the path between u and w, e ∈ χ(z); similarly, for all nodes z on the path between ν and w, f ∈ χ(z). Now, any node z on the path between u and ν must be either part of the path between u and w and the path between ν and w, therefore either e ∈ χ(z) or f ∈ χ(z). It follows that x ∈ ρ(z), as desired.

Therefore T is a tree decomposition for the primal graph of G.

Next, we show that the T is also a hypertree decomposition for G by verifying the conditions independently.

  1. For any node u of T, and for all vertices x ∈ ρ(u), there must exist an edge e ∈ χ(u) such that xe, because ρ(u) = ∪χ(ν). Therefore the condition holds.

  2. For any node u of T and for any descendant ν of u in T, we know from condition (4) of the definition of hierarchy decomposition that χ(u) ⊆ χ(ν). So, for any edge e ∈ χ(u), it also holds that e ∈ χ(ν). Therefore, e ∩ ρ(ν) = e ⊆ ρ(u), and so the condition holds.

We conclude that T is a hypertree decomposition for G. But, its width is hw(G). Since the hypertree width of G is the minimum width among all hypertree decompositions of G, it follows that

tw(G)hw(G),

which is the desired expression.

Next, we restate and prove Statement 2.

Statement 2

For any fixed k, computing whether hw(G) ≤ k can be done in time polynomial in the number of factors of G.

Proof

Consider Algorithm 1, which computes this quantity for a fixed k.

Algorithm 1.

HW(G, k): Compute if hw(G) ≤ k

if G has no edges then
    return true
end if
if k = 0 then
    return false
end if
for e ∈ edges(G) do
    Let be the graph that results from removing e from the connected component of G that
    contains e
    if HW(Ḡ, k − 1) then
        return true
    end if
end for
return false

Each execution of HW requires at most linear time in the number of hyperedges of G to compute its connected components. If we let e be the number of hyperedges of G, it also requires at most e executions of G with parameter k − 1. Therefore, HW will run in time O(ek), which is polynomial in the number of hyperedges, as desired.

As an aside here, we note that the hierarchy width can be expressed in terms of an existing graph parameter, the tree-depth [29, p. 115], which we denote td(G). To do this, we let L(G), the line graph of G, denote the graph such that every factor of G is a node of L(G), and two nodes of L(G) are connected by an edge if and only if their corresponding factors share a dependent variable. Using this, it is trivial to show (by definition) that

hw(G)=td(L(G)).

Since it is a known result that it is possible to compute whether a graph has tree-depth at most k in time polynomial (in fact, linear) in the number of nodes of the graph, we could have also used this to prove Statement 2; we avoided doing this to make the result more accessible.

Statement 10

The hierarchy width of a factor graph G is greater than or equal to the maximum degree of a variable in G.

Finally, we restate and prove Statement 10.

Statement 10

The hierarchy width of a factor graph G is greater than or equal to the maximum degree of a variable in G.

Proof

The statement follows by induction. Considering the parts of the definition of hierarchy width individually, removing a single hyperedge from a hypergraph only decreases the maximum degree of the hypergraph by at most 1, and splitting the hypergraph into connected components doesn’t change the maximum degree.

D Proofs of Factor Graph Template Results

In this section, we prove the results in Section 3.1. First, we prove Lemma 16.

Lemma 16

If G is an instance of a hierarchical factor graph template 𝒢 with E template factors, then hw(G) ≤ E.

Lemma 16

If G is an instance of a hierarchical factor graph template 𝒢 with E template factors, then hw(G) ≤ E.

Proof

We prove this result using the notion of hierarchy decomposition from the previous section. For the instantiated factor graph G, let T be a tree where each node ν of T is associated with a particular assignment of the first n head symbols of the rules. That is, there is a node of T for each tuple of object symbols (x1,…, xm)—even for m = 0. (Since the rules are hierarchical, and therefore must contain the same symbols in the same order, these assignments are well-defined.)

Label each node ν of T with the set containing all the instantiated factors of G that agree with this assignment of head variables. That is, if the head variable assignment for a factor ϕ is (y1,…, yp), then it will be in the labeling of the node ν = (x1,…, xm) if and only if mp and for all ip, yi= xi. It is not hard to show that this is a valid hierarchy decomposition for this factor graph.

The width of this hierarchy decomposition is at most the number of template factors E because each node ν can only possibly contain a single instantiated factor for each template factor. (This is because for each node, only one possible assignment of head variables is compatible with that node.) The Lemma now follows from an application of Statement 9

Next, we restate and prove Statement 4.

Statement 4

For any fixed hierarchical factor graph template 𝒢, if G is an instance of 𝒢 with bounded weights using either logical or ratio semantics, then the mixing time of Gibbs sampling on G is polynomial in the number of objects n in its dataset. That is, tmix = O (nO(1)).

Proof

If we use either logical or ratio semantics, the maximum factor weight will be bounded with M = O(log n). We furthermore know from Lemma 16 that for a particular hierarchical template, the hierarchy width is bounded independent of the dataset. So, hM = O(log n), and the Statement now follows directly from an application of Theorem 2

Contributor Information

Christopher De Sa, Email: cdesa@stanford.edu.

Ce Zhang, Email: czhang@cs.wisc.edu.

Kunle Olukotun, Email: kunle@stanford.edu.

Christopher Ré, Email: chrismre@stanford.edu.

References

  • 1.Chandrasekaran Venkat, Srebro Nathan, Harsha Prahladh. Complexity of inference in graphical models. arXiv preprint arXiv:1206.3204. 2012 [Google Scholar]
  • 2.Diaconis Persi, Khare Kshitij, Saloff-Coste Laurent. Gibbs sampling, exponential families and orthogonal polynomials. Statist. Sci. 2008 May;23(2):151–178. [Google Scholar]
  • 3.Diaconis Persi, Khare Kshitij, Saloff-Coste Laurent. Gibbs sampling, conjugate priors and coupling. Sankhya A. 2010;(1):136–169. [Google Scholar]
  • 4.Domingos Pedro, Webb William Austin. A tractable first-order probabilistic logic. AAAI. 2012 [Google Scholar]
  • 5.Gonzalez Joseph, Low Yucheng, Gretton Arthur, Guestrin Carlos. Parallel gibbs sampling: From colored fields to thin junction trees. AISTATS. 2011:324–332. [Google Scholar]
  • 6.Gottlob Georg, Greco Gianluigi, Scarcello Francesco. Treewidth and hypertree width. Tractability: Practical Approaches to Hard Problems. 2014:1. [Google Scholar]
  • 7.Ihler Alexander T, Iii John, Willsky Alan S. Loopy belief propagation: Convergence and effects of message errors. Journal of Machine Learning Research. 2005:905–936. [Google Scholar]
  • 8.Koller Daphne, Friedman Nir. Probabilistic graphical models: principles and techniques. MIT press; 2009. [Google Scholar]
  • 9.Kwisthout Johan, Bodlaender Hans L, van der Gaag Linda C. The necessity of bounded treewidth for efficient inference in bayesian networks. ECAI. 2010:237–242. [Google Scholar]
  • 10.Levin David Asher, Peres Yuval, Wilmer Elizabeth Lee. Markov chains and mixing times. American Mathematical Soc. 2009 [Google Scholar]
  • 11.Liu Xianghang, Domke Justin. Projecting markov random field parameters for fast mixing. In: Ghahramani Z, Welling M, Cortes C, Lawrence ND, Weinberger KQ, editors. Advances in Neural Information Processing Systems 27. Curran Associates, Inc; 2014. pp. 1377–1385. [Google Scholar]
  • 12.Lunn David, Spiegelhalter David, Thomas Andrew, Best Nicky. The BUGS project: evolution, critique and future directions. Statistics in medicine. 2009;(25):3049–3067. doi: 10.1002/sim.3680. [DOI] [PubMed] [Google Scholar]
  • 13.Marx Dániel. Tractable hypergraph properties for constraint satisfaction and conjunctive queries. Journal of the ACM (JACM) 2013;(6):42. [Google Scholar]
  • 14.McCallum Andrew, Schultz Karl, Singh Sameer. Factorie: Probabilistic programming via imperatively defined factor graphs. NIPS. 2009:1249–1257. [Google Scholar]
  • 15.Newman David, Smyth Padhraic, Welling Max, Asuncion Arthur U. Distributed inference for latent dirichlet allocation. NIPS. 2007:1081–1088. [Google Scholar]
  • 16.Ng Kee Siong, Lloyd John W, Uther William TB. Probabilistic modelling, inference and learning using logical theories. Annals of Mathematics and Artificial Intelligence. 2008;(1–3):159–205. [Google Scholar]
  • 17.Peters Shanan E, Zhang Ce, Livny Miron, Ré Christopher. A machine reading system for assembling synthetic Paleontological databases. PloS ONE. 2014 doi: 10.1371/journal.pone.0113523. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 18.Poole David. IJCAI. Citeseer: 2003. First-order probabilistic inference; pp. 985–991. [Google Scholar]
  • 19.Robertson Neil, Seymour Paul D. Graph minors. ii. algorithmic aspects of tree-width. Journal of algorithms. 1986;(3):309–322. [Google Scholar]
  • 20.Shin Jaeho, Wu Sen, Wang Feiran, De Sa Christopher, Zhang Ce, Wang Feiran, Ré Christopher. Incremental knowledge base construction using deepdive. PVLDB. 2015 doi: 10.14778/2809974.2809991. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 21.Singla Parag, Domingos Pedro. Lifted first-order belief propagation. AAAI. 2008:1094–1099. [Google Scholar]
  • 22.Smola Alexander, Narayanamurthy Shravan. An architecture for parallel topic models. PVLDB. 2010 [Google Scholar]
  • 23.Suciu Dan, Olteanu Dan, Ré Christopher, Koch Christoph. Probabilistic databases. Synthesis Lectures on Data Management. 2011;(2):1–180. [Google Scholar]
  • 24.Surdeanu Mihai, Ji Heng. Overview of the english slot filling track at the TAC2014 knowledge base population evaluation [Google Scholar]
  • 25.Theis Lucas, Sohl-dickstein Jascha, Bethge Matthias. Training sparse natural image models with a fast gibbs sampler of an extended state space. NIPS. 2012:1124–1132. [Google Scholar]
  • 26.Venugopal Deepak, Gogate Vibhav. On lifting the gibbs sampling algorithm. In: Pereira F, Burges CJC, Bottou L, Weinberger KQ, editors. NIPS. Curran Associates, Inc; 2012. pp. 1655–1663. [Google Scholar]
  • 27.Venugopal Deepak, Sarkhel Somdeb, Gogate Vibhav. Just count the satisfied groundings: Scalable local-search and sampling based inference in mlns. AAAI Conference on Artificial Intelligence. 2015
  • 28.Zhang Ce, Ré Christopher. DimmWitted: A study of main-memory statistical analytics. PVLDB. 2014 [Google Scholar]

Secondary Literature

  • 29.de Mendez Patrice Ossona, et al. Sparsity: graphs, structures, and algorithms. Springer Science & Business Media; 2012. [Google Scholar]
  • 30.den Hollander Frank. Probability Theory: The Coupling Method. 2012 [Google Scholar]

RESOURCES