CS154
Streaming Algorithms
L = cfw_x | x has more 1s than 0s
Initialize C := 0 and B := 0
Read the next bit x from the stream
If (C = 0) then B := x, C := 1
If (C 0) and (B = x) then C := C + 1
If (C 0) and (B x) then C := C 1
When the stream stops, accep
CS154
Turing Machines
Turing Machine
FINITE
STATE
q1
0
CONTROL
I
A
N
P
U
T
INFINITE TAPE
1
read
write
= cfw_0
move
0 0, R
,R
qaccept
0 0, R
,R
qreject
This Turing machine decides the language cfw_0
2
read
write
0 0, R
= cfw_0
move
,R
qaccept
0 0, R
,R
0
CS 154
A Universal Theory of Data
Compression:
Kolmogorov Complexity
The Church-Turing Thesis:
Everyones
Intuitive Notion = Turing Machines
of Algorithms
This is not a theorem
it is a falsifiable scientific hypothesis.
A Universal Theory of Computation
1
1/30/2014
CS 154
Recognizability, Decidability,
and Reductions
Definition: A Turing Machine is a 7-tuple
T = (Q, , , , q0, qaccept, qreject), where:
Q is a finite set of states
is the input alphabet, where
is the tape alphabet, where
and
: Q Q cfw_L,
2/6/2014
CS 154
Oracles, Rices Theorem,
the Recursion Theorem,
and the Fixed-Point Theorem
Next Thursday (2/13)
Midterm in class
Today: instead of a new homework,
youll get a practice midterm
(Dont panic! Practice midterm will be
harder than midterm)
1
2/
2/11/2014
CS 154
Self-Reference and
the Foundations of Mathematics
Thursday (2/13)
Midterm in class
Well allow one single-sided page of notes
Midterm will cover everything up to and including last
Thursdays lecture
If you are an SCPD student, contact SCPD
CS 154
NP-Complete Problems:
Theyre everywhere.
Theorem (Cook-Levin): 3SAT is NP-complete
Proof Idea:
(1) 3SAT NP (already done)
(2) Every language A in NP is polynomial time
reducible to 3SAT (this is the challenge)
We give a poly-time reduction from A t
2/4/2014
CS 154
Reductions, Undecidability,
and the Post Correspondence
Problem
A Concrete Undecidable Problem
ATM = cfw_ (M, w) | M is a TM that accepts string w
Theorem: ATM is recognizable but NOT decidable
Corollary: ATM is not recognizable
1
2/4/201
CS 154
Time Complexity,
P, and NP
CS 154
Turn in homework!
New homework coming out!
Get started early
1
Complexity Theory
What can and cant be computed with limited
resources on computation,
such as time, space, and so on
Captures many of the significant
1/9/2014
CS 154
Nondeterminism,
Finite Automata,
Regular Expressions
Read string left to right
0
0
1
0111
1
111
11
1
The DFA accepts a string if the process
ends in a double circle
1
1/9/2014
A DFA is a 5-tuple M = (Q, , , q0, F)
Q is the set of states (f
CS 154
More on P vs NP,
the Cook-Levin Theorem
P = TIME(nk)
kN
1
NP =
NNTIME(nk)
k
Theorem: L NP There is a constant k and
polynomial-time TM V such that
L = cfw_ x | y * [|y| |x|k and V(x,y) accepts ]
Proof:
(1) If L = cfw_ x | y |y| |x|k and V(x,y) acc
1/16/2014
CS154
Minimizing DFAs
CS154
Homework 1 is due!
(Turn it in now)
Homework 2 will appear
this afternoon
1
1/16/2014
Does this DFA have a
minimal number of states?
NO
0
1
1
1
1
0
0
0
Is this minimal?
0
1
1
0
2
1/16/2014
Theorem
For every regular la
1/21/2014
CS154
Finishing up DFA Minimization,
The Myhill-Nerode Theorem,
and Streaming Algorithms
CS154
Announcements
Michaels new office hours:
4:15-6:15pm, Gates B28
Please
(take cs154) XOR (take another course at the same time)
1
1/21/2014
Theorem
For
1/14/2014
CS 154
Finite Automata vs
Regular Expressions,
Non-Regular Languages
Regular Languages are closed
under all of the following operations:
Union: A B = cfw_ w | w A or w B
Intersection: A B = cfw_ w | w A and w B
Complement: A = cfw_ w * | w A
1/7/2014
CS 154
Introduction to Automata and
Complexity Theory
http:/stanford.edu/~rrwill/cs154-2014/
cs154.stanford.edu
INSTRUCTORS & TAs
Ryan Williams
Daniel Hollingshead
Michael Kim
1
1/7/2014
Grades
Homework
Final
Midterm
Homework / Problem Sets
Homew