You are on page 1of 5

GS019 - Lecture 1 on Complexity Theory Jarod Alper (jalper)

Introduction to Complexity Theory


Big O Notation Review
Linear function: r(n) = O(n).
Polynomial function: r(n) = 2O(1)
O(1)
Exponential function: r(n) = 2n
Logarithmic function: r(n) = O(log n)
Poly-log function: r(n) = logO(1) n
Definition 1 (T IM E) Let t : ℵ −→ ℵ. Define the time complexity class, T IM E(t(n)) to be

T IM E(t(n)) = {L | ∃ DTM M which decides L in time O(t(n))}.

Definition 2 (N T IM E) Let t : ℵ −→ ℵ. Define the time complexity class, N T IM E(t(n)) to be

N T IM E(t(n)) = {L | ∃ NDTM M which decides L in time O(t(n))}.

Example 1 Consider the language A = {0k 1k | k ≥ 0}.

Is A ∈ T IM E(n2 )?
Is A ∈ T IM E(n log n)?
Is A ∈ T IM E(n)?
Could we potentially place A in a smaller complexity class if we consider other computational
models?

Theorem 1 If t(n) ≥ n, then every t(n) time multitape Turing machine has an equivalent O(t2 (n))
time single-tape turing machine.

Proof: see Theorem 7.8 in Sipser (pg. 232)

Theorem 2 If t(n) ≥ n, then every t(n) time RAM machine has an equivalent O(t3 (n)) time
multi-tape turing machine.

Proof: optional exercise

Conclusion: Linear time is model specific; polynomical time is model indepedent.

Definition 3 (The Class P )

