0% found this document useful (0 votes)
13 views

ToC Assignment Solution (1) (1)

Uploaded by

kaushikanirudh38
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)
13 views

ToC Assignment Solution (1) (1)

Uploaded by

kaushikanirudh38
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
You are on page 1/ 4

@OpenAl

S — aSb|bSa|e

10. CFG and Unambiguity

* Context-Free Grammar (CFG): A set of production rules generating a language where every
derivation has a single parse tree.
e Unambiguity: A grammar is unambiguous if every string has a unique parse tree.

11. Regular Language Verification

e L = {a™™|n,m > 1} : Regular, as it can be expressed by a™b™.


e L = {a""|n > 1} : Not Regular, proven by Pumping Lemma.
e L= {a™V"|m > n} : Not Regular, as balancing is required.

12. CNF and GNF Construction

1. Normalization Steps:
o Remove null, unit, and useless productions.
o Convert to Chomsky Normal Form (CNF): Every rule is A — BC orA — a.
o Convert to Greibach Normal Form (GNF): Every rule is A — aa, where ais a string of
variables.

13. CFG for (011 + 1)(01):


S—AB, A—011|1, B—01

Let me know if you'd like detailed explanations for specific questions or visual aids like diagrams for
automata!

Q
yes provide detailed explaination for all these questions

)
I'll provide a detailed explanation for each question step by step.

1. Definitions

* Finite Automata (FA): A mathematical model used to recognize regular languages. It consists of:

o Afinite set of states (Q).


o An input alphabet ().
o A transition function (4).
o An initial state (qo).
o Aset of accepting states (F).

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTIVIL to PDE AP 477
@OpenAl
Example: Recognizing binary strings divisible by 2.

o Q= {qo,q1}, X ={0,1}, qo is the initial state, and F' = {qo}.


e Transition Diagram: A visual representation of an FA where:
o States are represented as circles.
o Transitions are arrows labeled with input symbols.
o The initial state has an incoming arrow with no source.
o Accept states are denoted by double circles.
Example: Diagram for binary divisibility by 2:

go — g1 on input 1, and ggp — gp on 0.

2. e-closure(q) and DFA Construction

e e-closure(q): The set of all states reachable from g using zero or more e-transitions.

Example: For states qq, g1, and gg:


€ €
P—q% G—¢@

e-closure(qo) = {qo, a1, 32}-


DFA Construction for Each Language:

1.L = {z € {a,b} : x|, is odd and |z|; is even} :

o States track the parity of@ and b.


Create four states (Odd,, Eveny), (0dd,, Oddy), (Even,, Eveny), (Even,, Oddy).
o

2. Binary strings where the third symbol from the right is 1:


o Use three states to track the last three symbols.
o Final state accepts if the third symbol is 1.
3. Strings where the number of 1’s =3 mod 4 :
o Create four states qp, 1, g2, g3 for remainders 0, 1, 2, 3.
© Transition ¢i —> q(i4+1) mod 4-
4. Strings with three consecutive 0’s:

o States track 0, 00, 000.


o Transition on 1 resets the progress.

3. DFA and NFA for Substrings

* DFA for “000” as a substring:

o States track how much of “000” has been seen.


o State g3 is the final state for matching.
Diagram:
0 0 0
Q0 —q —q@ g3
o NFA for two consecutive 0’s:

o States gy — g; on 0, and g; — g2 on 0.

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTIVIL to PDE AP 5/7
@OpenAl
o Non-deterministic because it doesn't reset progress for other inputs.

4.0dd 1’s and Even 0’s:

e States:
o go: Even 1’s and Even 0’s (Initial state).
o gp:0dd 1’s and Even 0’s.
o gp:Even 1’s and Odd 0’s.
o ¢3:0dd 1’s and Odd 0’s.

5. Relations Among Automata Types

® Regular expressions — NFA — DFA (using subset construction).


e DFA — Regular expressions (using state elimination).
e &-NFA adds e-transitions for flexibility, no power difference.

6. Pumping Lemma and L = {0"1"}:


o Assume L is regular.
e Pumping length
p. Fors = 0P17:
o s =zyz,[zyl < p,|y| > 0.
TS Ok,k' > 0.Pump y: zyQZ = 0P**17, which is not in L.

7 & 8. Regular Expressions

1. 0dd number of 1’s: (01*1)*.


2. strings ending in 00: (0 + 1)*00.
3. L1: Same as (2).
4. Ly:0(0 + 1)1

9. CFG for Equal a’s and b’s:

S — aSb|bSa|e

10. CFG and Unambiguity

e CFGis unambiguous if every string in the language has only one parse tree.

11. Regular Language Verification

1.L = {a"b™|n,m > 1} : Regular.


2. L = {a"b"|n > 1} : Not regular (Pumping Lemma).
3. L = {a™b"|m > n} : Not regular (requires counting).

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTIVIL to PDE AP 6/7
@OpenAl

12. CNF and GNF Conversion

e Convert productions:
o CNF: Every production A — BC orA — a.
o GNF: A — aa, whereais a string of variables.

13. CFG for (011 + 1)(01):


S—AB, A—011|1, B—01

If you need any of these solved in more depth, let me know!

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTIVIL to PDE AP 717

You might also like