



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Notes on Complexity Theory Last updated: October, 2005
Jonathan Katz
Recall from last time that a random walk on a graph gave us an RL algorithm for the problem of undirected graph connectivity. In this class, we also saw an RP algorithm for solving 2-SAT (see [2, Chapter 7] for details). We now develop some of the theory behind Markov chains and random walks on (undirected) graphs, toward a proof of the following result that was used to analyze both of the above algorithms:
Theorem 1 Consider a random walk on an undirected, connected, non-bipartite graph G with ℓ self-loops and m (other) edges. If there is an edge in G from vertex i to vertex j then the expected time for a random walk, starting at i, to reach j is less than 2 m + ℓ.
Let us begin with a brief introduction to (finite, time-homogeneous) Markov chains and random walks on graphs, along with a proof of a central result in this area. (Some of the definitions and results that follow need to be modified slightly for the case of infinite Markov chains.) For finite state space Ω, a sequence of random variables X 0 ,... on Ω is a Markov chain if there exist {pi,j } such that, for all t > 0 and x 0 ,... , xt− 2 , xi, xj ∈ Ω we have:
Pr[Xt = xj | X 0 = x 0 ,... , Xt− 2 = xt− 2 , Xt− 1 = xi] = Pr[Xt = xj | Xt− 1 = xi] = pi,j.
(From now on, we write i instead of xi for brevity.) In other words, the transition from Xt− 1 to Xt is memoryless and depends only on the value of Xt− 1 ; furthermore, the probability of a transition from state i to state j is time-independent. The t-step transition probabilities pti,j are defined in the natural way:
pti,j =
p ∑i,j t = 1 k∈Ω pi,k^ ·^ p
t− 1 k,j t >^1
Viewing the {pi,j } as an |Ω| × |Ω| matrix P (called the transition matrix ), the values {pti,j } corre- spond to the matrix P t. A finite Markov chain corresponds in the natural way to a random walk on a (possibly directed and/or weighted) graph. Focusing on undirected and non-weighted graphs (which is all we will ultimately be interested in for the purposes of these notes), a random walk on such a graph proceeds as follows: if we are at a vertex v at time t, we move to a random neighbor of v at time t + 1. If Ω are the vertices of this graph, such a random walk defines the Markov chain given by:
pi,j =
1 /deg(i) j is a neighbor of i 0 otherwise.
We remark that we allow self-loops in the graph. A self-loop contributes only 1 to the degree of the incident vertex.
Let π be a probability distribution over Ω, viewed as a row vector. We say π is stationary if π · P = π; equivalently, for all j ∈ Ω : π(j) =
i∈Ω
π(i) · pi,j.
We have the following fundamental theorem of random walks on undirected graphs (which is a corollary of a more general result for Markov chains):
Theorem 2 Let G be an undirected, connected, non-bipartite graph on n vertices. Then:
Note that for any undirected graph G, the conditions of the theorem can always be met by (1) re- stricting attention to a connected component of G, and (2) adding self-loops to all vertices. We will prove existence of a stationary distribution π as well as part 2 of the above theorem, and give an intuitive justification for part 3 (uniqueness of the stationary distribution, and the fact that all entries in π are non-zero, are left as exercises). Actually, we will prove a more general result for ergodic Markov chains: a finite Markov chain is ergodic if there exists a t 0 such that for all i, j and t > t 0 we have pti,j > 0. It is not too difficult to see that a random walk in an undirected, connected, non-bipartite graph defines an ergodic Markov chain, and so this is indeed a more general result. (In fact, it is not hard to see that the converse — a random walk in an undirected graph G defines an ergodic Markov chain only if G is connected and non-bipartite — holds as well.) Before proving the theorem, we introduce the notion of coupling and prove a lemma which will allow us to bound the statistical difference between two random variables. For distributions μ, ν over the same space Ω, a distribution ω on Ω × Ω is a coupling if the marginal distributions of ω give μ and ν, respectively; i.e.,
for all x ∈ Ω: μ(x) =
y∈Ω
ω(x, y)
for all y ∈ Ω: ν(y) =
x∈Ω
ω(x, y).
We have the following lemma:
Lemma 3 Let ω be a coupling of distributions μ, ν. Then:
SD(μ, ν) ≤ Pr (X,Y )←ω
where SD is the statistical difference between μ and ν, defined as:
SD(μ, ν) def =
x∈Ω
|μ(x) − ν(x)|.
and so on for any multiple kt∗. Since for t′^ > t we have Xt = Yt ⇒ Xt′ = Yt′ , we see that for any choice of initial states we have lim t→∞ Pr[Xt 6 = Yt] = 0.
By Lemma 3, this implies that the statistical difference between Xt and Yt goes to 0 as t approaches infinity. Fix some y ∈ Ω and for any x define at(x) = ptx,y. We first show: (1) at(x) converges for all x, and (2) at(x) converges to the same value for all x. In fact, setting X 0 = x 1 and Y 0 = x 2 and using the fact that the statistical difference between Xt and Yt goes to 0 as t approaches infinity, condition (2) follows immediately once we show (1). But (1) follows from the observation that we can set X 0 = x and Y 0 = πxP (where πx is the distribution in which x takes probability 1 and all other states have probability 0), so that the distribution of Yt is exactly the same as the distribution of Xt+1. It follows from the fact that SD(Xt, Yt) approaches 0 that SD(Xt, Xt+1) approaches 0; since at(x) is bounded (it is a probability, so 0 ≤ at(x) ≤ 1), it follows that the sequence converges.
Let π(y) def = limt→∞ ptx,y (by what we have just proved, the choice of x does not matter). We want to show that π is stationary. For any y ∈ Ω we have:
∑
x∈Ω
π(x) · px,y =
x∈Ω
t^ lim→∞ ptx^0 ,x
· px,y
= lim t→∞
x∈Ω
ptx 0 ,x · px,y
= lim t→∞ pt x+1 0 ,y = π(y) ,
as claimed (in the above, x 0 ∈ Ω \ {x} is an arbitrary state).
Given a Markov chain/random walk on a graph, we are often interested in the expected number of steps to go from vertex i to vertex j; this is known as the hitting time and is denoted hi,j. In particular, hi,i represents the expected time to walk from vertex i back to itself. We now heuris- tically argue — without giving a formal proof — that if the Markov chain has unique stationary distribution π, then hi,i = 1/π(i) (this is part 3 of Theorem 2). To see this, consider a random walk X 0 ,... starting from an arbitrary vertex, and look at the long-term behavior of the walk. We know that for all t large enough we have Pr[Xt = i] = π(i). Let δi(t) be an indicator random variable which is 1 iff Xt = i. Then for t large enough we have
Exp
δi(t) + δi(t + 1) + · · · + δi(t + n − 1) n
n
n∑− 1
k=
Exp[δi(t + k)] = π(i);
in other words, the expected frequency with which we are at vertex i is π(i). It follows that, for t large enough, the expected time between visits to i is 1/π(i). Since the random walk is memoryless, this actually holds at all times (and not just for t large enough). Finally, we come to the main result of interest for these notes (this is a slightly stronger version of Theorem 1):
Theorem 4 Consider a random walk on an undirected, connected, non-bipartite graph G with ℓ self-loops and m (other) edges. If there is an edge in G from vertex i to vertex j then hi,j + hj,i ≤ 2 m + ℓ and, in particular, hi,j < 2 m + ℓ.
Proof Define deg(i) as the number of edges incident to vertex i, counting self-loops only once. We can prove the theorem in two ways: looking at either the vertices or the edges.
First approach. Consider the Markov chain in which the vertices are the states, and transition probabilities are defined in the natural way. It can be checked by a simple calculation that π(v) = deg(v) 2 m+ℓ is a stationary distribution.^ It follows that, for any vertex^ v, we have^ hv,v^ =^
2 m+ℓ deg(v).^ If there is a self-loop at v then, since the graph is connected, deg(v) ≥ 2 and so hv,v ≤ 2 m 2 + ℓ and hv,v + hv,v ≤ 2 m + ℓ. This proves the theorem for the case i = j. More generally, we have:
2 m + ℓ deg(v) = hv,v =
deg(v)
u∈N (v)
(1 + hu,v) ,
where N (v) are the neighbors of v (the above assumes that v has no self-loops, but the analysis is the same either way). It follows that if there is an edge connecting (distinct) vertices u 0 , v, then hu 0 ,v < 2 m + ℓ. (That hu 0 ,v + hv,u 0 ≤ 2 m + ℓ is left as an exercise, but see the next part.)
Second approach. Consider a Markov chain in which we have 2m + ℓ states E′^ corresponding to the edges in our graph, taking direction into account (except for self-loops where the direction is irrelevant). When we take a step from vertex i to vertex j in our random walk, we view this as being in the “state” (i, j). Thus, we have a transition matrix defined by:
p(i,j),(j′,k′) =
1 /deg(j) j = j′ 0 otherwise
(Note that, viewing this [in the natural way] as a new graph in which vertices correspond to edges [with direction] in our original graph, the resulting graph is ergodic). One can check that the uniform distribution over E′^ is stationary. It follows that the expected time to re-visit the edge (j, i) is |E′| = 2m + ℓ. But re-visiting edge (j, i) corresponds to a one-step transition from j to i, re-visiting j, and then following edge (j, i) again. By the memorylessness of the random walk, this means that, beginning at i, the expected number of steps to visit j and then follow edge (j, i) is |E′|. But this gives the desired upper bound on the expected value of hi,j + hj,i.
Let R be a polynomial-time^1 (and polynomially-bounded) relation on pairs of elements. R of course defines the N P language LR = {x | ∃y : (x, y) ∈ R}. But in addition to asking about existence of witnesses, we can also ask about the number of witnesses. With that in mind, define:
fR(x) def = |{y | (x, y) ∈ R}|. (^1) From now one, when we say that R is a polynomial-time relation we mean also that it is polynomially-bounded. Equivalently, membership of (x, y) in R can be decided in time polynomial in |x| alone.
Proposition 6 There exists a poly-time relation R such that #R is #P-complete, but LR ∈ P.
Proof The counterexample is rather silly, but illustrative. Let R be any poly-time relation such that #R is #P-complete (say, #SAT ). Define the following poly-time relation R′:
(x, y′) ∈ R′^ ⇔ (y′^ = 0) or (y′^ = 1y and (x, y) ∈ R).
Note that LR′ = { 0 , 1 }∗^ ∈ P; however, #R′^ is still clearly #P-complete (why?).
The above problem is not very natural. However, there are examples of natural problems which give the same result. We discuss one prominent example next.
The permanent of a square matrix A = {ai,j } is defined as:
∑
σ∈Sn
∏^ n
i=
ai,σ(i) ,
where Sn is the set of permutations on n elements. You might recognize that this formula is very similar to the formula defining the determinant of a matrix; the difference is that in the case of the determinant there is an extra factor of (−1)sign(σ)^ in the sum, where sign(σ) is the sign of σ. Nevertheless, although the determinant can be computed in polynomial time, computing the permanent (even of a 0-1 matrix) is #P-complete. We will say more about this problem next lecture.
Section 1 was written using [3, Lecture 2] and [2, Chapter 7] as references. Sections 2.1 and 2.2 are largely based on [1, Lect. 10].
[1] O. Goldreich. Introduction to Complexity Theory (July 31, 1999).
[2] M. Mitzenmacher and E. Upfal. Probability and Computing: Randomized Algorithms and Prob- abilistic Analysis. Cambridge University Press, 2005.
[3] E. Vigoda. Lecture notes for CS37101-1: Markov Chain Monte Carlo Methods (Autumn 2003). Available at http://www.cc.gatech.edu/~vigoda/MCMC_Course/index.html.