Theory of Computation
Lecture #38
Sarmad Abbasi
Virtual University
Sarmad Abbasi (Virtual University) Theory of Computation 1 / 38
Lecture 38: Overview
Relationship between space and time complexity.
PSPACE
PSPACE-completeness
TQBF
Sarmad Abbasi (Virtual University) Theory of Computation 2 / 38
Space Complexity
Let us review some relationships between space and time and
non-determinism and determinism.
1 DTIME(t(n)) ⊆ NTIME(t(n)).
2 DSPACE(s(n)) ⊆ NSPACE(s(n)).
3 TIME(s(n)) ⊆ DSPACE(s(n)).
These relationships are trivial.
Sarmad Abbasi (Virtual University) Theory of Computation 3 / 38
Space Complexity
Here are the non-trivial relationships.
1 NTIME(t(n)) ⊆ DTIME(2O(t(n)) ). Simulate the non-deterministic
TM.
2 NSPACE(s(n)) ⊆ DSPACE(s2 (n)). Savitch’s theorem.
3 DSPACE(s(n)) ⊆ DTIME(2O(s(n)) ) for s(n) ≥ n.
Sarmad Abbasi (Virtual University) Theory of Computation 4 / 38
Space Complexity
Our favorite complexity classes:
Time: [
P= DTIME(nk ).
k
[
NP = NTIME(nk ).
k
k
[
EXPTIME = NTIME(2n ).
k
Space: [
PSPACE = DSPACE(nk ).
k
[
NPSPACE = NSPACE(nk ).
k
Sarmad Abbasi (Virtual University) Theory of Computation 5 / 38
Space Complexity
Thus we have the following relationships:
P ⊆ NP ⊆ PSPACE = NPSPACE ⊆ EXPTIME.
So far complexity theorist have only been able to show that
P 6= EXPTIME.
Therefore, one of the above (or all) containments must be non-trivial
but this all we can say now.
Sarmad Abbasi (Virtual University) Theory of Computation 6 / 38
Space Complexity
This picture shows these complexity classes.
Put Picture from Sipser Figure 8.1 Page 282.
Sarmad Abbasi (Virtual University) Theory of Computation 7 / 38
Space Complexity
Motivated by the theory of NP-completeness we can ask the question
if there are any PSPACE-complete problems? What kind of problems
these would be?
Sarmad Abbasi (Virtual University) Theory of Computation 8 / 38
Space Complexity
Let us make a precise definition first.
A language B is PSPACE-complete if
1 B is in PSPACE.
2 every A in PSPACE is polynomial time reducible to B.
Sarmad Abbasi (Virtual University) Theory of Computation 9 / 38
Space Complexity
Pictorially we will have:
Sarmad Abbasi (Virtual University) Theory of Computation 10 / 38
Space Complexity
Why is it that we require that A be polynomial time reducible to B?
Why not require that it is polynomial space reducible to B?
Sarmad Abbasi (Virtual University) Theory of Computation 11 / 38
Space Complexity
Well, what we want to say is that if a PSPACE-complete language is
easy then all languages in PSPACE are easy! In other words, we claim
that
Theorem
If any PSPACE-complete language is in P then
PSPACE = P
this is the critical theorem (and its analogue in the theory of
NP-completeness) that gives evidence that PSPACE-complete
languages are hard.
Sarmad Abbasi (Virtual University) Theory of Computation 12 / 38
Space Complexity
The proof of this theorem reveals the answer. Let B be any
PSPACE-complete language. If B is in P then there a polynomial time
TM M that accepts B in time O(nk ). Let A ∈ PSAPCE. Since
A ≤p B
there a polynomial time reduction f from A to B. Let N be a polynomial
time TM N that computes f in time O(nr ). Consider the following
algorithm:
Sarmad Abbasi (Virtual University) Theory of Computation 13 / 38
Space Complexity
1 On input x.
2 using N compute y = f (x).
3 Run M on y . If M accepts accept else reject.
Clearly this algorithm recognizes B. The running time of this algorithm
is
O(|x|r ) + O(|y |k ).
If |x| = n then |y | ≤ nr thus the above algorithm runs in
O(nkr ).
This shows that A is in P.
Sarmad Abbasi (Virtual University) Theory of Computation 14 / 38
Space Complexity
Now the critical point is that f can be computed in polynomial time. If f
were polynomial space computable we could only say that the above
algorithm runs in polynomial space. We will end up proving the
following uselessly trivial theorem:
If any PSPACE-complete language is in P then
PSPACE = PSPACE
Sarmad Abbasi (Virtual University) Theory of Computation 15 / 38
Space Complexity
Note that if B is PSAPCE-complete and A ∈ NP then
A ≤p B.
Thus all PSPACE-complete languages are also NP-complete.
Sarmad Abbasi (Virtual University) Theory of Computation 16 / 38
Space Complexity
Recall the Cook-Levin Theorem:
Theorem
SAT is NP-complete.
It gave us a vast understanding of NP. It identified one hard problem in
NP. What we want is to identify such a problem for PSPACE.
Sarmad Abbasi (Virtual University) Theory of Computation 17 / 38
Space Complexity
Recall SAT. What we want to do is consider its generalizations now.
Let us look at SAT
Given a boolean formula on n variable x1 , . . . , xn
φ(x1 , . . . , xn )
does there exist a satisfying assignment for φ?
Sarmad Abbasi (Virtual University) Theory of Computation 18 / 38
Space Complexity
Another way to phrase SAT is to say if the following is the formula
∃x1 ∃x2 ∃ . . . ∃xn φ(x1 , . . . , xn ).
Sarmad Abbasi (Virtual University) Theory of Computation 19 / 38
Space Complexity
We notice that we are only using one quantifier here. What if we allow
both quantifiers?
Consider the formula:
φ = ∀x∃y [(x ∨ y ) ∧ (x ∨ y )].
This is called a fully quantified boolean formula. A fully quantified
boolean formula is also called a sentence and it is either true or false.
Now we are ready to define TQBF.
Sarmad Abbasi (Virtual University) Theory of Computation 20 / 38
Space Complexity
TQBF {hφi : φ is a true fully quantified boolean formula }.
Sarmad Abbasi (Virtual University) Theory of Computation 21 / 38
Space Complexity
The first thing to notice is that TQBF is in PSPACE. To prove this we
have to give a polynomial space algorithm that solves this problem.
This is almost trivial once we define when a QBF is true.
Sarmad Abbasi (Virtual University) Theory of Computation 22 / 38
Space Complexity
If φ is a formula on 0 boolean variables then we can evaluate it to find
out if it is true. For example
(0 ∨ 0) ∧ (1 ∨ 0)
is false and
(1 ∨ 0) ∧ (1 ∨ 1)
is true.
Sarmad Abbasi (Virtual University) Theory of Computation 23 / 38
Space Complexity
Let Q1 x1 , . . . , Qn xn φ(x1 , . . . , xn ) be a boolean formula on n variables.
Where Qi ∈ {∀, ∃} We can obtain two formulas
φ|x1 =0 and φ|x1 =1
by first substituting x1 = 0 in φ and then substituting x1 = 1 in φ.
Sarmad Abbasi (Virtual University) Theory of Computation 24 / 38
Space Complexity
For
φ = ∀x∃y [(x ∨ y ) ∧ (x ∨ y )].
We have
φ|x=0 = ∃y [(0 ∨ y ) ∧ (0 ∨ y )].
and
φ|x=1 = ∃y [(1 ∨ y ) ∧ (1 ∨ y )].
Sarmad Abbasi (Virtual University) Theory of Computation 25 / 38
Space Complexity
We define
∀x1 φ
to be true if both
φ|x1 =0 and φ|x1 =1
are true.
Sarmad Abbasi (Virtual University) Theory of Computation 26 / 38
Space Complexity
We define
∃x1 φ
to be true if both
φ|x1 =0 or φ|x1 =1
is true.
Sarmad Abbasi (Virtual University) Theory of Computation 27 / 38
Space Complexity
Let us work out an example. Consider
φ = ∀x∃y [(x ∨ y ) ∧ (x ∨ y )].
φ|x=0 = ∃y [(0 ∨ y ) ∧ (0 ∨ y )].
and
φ|x=1 = ∃y [(1 ∨ y ) ∧ (1 ∨ y )].
and both these must be true for the formula to be true.
Sarmad Abbasi (Virtual University) Theory of Computation 28 / 38
Space Complexity
To check
φ|x=0 = ∃y [(0 ∨ y ) ∧ (0 ∨ y )]
we have to check
φ|x=0,y =0 = [(0 ∨ 0) ∧ (0 ∨ 0)]
which evaluates to false so we need to check the other one!
φ|x=0,y =1 = [(0 ∨ 1) ∧ (0 ∨ 1)]
This shows us that is true and we get
φ|x=0 = ∃y [(0 ∨ y ) ∧ (0 ∨ y )]
is true.
Sarmad Abbasi (Virtual University) Theory of Computation 29 / 38
Space Complexity
Recall we were considering
φ = ∀x∃y [(x ∨ y ) ∧ (x ∨ y )].
We had to check
φ|x=0 = ∃y [(0 ∨ y ) ∧ (0 ∨ y )].
and
φ|x=1 = ∃y [(1 ∨ y ) ∧ (1 ∨ y )].
and both true for the formula to be true. We have checked the first one
and now you can easily check the second one yourself and figure out if
the original formula is true.
Sarmad Abbasi (Virtual University) Theory of Computation 30 / 38
Space Complexity
Note that we have given a definition of when a QBF is true. This
definition leads to a recursive algorithm. Let us write down this
algorithm:
Eval(φ, n):
1 if n = 0 then φ has no variables. Directly evaluate if and return the
value.
2 If n > 1 then let x1 be the first quantified variable in φ.
3 If φ = ∃x1 ψ
4 return (Eval(φ|x1 =0 , n − 1)∨ Eval(φ|x1 =1 , n − 1))
5 If φ = ∀x1 ψ
6 return (Eval(φ|x1 =0 , n − 1)∧ Eval(φ|x1 =1 , n − 1))
Sarmad Abbasi (Virtual University) Theory of Computation 31 / 38
Space Complexity
Note that this is a recursive algorithm with n as its depth of recursion.
It only stores a polynomial amount on the stack each time. Thus this
algorithm runs in polynomial space. So this problem is in PSPACE.
Sarmad Abbasi (Virtual University) Theory of Computation 32 / 38
Space Complexity
Next our goal is to show that TQBF is PSPACE-hard. This is not going
to be easy as we have to show that for every language A ∈ PSPACE
A ≤p TQBF .
Sarmad Abbasi (Virtual University) Theory of Computation 33 / 38
Space Complexity
Let us start. We do not know much about A. The only thing that we
know is that it belongs to PSPACE. That means there a TM M that
accepts A in polynomial space. Let us take that TM M and collect a
few facts about it.
Sarmad Abbasi (Virtual University) Theory of Computation 34 / 38
Space Complexity
Firstly we observe that M runs in space O(nk ). Therefore, it accepts in
time at most
k
2O(n ) .
Sarmad Abbasi (Virtual University) Theory of Computation 35 / 38
Space Complexity
Suppose x is an input and C0 is the initial configuration of M on x. We
know that
M accepts x if an accepting configuration of M is reachable from C0 in
k
at most t = 2O(n ) steps.
Sarmad Abbasi (Virtual University) Theory of Computation 36 / 38
Space Complexity
Thus M accepts x if and only if there is a accepting history of M on x
k
of length at most 2O(n ) . Can we use the same idea as given in the
Cook-Levin theorem?
Sarmad Abbasi (Virtual University) Theory of Computation 37 / 38
Space Complexity
In the Cook-Levin theorem each configuration was of length
polynomial and the length of the computation history was also
polynomial. In this case,the length is a problem. Nevertheless those
ideas are going to help us. So you must review the proof of the
Cook-Levin theorem in order to understand this proof completely.
Sarmad Abbasi (Virtual University) Theory of Computation 38 / 38