Homework - PowerPoint PPT Presentation

About This Presentation
Title:

Homework

Description:

Section 2; April 17 (Tuesday) 2. Covert the following context-free grammar into a Chomsky Normal Form. S abABCde A aAa B ba C cab. G: S BA | CDg B aEA A DEd C Ce D Df ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 4
Provided by: scie210
Learn more at: http://www.cs.rpi.edu
Category:
Tags: cab | homework

less

Transcript and Presenter's Notes

Title: Homework


1
Homework 7 (Models of Computation, Spring,
2001) Due Section 1 April 16 (Monday)
Section 2 April 17 (Tuesday)
Notice that this homework has 7 problems.
1. This problem is to clean up context-free
grammar G shown below. Using the two algorithms
presented in the class, we are going to eliminate
all useless symbols from the following
context-free grammar G. Answer the following two
questions. (a) Using the algorithm in Lemma 1 for
grammar G construct a context-free grammar G
such that L(G) L(G) and every nonterminal
symbol in G derives a string x ?(VT), where VT
is set of terminal symbols of G. (b) Using the
algorithm in Lemma 2 for grammar G, the result
of part (a), and construct a context-free grammar
G such that L(G) L(G), and for each symbol
X (which is either terminal or nonterminal
symbol) in G, starting with the start symbol,
it is possible to derive a string containing X.
Your answer should include detailed procedure
(steps of the algorithm) that you took to collect
the information needed to get your answer. No
grade will be given to an answer that only shows
the final result.
G S ?BA CDg B ?aEA A ?
DEd C ? Ce D ? Df ?
E ? Eg g F ?
hF h G ?cGCc I ? cDEFab
2. Covert the following context-free grammar into
a Chomsky Normal Form. S ? abABCde
A ? aAa B ? ba C ? cab
2
3. (a) Show that the following grammar is
ambiguous. S ? S S S S
T T ? a b (b) Let be the
addition and be the multiplication. Then the
above grammar generates mathematical expressions
with the two operators on two variable a and b.
Convert the above grammar to an unambiguous
context-free grammar such that it generates the
same language and has higher precedence than
. (c) Convert the above grammar to an
unambiguous context-free grammar such that -
it generates the same language, - the two
operators and have the same precedence, and
- the evaluation is done right to left.
4. The following syntax flow graph is a
simplified definition of the Pascals syntax flow
graph for lt IF statementgt. Assume that all the
strings in a circle are terminal symbols. (a)
Convert this syntax flow graph for ltIf-statementgt
to a context-free grammar that generate the same
language, and show that the grammar is ambiguous.
(b) Convert your grammar to an unambiguous
grammar that generates the same if statements.
You should briefly describe your idea.

3
5. Using the pumping lemma we want to prove
that language L xxR x ?a, b, c is not
regular as follows. Complete the proof by
answering the questions.
Proof. Suppose that L is regular. Then L should
satisfy the pumping lemma. Let n be the constant
of the lemma. Clearly, all the following strings
belong to L. (a) abccba (b)
a100b100b100a100 (c ) an/2bn/2b n/2an/2
(d) anbnbnan Question 1 Which string will you
choose for z of the lemma? Why the other strings
cannot be a candidate for z? If none of the
above strings can be a candidate for z, what is
your choice from L? Question 2 Let u, v, w ?a,
b, c be the strings of the lemma such that z
uvw. What will be in v? Shortly describe all
possible contents of string v. Question 3 The
pumping lemma says For all i ? 0, string uviw ?
L. How do you deal with this statement for your
proof? Justify what you do.
6. Which of the following language are regular.
Prove your answer. Your answer will be graded
according to the logical completeness.
L1 aibjak i, j, k gt 0 L2
aibjai i, j gt 0
7. For a string x, let a(x), b(x), and c(x)
denote, respectively, the number of as, number
of bs and number of cs in string x. Which of
the following languages are context-free? Prove
your answer. Your answer will be graded according
to the logical completeness. L3
x x ?a,b,c, and a(x) gt c(x)
L4 x x ?a,b,c, and a(x) b(x)
c(x) L5 x x ?a,b,c, and
a(x) gt b(x) gt c(x)
Write a Comment
User Comments (0)
About PowerShow.com