600.271: Automata and Computation Theory, Fall 2015
Midterm 2 - Thursday, October 29th
Name (print): 3 O LL/lﬂ O N S JHED ID:
Academic Integrity Pledge.
“I agree to complete this exam without unauthorized assistance from any person, materials or device. ”
1
600.271: Automata and Computation Theory, Fall 2015
Midterm 1 SOLUTIONS
1. (20 points) Give a regular expression generating the following language L1 over alphabet = cfw_r, s, t.
L1 = cfw_ w | w contains substrings rs and trt
rs trt
trt rs
2. (20 poi
Complement Operation on Sets
l
Complement is a unary operation on sets where
complement(B) = B = cfw_ w | w is not a member of B
But w has to be a member of the universe of items we
consider
l
So if were talking about some alphabet and some
language B ov
Example
Given NFA N over alphabet = cfw_a,b:
Convert it to DFA M using the subset construction
Example
We construct DFA M = (Q, , , start, F),
where:
Q = P(Q) = cfw_ cfw_ , cfw_1,cfw_2,cfw_3,cfw_1,2,cfw_1,3,cfw_2,3,cfw_1,2,3
=
= see next slide
start =
F
Syllabus
Computer Science 600.271
Automata and Computation Theory
Fall, 2015
(3 credits, EQ)
Description
This course is an introduction to the theory of computing. Topics include design of finite state automata,
pushdown automata, linear bounded automata,
600.271: Automata and Computation Theory
Closure of Turing-Decidable Languages Under Kleene Star
Closure of Turing-Recognizable Languages Under Kleene Star
Here are two examples of closure proofs, both involving the Kleene star operation. While one can wr
600.271: Automata and Computation Theory, Fall 2015
Practice Problems, Section 1.1
All textbook references (page numbers, problem numbers, etc.) in this course come from the 3rd
edition of the Sipser text. Exercises and problems from the Sipser textbook a
26/39
Union: an operation on two sets (languages)
Recall the union operation on two sets:
A [ B = cfw_x | x 2 A or x 2 B
Note that union is an operation performed over two sets, not over two
individual strings! In our case, the sets are languages.
600.2
1
Consider the language
A = cfw_ 0 n1 n | n 0
l
Notation: xn means x concatenated n times (not
arithmetic exponentiation!)
l
Can you design an NFA which recognizes A?
2
Consider the language
A = cfw_ 0 n1 n | n 0
l
Notation: xn means x concatenated n ti
Automata and Computation Theory
Closure of Turing-Decidable Languages Under Kleene Star
Closure of Turing-Recognizable Languages Under Kleene Star
Here are two examples of closure proofs, both involving the Kleene star operation. While one can write
these
New Tool: Nondeterminism
Until now, FA were deterministic, meaning each
step of computation was uniquely determined by
the current state and next input there were no
choices to make
Well start calling these DFA now
New Type of FA: Nondeterministic
Finite
Build a TM M1 to recognize
L 1 = cfw_ 0 n1 n | n > 0
IDEA:
Scan the input on the tape, matching each 0 with a 1.
Mark off the characters as we match them up by
writing over them with new symbols.
Once weve marked everything off, we know the input
string
New Model of Computation: PDAs
l
Pushdown Automata (PDAs)
l
Like NFAs, but have extra memory: a stack
PDA can write symbols on the stack and read them back later
Stack characters come from a set of symbols called
( may be same or different from )
Read
600.271 Automata and Computation Theory, Fall 2015
Practice Problems, Chapter 5 (Sections 5.1, 5.3)
TIP1: For these problems (as for problems related to Chapter 4), be sure that you have a copy of the
handout Transform-computing Turing machines and some T
600.271: Automata and Computation Theory, Fall 2015
Practice Problems, Chapter 4 (Sections 4.1, 4.2)
TIP 1: For these problems, be sure that you have a copy of the handout Transform-computing Turing
machines and some Turing-decidable problems to which you
Relationships Among
Classes of Languages
l
We know there are languages which arent regular.
Are there languages which arent even context-free?
regular
languages
context-free
languages
?
Are there languages which arent
even context-free?
l
Consider the fol
Reducibility
l
Reducing problem A to another problem B means
converting A into another (related) problem,
where a solution to B can be used to give a
solution to A
l
Real-life example: finding your way around campus
reduces to finding a campus map
l
Givin
600.271: Automata and Computation Theory, Fall 2015
Practice Problems, Section 1.2
Section 1.2 Nondeterminism
(A) Show that the language L = cfw_w | w contains substring 111 or substring 101 over alphabet
= cfw_0, 1 is regular. (Note that the mathematica
Comprehension Check (Clicker Q)
l
Acceptance problem for TMs
ATM = cfw_ <M,w> | M is a TM that accepts string w
How would you expect we can classify ATM?
A)
B)
C)
D)
both Turing-recognizable and co-Turing-recognizable
Turing-recognizable but not co-Turin
Chapter 4: Decidability
l
Question: Which problems can be completely
solved by an algorithm (and therefore a TM), and
which cannot?
l
decidable is the same as Turing-decidable
Acceptance Problem for DFAs
l
Suppose we wish to ask:
For a given DFA D and str
EXAMPLE:
Put the following CFG into
Chomsky Normal Form (CNF)
S ABS |
A xyz |
B wB | v
1) Add new start symbol
S ABS |
A xyz |
B wB | v
S0 S
S ABS |
A xyz |
B wB | v
2) Remove epsilon rules
S0 S
S ABS |
A xyz |
B wB | v
S0 S
S ABS | | BS
A xyz
B w
Comprehension Check (Clicker Q)
l
The pumping lemma starts with If L is a regular
language, then.
l
We use the pumping lemma to show that a
language is:
a) Regular
b) Not Regular
Pumping Lemma
l
The pumping lemma starts with If L is a regular
language, th
600.271: Automata and Computation Theory, Fall 2015
Example: Proof Using the Pumping Lemma for Context-Free Languages
The notation nx (y) is used to indicate the number of occurrences of symbol x in a string y. As an
example of using the Pumping Lemma for
Context-Free Languages
l
Definition: A language is called context-free if it
is generated by a context-free grammar
l
How does the class of context-free languages
compare to the class of regular languages?
l
How do you know?
Another Example Grammar
S NP V
600.271: Automata and Computation Theory, Fall 2015
Practice Problems, Section 2.2
Section 2.2 Pushdown Automata
(A) Sipser 2.5 b c e f (and also the rest)
(B) Sipser 2.10
(C) Sipser 2.11
(D) Give a PDA recognizing the language described in Sipser 2.22.
(
600.271: Automata and Computation Theory, Fall 2015
Practice Problems, Section 1.3
Section 1.3 Regular Expressions
(A) Sipser 1.18 c,d,h,k,l (and also the rest)
(B) Sipser 1.19 a,c (and also b)
(C) Sipser 1.20 a,b,e,h (and also the rest)
(D) Sipser 1.21 a
600.271: Automata and Computation Theory, Fall 2015
Practice Problems, Section 1.4
Section 1.4 Nonregular Languages
(A) Sipser 1.29 b (and also a and c)
(B) Sipser 1.30
(C) Use the Pumping Lemma to show that the language L = cfw_an bm | 0 m n is nonregula
CSC 3314: Theory of Computation
Practice Problems, Section 2.1
Section 2.1 Context-Free Grammars
(A) Sipser 2.1 c d
(B) Sipser 2.3 e f g h i j l n
(C) Sipser 2.4 b d f
(D) Sipser 2.6 b (and also the rest)
(E) Sipser 2.13
THE PROBLEMS BELOW COVER MATERIAL
600.271: Automata and Computation Theory, Fall 2015
Practice Problems, Section 2.3
Section 2.3 Non-Context-Free Languages
(A) Sipser 2.2
(B) Sipser 2.30 a d
(C) Sipser 2.31
(D) Sipser 2.33.
In some versions of the 2nd edition, Sipser 2.33 has a typo in it
600.271: Automata and Computation Theory, Fall 2015
Topics to Review for the Final Exam
During the course of the semester, we covered Sipser Ch 1, Ch 2 except 2.4, Ch 3, Ch 4, Ch 5 except 5.2, and Ch 7.
On the final, there will be slightly more emphasis o