



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




CS 172: Computability and Complexity, Spring 2010 S. A. Seshia and O. Etesami
March 1, 2010
Instructions:
This exam is open-book, open-notes. Please turn off and put away electronic devices such as cell phones, laptops, etc.
You have a total of 75 minutes. There are 4 questions worth a total of 100 points. The questions vary in difficulty, so if you get stuck on any question, it might help to leave it and try another one.
Answer each question in the space provided below the question. If you need more space, you can use the reverse side of that page. You can use without proof any result proved in class, in Sipser’s book, or during discussion sections, but clearly state the result you are using.
Do not turn this page until the instructor tells you to do so!
For each of the following questions, state TRUE or FALSE. Justify your answer in brief, indicating only the “proof idea” or counterexample, drawing a diagram if needed.
(a) If L is regular, then so is any subset of L.
(b) Consider the grammar G = ({S, A}, { 0 , 1 }, R, S) where R has the rules S → 0 S 1 | A 1 and A → | 0 S Then L(G) contains the string 00111.
(c) The regular expression (10 ∪ 1)1∗^ generates the language {w | w ∈ { 0 , 1 }∗^ and w contains at least one 1 and at most one 0 }.
Let L = { 1 n^ | n is a prime number}. Prove L is not regular.
[Recall that an integer n is said to be composite (i.e., not prime) if there exists integers n 1 , n 2 > 1 such that n = n 1 n 2 .]
A two-stack pushdown automaton (2-stack PDA) is exactly like a pushdown automaton except that it has two stacks from which we can push and pop at each step. More formally, a 2-stack PDA consists of a 6-tuple (Q, Σ, Γ, δ, q 0 , F ) where the transition function is defined as δ : Q × Σ × Γ × Γ → 2 (Q×Γ×Γ)
If (q′, b′ 1 , b′ 2 ) ∈ (q, a, b 1 , b 2 ), it means that the 2-stack PDA can read the input character a, pop b 1 from the first stack, pop b 2 from the second stack, push b′ 1 onto the stack, push b′ 2 onto the stack, and go from state q to state q′. The acceptance condition for a 2-stack PDA is just as in the PDA.
(a) Let L 1 and L 2 be context-free languages. Show that L 1 ∩ L 2 is recognizable by a 2-stack automaton.