0% found this document useful (0 votes)
57 views16 pages

EECE 338 - Course Summary

The document provides an overview of regular languages, context-free languages, and the relationships between them. It covers deterministic finite automata, nondeterministic finite automata, regular expressions, closure properties of regular languages, pumping lemma, context-free grammars, Chomsky normal form, pushdown automata, closure properties of context-free languages, and the pumping lemma for context-free languages. Examples of non-regular and non-context-free languages are also given.

Uploaded by

. .
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views16 pages

EECE 338 - Course Summary

The document provides an overview of regular languages, context-free languages, and the relationships between them. It covers deterministic finite automata, nondeterministic finite automata, regular expressions, closure properties of regular languages, pumping lemma, context-free grammars, Chomsky normal form, pushdown automata, closure properties of context-free languages, and the pumping lemma for context-free languages. Examples of non-regular and non-context-free languages are also given.

Uploaded by

. .
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

EECE 338 Final Notes Spring 2021

Chapter 1 - Regular Languages

Deterministic Finite Automata (DFAs)

A deterministic finite automaton is a 5-tuple (Q, Σ, δ, q0 , F ), where:


(1) Q is a finite set called the states
(2) Σ is a finite set called the alphabet
(3) δ : Q × Σ → Q is the transition function
(4) q0 ∈ Q is the start state
(5) F ⊆ Q is the set of accept states

The formal definition of computation for a DFA is as follows: Let M = (Q, Σ, δ, q0 , F ) be a DFA and let w = w1 w2 ...wn be a
string where each wi ∈ Σ. Then, M accepts w if a sequence of states r0 , r1 , ..., rn ∈ Q exists such that:
(1) r0 = q0
(2) δ(ri , wi+1 ) = ri+1 for i = 0, ..., n − 1
(3) rn ∈ F

A DFA must have transitions in each state that cover every possible case.

Nondeterministic Finite Automata (NFAs)

A nondeterministic finite automaton is also a 5-tuple (Q, Σ, δ, q0 , F ) having the same formal definition as a DFA, with the excep-
tion that the transition function is δ : Q × Σ → P(Q) instead.

An NFA also has a similar formal definition of computation to a DFA, with the exception that ri+1 ∈ δ(ri , wi+1 ) for i = 0, ..., n − 1.

NFAs differ from DFAs in 3 ways: (1) δ(q, a) can be qa or qb or ... , (2) δ(q, a) can be undefined, and (3)  transitions are allowed.

Theorem: Every NFA has an equivalent DFA and vice versa.

Regular Operations

We say that a language A is regular if some finite automaton (DFA or NFA) M exists such that L(M ) = A.

Let A1 and A2 be regular languages. We can say that the class of regular languages is < ... > by constructing an NFA N to recognize
each operation:

(a) (b) (c)

Figure 1. (a) Closed Under Union (b) Closed Under Concatenation (c) Closed Under Star

Note: Regular languages are also closed under intersection, complementation, and reversal.

1
2

Regular Expressions

R is a regular expression over Σ if R is:


(1) a for some a ∈ Σ
(2) 
(3) φ
(4) R1 ∪ R2 , where R1 and R2 are regex
(5) R1 R2 , where R1 and R2 are regex
(6) R∗ where R is a regex

Theorem: A language is regular ⇔ A language is described by a regular expression


Note: φ∗ = 

Non-regular Languages

Pumping Lemma (On example A = {0n 1n |n ≥ 0}):


• Assuming A is a regular language, PL implies that A has a pumping length p
• Consider string s = 0p 1p ∈ A
• |s| = 2p ≥ p, so PL will hold
• We can split s into 3 pieces s = xyz satisfying conditions:
(1) xy i z ∈ A for each i ≥ 0
(2) |y| > 0, and
(3) |xy| ≤ p
• x and y consist of all 0’s, and z consists of the remaining 0’s (possibly) and p 1’s.
• So we have x = 0j , y = 0k , z = 0m 1p where j ≥ 0, k > 0, m ≥ 0
• s = xyz =⇒ 0p 1p = 0j 0k 0m 1p = 0j+k+m 1p
• Consider string xyyz ∈ A: xyyz = 0j + k + m + k1p = 0p+k 1p ∈ / A since k > 0
• Contradiction =⇒ A = {0n 1n |n ≥ 0} is non-regular

Examples of non-regular languages include A =