[
P = T IM E(nk )
k

Definition 4 (The Class N P )


GS019 - Lecture 1 on Complexity Theory Jarod Alper (jalper)
[
NP = N T IM E(nk )
k

Equivalent Definition of NP
NP = {L|L has a polynomial time verifier }.
A polynomial time verifier for a language A is an algorithm, V , where A = {w|V acepts < w, c >
for some string c}.

Example 2 Let RELP RIM E = {< x, y > | gcd(x, y) = 1}. Is RELP RIM E ∈ N P ? Is
RELP RIM E ∈ P ?

Example 3 P AT H = {< G, s, t > | G has a directed path from s to t}. Is P AT H ∈ P ?

Construct a deterministic polynomial time Turing machine, M , that decides P AT H.

M = “On Input < G, s, t > where G is a directed graph with nodes s and t.
1. Place a mark on node s.
2. While there exists an unmarked node do
3. Search for all edges (a, b) where a is marked and b unmarked, and mark such b.
4. If t is marked, accept; otherwise, reject.

To show an algorithm runs in polynomial, one must show that each step is executed only a poly-
nomial number of steps as well as each steps executes in polynomial time.

Example 4 SAT = {< φ > |φ is a satisfiable boolean formula }. Is SAT ∈ N P ?

Construct a nondeterministic polynomial time Turing machine, M , as follows:

M = “On Input < φ >:


1. Nondeterministically select an assignment of the variables, x.
2. Teset where x satisfies φ.
3. If thest test passes, accept; otherwise, reject.”

Example 5 V ALU E = {< φ, x > | φ(x) where φ is a boolean formula and x an assignment of
variables }. Is V ALU E ∈ P ?

Example 6 RAT ION ALROOT = {< p > | ∃q ∈ Q such that p(q) = 0 where p(x) = a0 + a1 x +
. . . + ak xk is a polynomial of degree k where ∀ i = 1 . . . k, ai ∈ ℵ.
Is RAT ION ALROOT ∈ P ?

Construct a nondeterministic polynomial time Turing machine, M , for RATIONALROOT:

M = “On Input < p > where p(x) = a0 + a1 x + . . . + ak xk , ai ∈ ℵ.


GS019 - Lecture 1 on Complexity Theory Jarod Alper (jalper)

1. Nondeterministically select q ∈ Q.
2. Evaluate p(q).
3. If p(q) = 0, accept; otherwise, reject.”

Does this run in polynomial time? Cearly, to evaulate p(q) is polynomial in the length of q since
multipication can be computed in polynomial time. How big is q though? From the Rational Root
Theorem in algebra, any rational root, x, of p(x) = 0 is of the form x = st where s|a0 and t|ak .
Since |a0 | = log(a0 ) < n and |ak | = log(ak ) < n, |q| = O(n). Thus, step 1 and 2 can be computed
in polynomial steps.
Example
P 7 Let SU BSET SU M = {< S, t > | ∃{y1 , y2 , . . . , yn } = Y ⊆ S = {s1 , s2 , . . . , sn } such
that i yi = t}
Construct a nondeterministic polynomial time Turing machine, M , as follows:

M = “On Input < S, t >:


1. Nondeterministically select a subset c of the numbers in S.
2. Test whether c is a collection of numbers that sum to t.
3. If thest test passes, accept; otherwise, reject.”
Theorem 3 P ⊆ N P
Proof: A O(t(n)) DTM has an equivalent O(t(n)) NDTM. 2
Definition 5 (The Class EXP T IM E)
[ k
EXP T IM E = T IM E(2n )
k

Definition 6 (The Class N EXP T IM E)


[ k
N EXP T IM E = N T IM E(2n )
k

Relations:
P ⊆ N P ⊆ EXP T IM E ⊆ N EXP T IM E
Definition 7 (Space Complexity Classes)
SP ACE(t(n)) = {L | ∃ DTM M which decides L in space O(t(n))}.

N SP ACE(t(n)) = {L | ∃ NDTM M which decides L in space O(t(n))}.

[
P SP ACE = SP ACE(nk )
k
[
N P SP ACE = N SP ACE(nk )
k
GS019 - Lecture 1 on Complexity Theory Jarod Alper (jalper)

Definition 8 (Logarithmic Space Classes)

L = SP ACE(log n)
N L = N SP ACE(log n)

How can our definition of a turing machine use only logarithmic space since the input tape uses
linear space? We introduce a new turing machine with two tapes: a read-only input tape and a
read/write tape.

Example 8 P AT H ∈ N L

Relations between time and space:

Theorem 4 T IM E(f (n)) ⊆ SP ACE(f (n))

Proof: A deterministic turing machine that decides membership in O(f (n)) steps can use at most
O(f (n)) space since one TM step requires can only write to one memory cell. 2

Theorem 5 If f (n) ≥ log(n), SP ACE(f (n)) ⊆ T IM E(kf (n) )

Proof: Define a configuration as a snap shot of a turing machine including the position of the heads,
the state of the control unit, and the contents of all cells on tape. If our turing machine is restricted
to O(f (n)) space, the work tape head can be in only O(f (n)) locations and the input tape head
can be in only O(n). The control unit can be in any of c positions were c is a constant representing
the number of states in the fsm. If we have k characters that can be written to a cell, then there
are O(kf (n) ) possibilities for the content of the tape. Thus, there are O(c n f (n) kf (n) ) = O(kf (n) )
configurations. If the turing machine is to halt, there will be no duplicate configuration and thus
it must run in O(kf (n) )2.

Corollary 1 L ⊆ P

Corollary 2 P ⊆ P SP ACE

Corollary 3 P SP ACE ⊆ EXP T IM E

Complements of complexity classes

Definition 9 (coC) The complement of a complexity class of decision problems C, denoted coC,
is the set of decision problems that are complemnt of decision problems of C.

Example 9 coSAT = {< φ > |φ is NOT a satisfiable boolean formula }. Is coSAT ∈ N P ? Is


coSAT ∈ EXP T IM E? Is coSAT ∈ P SP ACE?

Theorem 6 If C is a deterministic time or space complexity class, then C = coC.


GS019 - Lecture 1 on Complexity Theory Jarod Alper (jalper)

Proof: Deterministic turing machines are closed under complementation.

Is NP = coNP?
T
Theorem 7 N P coN P 6= {}
T
Proof: Let P RIM ALIT Y = {< n > |n is prime}. We show P RIM ALIT Y ∈ N P coN P .
not quite done.

Lemma 1 An integer p > 2 is prime iff there is an integer 1 < r < p such that r p−1 ≡ 1(modp)
p−1
and ∀q such that q|p − 1, r q 6 ≡1(modp).

Proof: not quite done

You might also like