NAME ____________________________________________
CS 420/520 Theory of Computation, Spring 2019 at Indiana State University, taught by Jeff Kinne
Exam 3 - Final Exam
Points - each part is graded as 0, 1/3, 2/3, or 3/3.
Part I) Identify which complexity class, and prove it
We have studied the following complexity classes
(A) REG - regular languages, (B) CFL - context-free languages
(C) P - polynomial-time decidable, (D) NP - nondeterministic polynomial time
(E) decidable (but not necessarily in any of the above), (F) undecidable
Questions 1-6 are six languages. There is exactly one for each of the six
complexity classes. For each language, indicate which complexity class it is
in. For (A)-(E), give the appropriate type of machine/algorithm that shows
the language is in the class. For (B) also give a proof that the language
is not regular. For (C) also give a proof that the language is not CF.
For (F) give a proof that the language is not decidable.
I.1. Language - {(ab)^n (ba)^n | n >= 0}
In the language: abba, ababbaba,abababbababa, empty string
Not in the language: abab, aaa, bbb, ab, ba, bababa, abbaba
I.2. Language - {(ab)^n (ba)^m | n >= 0 and m >= 0}
In the language: ab, ba, abba, ababba, ababbaba, baba, empty string
Not in the language: aa, abb, baab, bb, a, b
I.3. Language - {(ab)^n (ba)^n (ab)^n | n >= 0}
In the language: abbaab, ababbabaabab, empty string
Not in the language: abba, abab, baba, a, b, ababbabaab
I.4. Language - {(M, w) | M is a TM that takes two inputs and there exists at least two
different y1 and y2 such that M(x,y1) and M(x, y2) both accept}
I.5. Language - {(M, w) | M is a TM and M(w) accepts using only the tape cells that w
was originally written on}
I.6. Language - { Y | Y is a Java program that never goes into an infinite loop, so it halts for all inputs}
Part II) Regular Languages
II.1. Give a Python3 regular expression for the given language.
Note - you should know what the following symbols do/mean in Python3 RE's
. ^ $ * + ? {} [] () \d \s \w
and you should remember the \\ issue and using r''
Language: valid C identifier string - sequence of at least one character from letters, numbers, underscore, and begins with non-digit.
(More practice - valid phone #, email address, name, sentence.)
II.2. Prove the following statements. Statements I will choose from -
regular languages are closed under intersection
regular languages are closed under union
regular languages are closed under concatenation
regular languages are closed under complement
given an NFA, there exists a DFA that accepts the same language
given a RE, there exists an NFA that accepts the same language
Part III) Context Free Languages
III.1. Given the following CFG -
-->
--> | epsilon
--> '.' | epsilon
--> 'E' | epsilon
--> + | - | epsilon
--> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
Give a string that is in the language:
Give a string that is not in the language:
Is this language itself closed under star? That is, if a string w is in the language, are ww, www, wwww, etc. also in the language?
III.2. Write out the transition table for the following PDA:
http://cs.indstate.edu/~jkinne/cs420-s2019/code/exam3_sample_pda.jpg
Give a string that is accepted by the PDA:
Give a string that is not accepted by the PDA:
What is the shortest string accepted by the PDA?
If the set of accept states was swapped (so 2 and 3 are accept states) - what would the language be?
Part IV) TM's and Other
IV.1. Configuration history of a TM. Write down the configuration of the following TM
running on the following input, and write the configurations until the machine
enters the accept state, enters the reject state, or rejects due to no-transition-
defined.
TM: https://bytesoftheday.files.wordpress.com/2014/10/turing_machine.png
Input: abbc
IV.2. If the language is decidable, describe an algorithm to decide the language and explain
why it is correct. If the language is undecidable, prove it is undecidable using
one of the following techniques - reduction of known undecidable language, application
of Rice's Theorem, or direct proof by diagonalization.
Language - { | Y is a Java program that contains at least one variable that is initialized but then never used after initialization}