• {0n 1n | n ≥ 0}
• {02n 1n | n ≥ 0}
• {0i 1j | i > j}
• {ww | w ∈ {0, 1}∗ }
• {w | w ∈ Σ∗ has equal # of 0’s and 1’s}
• {w | w ∈ Σ∗ , w = wR }
• {1n | n is a prime number}

Note: All finite languages are regular.

Chapter 2 - Context-Free Languages


Context-Free Grammars

A CFG is a 4-tuple G = (υ, Σ, R, S) where:


(1) υ is the finite set of variables
(2) Σ is the finite set terminals such that Σ ∩ υ = φ
(3) R is the finite set of rules, each of the form A → w, where A ∈ υ and w ∈ (υ ∪ Σ)∗
(4) S ∈ υ is the start variable


L(G) = {w ∈ Σ∗ | S =⇒ w} is a context-free language.

A grammar G is called ambiguous if ∃ a string w ∈ L(G) with 2 different parse trees (different leftmost derivations).

Theorem: Regular languages are CFLs.

Closure Properties

Given CFGs G1 = (υ1 , Σ, R1 , S1 ) and G2 = (υ2 , Σ, R2 , S2 ), we can construct CFG G = (υ, Σ, R, S) such that G is:
• Closed Under Union: υ = υ1 ∪ υ2 ∪ {S} and R = R1 ∪ R2 ∪ {S → S1 |S2 }
• Closed Under Concatenation: υ = υ1 ∪ υ2 ∪ {S} and R = R1 ∪ R2 ∪ {S → S1 S2 }
• Closed Under Star: Add to R the rule S → SS | 
• Closed Under Intersection with a Regular Language: If A is a CFL and B is a regular language, then A ∩ B is a
CFL.
• Closed Under Reverse
• NOT Closed Under Intersection
• NOT Closed Under Complement
3

Chomsky Normal Form

A CFG is in Chomsky Normal Form (CNF) if every rule is of the form:


• A → BC (A, B, and C are variables, and B, C 6= start variable)
• A → a (A is a variable and a is a terminal)
We also permit the rule S → 

Theorem: Any CFL is generated by a CFG in CNF. We can convert a given CFG to CNF through the following steps:
(1) Add a new start variable: S0 → S
(2) Remove -rules: Remove all rules A →  where A is not the start variable. For each occurrence of A in the right-hand
side of a rule, we add a new rule with that occurrence deleted (e.g. for R → uAvAw, we add the rules R → uvAw, R →
uAvw, R → uvw)
(3) Remove unit rules: Remove rules of the form A → B, where A and B are both variables. Then, whenever a rule B → u
appears (where u is a string of terminals and/or variables), we add the rule A → u.
(4) Convert remaining rules into the proper form: Replace each rule A → u1 u2 ...uk , where k ≥ 3, with the rules
A → u1 A1 , A1 → u2 A2 , A2 → u3 A3 , ... , Ak−2 → uk−1 uk . Replace any terminal ui in the preceding rules with the new
variable Ui and add the rule Ui → ui .

Note: Deriving any string w of size n from a grammar G in CNF takes at most 2n − 1 derivations (steps).

Testing CFG Membership (CYK Algorithm)

Given a CFG in CNF and a string w ∈ Σ∗ , we can check if w ∈ L(G) in poly-time using the following algorithm:
• Say w = w1 ...wn , where n > 0 (If n = 0, simply check if s →  ∈ R)
• Base Case: If i = j, check if ∃ A → wi ∈ R
∗ ∗ ∗
• Recurrence: If j > i, A =⇒ wi ...wj if ∃ rule A → BC and i ≤ k < j such that B =⇒ wi ...wk and C =⇒ wk+1 ...wj .
• Time: O(|G| × n ) 3

Pushdown Automata (PDA)

A PDA (may be non-deterministic) is a 6-tuple (Q, Σ, T, δ, q0 , F ) such that:


(1) Q is the finite set of states.
(2) Σ is the input alphabet
(3) T is the stack alphabet
(4) δ : Q × Σ × T → P(Q × T ) is the transition function
(5) q0 ∈ Q is the start state
(6) F ⊂ Q is the set of accept states.

PDA M accepts string w if w can be expressed as w = w1 ...wn , where wi ∈ Σ and ∃ a set of states r0 , r1 , ..., rm ∈ Q and
s0 , s1 , ..., sm ∈ T ∗ representing the history of stack contents such that:
(1) r0 = q0 and s0 =  (empty stack)
(2) (ri , b) ∈ δ(ri−1 , wi , a) (For i = 1..m, ∃a, b ∈ T and t ∈ T ∗ such that si−1 = at and si = bt)
(3) rm ∈ F

Theorem: A language is CFL ⇔ A language is recognized by a PDA.


• ⇒ direction: Given a CFG G = (V, Σ, R, S), we can construct a PDA that simulates a leftmost derivation of G by following
these steps (The compact form of PDA P has 3 states, qstart , qloop , qaccept , where qloop allows us to push a complete string
to the stack instead of one symbol. It can be modified, by adding more states, to push the string symbols one-by-one):
(1) Place the marker symbol $ and the start variable S on the stack.
(2) Repeat the following steps forever:
(a) If the top of the stack is a variable symbol A, nondeterministically select one of the rules of A and substitute
A by the string on the right-hand side of the corresponding rule (δ(qstart , , A) = {(qloop,w )}, where A → w is
a rule).
(b) If the top of the stack if a terminal symbol a, read the next symbol from the input and compare it to a. If
they match, pop a from the stack and repeat. If they do not match, reject on this branch of the nondeterminism
(δ(qloop , a, a) = {(qloop , )}).
(c) If the top of the stack is the empty stack marker $, enter the accept state. Doing so accepts the input if it
has all been read (δ(qloop , , $) = {(qaccept , )}).

• ⇐ direction: Given a PDA P = (Q, Σ, T, δ, q0 , {qaccept }), we can construct an equivalent CFG G = {Apq | p, q ∈ Q}, Σ, R, {Aq0 qaccept }
by following these steps (Note that Apq is the rule in G that takes P from state p on an empty stack to state q on an empty
stack):
(1) For each p, q, r, s ∈ Q, u ∈ T, and a, b ∈ Σ : If δ(p, a, ) contains (r, u) and δ(s, b, u) contains (q, ), add the rule
Apq → aArs b to R (If the first pushed symbol (u) and the last popped symbol (u) between states p and q is the same,
add the mentioned rule).
(2) For each p, q, r ∈ Q, add the rule Apq → Apr Arq to R (If the first pushed symbol and the last popped symbol are
NOT the same, add the mentioned rule, where r is the state between p and q when the stack becomes empty).
(3) Finally, for each p ∈ Q, add the rule App →  to R
4

Non-Context-Free Languages

Pumping Lemma (On example B = {an bn cn | n ≥ 0}):


• Assume B is CFL. PL implies that B has a pumping length p ≥ 1
• Consider string s = ap bp cp ∈ B, so |s| = 3p ≥ p =⇒ PL holds
• We can split s into 5 pieces s = uvxyz = ap bp cp satisfying uv i xy i z ∈ B for every i ≥ 0, |vy| > 0, and |vxy| ≤ p
• We have 2 possibilities for splitting s = uvxyz:
(1) Strings v and y are uniform (e.g. v = a...a and y = b...b):
– uv 2 xy 2 z won’t have the same number of a’s, b’s, and c’s since |vy| > 0 =⇒ uv 2 xy 2 z ∈ /B
(2) Strings v and y are NOT both uniform (e.g. v = a...ab...b and y = b...b):
/ L(a∗ b∗ c∗ ) =⇒ ∈
– uv 2 xy 2 z ∈ /B
• Contradiction =⇒ B is not CFL

Examples of non-CFLs include L =


• {an bn cn | n ≥ 0}
• {an bn an | n ≥ 0}
• {ai bj ck | 0 ≤ i ≤ j ≤ k}
• {ww | w ∈ Σ∗ }
• {0i 1j | j = i2 }

Chapter 3 - The Church-Turing Thesis


Single-Tape Turing Machines

A Turing machine is a 7-tuple (Q, Σ, T, δ, q0 , qaccept , qreject ) such that:


(1) Q is the set of states
(2) Σ is the input alphabet not containing the blank symbol t
(3) T is the tape alphabet, where t ∈ T and Σ ⊆ T
(4) δ : Q × T → Q × T × {L, R} is the transition function
(5) q0 is the start state
(6) qaccept ∈ Q is the accept state
(7) qreject ∈ Q is the reject state

Computation of a TM: A TM computes by first receiving an input w = w1 w2 ...wn ∈ Σ∗ on the leftmost n squares of its tape,
the rest of tape being filled with t. The head starts at the leftmost square of the tape, and the TM can recognize where the input
has ended by detecting the first t, since t ∈/ Σ. Then, the computation proceeds according to the rules of the transition function
δ. If the TM ever tries to move its head to the left off the left-hand end of the tape, it stays in place. The computation of a TM
continues until it reaches an accept or reject state (halts). If neither states are reached, the TM computes forever.

Configurations of a TM: A setting of the current (1) state, (2) tape contents, and (3) head position is called a configuration
of a TM. For a state q and two strings u, v over the tape alphabet T , and the head positioned over the first symbol of v, the
configuration is written as uqv . We say that a configuration C1 yields C2 if C1 goes to C2 in one step. Common configurations
include:
• Starting Configuration: q0 w, where w is the input string
• Accepting Configuration: uqaccept v
• Rejecting Configuration: uqreject v

A TM accepts input if ∃ a sequence of configurations that begin with the starting configuration and end with the accepting con-
figuration, with each configuration in between legally yielded from the one that precedes it.

A language A is:
• Turing Recognizable (Recursively Enumerable) if ∃ a TM M such that L(M ) = A, and on input w, M either accepts,
rejects, or loops forever.
• Co-Turing Recognizable if its complement is TR.
• Decidable if ∃ a decider TM M (halts on all inputs) such that L(M ) = A

Theorem: An infinite language is TR ⇒ It has an infinite decidable subset.

Variants of Turing Machines

(1) Multitape Turing Machine: A multitape TM is similar to a single-tape TM, except that it contains k tapes. It has the
transition function δ : Q × T k → Q × (T × {L, R})k . Initially, the input is placed on tape 1, while all other tapes are
initialized to t.

Theorem: Every multitape TM has an equivalent single-tape TM. Given a k-tape TM M, we can construct a single-tape
TM M’ that simulates M by:
(a) Storing the non-t of the k tapes on a single tape, separated by a new symbol #.
(b) Marking the symbol under the heads with dots, and adding the marked symbols to the tape alphabet.
5

The slowdown for this conversion is quadratic: t(n) → O(t(n)2 ), where n is the length of the input.

(2) Nondeterministic Turing Machine: Is similar to a TM, and has the transition function δ : Q × T → P(Q × T × {L, R}).
Its computation tree contains branches that are either (1) accepting, (2) rejecting, or (3) non-halting. If any branch in this
tree reaches an accepting configuration, the NTM accepts.

Theorem: Every NTM N has an equivalent deterministic (decider, if N always halts) TM D. We can construct D as
follows:
(a) On input w, D simulates M by breadth-first search (BFS) on the computation tree of M on w (instead of DFS,
which can get D stuck on non-halting branches).
(b) If BFS finds an accepting configuration, accept. If BFS returns without finding an accepting configuration, reject.

(3) Enumerator: An enumerator E is a TM with 2 tapes (work tape(read/write) and output tape (read)). It is also a 5-tuple
with the transition function δ : Q × T → Q × (T × {L, R}) × (Σ ∪ {t} × {S, R}). This means that the enumerator’s work tape
(associated with (T × {L, R})) can move left (L) and right (R), while the output tape (associated with (Σ ∪ {t} × {S, R}))
can move right (R) or stay in place (S). Initially, the tapes are empty, and according to the transition function, E runs forever.

Theorem: A language is TR ⇔ A language is enumerated by an enumerator.


Theorem: A language is decidable ⇔ A language is enumerated by an enumerator in string order.

Church-Turing Thesis

The Church-Turing Thesis is a hypothesis that states: A function is computable ⇔ A function is computable by a TM.

Chapter 4 - Decidability
Decidable Problems - Regular Languages

• ADFA = {hB, wi | B is a DFA that accepts input string w}

Proof: Let M be a TM that decides ADFA


M = ”On input hB, wi, where B is a DFA and w is a string:
(1) Simulate B on w
(2) If the simulation ends in an accept state, accept. If it ends in a reject state, reject.”

• ANFA = {hB, wi | B is a NFA that accepts input string w}

Proof: Let N be a TM that decides ANFA


N = ”On input hB, wi, where B is a DFA and w is a string:
(1) Convert NFA B to an equivalent DFA C using the conversion procedure mentioned in Chapter 1.
(2) Run a decider TM M for ADFA on input hC, wi.
(3) If M accepts, accept. Otherwise, reject.”

• AREX = {hR, wi | R is a regular expression that generates string w}

Proof: Let P be a TM that decides AREX


P = ”On input hR, wi, where R is a regex and w is a string:
(1) Convert regex R to an equivalent NFA A using the conversion procedure mentioned in Chapter 1.
(2) Run a decider TM N for ANFA on input hR, wi.
(3) If N accepts, accept. Otherwise, reject.”

• EDFA = {hAi | A is a DFA and L(A) = φ}

Proof: Let T be a TM that decides EDFA


T = ”On input hAi, where A is a DFA:
(1) Mark the start state of A
(2) Repeat until no new states get marked: Mark any state that has a transition coming into it from any state that is
already marked.
(3) If no accept state is marked, accept. Otherwise, reject.”

• EQDFA = {hA, Bi | A and B are DFAs and L(A) = L(B)}

Proof: Let F be a TM that decides EQDFA


F = ”On input hA, Bi, where A and B are DFAs:
(1) Construct a DFA C whose language L(C) = (L(A) ∩ L(B)) ∪ (L(A) ∩ L(B)) (Regular languages are closed under
intersection, union, and complement)
(2) Run a TM decider T for EDFA on input hCi
(3) If T accepts, accept. If T rejects, reject.
6

Decidable Problems - CFGs

• ACFG = {hG, wi | G is a CFG that generates string w}

Proof: Let S be a TM that decides ACFG


S = ”On input hG, wi, where G is a CFG and w is a string:
(1) Convert G into Chomsky Normal Form.
(2) List all derivations with 2n − 1 steps, where n is the length of w, except if n = 0, then instead list all derivations with
one step (Remember that a grammar G in CNF takes at most 2n − 1 derivations to generate any string ∈ L(G)).
(3) If any of these derivations generate w, accept. Otherwise, reject.”

• ECFG = {hGi | G is a CFG and L(G) = φ}

Proof: Let R be a TM that decides ECFG (This algorithm checks if the start variable can generate a string of terminals)
R = ”On input hGi, where G is a CFG:
(1) Mark all terminal symbols in G.
(2) Repeat until no new variables get marked: Mark any variable A where G has a rule A → U1 U2 ...Uk and each symbol
U1 , ..., Uk has already been marked.
(3) If the start variable is not marked, accept. Otherwise reject.”

Theorem: Every CFL is decidable


Proof: Let G be a CFG for a language A and design a TM MG that decides A.
MG = ”On input w:
(1) Run a TM decider S for ACFG on hG, wi.
(2) If S accepts, accept. Otherwise, reject.”

Countability

First, we define three types of functions f : A → B:


(1) One-to-one (injective): f never maps two elements to the same place (f (a) 6= f (b) whenever a 6= b)
(2) Onto (surjectuve): f hits every element of B (∀ b ∈ B, ∃ a ∈ A such that f (a) = b)
(3) Correspondence (bijection): f is a correspondence if it is both one-to-one and onto.

Theorem: A set is countable if it is either finite or has the same cardinality as N.

Lemma 1: If a set is infinite and ∃ an injection g : A → N, then A is countable.

Lemma 2: If a set is infinite and its elements can be ordered, then this set is countable.

Examples of countable sets include:


• N
• Z (can map (from N to Z) 1 to 0, 2 to 1, 3 to -1, 4 to 2, 5 to 3, and so on (zig-zag))
• N × N (zig-zag along the diagonals of 2D N × N and assign a value from N to each point OR N × N → N injective)
• Z × Z (spiral from the center of 2D Z × Z and assign a value from N to each point)
• Q (simple diagonal mapping, with no repetition allowed OR Q → Z × Z → N injection)
• Σ∗ (Order by string order and assign natural number ranks according to string size)
• The set TMΣ of all TMs over a fixed alphabet Σ (fix an encoding of each TM to binary, then injection to N)

Theorem: R is uncountable (there is no correspondence between N and R)


Proof (by diagonalization): Suppose there is a f correspondence between N and R. Then we must be able to pair all members of
N with all members of R. So, we list elements of R according to some order given by f :

f (1) = ∗.a11 a12 a13 ...


f (2) = ∗.a21 a22 a23 ...
f (3) = ∗.a31 a32 a33 ...
......

Consider the diagonal, and let x = 0.b1 b2 b3 ... where bi 6= aii and bi 6= 0 or 9. Thus, ∃i such that f (i) 6= x, since they disagree on
the ith digit. Therefore, f is NOT injective, and so R is uncountable.

Corollary: Some languages are NOT TR.


Proof: Let L be the set of all languages over Σ. We can find a correspondence between L and B, which is uncountable. Let
Σ∗ = {s1 , s2 , s3 , ...}. Each language A ∈ (L) has a unique sequence ∈ B. The ith bit of that sequence, called the characteristic
sequence χA of A, is 1 if si ∈ A and 0 if si ∈/ A. Thus, since χA ∈ B, f : L → B is a correspondence, and L is therefore uncountable.

Theorem: ATM = {hM, wi | M is a TM that accepts input string w} is undecidable (TR) (Proof is by diagonalization, not
included in these notes).
7

Chapter 5 - Reducibility
Undecidable Problems from Language Theory

• HALTTM = {hM, wi | M is a TM that halts on input string w}

Proof: Assume that HALTTM is decided by a TM R. Construct a decider TM S for ATM :


S = ”On input hM, wi:
(1) Run R on hM, wi
(2) If R rejects, reject
(3) If R accepts, simulate M on w until it halts
(4) If M accepts, accept. Else (if M rejects), reject.”
(5) Contradiction =⇒ HALTTM is undecidable.

• ETM = {hM i | M is a TM and L(M ) = φ}

Proof: Assume that ETM is decided by a TM R. Construct a decider TM S for ATM :


S = ”On input hM, wi:
(1) TM M1 = ”On input x:
(a) Run M on w
(b) If M accepts w, accept x. If M rejects w, reject x.
(2) Run R on input hM1 i
(3) If R accepts, reject. If R rejects, accept.”
(4) Contradiction =⇒ ETM is undecidable (CoTR).

• REGU LARTM = {hM i | M is a TM and L(M ) is regular}

Proof: Assume that REGU LARTM is decided by a TM R. Construct a decider TM S for ATM :
S = ”On input hM, wi:
(1) TM M1 = ”On input x:
(a) If x is of the form 0n 1n , accept
(b) Else, run M on w. If M accepts, accept.”
(2) Run R on input hM1 i
(3) If R accepts, accept. If R rejects, reject.”
(4) Contradiction =⇒ REGU LARTM is undecidable (Neither TR nor CoTR).

• EQTM = {hM1 , M2 i | M1 and M2 are TMs and L(M1 ) = L(M2 )}

Proof: Assume that EQTM is decided by a TM R. Construct a decider TM S for ETM :


S = ”On input hM i:
(1) TM M1 = ”On input x:
(a) reject.”
(2) Run R on input hM1 , M2 i
(3) If R accepts, accept. If R rejects, reject.”
(4) Contradiction =⇒ EQTM is undecidable (Neither TR nor CoTR).

Reduction Via Computation History

A Linear Bounded Automaton (LBA) is a TM that is not allowed to move to a portion of the tape not containing the input. It
uses O(n) memory, where n is the input length.

Lemma: Let M be an LBA with q states and g symbols ∈ T , and let n be the length of the input string w. Then, there are at
most ng n q configurations of M on w

Computation History: Let M be a TM and w be an input string. An accepting computation history of M on w is a sequence
of configurations C1 , C2 , ..., Cl such that
(1) C1 is the starting configuration of M on w
(2) Ci+1 follows legally from Ci
(3) Cl is an accepting configuration

Note: Ci s must be distinct. If they are not, then M would loop infinitely on w

Theorem: ALBA = {hM, wi | M is an LBA that accepts input string w} is decidable.


Proof: Let M be an LBA and w be its input string. If M halts on w, it must do so in a maximum of ng n q steps. So, we construct
a decider TM D for ALBA as follows:
D = ”On input hM, wi:
(1) Simulate M on w for ng n q steps or until it halts.
(2) If M has halted and accepted, accept. Else, reject.”

Thus, ALBA is decidable.


8

Theorem: ELBA = {hM i | M is an LBA and L(M ) = φ} is undecidable.


Proof: First, construct an LBA B which takes input x such that L(B) = {#C1 #C2 #...#Cl #} is the accepting computation history
of M on w. To do that, B checks the following three conditions:
(1) C1 = qstart w, which B can easily check.
(2) Ci+1 follows legally from Ci , which B can check by scanning the input and using markers (it checks if consecutive con-
figurations are identical, except for the cell at the head position and the two cells adjacent to it, which must be updated
correctly according to the transition function of M ).
(3) Cl contains qaccept

Now, we assume that ELBA is decided by TM R, and we construct a TM decider S for ATM :
S = ”On input hM i:
(1) Construct LBA B as previously mentioned, taking input x, the computation history of running M on w.
(2) Run R on hBi
(3) If R accepts, reject. Else, accept.”
(4) Contradiction =⇒ undecidable

Theorem: ALLCFG = {hGi | G is a CFG and L(G) = Σ∗ } is undecidable.


Proof: First, we construct a CFG G that generates all computation histories iff M does NOT accept w. So, if M accepts w, G
generates all strings EXCEPT the accepting computation history of M on w. So, G generates all computation histories that follow
any of the following three conditions:
(1) that do NOT start with C1
(2) Ci+1 does NOT follow legally from Ci under the rules of M
(3) that do NOT end with an accepting configuration

Now, we construct D, the equivalent PDA of G using the construction technique mentioned in Chapter 2. D starts by nondeter-
ministically deciding which of the three conditions to check. If conditions 1 and 3 are satisfied (easy to check), D accepts. To
check the 2nd condition, we must have written the computation histories in G to be in alternating reverse order. Now, D can
push a configuration to the stack, and check whether the configuration after it follows legally from it by popping each symbol and
comparing. The rest of the proof is the same as the previous proof.

Mapping Reducibility

A function f : Σ∗ → Σ∗ is a computable function if a TM M , on every input w, halts with just f (w) on its tape.

Mapping Reducibility: A language A is mapping reducible to language B, written A ≤m B, if there is a computable function
f : Σ∗ → Σ∗ , where for every w
w ∈ A ⇔ f (w) ∈ B
Properties:
• A ≤m B, and B is Decidable/TR/CoTR =⇒ A shares the same properties
• A ≤m B, and A is Undecidable/Not TR/Not CoTR =⇒ B shares the same properties
• A is both TR and CoTR ⇔ A is decidable
• A is TR or CoTR and A ≤m A, then A is decidable
• A ≤m B =⇒ A ≤m B
• A ≤m B and B ≤m C =⇒ A ≤m C

To prove language A:
• Not TR: ATM ≤m A or ATM ≤m A
• Not CoTR: ATM ≤m A

The following are examples of mapping reducibilities:


• ATM ≤m HALTTM : The following machine F computes the function f :

F = ”On input hM, wi:


(1) Construct the following machine M 0 :
M 0 = ”On input x:
(a) Run M on x
(b) If M accepts, accept. If M rejects, enter a loop.
(2) Output hM 0 , wi.”

• ATM ≤m ETM : The following machine F computes the function f :

F = ”On input hM, wi:


(1) M1 = ”On input x:
(a) Run M on w
(b) If M accepts w, accept x. If M rejects w, reject x.”
(2) Output hM1 i.”

• ATM ≤m REGU LARTM


9

• ETM ≤m EQTM

• ATM ≤m ELBA

Theorem: EQTM is neither TR nor CoTR.


Proof:
(1) Not TR: ATM ≤m EQTM :
F = ”On input hM, wi:
(a) Construct M1 , which rejects all inputs, and M2 , which accepts if M accepts w.
(b) Output hM1 , M2 i.”

(2) Not CoTR: ATM ≤m EQTM :


F = ”On input hM, wi:
(a) Construct M1 , which accepts all inputs, and M2 , which accepts if M accepts w.
(b) Output hM1 , M2 i.”

Theorem: REGU LARTM is neither TR nor CoTR.


Proof:
(1) Not TR: ATM ≤m REGU LARTM :
F = ”On input hM, wi:
(a) TM M1 = ”On input x:
(i) If x has the form 0n 1n , run M on w and accept if M accepts w.
(ii) Else, reject.”
(b) Output hM1 i.”

(2) Not CoTR: ATM ≤m REGU LARTM :


G = ”On input hM, wi:
(a) TM M1 = ”On input x:
(i) If x has the form 0n 1n , accept.
(ii) Else, run M on w and if M accepts w, accept.
(b) Output hM1 i.”

Chapter 7 - Time Complexity


Complexity Relationships Among Models

• Every t(n) ≥ n time multitape TM has an equivalent O(t(n)2 ) time single-tape TM (Proof: After constructing a single-
tape (S) TM from a k-tape (M ) TM as described on page 4, we analyze the simulation: To simulate each of M ’s steps, S
performs two scans and possibly up to k rightward shifts (O(t(n))). Since M uses O(t(n)) steps, the entire simulation takes
O(t(n)) (since S has to setup its tape at the beginning) + O(t(n)2 ) = O(t(n)2 ) steps).

• Every t(n) ≥ n time single-tape NTM has an equivalent 2O(t(n)) time single-tape deterministic TM (Proof: After con-
structing a single-tape deterministic TM from an NTM as described on page 5, we analyze the simulation: The maximum
length of any branch = t(n) and each node in the tree can have at most b children, so the total number of leaves in the
tree is at most bt(n) =⇒ The total number of nodes in the tree is bounded by O(bt(n) ). By BFS, we need O(t(n)) time to
traverse a branch, so the total running time would be O(t(n)bt(n) ) = 2O(t(n)) ).

• Any language that can be decided in o(nlogn) (small-o) time on a single-tape TM is regular.

• Every context-free language ∈ P .

The Class P

P is the class of languages that are decidable in polynomial time on a deterministic single-tape TM. Formally defined,
[
P = T IM E(nk )
k
Theorem: P AT H ∈ P
Proof: M = ”On input hG, s, ti, where G is a directed graph with nodes s and t:
(1) Place a mark on node s.
(2) Repeat the following until no additional nodes are marked:
(a) Scan all edges of G. If an edge (a, b) is found going from a marked node a to an unmarked node b, mark b.
(3) If t is marked, accept. Otherwise, reject.”
10

The Class NP

A verifier for a language A os an algorithm V , where A = {w | V accepts hw, ci for some string c}, where w is the input string and
c is the certificate (proof). A poly-time verifier runs in poly-time in the length of w. A language A is polynomially verifiable if
it has a poly-time verifier.

NP is the class of language that are polynomially verifiable.

Theorem: A language ∈ N P ⇔ It is decided by a poly-time NTM.


Proof of →: Assume V is a poly-time verifier (runs in time nk ), and construct NTM N as follows:
N = ”On input w of length n:
(1) Nondeterministically select string c of length at most nk .
(2) Run V on input hw, ci.
(3) If V accepts, accept. Otherwise, reject.”
Proof of ←: Construct verified V from N as follows: V = ”On input hw, ci:
(1) Simulate N on input w, treating each symbol of c as a description of the nondeterministic choice to make at each step.
(2) If this branch of N ’s computation accepts, accept. Otherwise, reject.

Theorem: HAM P AT H = {hG, s, ti | G is a directed graph with a Hamiltonian path from s to t} ∈ N P


Proof: N = ”On input hG, s, ti, where G is a directed graph with nodes s and t:
(1) Write a list of m numbers, p1 , p2 , ..., pm , where m is the number of nodes in G. Each number in this list is nondeterministically
selected to be between 1 and m.
(2) Check for repetitions in the list. If any are found, reject.
(3) Check whether s = p1 and t = pm . If either fail, reject.
(4) For each i between 1 and m − 1, check whether (pi , pi+1 ) is an edge of G. If any are not, reject. Otherwise, all tests have
been passed, so accept.”

Theorem: CLIQU E = {hGi | G is an undirected graph with a k−clique } ∈ N P


Verifier Proof: V = ”On input hhG, ki, ci,:
(1) Test whether c is a sub-graph with k nodes in G.
(2) Test whether G contains all edges connecting nodes in c.
(3) If both pass, accept. Otherwise, reject.”
NTM Proof: N = ”On input hG, ki,:
(1) Nondeterministically select a subset c of k nodes of G.
(2) If G contains all edges connecting nodes in c, accept. Otherwise, reject.”

Theorem: SU BSET − SU M = {hS, ti | S = {x1 , ..., xk }, and for some {y1 , ..., yl } ⊆ {x1 , ..., xk } we have Σyi = t} ∈ N P
Verifier Proof: V = ”On input hS, ti,:
(1) Test whether c is a collection of numbers that sum to t.
(2) Test whether S contains all the numbers in c.
(3) If both pass, accept. Otherwise, reject.”
NTM Proof: N = ”On input hG, ki,:
(1) Nondeterministically select a subset c of the numbers in S.
(2) If c sums to t, accept. Otherwise, reject.”

NP-Completeness

If a language known to be NP-complete is proven to ∈ P, all problems in NP would be poly-time solvable (P becomes = NP).

A function f : Σ∗ → Σ∗ is a poly-time computable function if a poly-time TM M , on every input w, halts with just f (w) on its tape.

Poly-time Mapping Reducibility: A language A is poly-time mapping reducible to language B, written A ≤p B, if there is a
poly-time computable function f : Σ∗ → Σ∗ , where for every w
w ∈ A ⇔ f (w) ∈ B
Theorem: A language B is NP-complete if it satisfies two conditions:
(1) B ∈ N P
(2) Every A ∈ N P ≤p B

The Cook-Levin Theorem: SAT = {hφi | φ is a satisfiable Boolean formula} is NP-complete (proof not included in these notes)
11

Theorem: SAT ≤p 3SAT (Proof is a slight adjustment to the Cook-Levin Theorem).

Theorem: 3SAT ≤p CLIQU E


Proof Idea: Let φ be a 3-cnf boolean formula with k clauses. The reduction generates a string hG, ki, where G is an undirected
graph defined as follows:
(1) The nodes in G are organized into k groups of three nodes (called triples). Each triple corresponds to one of the clauses in
φ, and each node in the triple corresponds to a literal in the associated clause.
(2) Connect all nodes in G with edges except for these two types:
(a) Nodes in the same triple.
(b) Nodes with contradictory labels (x and x)
If φ has a satisfying assignment, at least one literal in each clause is TRUE. If we select one TRUE node from each triple, we form
a k−clique, where k is the number of clauses.
On the other hand, if G contains a k−clique, we can assign TRUE values to the nodes in this clique and we would obtain a satisfying
assignment for φ (since no two nodes from the same clause (or that have contradictory labels) can exist in this clique)

Theorem: 3SAT ≤p V ERT EX − COV ER = {hG, ki | G is an undirected graph that has a k−node vertex cover} Proof Idea:
Let φ be a 3-cnf boolean formula with k clauses. The reduction generates a string hG, ki, where G is an undirected graph defined as
follows:
(1) Variable Gadget: For every variable x in φ, we create two nodes labeled x and x and connect them with an edge.
(2) Clause Gadget: For every clause in φ, we create a node triple whose nodes are connected and correspond to the variables
in that clause. We then connect each variable in this triple with its corresponding node in the variable gadget.
(3) We let k = m + 2l, where m = the number of variables and l = the number of clauses.

Theorem: 3SAT ≤p HAM P AT H (Proof not included in these notes)

Theorem: HAM P AT H ≤p U HAM P AT H


Proof Idea: This reduction takes a directed graph G with nodes s and t, and constructs an undirected graph G0 with nodes s0 = sout
and t0 = tin as follows:
(1) Replace s with s0 = sout and t with t0 = tin
(2) Replace every node ui between s and t with the triple uin mid , uout .
i , ui i

Theorem: 3SAT ≤p SU BSET − SU M (Proof not included in these notes)

Notes:
• We say that an f (n) ≥ n space TM runs in 2O(f (n)) time
• P 6= EXP T IM E
• Regular languages and CFLs ∈ P

Chapter 8 - Space Complexity


Savitch’s Theorem

Savitch’s Theorem states that any NTM that uses f (n) ≥ n space can be coverted to a deterministic TM that uses f 2 (n) space.
In other words, for f (n) ≥ n,
N SP ACE(f (n)) ⊆ SP ACE(f 2 (n))
where SP ACE(f (n)) is the set of languages decided by an O(f (n)) space deterministic TM, and N SP ACE(f (n)) is the set of
languages decided by an O(f (n)) space NTM.

The Classes PSPACE and NPSPACE

• PSPACE is the class of languages that are decidable in poly-space on a deterministic TM.
• NPSPACE is the class of languages that are decidable in poly-space on a nondeterministic TM (NTM).
We know, by Savitch’s Theorem, that P SP ACE = N P SP ACE (since the square of any polynomial is still a polynomial).

A language B is PSPACE-complete if it satisfies the following two conditions:


(1) B ∈ P SP ACE
(2) Every A ∈ P SP ACE ≤p B (still poly-time reducible; we don’t define poly-space reducibility)
If B only satisfies condition 2, we sat that it is PSPACE-hard .

Theorem: T QBF is PSPACE-complete


Short Proof: First show that T QBF ∈ P SP ACE: T = ”On input hφi, a fully quantified boolean formula:
(1) If φ contains no quantifiers, evaluate φ and accept if it is TRUE. Otherwise, reject.
(2) If φ = ∃xψ, recursively call T on ψ, first substituted with 0 then with 1. If either results accept, accept. Otherwise, reject.
(3) If φ = ∀xψ, recursively call T on ψ, first substituted with 0 then with 1. If both results accept, accept. Otherwise, reject.
Next, show that T QBF is PSPACE-hard: By reducing from a language A ∈ P SP ACE that is decided by a TM M taking input w,
we reach the following boolean formula that is only true iff M accepts w:
φc1 ,c2 ,t = ∃m1 ∀(c3 , c4 ) ∈ {(c1 , m1 ), (m1 , c2 )}[φc3 ,c4 , t ]
2

=⇒ O(f (n)2 ) space.


12

Theorem: F ORM U LA − GAM E is PSPACE-complete


Proof: F ORM U LA − GAM E is exactly the same language as T QBF , just different wording.

Notes:
• N P ⊂ P SP ACE
• coN P ⊂ P SP ACE

The Classes L and NL

• L is the class of languages that are decidable in log-space on a deterministic TM.


• NL is the class of languages that are decidable in log-space on a nondeterministic TM (NTM).

If M is a TM with a separate read-only tape, we define its configuration to only include the current state and the positions of the
two heads. We no longer include the input w in the configuration =⇒ n2O(f (n)) configurations.

Theorem: A = {w = 0k 1k | k ≥ 0} ∈ L (Proof: Count 0’s and 1’s on work tape (log space for binary encoding), and accept if
counts are equal).

Theorem: A = {ww | w ∈ {0, 1}∗ } ∈ L (Proof: First counter counts the length of the input (n), and rejects if n is odd. Then, we
iterate until n
2
, and reject if any wi 6= w n +i . Finally, we accept after the loop terminates with no rejections.)
2

Theorem: P AT H ∈ N L
Proof: N = ”On input hG, s, ti,
(1) Record the position of the current node at each step only on the work tape.
(2) Loop to m = number of nodes and nondeterministically select the next node (from the nodes pointed at by the current
node). If node t is reached, accept.
(3) Reject

A log-space transducer is a TM that computes a function f : Σ∗ → Σ∗ , where f (w) is the string remaining on its output tape
after it halts. It consists of a:
(1) Read-only input tape
(2) Read-write work tape (may contain O(logn) symbols), and a
(3) Write-only output tape (the head on this tape can only move rightward)
A language A is log-space reducible to B, written A ≤L B, if A is mapping reducible to B by means of a log-space computable
function f .

A language B is NL-complete if:


(1) B ∈ N L
(2) Every A ∈ N L ≤L B

Theorem: P AT H is NL-complete
Proof: Consider that A is computed by a log-space TM M on input w, and let the function f reduce A to P AT H:
F = ”On input w,
(1) Construct directed graph G as follows:
(a) Listing the Nodes: Each node of G is a configuration of M on w, and so each node takes clogn space for some
constant c. The transducer goes through all possible strings of length clogn and tests whether each string is a legal
configuration of M on w, then outputs those that pass the test. The start node, s, is the start configuration, and the
target node, t, is the accepting configuration (we modify M to have a unqiue accepting configuration).
(b) Listing the Edges: Similarly, check if some configuration c1 legally yields c2 under the transition function of M
(which can be done in log-space since we only need to check the tape contents under the head locations given by c1 to
determine if the yield is legal). The transducer then outputs all pairs (c1 , c2 ) that qualify.
Notes:
• NL ⊂ P
• N L = coN L

Chapter 9 - Intractability
Circuit Complexity

A Boolean circuit is a collection of gates (AND, OR, and NOT) and inputs connected by wires. It is a Directed Acyclic Graph
(DAG).

A circuit family C is an infinite list of circuits (C0 , C1 , C2 , ...) where Cn has n input variables. We say that C decides a language
A over {0, 1} if, ∀w, w ∈ A ⇔ Cn (w) = 1, where n = len(w).

The circuit complexity of a language is the size (number of gates) complexity of a minimal circuit family for that language.

Theorem: For t(n) ≥ n, if A ∈ T IM E(t(n)), then A has circuit complexity O(t2 (n)) (Proof not included in these notes).

We say that a circuit is satisfiable if some setting of the inputs causes the circuit to output 1.
13

Theorem: CIRCU IT − SAT = {hCi | C is a satisfiable Boolean circuit } is NP-complete


Proof Idea: For the reduction A ≤p CIRCU IT − SAT , to show that w ∈ A ⇔ Boolean circuit C is satisfiable, we obtain the
circuit simulating V , the verifier of A, whose input is hx, ci (by the same method of proof for the previous theorem, which uses
lights/tableau). We fill in the inputs that correspond to x with the symbols of w, and the inputs that remain correspond to c, and
then we output the resultant circuit C.
The running time of V is nk , so the circuit complexity of C is O(n2k ), which is polynomial.

Theorem: CIRCU IT − SAT ≤P 3SAT


Proof: Convert a circuit C to a formula φ, whereby C is satisfiable iff φ is satisfiable. By renaming the input variables (x1 , ..., xl )
and the output (gate) variables (g1 , ..., gm ) as (w1 , ..., wl+m ), we can convert the circuit to a Boolean expression as follows:
(1) NOT Gates: (wi → wj ) ∧ (wi → wj ), which is equivalent to (wi ∨ wj ) ∧ (wi ∨ wj ), where wi is the input variable and wj
is the output variable.

(2) AND Gates: ((wi ∧ wj ) → wk ) ∧ ((wi ∧ wj ) → wk ) ∧ ((wi ∧ wj ) → wk ) ∧ ((wi ∧ wj ) → wk ), which is equivalent to


(wi ∨ wj ∨ wk ) ∧ (wi ∨ wj ∨ wk ) ∧ (wi ∨ wj ∨ wk ) ∧ (wi ∨ wj ∨ wk ), where wi and wj are the inputs and wk is the output.

(3) OR Gates: ((wi ∧ wj ) → wk ) ∧ ((wi ∧ wj ) → wk ) ∧ ((wi ∧ wj ) → wk ) ∧ ((wi ∧ wj ) → wk ), which is equivalent to


(wi ∨ wj ∨ wk ) ∧ (wi ∨ wj ∨ wk ) ∧ (wi ∨ wj ∨ wk ) ∧ (wi ∨ wj ∨ wk ), where wi and wj are the inputs and wk is the output.

(4) Add the clause (wm ) to φ, where wm is the final output gate.
(5) Finally, for any clause containing fewer than 3 literals, we repeat one of the existing literals inside to ensure φ is in 3-cnf.

Hierarchy Theorems

Space Hierarchy

A function f (n) ≥ O(logn) is called space constructible if the function


1n → binary rep. of f (n)
is computable in space O(f (n))

Theorem: For any space constructible function f , a language A exists that is decidable in O(f (n)) space but not in o(f (n)) space.
Proof: D is an O(f (n)) space algorithm that decides languages A which is not decidable in o(f (n)) time:
D = ”On input w:
(1) Let n be the length of w.
(2) Compute f (n) using space constructibility and mark off this much tape. If later stages ever attempt to use more, reject.
(3) If w is not of the form hM i10∗ for some TM M , reject.
(4) Simulate M on w while counting the number of steps used in the simulation. If this count ever exceed 2f (n) , reject.
(5) If M accepts, reject. If M rejects, accept.

Corollaries:
• For any two functions f1 and f2 where f1 (n) = o(f2 (n)) and f2 is space constructible, SP ACE(f1 (n)) ( SP ACE(f2 (n)).
• For any two real numbers 0 ≤ 1 < 2 , SP ACE(n1 ) ( SP ACE(n2 )
• N L ( P SP ACE
• P SP ACE ( EXP SP ACE

Time Hierarchy

A function t(n) ≥ O(nlogn) is called time constructible if the function


1n → binary rep. of t(n)
is computable in time O(t(n))
t(n)
Theorem: For any time constructible function t, a language A exists that is decidable in O(t(n)) time but not in o( logt(n) ) time
(Proof not required).

Corollaries:
2 t (n)
• For any two functions t1 and t2 where t1 (n) = o( logt ) and t2 is time constructible, T IM E(t1 (n)) ( T IM E(t2 (n)).
2 (n)
• For any two real numbers 0 ≤ 1 < 2 , T IM E(n ) ( T IM E(n2 )
1

• P ( EXP T IM E

Chapter 10 - Advanced Topics


Probabilistic Algorithms

A probabilistic TM is a TM that can flip coins by means of a pseudo-random number generator. It is similar to an NTM where
each probabilistic step has 2 equally likely legal moves. We can observe the following probabilities:
• P r[Branch b] = 2 number of coin flips in b
• P r[M acc w] = ΣP r[b], where b is an accepting branch of M
• P r[M rej w] = 1 − P r[M acc w]
14

We say that a probabilistic TM M decides language A with error = ε if:


• w ∈ A =⇒ P r[M acc w] ≥ 1 − ε
• w∈ / A =⇒ P r[M rej w] ≥ 1 − ε

Markov Inequality: Let X be a random variable that takes positive values and let a ≥ 0. Then:
E(X)
P r[X ≥ a] =
a

Chebychev Inequality: Let Y be a random variable and let δ > 0. Then:


V ar(Y )
P r[|Y − E(Y )| ≥ δ] ≤
δ2
where V ar(Y ) = E(Y 2 ) − E(Y )2

Weak Law of Large Numbers: Let X1 , ..., Xn be pair-wise independent random variables (Xi and Xj are independent ∀i 6= j)
with common mean q and common variance σ 2 . Then, ∀ε > 0:
n σ2
P r[| Σ − qn| ≥ εn] =
i=1 ε2 n

Chernoff Inequality: Let X1 , ..., Xn be independent random variables that take 0/1 values and let µ = E(ΣXi ). Then, (∀δ > 0):
i
(1) Upper tail:
2−µ(1+δ)
µ (
e−δ δ > 2e − 1

P r[ΣXi − µ] ≤ ≤ 2
i (1 + δ)1+δ −µ δ4
2 otherwise

(2) Lower tail:



e−δ

δ2
P r[ΣXi − µ] ≤ ≤ e−µ 2
i (1 − δ)1−δ

The Class BPP

1
BPP (Bounded-error Probabilistic Poly-time) is the class of languages decided by a prob. poly-time TM with error = 3
.

The choice of the above value of error is explained by the Amplification lemma: Let A be decidable by a prob. poly-time TM M
with error probability 13 , then, for any f (n) = poly(n), ∃ a prob. poly-time TM M 0 which decides A with error probability e−f (n) .
Proof: M 0 = ”On input w:
(1) Let k = d48f (n)e.
(2) Run M on w k times.
(3) If most runs accept, accept. Otherwise, reject.”
Thus, we obtain (proof using the Chernoff inequality):
• w ∈ A =⇒ P r[M 0 rej w] ≤ e−f (n)
• w∈/ A =⇒ P r[M 0 acc w] ≤ e−f (n)

The Class RP (one-sided error)

RP (Randomized Poly-time) is the class of languages decided by a prob. poly-time TM such that:
• w ∈ A =⇒ P r[M acc w] ≥ 21
• w∈/ A =⇒ P r[M acc w] = 0

We can also replace 21 with any constant or with ε = 1 − 2−f (n) for a polynomial f (n) by running M k times and accepting if at
least one run accepts.

Notes:
• RP ⊂ BP P
• coRP ⊂ BP P
• RP ∩ coRP = ZP P (Zero-error Probabilistic Expected Poly-time)
• BP P ⊂ P SP ACE
• BP P ⊂ P/P oly
15

Elementary Approximation Algorithms

Notes:
• A decision problem A is NP-hard if, ∀B ∈ N P, B ≤P A (A may not be in NP, e.g. TQBF ).
• NP-complete =⇒ NP-hard.
• Existence of a poly-time algorithm for A =⇒ P = N P .

An optimization problem is NP-hard if its corresponding decision problem is NP-hard.

An algorithm for an optimization problem is called a ρ−approximation algorithm if it finds a solution of cost:
• ≤ ρ(cost of minimum cost solution)
• ≥ ρ1 (cost of maximum cost solution)

Approximation algorithm for MIN-VERTEX-COVER:


Approx-VC(G):
(1) C ← φ
(2) E 0 ← E
(3) while E 0 6= φ :
(a) (u, v) ← any edge in E 0
(b) Add u and v to C
(c) Remove every edge incident to either u or v from E 0
(4) return C

Approx-VC is a 2-approximation algorithm for MIN-VERTEX-COVER, i.e. it produces a VC C such that |C| ≤ 2|C ∗ |, where C∗ is
a minimum VC of G.
Proof: Let A = the set of edges selected in step (3a). We have:
(1) |C| = 2|A|
(2) C ∗ contains at least one endpoint of each edge in A (since C ∗ is a VC and A is a set of edges).
(3) No 2 edges in A share an endpoint (by cleanup in step (4)).
By observations 2) and 3) =⇒ |C ∗ | ≥ |A|. Thus, by 1) =⇒ |C| ≤ 2|C ∗ |

Approximation algorithm for MAX-CUT :


Approx-MaxCut(G):
(1) Arbitrarily initialize S and T (e.g. S = φ and T = V ).
(2) while ∃ a node v ∈ S with more adjacent nodes in S than T , or a node u ∈ T vice versa:
(a) Move v to T or u to S.
(3) return (S, T )

Approx-MaxCut is a 2-approximation algorithm for MAX-CUT.


c
Proof: Let Ecut = {(u, v) | u ∈ S and v ∈ T } and Ecut = {(u, v) | u, v ∈ S or u, v ∈ T }
c | = |E|
(1) |Ecut | + |Ecut
c |
(2) By construction, |Ecut | ≥ |Ecut
1 ∗ |, we obtain |E 1 ∗ |
By observations 1) and 2) =⇒ |Ecut | ≥ 2
|E|. Now, by the trivial bound |E| ≥ |Ecut cut | ≥ 2
|Ecut
16

Closure Properties of Some Classes:

Class Union Intersection Concatenation Star Complement


P Yes Yes Yes Yes Yes
NP Yes Yes Yes Yes Open Problem
EXPTIME Yes Yes Yes Yes Yes
PSPACE Yes Yes Yes Yes Yes
EXPSPACE ? ? ? ? Yes
L ? ? ? Yes iff L = NL Yes
NL Yes Yes Yes Yes Yes
BPP Yes Yes ? ? Yes
RP Yes Yes Yes ? Open Problem
ZPP ? ? ? ? Yes
Regular Yes Yes Yes Yes Yes
CFG Yes No Yes Yes No
Decidable Yes Yes Yes Yes Yes
TR Yes Yes Yes Yes No

Properties of ≤P orL (Let CLASS be any of the classes we discussed, such as P, NP, coNP, PSPACE, EXPTIME, L, NL, coNL,...):
• A ≤P orL B and B ∈ CLASS =⇒ A ∈ CLASS.
• A ≤P orL B and A ∈ / CLASS =⇒ B ∈ / CLASS.
• A ≤P orL B, where A is NP(L)-complete and B ∈ N P (L) =⇒ B is NP(L)-complete.

Some Open Problems:


?
• P = NP
?
• P = BP P
?
• P = RP
?
• L = NL
?
• RP = coRP
?
• N P = coN P
?
• N P = P SP ACE
?
• P = P SP ACE
?
• N P = EXP T IM E
?
• P SP ACE = EXP T IM E

Some Hierarchy Relations:


• N L ⊆ P ⊆ N P ⊆ P SP ACE
• P SP ACE ⊆ EXP T IM E ⊆ EXP SP ACE
• N L ⊂ P SP ACE ⊂ EXP SP ACE
• P ⊂ EXP T IM E
Note that a strict subset (proved 6=) is denoted by ⊂, while an unconfirmed subset-equal (= is an open problem) is denoted by ⊆.

You might also like