0% found this document useful (0 votes)
22 views12 pages

Final 02 SD

Uploaded by

Ahmed Ibrahim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views12 pages

Final 02 SD

Uploaded by

Ahmed Ibrahim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Final Exam

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.

Signature and Date

• 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

(a) TRUE FALSE — If a language L is accepted by a nondeterministic finite au-


tomaton, then there must be some PDA that also accepts
L.

(b) TRUE FALSE — If L is generated by a context-free grammar that is not a


regular grammar, then L must not be a regular language.

(c) TRUE FALSE — If L1 is a context-free language and L2 is not context-free,


then L1 L2 must be context-free.

(d) TRUE FALSE — If L1 is a context-free language and L2 is not context-free,


then L1 L2 must not be context-free.

(e) TRUE FALSE — Every context-free language is a nonregular language.

(f) TRUE FALSE — Every nondeterministic PDA can be transformed into an


equivalent deterministic PDA.

(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.

(h) TRUE FALSE — If w is an input string and T is a transition graph, then T


must either accept or reject w.

(i) TRUE FALSE — If w is an input string and T is a Turing machine, then T


must either accept or reject w.

(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.

2.1. If a language L is finite, then


(a) there must not exist a pushdown automaton for L.
(b) L must have a transition graph.
(c) L must be a non-regular language.

2.2. If L1 and L2 are context-free languages, then L1 ∩ L2


(a) must be context-free.
(b) must not be context-free.
(c) may or may not be context-free.

2.3. If L is a language accepted by a nondeterministic finite automaton, then L


(a) must be context-free.
(b) must not be context-free.
(c) may or may not be context-free.

2.4. If L is not a context-free language, then


(a) L must be finite.
(b) L must be a non-regular language.
(c) L must be a regular language.

2.5. If L is generated by a context-free language in Chomsky normal form, then


(a) L must be regular.
(b) L must be non-regular.
(c) L can be either regular or non-regular.

2.6. If L is accepted by a finite automaton, then


(a) there must exist some Turing machine that accepts L.
(b) there must not exist some Turing machine that accepts L.
(c) there may or may not exist some Turing machine that accepts L.

2.7. If L is a language accepted by some Turing machine M , then


(a) w ∈ L0 must be rejected by M .
(b) running M with w ∈ L initially loaded on the TAPE will result in M ending in
a HALT state.
(c) L must be a nonregular language.

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

where S, X are nonterminals.


(iv) L has context-free grammar

S → aSa | aXa
X → aX | bX | Λ

where S, X are nonterminals.


Which of the following is true?
(a) Only statement (i) is correct.
(b) Only statement (ii) is correct.
(c) Only statement (iii) is correct.
(d) Only statement (iv) is correct.
(e) Only statements (i) and (iii) are correct.
(f) Only statements (i) and (iv) are correct.
(g) Only statements (ii) and (iii) are correct.
(h) Only statements (ii) and (iv) are correct.
(i) Only statements (ii), (iii) and (iv) are correct.
(j) All the 4 statements are correct.
(k) None of the 4 statements is correct.

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:

(i) L is a regular language.


(ii) L is a context-free language, but not a regular language.
(iii) L is recursively enumerable, but not a context-free language.

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, . . .).

Circle one: Category (i) Category (ii) Category (iii)

(b) L = {bn an bn : n ≥ 0}.

Circle one: Category (i) Category (ii) Category (iii)

6
(c) L = {a2n : n ≥ 0}.

Circle one: Category (i) Category (ii) Category (iii)

(d) L = {am bm an bn : m ≥ 0, n ≥ 0}.

Circle one: Category (i) Category (ii) Category (iii)

Scratch-work area for problem 3.

7
4. [10 points] Let L = {a3n b2n : n = 0, 1, 2, . . .}.

(a) [5 points] Give a pushdown automaton that accepts L.

Draw PDA here:

8
(b) [5 points] Give a Turing machine that accepts L.

Draw Turing machine here:

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?

YES NO (Circle one)

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.

Prove that (L1 ∩ L2 )L3 is a context-free language.

12

You might also like