Escolar Documentos
Profissional Documentos
Cultura Documentos
Date 2011-01-18 Teacher Stefan Bygde Examiner Gordana Dodig-Crnkovi c The exam is in three parts; Regular Languages, Context-Free Languages and Recursively Enumerable Languages. Each part corresponds to a midterm. If you passed the corresponding midterm, you dont need to write it. If you still decide to write it, the best of the exam score and the midterm score will count. This exam is open-book, and any material is allowed except for mobile phones and internet access.
Grading
Exam pass (grade 3) grade 4 grade 5 Regular Languages 7 9 12 Context-Free Languages 7 9 12 Recursively Enumerable Languages 6 8 10 The nal grade in the course will be an average of the above. But all parts have to be passed to get a grade.
How to write
Clearly state which problem on which part of the exam you solve Start every new problem on a new sheet of paper Good Luck! Stefan and Gordana
Consider the NFA above: 1. Convert the automation to a DFA using the subset construction. Show every step. 2. Using the resulting DFA (or the original NFA), create a regular expression by eliminating states. Clearly show every step of the algorithm.
Problem 2 (6 points)
For each of the following languages L. State weather L is regular or not, prove your answer! L is the language over = {a, b} such that any string w contains at least two as but at most two bs. L = {ww|w, w {0, 1}} where w is w but where zeroes are replaced with ones and vice versa. Example: if w = 0110, then w = 1001.
What language does it accept? (3 points) Make a context-free grammar accepting the same language. (5 points)
Problem 2 (6 points)
For the following languages, determine if they are context-free or not. Prove your answer. L = {w {a, b, c}|w every symbol in w occurs the same number of times} L = {ww|w, w {0, 1}} where w is w but where zeroes are replaced with ones and vice versa. Example: if w = 0110, then w = 1001. L = {xyx|x, y {a, b} }
Problem 2 (3 points)
Show that the absolute value (positive dierence) |x y| is computable using primitive recursive functions (by dening a primitively recursive function for it). You may assume that LessThan, Subtract and if are primitively recursive functions. Show one example that |2 3| = 1.
Problem 3 (6 points)
For the following languages, determine if L is decidable or not. Prove your answer. Given a TM M and a string w. Does M accept w within 10 steps? Given a TM M , does M accept more than 10 strings? Given a TM M , does M accept any string of length 10?
Suggested Solutions
Regular Languages, Problem 1
1. The transition function is given below: ({0}, a) = {0} ({0}, b) = {1, 2} ({1, 2}, a) = {1, 2, 3} ({1, 2}, b) = {1, 2} ({1, 2, 3}, a) = {1, 2, 3} ({1, 2, 3}, b) = {1, 2} The resulting automation is shown below:
2. Starting from the previous DFA, we add lambda-transitions from the accepting states, to a single nal state.
The resulting regular expression is: a ( + bb a(a + bb a) ) Note that, depending on in which order you remove the states, you can get dierent regular expressions as result, although they should all describe the same language.
Input was the string abab, and as expected, since abab contains two as, the tape contains 11 when the TM enter its nal state.