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

TCS UT 1 QB

The document discusses various concepts in formal languages, including the construction of epsilon NFA for a given regular expression, the definition of homomorphism, and properties of regular and context-free languages. It also addresses the differences between NFA and DFA, Mealy and Moore machines, and the pumping lemma for regular languages. Additionally, it covers ambiguous grammar and provides examples of derivations and parse trees.

Uploaded by

hulk81947
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)
11 views

TCS UT 1 QB

The document discusses various concepts in formal languages, including the construction of epsilon NFA for a given regular expression, the definition of homomorphism, and properties of regular and context-free languages. It also addresses the differences between NFA and DFA, Mealy and Moore machines, and the pumping lemma for regular languages. Additionally, it covers ambiguous grammar and provides examples of derivations and parse trees.

Uploaded by

hulk81947
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/ 8

● Draw epsilon NFA for given regular expression (0+1)*01(0+1)*

● Explain homomorphism.

Asnwer Assignement no 2 Q1 (A)

or

Homomorphism

1. A homomorphism is a mapping h with domain Σ ∗ for some alphabet which

preserves concatena�on: h(v · w) =h(v) · h(w).

2. Simply speaking in homomorphism we replace each leter in a language with

another leter in some other language.

3. A homomorphism on an alphabet is a func�on that gives a string for each

symbol in that alphabet.

4. Example: h(0) = ab; h(1) = E. Extend to strings by h(a1…an) =h(a1)…h(an).

Example: h(01010) = ababab.

5. If L is a regular language, and h is a homomorphism on its alphabet, then

h(L)= {h(w) | w is in L} is also a regular language


● Find the regular expression for the language of all strings containing at most two 0's over

Σ={0,1)

 R.E= 1∗+1∗01∗+1∗01∗01∗

● Which strings are not generated by the given grammar? S -> SaSbS|∈ .Strings : aabb,

aababb, aaabb, abb



 Not generated: aaabb, abb

 Generated: aabb, aababb

● Briefly explain any four closure proper�es of regular languages.


Union

If L1 and If L2 are two regular languages, their union L1 U L2 will also be regular.

Example

L1 = {an | n > O} and L2 = {bn | n > O}

L3 = L1 U L2 = {an U bn | n > O} is also regular.

Intersec�on

If L1 and If L2 are two regular languages, their intersec�on L1 ∩ L2 will also be regular.

Example

L1= {am bn | n > 0 and m > O} and

L2= {am bn U bn am | n > 0 and m > O}

L3 = L1 ∩ L2 = {am bn | n > 0 and m > O} are also regular.

Concatena�on

If L1 and If L2 are two regular languages, their concatena�on L1.L2 will also be regular.

Example

L1 = {an | n > 0} and L2 = {bn | n > O}

L3 = L1.L2 = {am . bn | m > 0 and n > O} is also regular.

Kleene Closure

If L1 is a regular language, its Kleene closure L1* will also be regular.

Example

L1 = (a U b )

L1* = (a U b)*
Complement

If L(G) is a regular language, its complement L'(G) will also be regular. Complement of a language can
be found by subtrac�ng strings which are in L(G) from all possible strings.

Example

L(G) = {an | n > 3} L'(G) = {an | n <= 3}

● State a few closure proper�es of context free languages.

 Answer Assigment no 3 Q3 (A)

● Explain how NFA differs from DFA. Men�on defini�on and an example for each.

 Answer assignment no 1 Q4[A]

● Tabulate differences between Mealy and Moore machines.

 Answer assignment no 1 Q4[B]

● State and the pumping lemma theorem for regular language.

L = {anbn for n = 0,1,2,........} Using pumping lemma check whether L is regular or not

regular?

The Pumping Lemma is a property that all regular languages sa�sfy. It is used to prove that certain
languages are not regular.

Theorem

For any regular language L, there exists an integer P, such that for all w in L

|w|>=P

We can break w into three strings, w=xyz such that.

(1)lxyl < P

(2)lyl > 1

(3)for all k>= 0: the string xykz is also in L


● What is ambiguous grammar? Show that the following grammar is ambiguous.

S → aSbS|bSaS|∈. Show that the string abab has two parse trees

 A CFG is said to be ambiguous if there exists more than one deriva�on tree for the given input
string i.e., more than one Le�Most Deriva�on Tree (LMDT) or RightMost Deriva�on Tree (RMDT).
● Find the regular expression corresponding to each of the following subset {0,1}

(A) The language of all strings containing at least two 0's.

(B) The language of all strings containing at most two 0's.

Answer assignment no 1 Q5

● Consider following grammar :

S→ iCtS | iCtSeS | a

C→b

For string “ibaeibta” find the following :

(i)Le�most deriva�on

(ii)Rightmost deriva�on

(iii)Parse tree

Answer Assignment no3 Q4


Properties of Context Free Language

Union : If L1 and L2 are two context free languages, their union L1 ? L2 will also be
context free.
For example,
L1 = { anbncm | m >= 0 and n >= 0 } and L2 = { anbmcm | n >= 0 and m >= 0 }
L3 = L1 ? L2 = { anbncm ? anbmcm | n >= 0, m >= 0 } is also context free.

Concatenation : If L1 and If L2 are two context free languages, their concatenation


L1.L2 will also be context free. For example,
L1 = { anbn | n >= 0 } and L2 = { cmdm | m >= 0 }
L3 = L1.L2 = { anbncmdm | m >= 0 and n >= 0} is also context free.

Kleene Closure : If L1 is context free, its Kleene closure L1* will also be context free.
For example,
L1 = { anbn | n >= 0 }
L1* = { anbn | n >= 0 }* is also context free.

You might also like