Name - Debraj Saha Reg - No. - D222307730 Sub.-Theory of Automata
Name - Debraj Saha Reg - No. - D222307730 Sub.-Theory of Automata
SCHOOL
Theory of Automata
SESSION: 2024-2025
DEBRAJ SAHA
DEPARTMENT DCST
SEMESTER 5TH
YEAR 3RD
INDEX
ASSIGNMENT NO PARTICULAR PAGE SINGNATURE
NO
1 ASSIGNMENT -1 1-2
2 3-4
ASSIGNMENT -2
3 ASSIGNMENT -3 5-6
4 ASSIGNMENT - 4 7-9
Page – 1
Assignment- 1
Q)
Page- 2
Page – 3
Assignment- 2
Q) Find out Finite Automata of Regular Expression : (a+ba)* bb + (aa)*
=> To construct a Finite Automaton (FA) for the given regular expression (a+ba)∗bb+(aa)∗(a+ba)*bb +
(aa)*(a+ba)∗bb+(aa)∗, let's break it down step-by-step.
(a+ba)∗bb+(aa)∗(a+ba)* bb + (aa)*(a+ba)∗bb+(aa)∗
1. (a+ba)∗bb(a+ba)* bb(a+ba)∗bb:
o This represents a sequence of either 'a' or 'ba' repeated any number of times, followed by the
string 'bb'.
2. (aa)∗(aa)*(aa)∗:
o This represents an even number of 'a's (i.e., 'aa' repeated zero or more times).
NFA Construction:
FA for (aa)∗(aa)*(aa)∗:
NFA Construction:
Page- 4
Now that we have NFAs for both parts of the regular expression, we need to combine them to reflect the
union (a+ba)∗bb+(aa)∗(a+ba)*bb + (aa)*(a+ba)∗bb+(aa)∗.
Final Automaton:
Accepts strings like 'bb', 'abb', 'babb', 'baabb', etc., from the first part
(a+ba)∗bb(a+ba)*bb(a+ba)∗bb.
Accepts strings like '', 'aa', 'aaaa', etc., from the second part (aa)∗(aa)*(aa)∗.
Page- 5
Assignment- 3
Q) L= { aᵖ | p is prime}. Prove this language is not regular.
=>
Page- 6
Thus, pumping the string apa^pap can result in a string whose length is not prime, contradicting the
requirement that the language consists only of strings of prime length.
Step 3: Contradiction
This contradiction implies that the string cannot be pumped, and hence the language L={ap∣p is prime}L = \
{ a^p \mid p \text{ is prime} \}L={ap∣p is prime} does not satisfy the pumping lemma. Therefore, LLL is
not a regular language.
Page- 6
Page-7
Assignment- 4
Q) Convert the following CFG into GNF —
To convert the given Context-Free Grammar (CFG) into Greibach Normal Form (GNF), we
follow a step-by-step process. In GNF, each production must have the form:
Where:
AAA is a non-terminal,
aaa is a terminal,
α\alphaα is a (possibly empty) string of non-terminals.
Given Grammar:
S→ABS \rightarrow ABS→AB A→BS∣bA \rightarrow BS \mid bA→BS∣b B→SA∣aB \rightarrow SA \mid
aB→SA∣a
Step-by-Step Conversion:
Step 1: Rearrange Productions so that RHS starts with a terminal or a single non-terminal
We want to avoid right-hand sides that start with non-terminals. Currently, many productions start with non-
terminals, so we will address that by applying substitution.
Let's first deal with the production S→ABS \rightarrow ABS→AB. The RHS starts with non-terminals, so
we substitute AAA and BBB where needed.
1. S→ABS \rightarrow ABS→AB will be expanded using the production for A→BS∣bA \rightarrow
BS \mid bA→BS∣b. So substitute these into SSS:
o If A→BSA \rightarrow BSA→BS, we get S→BSBS \rightarrow BSBS→BSB.
o If A→bA \rightarrow bA→b, we get S→bBS \rightarrow bBS→bB.
2. Next, handle the production A→BSA \rightarrow BSA→BS. Since B→SA∣aB \rightarrow SA \mid
aB→SA∣a, we substitute:
o If B→SAB \rightarrow SAB→SA, we get A→SASA \rightarrow SASA→SAS.
o If B→aB \rightarrow aB→a, we get A→aSA \rightarrow aSA→aS.
Page-8
We need the productions to start with a terminal followed by (possibly empty) non-terminals. Let's look at
each non-terminal:
1. For SSS, the current productions are: S→BSB∣bBS \rightarrow BSB \mid bBS→BSB∣bB To satisfy
GNF, we substitute the production for B→a∣BSBA∣bBAB \rightarrow a \mid BSBA \mid
bBAB→a∣BSBA∣bBA into S→BSBS \rightarrow BSBS→BSB and S→bBS \rightarrow bBS→bB:
o S→BSBS \rightarrow BSBS→BSB: Replace B→aB \rightarrow aB→a, so S→aSBS \
rightarrow aSBS→aSB, which is valid.
o S→bBS \rightarrow bBS→bB: Replace B→aB \rightarrow aB→a, so S→baS \rightarrow
baS→ba, which is valid.
2. For AAA, the current productions are: A→SAS∣aS∣bA \rightarrow SAS \mid aS \mid bA→SAS∣aS∣b
These already satisfy GNF because they start with terminals.
3. For BBB, the current productions are: B→BSBA∣bBA∣aB \rightarrow BSBA \mid bBA \mid
aB→BSBA∣bBA∣a Let's replace productions to ensure GNF:
o B→BSBAB \rightarrow BSBAB→BSBA: Replace B→aB \rightarrow aB→a, so B→aSBAB
\rightarrow aSBAB→aSBA, which is valid.
o B→bBAB \rightarrow bBAB→bBA: Replace B→aB \rightarrow aB→a, so B→baAB \
rightarrow baAB→baA, which is valid.
Now, the grammar is in GNF, where each production starts with a terminal followed by (possibly empty)
non-terminals.
Page-9
S→aSB∣baS \rightarrow aSB \mid baS→aSB∣ba A→aS∣bA \rightarrow aS \mid bA→aS∣b B→aSBA∣baA∣aB
\rightarrow aSBA \mid baA \mid aB→aSBA∣baA∣a