Professional Documents
Culture Documents
Introduction To Automata and Complexity Theory: Cs154.stanford - Edu
Introduction To Automata and Complexity Theory: Cs154.stanford - Edu
Lera Nikolaenko
Sunny Rajan
Textbook
Grades
Homework
Final
Midterm
timelessness
10
Course Outline
PART 1
Finite Automata: Very Simple Models
DFAs, NFAs, regular languages, regular expressions, pumping lemma,
Myhill-Nerode, computing the minimum DFA, streaming algorithms
PART 2
Computability Theory: Very Powerful Models
Turing Machines, decidability, recognizability, reducibility, Rices
theorem, foundations of math, oracles, Kolmogorov Complexity
PART 3
Complexity Theory: The Modern Models
time complexity, classes P and NP, NP-completeness, space
complexity, PSPACE, PSPACE-completeness, polynomial time with
oracles
11
Course Outline
PART 1
Finite Automata: 1940s 50s, 90s present
DFAs, NFAs, regular languages, regular expressions, pumping lemma,
Myhill-Nerode, computing the minimum DFA, streaming algorithms
PART 2
Computability Theory: 1930s 50s, 70s 80s
Turing Machines, decidability, recognizability, reducibility, Rices
theorem, foundations of math, oracles, Kolmogorov Complexity
PART 3
Complexity Theory: 1960s present
time complexity, classes P and NP, NP-completeness, space
complexity, PSPACE, PSPACE-completeness, polynomial time with
oracles
12
CS103 vs CS154
PART 1
Finite Automata
PART 2
Computability Theory
PART 3
Complexity Theory
CS103 gave you a decent intro to all three of these parts
If you havent taken CS103, thats OK, but be warned...
MATHEMATICAL PROOFS
A good proof should be:
Clear -- easy to understand
Correct
14
Heres an example.
Suppose A {1, 2, , 2n} with |A| = n+1
TRUE or FALSE?
There are always two numbers in A such that
one number divides the other number
TRUE
Example: A {1, 2, 3, 4}
1 divides every number.
If 1 isnt in A then A = {2,3,4}, and 2 divides 4
16
LEVEL 1
HINT 1:
THE PIGEONHOLE PRINCIPLE
If you drop 6 pigeons in 5 holes,
then at least one hole will have
more than one pigeon
17
LEVEL 1
HINT 1:
THE PIGEONHOLE PRINCIPLE
If you drop 6 pigeons in 5 holes,
then at least one hole will have
more than one pigeon
18
LEVEL 1
HINT 1:
THE PIGEONHOLE PRINCIPLE
If you drop n+1 pigeons in n holes
then at least one hole will have
more than one pigeon
HINT 2:
Every integer a can be written as
a = 2km, where m is an odd number (k is an integer)
Call m the odd part of a
19
LEVEL 2
Proof Idea:
Given A {1, 2, , 2n} and |A| = n+1
Using the pigeonhole principle,
well show there are elements a1 a2 of A
such that a1 = 2im and a2 = 2km
for some odd m and integers i and k
21
LEVEL 3
Proof:
24
q2
0
1
start state (q0)
q3
states
25
11
1
0,1
1
0111
111
1
0
0
1
Some Vocabulary
An alphabet is a finite set (e.g., = {0,1})
A string over is a finite length sequence of
elements of
* = the set of all strings over
For string x, |x| is the length of x
The unique string of length 0 is denoted by
and is called the empty string
A language over is a set of strings over
In other words: a language is a subset of *
27
Why Languages?
A language over is a set of strings over
In other words: a language is a subset of *
Languages = Functions that take strings as
input, and output a single bit
Every language L over corresponds to a
unique function f : * {0,1}:
Define f such that f(x) = 1 if x L
= 0 otherwise
28
29
: Q Q transition function
q0 Q is start state
F = {q1, q2} Q accept states
q1
1
0,1
q0
q2
0
0
q3
q0
0
q0
1
q1
q1
q2
q3
q2
q3
q0
q2
q2
q2
30
0,1
M
1
0
0,1
33
q0
0,1
L(M) = {0,1}*
34
q0
0,1
L(M) =
35
1
q0
q1
1
36
q0 F
M = ({p,q}, {0,1}, , p, {q})
0
0
1
p
Theorem:
L(M) = {w | w has odd
number of 1s }
1
Proof: By induction on n, the length of a string.
Base Case n=0: L and L(M)
Induction Step Suppose for all w *, |w| = n,
M accepts w
w has odd number of 1s
A string of length n+1 has the form w0 or w1, |w|=n
IH: w has odd # of 1s iff M is in state q after reading w
1. If our string of length n+1 is w0, and w has even # of
1s, then M is in state p after reading w0
M rejects w0
37
0,1
0
0
1
q0
q00
q001
38
39
40
41
42
43
0
1
q0
q1
1
1
0
p0
p1
0
45
1
q0,p0
q1,p0
1
0
1
q0,p1
q1,p1
1
What about the INTERSECTION
of two languages?
46
47
48
50
0,1
0
0,1
end
56