0% found this document useful (0 votes)
163 views11 pages

Name - Debraj Saha Reg - No. - D222307730 Sub.-Theory of Automata

Uploaded by

debrajsaha252
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
163 views11 pages

Name - Debraj Saha Reg - No. - D222307730 Sub.-Theory of Automata

Uploaded by

debrajsaha252
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

E CALCUTTA TECHNICAL SCHOOL

TH

110, S.N. Banerjee Road, Kolkata, India, West Bengal

Theory of Automata

SESSION: 2024-2025

DEBRAJ SAHA
DEPARTMENT DCST

REG NO. D222307730

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.

Step 1: Breaking down the Regular Expression

The given regular expression is:

(a+ba)∗bb+(aa)∗(a+ba)* bb + (aa)*(a+ba)∗bb+(aa)∗

This can be broken down into two parts:

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).

Step 2: Constructing Finite Automata for each part

FA for (a+ba)∗bb(a+ba)* bb(a+ba)∗bb:

This part consists of two subexpressions:

• a+baa + baa+ba: This represents either 'a' or 'ba'.


• ∗*∗: This allows repeating these subexpressions.
• bbbbbb: Finally, we have the string 'bb' after the repetition.

NFA Construction:

1. A start state q0q_0q0.


2. From q0q_0q0, transition on 'a' to state q1q_1q1.
3. From q0q_0q0, transition on 'b' to state q2q_2q2 and then on 'a' to state q1q_1q1 (to account for 'ba').
4. From q1q_1q1, allow the automaton to loop back to q0q_0q0 to handle repetitions (due to the Kleene
star).
5. From q1q_1q1, transition on 'b' to state q3q_3q3.
6. From q3q_3q3, transition on another 'b' to state q4q_4q4 (accepting state).

FA for (aa)∗(aa)*(aa)∗:

This part represents an even number of 'a's.

NFA Construction:

1. Start at state p0p_0p0.


2. Transition on 'a' from p0p_0p0 to state p1p_1p1.
3. Transition on 'a' again from p1p_1p1 back to p0p_0p0 (accepting state for even number of 'a's).
4. This loop continues for as long as the input consists of 'aa'.

Step 3: Combining the Two Finite Automata


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)∗.

1. Create a new start state qstartq_{\text{start}}qstart.


2. Add ϵ\epsilonϵ-transitions (empty string transitions) from qstartq_{\text{start}}qstart to the start
states of both:
o The NFA for (a+ba)∗bb(a+ba)*bb(a+ba)∗bb.
o The NFA for (aa)∗(aa)*(aa)∗.
3. The final automaton will accept input strings if they are accepted by either of the two NFAs.

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 —

S –> AB, A—> BS | b, B —> SA | a

 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:

A→aαA \rightarrow a\alphaA→aα

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.

Step 2: Substitute non-terminals with their corresponding productions

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.

Thus, SSS now has:

S→BSB∣bBS \rightarrow BSB \mid bBS→BSB∣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.

Thus, AAA now has:

A→SAS∣aS∣bA \rightarrow SAS \mid aS \mid bA→SAS∣aS∣b


Page-8

3. Finally, handle B→SAB \rightarrow SAB→SA in a similar way:


o Substitute S→BSB∣bBS \rightarrow BSB \mid bBS→BSB∣bB into B→SAB \rightarrow
SAB→SA, giving:
▪ If S→BSBS \rightarrow BSBS→BSB, we get B→BSBAB \rightarrow
BSBAB→BSBA.
▪ If S→bBS \rightarrow bBS→bB, we get B→bBAB \rightarrow bBAB→bBA.

Thus, BBB now has:

B→BSBA∣bBA∣aB \rightarrow BSBA \mid bBA \mid aB→BSBA∣bBA∣a

Step 3: Arrange the Productions to GNF Form

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.

Thus, SSS now has:

S→aSB∣baS \rightarrow aSB \mid baS→aSB∣ba

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.

Thus, AAA remains:

A→aS∣bA \rightarrow aS \mid bA→aS∣b

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.

Thus, BBB now has:

B→aSBA∣baA∣aB \rightarrow aSBA \mid baA \mid aB→aSBA∣baA∣a

Final Grammar in GNF:

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

This is the Greibach Normal Form of the given CFG.

You might also like