Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

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.

What you will learn

  • Are the given claims about regular expressions true or false?
  • Find the language accepted by the given NFA using Arden's Theorem.
  • State and prove Arden's Theorem.
  • Write the regular expression for the given languages.
  • Prove that if a language is regular, there exists a regular expression that generates it.
  • Prove that the given languages are not regular using the Pumping Lemma.

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.