Regular Expressions and Language Theory Assignment, Cheat Sheet of Compilers

An assignment on regular expressions and language theory. It includes tasks such as defining regular languages, determining equivalence of regular expressions, constructing transition graphs, and proving properties of regular languages using the pumping lemma and arden's theorem.

Typology: Cheat Sheet

2021/2022

Uploaded on 11/15/2022

divyansh-rai-3
divyansh-rai-3 🇮🇳

1 document

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Assignment 2
1. Write down the definition of Regular Language with suitable example.
2. Determine the following claims are true or false for all regular expressions 𝑟1 and 𝑟2. The symbol
stands for equivalence.
a. (𝑟1
) 𝑟1
b. (𝑟1
𝑟2
) (𝑟1+ 𝑟2)
c. (𝑟1
𝑟2
)(𝑟1𝑟2)
3. Give the regular expression of following languages with Σ = {𝑎, 𝑏}:
a. 𝐿1= {𝑎𝑚𝑏𝑛|𝑚 4 𝑎𝑛𝑑 𝑛 1}
b. 𝐿2= {𝑎𝑚𝑏𝑛|(𝑚 + 𝑛) 𝑖𝑠 𝑜𝑑𝑑}
c. 𝐿3= {𝑎𝑚𝑏𝑛|𝑚 3 𝑎𝑛𝑑 𝑛 𝑖𝑠 𝑒𝑣𝑒𝑛}
d. 𝐿1
e. 𝐿2
f. 𝐿3
g. 𝐿4= {𝑣𝑤𝑣|𝑣, 𝑤𝜖{𝑎 , 𝑏} 𝑎𝑛𝑑 |𝑣| 2}
h. 𝐿5= {𝑤|𝑤𝜖{𝑎, 𝑏 } 𝑎𝑛𝑑 |𝑤|𝑚𝑜𝑑3 = 0}
i. 𝐿5
4. Give the regular expression of the following languages with Σ = {𝑎, 𝑏, 𝑐}:
a. All strings having exactly two a’s.
b. All strings having at least two a’s.
c. All strings having at most two a’s.
d. All strings having at least one occurrence of each alphabet.
e. All strings in which all runs of a’s lengths that are multiples of three.
5. Give the regular expression of following languages with Σ = {0, 1}:
a. All strings ending with 11.
b. All strings not ending with 11.
c. All strings, in which first two and last two symbols are same and the length of string is
more than 3.
d. All strings with even number of 1’s.
e. All strings having two times occurrence of 00. 000 is also counted as two time
occurrence of 00.
6. Construct the Generalized Transition Graph (GTG) and find the regular expression of the
following languages:
a. 𝐿 = {𝑤𝜖{0,1}|𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓(0)= 2𝑛 + 1 𝑎𝑛𝑑 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓(1)= 2𝑚 + 1 𝑤ℎ𝑒𝑟𝑒 𝑛, 𝑚
0}
b. 𝐿 = {𝑤𝜖{0,1}|𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓(0)= 2𝑛 𝑎𝑛𝑑 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓(1)= 2𝑚 𝑤ℎ𝑒𝑟𝑒 𝑛, 𝑚 0}
7. Proof that if 𝐿 is a regular language then there exist a regular expression 𝑟 such that 𝐿 = 𝐿(𝑟).
8. Construct the NFA that accepts the following languages on alphabets Σ = {𝑎, 𝑏 }:
a. 𝐿(𝑎+ 𝑎(𝑎 + 𝑏)𝑐)
b. 𝐿(𝑎𝑏𝑎𝑎 +𝑏𝑏𝑎𝑎𝑏)
c. 𝐿((𝑎𝑏𝑎𝑏)+ (𝑎𝑎𝑎+ 𝑏))
pf2

Partial preview of the text

Download Regular Expressions and Language Theory Assignment and more Cheat Sheet Compilers in PDF only on Docsity!

Assignment 2

  1. Write down the definition of Regular Language with suitable example.
  2. Determine the following claims are true or false for all regular expressions 𝑟 1

and 𝑟

2

. The symbol

≡ stands for equivalence.

a.

1

1

b. (𝑟

1

2

1

2

c. (𝑟

1

2

1

2

  1. Give the regular expression of following languages with Σ = {𝑎, 𝑏}:

a. 𝐿

1

𝑚

𝑛

b. 𝐿

2

𝑚

𝑛

c. 𝐿

3

𝑚

𝑛

d. 𝐿

1

e. 𝐿

2

f. 𝐿

3

g. 𝐿

4

h. 𝐿

5

i. 𝐿

5

  1. Give the regular expression of the following languages with Σ = {𝑎, 𝑏, 𝑐}:

a. All strings having exactly two a’s.

b. All strings having at least two a’s.

c. All strings having at most two a’s.

d. All strings having at least one occurrence of each alphabet.

e. All strings in which all runs of a’s lengths that are multiples of three.

  1. Give the regular expression of following languages with Σ = { 0 , 1 }:

a. All strings ending with 11.

b. All strings not ending with 11.

c. All strings, in which first two and last two symbols are same and the length of string is

more than 3.

d. All strings with even number of 1’s.

e. All strings having two times occurrence of 00. 000 is also counted as two time

occurrence of 00.

  1. Construct the Generalized Transition Graph (GTG) and find the regular expression of the

following languages:

a. 𝐿 = {𝑤𝜖

b. 𝐿 = {𝑤𝜖

  1. Proof that if 𝐿 is a regular language then there exist a regular expression 𝑟 such that 𝐿 = 𝐿(𝑟).
  2. Construct the NFA that accepts the following languages on alphabets Σ = {𝑎, 𝑏}:

a. 𝐿(𝑎

b. 𝐿(𝑎𝑏

c. 𝐿((𝑎𝑏𝑎𝑏)

d. 𝐿(

  1. Construct the DFA that accepts the following languages on alphabets Σ = {𝑎, 𝑏}:

a. 𝐿(𝑎𝑎

b. 𝐿(

c. 𝐿(𝑎𝑏

d. 𝐿(𝑎𝑏

  1. Find the equivalent GTG with two states and the language accepted by the following Transition

Graph:

a.

b.

  1. State the Pumping Lemma for the regular languages.
  2. Proof that the following languages are not regular using Pumping Lemma

a. 𝐿 = {𝑤|𝑛

𝑎

𝑏

b. 𝐿 = {𝑤|𝑛

𝑎

𝑏

c. 𝐿 = {𝑎

𝑛

d. 𝐿 = {𝑎

𝑛!

  1. State and proof the Arden’s Theorem.
  2. Find the language accepted by the given NFA using Arden’s Theorem:
  3. State the Kleen’s theorem with suitable example.

Note: If any query please ask in class.