Flat Concepts
Flat Concepts
FORMAL LANGUAGES,
AUTOMATA AND
COMPUTABILITY
15-453
FORMAL LANGUAGES,
AUTOMATA AND
COMPUTABILITY
YOU NEED TO PICK UP
• THE SYLLABUS,
• THE COURSE SCHEDULE,
• THE PROJECT INFO SHEET,
• TODAY’S CLASS NOTES
WWW.FLAC.WS
INSTRUCTORS & TAs
Final 15%
25% Midterm II
15%
Project
Final 15%
25% Midterm II
15%
HOMEWORK
Homework will be assigned every Tuesday and
will be due one week later at the beginning of
class. Late homework will be accepted only under
exceptional circumstances.
• What's New]
This class is about mathematical
models of computation
WHY SHOULD I CARE?
WAYS OF THINKING
PART 2
Computability Theory:
Turing Machines, decidability, reducibility, the arithmetic hierarchy, the
recursion theorem, the Post correspondence problem.
PART 3
Complexity Theory and Applications:
time complexity, classes P and NP, NP-completeness, space complexity,
PSPACE, PSPACE-completeness, the polynomial hierarchy, randomized
complexity, classes RP and BPP.
Mathematical Models of Computation
(predated computers as we know them)
PART 1 1940’s-50’s (neurophysiology,
Automata and Languages: linguistics)
finite automata, regular languages, pushdown automata, context-free
languages, pumping lemmas.
PART 2
Computability Theory: 1930’s-40’s (logic, decidability)
Turing Machines, decidability, reducibility, the arithmetic hierarchy, the
recursion theorem, the Post correspondence problem.
PART 3 1960’s-70’s
Complexity Theory and Applications: (computers)
time complexity, classes P and NP, NP-completeness, space complexity,
PSPACE, PSPACE-completeness, the polynomial hierarchy, randomized
complexity, classes RP and BPP.
This class will emphasize PROOFS
TRUE or FALSE:
There are always two numbers in A
such that one divides the other
TRUE
LEVEL 1
HINT 1:
THE PIGEONHOLE PRINCIPLE
If you put 6 pigeons in 5 holes
then at least one hole will have
more than one pigeon
LEVEL 1
HINT 1:
THE PIGEONHOLE PRINCIPLE
If you put 6 pigeons in 5 holes
then at least one hole will have
more than one pigeon
LEVEL 1
HINT 1:
THE PIGEONHOLE PRINCIPLE
If you put 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
LEVEL 2
PROOF IDEA:
Given: A ⊆ {1, 2, …, 2n} and |A| = n+1
TUESDAY JAN 14
11 1
0
0,1
1
0111 111 1
0 0
0 0
1
start state (q0) q3 states
SOME VOCABULARY
An alphabet Σ is a finite set (e.g., Σ = {0,1})
M accepts ε iff q0 ∈ F
L(M) = ?
q0 0,1
L(M) = ?
0 0
1
q0 q1
1
L(M) = ?
0 0
1
q0 q1
1
1
p q
1
Q Σ q0 F
δ 0 1
M = ({p,q}, {0,1}, δ, p, {q})
p p q
0 0
q q p
1 THEOREM:
p q L(M) = {w | w has odd
1 number of 1s }
Q Σ q0 F
δ 0 1
M = ({p,q}, {0,1}, δ, p, {q})
p p q
0 0
q q p
1 THEOREM:
p q L(M) = {w | w has odd
1 number of 1s }
Proof: By induction on n, the length of a string.
Base Case: n=0: ε ∉ RHS and ε ∉ L(M). Why?
Q Σ q0 F
δ 0 1
M = ({p,q}, {0,1}, δ, p, {q})
p p q
0 0
q q p
1 THEOREM:
p q L(M) = {w | w has odd
1 number of 1s }
Proof: By induction on n, the length of a string.
Base Case: n=0: ε ∉ RHS and ε ∉ L(M). Why?
Induction Hypothesis: Suppose for all w ∈ Σ*, |w| = n,
w ∈ L(M) iff w has odd number of 1s.
Induction step: Any string of length n+1 has the form w0 or w1.
Q Σ q0 F
δ 0 1
M = ({p,q}, {0,1}, δ, p, {q})
p p q
0 0
q q p
1 THEOREM:
p q L(M) = {w | w has odd
1 number of 1s }
Proof: By induction on n, the length of a string.
Base Case: n=0: ε ∉ RHS and ε ∉ L(M). Why?
Induction Hypothesis: Suppose for all w ∈ Σ*, |w| = n,
w ∈ L(M) iff w has odd number of 1s.
Induction step: Any string of length n+1 has the form w0 or w1.
Now w0 has an odd # of 1’s ⇔ w has an odd # of 1’s⇔
M is in state q after reading w (why?) ⇔
M is in state q after reading w0 (why?) ⇔w0 ∈ L(M)
Q Σ q0 F
δ 0 1
M = ({p,q}, {0,1}, δ, p, {q})
p p q
0 0
q q p
1 THEOREM:
p q L(M) = {w | w has odd
1 number of 1s }
Proof: By induction on n, the length of a string.
Base Case: n=0: ε ∉ RHS and ε ∉ L(M). Why?
Induction Hypothesis: Suppose for all w ∈ Σ*, |w| = n,
w ∈ L(M) iff w has odd number of 1s.
Induction step: Any string of length n+1 has the form w0 or w1.
Now w1 has an odd # of 1’s ⇔ w has an even # of 1’s⇔
M is in state p after reading w (why?) ⇔
M is in state q after reading w1 (why?) ⇔w1 ∈ L(M) QED
Build a DFA that accepts all and only those
strings that contain 001
Build a DFA that accepts all and only those
strings that contain 001
0,1
1 0
0 0 1
q q0 q00 q001
1
DEFINITION: A language L is
regular if it is recognized by a DFA,
i.e. if there is a DFA M s.t. L = L(M).
Proof: Let
M1 = (Q1, Σ, δ1, q01, F1) be finite automaton for L1
and
M2 = (Q2, Σ, δ2, q0, F2) be finite automaton for L2
2
q0 = (q10, q20)
F = { (q1, q2) | q1 ∈ F1 or q2 ∈ F2 }
1
q0 q1
1 1
1
0
p0 p1
0
UNION? INTERSECTION?
UNION
1
q0,p0 q1,p0
1
0 0
0 0
1
q0,p1 q1,p1
1
INTERSECTION
1
q0,p0 q1,p0
1
0 0
0 0
1
q0,p1 q1,p1
1
Intersection THEOREM
Given two languages, L1 and L2, define
the intersection of L1 and L2 as
L1 ∩ L2 = { w | w ∈ L1 and w ∈ L2 }