Exercises On Grammars And Regular Expressions Worksheet With Answer Key - Olena Gryn, Louisiana State University, 2006

ADVERTISEMENT

Solutions of the exercises on
Grammars and Regular Expressions
Olena Gryn
olg@itu.dk
December, 2006
updated
Exercise 1 on slide 6
What is the language generated by G
= ({a, b, S, T, U }, {a, b}, S, P ) if P is altered to:
1
S → T
S → bSb
T → aT
T →
Solution
m
n
m
) = {b
: n ≥ 0, m ≥ 0}
L(G
a
b
1
Exercise 2 on slide 6
Make a grammar generating {a
n
2n
: n ≥ 0}
b
Solution
= ({a, b, S}, {a, b}, S, P ) with P defined by:
G
1
S → aSbb|
Exercise on slide 12
Why is the (inductive) definition of a regular expression a proper definition (it seems to be
recursively defined)?
Solution
It is because such defined regular set can be generated by a regular grammar. This follows from
the fact, that every regular set defined by such definition can be recognized by a finite-state
automaton. And this can be proved from the fact, that {a},{ }, ∅ are recognized by a finite-state
automaton, and A
, (A ∪ B), (AB) are recognized by a finite-state machine whenever A and B
are (see pp. 657-658 in Discrete mathematics and Its Applications, by Rosen).
1

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 8