Professional Documents
Culture Documents
Lecture #43
Sarmad Abbasi
Virtual University
Theory of Computation
1 / 31
Space Complexity
Theorem
NL = co-NL.
Theory of Computation
2 / 31
Space Complexity
Theory of Computation
3 / 31
Space Complexity
Note that
Theorem
A L B
if and only if
A L B
Theory of Computation
4 / 31
Space Complexity
This implies that PATH is co-NL complete. Since we will also show that
PATH
is in NL. This would tell us that NL = co NL.
Theory of Computation
5 / 31
Space Complexity
Theory of Computation
6 / 31
Space Complexity
Theory of Computation
7 / 31
Space Complexity
PATH is in NL.
PATH is NL-complete.
Theory of Computation
8 / 31
Space Complexity
Theory of Computation
9 / 31
Space Complexity
Consider the following non-deterministic algorithm.
1
Input G = (V , E) and s, t V .
For i = 1, . . . , n
Guess a vertex w V ;
if (v , w) 6 E reject;
else if w = t accept;
v = w;
The space used by this algorithm is the space to store i and v the
current vertex. The maximum value of i is n and there are n vertices in
the graph. Thus the total space used in O(log n).
Theory of Computation
10 / 31
Space Complexity
Theory of Computation
11 / 31
Space Complexity
Theory of Computation
12 / 31
Space Complexity
Theory of Computation
13 / 31
Space Complexity
To find out if M accepts x all we have to is to find out if from the vertex
that corresponds to the initial configuration can we reach a vertex that
corresponds to the final configuration.
Theory of Computation
14 / 31
Space Complexity
Note that each configuration c of a NTM is specified by
1
Theory of Computation
15 / 31
Space Complexity
Theory of Computation
16 / 31
Space Complexity
Let us denote by
GM (x)
the graph described above. Let us consider the following algorithm.
1
On input x.
Compute GM (x)
Theory of Computation
17 / 31
Space Complexity
Theory of Computation
18 / 31
Space Complexity
Next we will show that PATH is in NL. This is not a simple theorem. We
have to first understand the problem very carefully.
Theory of Computation
19 / 31
Space Complexity
Theory of Computation
20 / 31
Space Complexity
Theory of Computation
21 / 31
Space Complexity
Theory of Computation
22 / 31
Space Complexity
This problem is easier to solve. Let us look at a overview of a
non-deterministic TM that solves this problem and then we will improve
it.
1
Guess c vertices v1 , . . . , vc
For i = 1, . . . , c
Accept.
Theory of Computation
23 / 31
Space Complexity
This machine solves the problem. Lets see why! For it to reach accept
state it would verify that at least c vertices are reachable from s and t
is not one of them. Furthermore, if t is not reachable from s and the
machine makes all the right guesses it will accept. Thus at least one
branch will accept if and only if t is not reachable from s. But how
much space does this algorithm take?
Theory of Computation
24 / 31
Space Complexity
There are two problems in the algorithm.
1
This is too space wasteful. So, we use the previous trick that we used
to solve PATH. We do not need to guess the whole set
{v1 , . . . , vc }
and similarly we do not need to guess the whole path. We can guess
them as we go along. Thus saving space. Let us look at these ideas
clearly.
Theory of Computation
25 / 31
Space Complexity
Theory of Computation
26 / 31
Space Complexity
What we can do is guess the current bit of this vector one at a time.
Thus if gi = 1 we are guessing that the vertex is in G otherwise not.
Also, as we did previously we can forget all the previous bits and only
remember the number of them which were in G this way we will know
the size of G at the end of the loop.
Theory of Computation
27 / 31
Space Complexity
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Theory of Computation
28 / 31
Space Complexity
Theory of Computation
29 / 31
Space Complexity
Now, our task is a bit simpler. But we notice that it is even simpler than
we thought. What we want is an non-deterministic algorithm that does
the following.
1
On input G and s.
Theory of Computation
30 / 31
Space Complexity
Theory of Computation
31 / 31
Space Complexity
Theory of Computation
32 / 31