Final 02 SD
Final 02 SD
CIS 341: Introduction to Logic and Automata — Spring 2002, day sections
Prof. Marvin K. Nakayama
Print Name:
Student Number:
I have read and understand all of the instructions below, and I will obey the Academic Honor
Code.
• This exam has 12 pages in total, numbered 1 to 12. Make sure your exam has all the
pages.
• This exam will be 2.5 hours in length.
• This is an open-book, open-note exam.
• For all problems, follow these instructions:
1. Show your work and give reasons (except for question 1).
2. Give only your answers in the spaces provided. I will only grade what you put in the
answer space, and I will take off points for any scratch work in the answer space.
Use the scratch-work area to work out your answers before filling in the answer
space.
3. FA stands for finite automaton; TG stands for transition graph; CFG stands for
context-free grammar; CFL stands for context-free language; PDA stands for push-
down automaton; TM stands for Turing machine.
4. For any proofs, be sure to provide a step-by-step argument, with justifications (e.g.,
cite a theorem or definition in the textbook) for every step. You may assume that
the theorems in the textbook hold; i.e., you do not have to reprove the theorems in
the textbook. When using a theorem or result from the textbook, make sure you
refer to it by number (e.g., Theorem 3) or page number.
Problem 1 2 3 4 5 6 Total
Points
1
1. [20 points] For each of the following, circle TRUE if the statement is always correct.
Otherwise, circle FALSE
(g) TRUE FALSE — We can construct a PDA for the language L = {a2n bn :
n = 1, 2, 3, . . .} by first constructing an FA for L, and then
converting the FA into a PDA for L.
(j) TRUE FALSE — There is a Turing machine that can take as input any
encoded Turing machine P and any input w for P and
decide if P halts on input w.
2
2. [20 points] For each of the following multiple-choice questions, circle the letter of the
correct answer.
3
2.8. Let Σ = {a, b}, and let L be the language over Σ exactly consisting of all strings
that do not contain the substring aaa. Consider the following regular expressions:
(i) (a + b)∗ (a + aa)∗ (a + b)∗
(ii) (b + ab + aab)∗ (Λ + a + aa)
(iii) (Λ + a + aa)(b + ba + baa)∗
Which of the following is correct?
(a) Only regular expression (i) generates L.
(b) Only regular expression (ii) generates L.
(c) Only regular expression (iii) generates L.
(d) Only regular expressions (i) and (ii) generate L.
(e) Only regular expressions (i) and (iii) generate L.
(f) Only regular expressions (ii) and (iii) generate L.
(g) All 3 regular expressions generate L.
(h) None of the 3 regular expressions generates L.
2.9. Let Σ = {a, b}, and let L = {an wan : n ≥ 1, w ∈ Σ∗ }. Consider the following
statements:
(i) L has regular expression a∗ (a + b)∗ a∗ .
(ii) L is a non-regular language.
(iii) L has context-free grammar
S → aSa | aS | bS | aa
S → aSa | aXa
X → aX | bX | Λ
4
2.10. Suppose L is a language generated by a regular grammar, and consider the following
statements:
(i) L is a regular language.
(ii) L is a context-free language.
(iii) There is a Turing machine that accepts L.
Which of the following is correct?
(a) Only statement (i) is true.
(b) Only statement (ii) is true.
(c) Only statement (iii) is true.
(d) Only statements (i) and (ii) are true.
(e) Only statements (i) and (iii) are true.
(f) Only statements (ii) and (iii) are true.
(g) All 3 statements are true.
(h) None of the 3 statements is true.
5
3. [20 points] Let Σ = {a, b}. Each of the following languages L defined over Σ falls into
one of the following categories:
For each of the following languages, specify which category it is in. If a language L is in
category (i), give a regular expression for L. If a language L is in category (ii), give a
context-free grammar for L. If a language L is in category (iii), you only need to specify
that it is in this category.
(a) L exactly consists of all strings w ∈ Σ∗ such that w = reverse(w) and the length of
w is divisible by 4 (i.e., w has length 4n for some n = 0, 1, 2, 3, . . .).
6
(c) L = {a2n : n ≥ 0}.
7
4. [10 points] Let L = {a3n b2n : n = 0, 1, 2, . . .}.
8
(b) [5 points] Give a Turing machine that accepts L.
9
Scratch-work area for problem 4.
10
5. [10 points] Let L1 , L2 , L3 , . . . be an infinite sequence of context-free languages, each of
which is defined over a common alphabet Σ. Let L be the infinite union of L1 , L2 , L3 , . . .;
i.e., L = L1 + L2 + L3 + · · ·. Is it always the case that L is a context-free language?
If your answer is YES, give a proof. If your answer is NO, give a counterexample. Explain
your answer.
11
6. [20 points] Let L1 , L2 , and L3 be languages defined over the alphabet Σ = {a, b},
where
• L1 consists of all possible words over Σ except the words w1 , w2 , . . . , w100 ; i.e., start
with all possible words over the alphabet, take out 100 particular words, and the
remaining words form the language L1 ;
• L2 can be generated by a context-free grammar that is a regular grammar; and
• L3 is accepted by some push-down automaton.
12