32
Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology 1 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 3 rd Year - Computer Science and Engineering, 5th Semester FORMAL LANGUAGE AND AUTOMATA THEORY QUESTION BANK 2 Marks Question and Answer UNIT-I 1. Define set. A set is a collection of objects. E.g.: The collection of the four etters. S={ a,b,c,d} 2. Define function. A function is a rule that assigns to elements of one set a unique element of another set 3. Define relation. A relation is a set of pairs. The first component of each pair is chosen from a set called the domain and second component of each pair is chosen from a set called the range. 4. Give the examples/applications designed as finite state system .Text editors and lexical analyzers are designed as finite state systems. A lexical analyzer scans the symbols of a program to locate strings corresponding to identifiers, constants etc, and it has to remember limited amount of information. 6. Define alphabet. A finite set of non-empty set of symbols is called alphabet. 7. What do you mean by string? A finite sequence of symbols is called string.

FORMAL LANGUAGE AND AUTOMATA THEORY - …chettinadtech.ac.in/storage/12-06-21/12-06-21-11-26-03-1518-mani... · FORMAL LANGUAGE AND AUTOMATA THEORY QUESTION BANK 2 Marks Question

  • Upload
    vudang

  • View
    228

  • Download
    4

Embed Size (px)

Citation preview

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

1

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

3rd Year - Computer Science and Engineering,

5th Semester

FORMAL LANGUAGE AND AUTOMATA THEORY

QUESTION BANK 2 Marks Question and Answer

UNIT-I

1. Define set.

A set is a collection of objects.

E.g.: The collection of the four etters. S={ a,b,c,d}

2. Define function.

A function is a rule that assigns to elements of one set a unique element of another set

3. Define relation.

A relation is a set of pairs. The first component of each pair is chosen from a set called the domain and second component of each pair is chosen from a set called the range.

4. Give the examples/applications designed as finite state system

.Text editors and lexical analyzers are designed as finite state systems. A lexical analyzer

scans the symbols of a program to locate strings corresponding to identifiers, constants etc, and

it has to remember limited amount of information.

6. Define alphabet.

A finite set of non-empty set of symbols is called alphabet.

7. What do you mean by string?

A finite sequence of symbols is called string.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

2

8. Define language.

The language can be defined as a colAPion of strings or words over certain input set.

9. Define Abstract machines with e.g.

The computer which performs computation are not actual computers

they are abstract machine

E.g.: Finite Automata, Push down automata and Turing machine.

10. Define Finite Automaton (FA)

FA consists of a finite set of states and a set of transitions from state to state that

occur on input symbols chosen from an alphabet ∑. Finite Automaton is denoted by a

5- tuples (Q,∑,δ,q0,F), where Q is the finite set of states , ∑ is a finite input alphabet,

q0 in Q is the initial state, F is the set of final states and δ is the transition mapping

function Q * Σ to Q.

11. Define DFA.

A DFA consists of A=( Q,∑,δ,q0,F) Where

Q is the finite set of states ,

∑ is a finite input alphabet,

q0 in Q is the initial state,

F is the set of final states and δ is the transition mapping function Q * Σ to Q.

12. Define NFA

A NFA consists of A=( Q,∑,δ,q0,F) Where

Q is the finite set of states ,

∑ is a finite input alphabet, q0 in Q is the initial state,

F is the set of final states and δ is the transition mapping function

δ: Q x (∑U{ ε}) = 2Q

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

3

13. Define Transition diagram

Transition diagram is a directed graph in which the vertices of the graph correspond to

the states of FA. If there is a transition from state q to state p on input a, then there is an arc

labeled ‘ a ‘ from q to p in the transition diagram.

14. What are the applications of automata theory?

o In compiler construction.

o In switching theory and design of digital circuits. To verify the correctness of a

program.

o Design and analysis of complex software and hardware systems.

o To design finite state machines such as Moore and mealy machines.

15. What are the components of Finite automaton model?

The components of FA model are Input tape, Read control and finite control. (a)The input

tape is divided into number of cells. Each cell can hold one i/p symbol. (b)The read head

reads one symbol at a time and moves ahead.

(c)Finite control acts like a CPU. Depending on the current state and input symbol read

from the input tape it changes state.

16. Differentiate NFA and DFA.

NFA or Non Deterministic Finite Automaton is the one in which there exists many

paths for a specific input from current state to next state. NFA can be used in theory of

computation because they are more flexible and easier to use than DFA. Deterministic

Finite Automaton is a FA in which there is only one path for a specific input from current

state to next state. There is a unique transition on each input symbol.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

4

17. What is Є-closure of a state q0?

Є-closure (q0) denotes a set of all vertices p such that there is a path from q0 to labeled Є.

18. What is a Regular Language?

The language accepted by M is L(M) is the set {x | δ(q0,x) is in F}. A language is

regular if it is accepted by some finite automaton.

19. Define star closure and positive closure.

Star closure –zero or more. Occurrence

Positive closure – one or more occurrence

(eg) a* = { ε,a,aa,….} , a+ = {a,aa,….} L+ = L* - {ε}

20. Define NFA with ε-transition. Is the NFA’s with ε-transitions are more powerful that NFA’s

without ε -transition?

The NFA with €- moves defined by 5tuple or quintyple as similarly as NFA, except δ (Q,∑,

δ,qo,F) with all components as before and δ: Qx(∑U{ ε}) = 2Q

No, NFA with ε-transition and NFA without ε-transition have the same power.

21. Define Finite State Systems

The finite automaton is a mathematical model of a system, with discrete

inputs outputs and a finite number of memory configuration called states.

and

22. Is it true the language accepted by NFA is different from the regular language?

Justify. Your answer.

No, it is false. For every regular expression r there exists a NFA with ε-transition that

accepts L(r).

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

5

23 .

24.

25.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

6

FORMAL LANGUAGE AND AUTOMATA THEORY

UNIT-II

REGULAR LANGUAGES

1. What is a regular expression?

A regular expression is a string that describes the whole set of strings according to

certain syntax rules. These expressions are used by many text editors and utilities to

search bodies of text for certain patterns etc.

Definition is: Let Σ be an alphabet. The regular expression over Σ and the sets they denote are:

i. Φ is a r.e and denotes empty set.

ii. Є is a r.e and denotes the set {Є}

iii. For each ‘a’ in Σ , a+ is a r.e and denotes the set {a}.

iv. If ‘r’ and ‘s’ are r.e denoting the languages R and S respectively then (r+s), (rs)

and (r*) are r.e that denote the sets RUS, RS and R* respectively

2. List out the operator of regular expression.

1. Union of two Languages

2. Concatenation of two Languages

3.Closure of a Language

3. Write a r.e to denote a language L which accepts all the strings

which begin or end with either 00 or 11.

The r.e consists of two parts:

L1= (00+11) (any no of 0’s and

1’s)

= (00+11) (0+1)*

L2= (any no of 0’s and

1’s)(00+11)

= (0+1)*(00+11)

Hence r.e R=L1+L2 = [(00+11)(0+1)*] + [(0+1)* (00+11)]

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

7

4. Construct a r.e for the language which accepts all strings with atleast

two c’s over the set Σ={c,b}

(b+c)* c (b+c)* c (b+c)*

5.Construct a r.e for the language over the set Σ={a,b} in which total number of a’s are divisible

by 3

ANS : ( b* a b* a b* a b*)*

6. what is: (i) (0+1)* (ii)(01)* (iii)(0+1) (iv)(0+1)

(0+1)*= {Є , 0 , 1 , 01 , 10 ,001 ,101 ,101001,…………………} Any combinations of

0’s and 1’s.

(01)*= {Є , 01 ,0101 ,010101 ,…………………………………..} All combinations with

the pattern 01.

(0+1) = 0 or 1,No other possibilities.

(0+1)+ = {0,1,01,10,1000,0101,………………………………….}

7 .Reg exp denoting a language over Σ ={1} having (i) even length of string

(ii) odd length of a string.

Ans :(i) Even length of string R=(11)*

(ii) Odd length of the string R=1(11)*

8.Reg exp for:

(i)All strings over {0,1} with the substring ‘0101’

(ii)All strings beginning with ’11 ‘and ending with ‘ab’

(iii)Set of all strings over {a,b}with 3 consecutive b’s.

(iv)Set of all strings that end with ‘1’and has no substring ‘00’

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

8

Ans: (i)(0+1)* 0101(0+1)*

(ii)11(1+a+b)* ab

(iii)(a+b)* bbb (a+b)*

(iv)(1+01)* (10+11)* 1

9. Reg exp for the language that accepts all strings in which ‘a’ appears tripled over

the set Σ ={a}.

Ans : reg exp=(aaa)*

10. What is the closure property of regular sets?

The regular sets are closed under union, concatenation and Kleene closure. r1Ur2= r1 +r2

r1.r2= r1r2 ( r )*=r*

The class of regular sets are closed under complementation, substitution, homomorphism

and inverse homomorphism.

11. Write the exp for the language starting with and has no

consecutive b’s .reg exp=(a+ab)*

.12. What is the order of precedence of operators used in regular expression?

i.Operator is having the highest precedence.

ii.Next the concatenation or dot operator (.).

iii.+ Operator is having the lowest precedence.

13. Describe the algebra of regular expression.

Regular expressions obey many laws of arithmetic.

a. Union and Concatenation are associative.

b. Union is commutative.

c. Union is idempotent.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

9

14. Define pumping lemma for regular languages.

Let L be a regular language. Then there exists a constant n such that for every in L such that |w|≥n. w = xyz such that

a. y ≠ Є. b. |xy| ≤ n. c. For all i≥0, xyiz Є L.

15. How do you test the emptiness of regular language?

string w

The emptiness is defined by checking whether there is a path from the start sate to some

accepting state. If there is a path available the languages non-empty. If the accepting states

are separated from the start state then the language is empty.

16. List the application of regular expression.

a. Regular expression in UNIX

b. Lexical Analysis.

c. Finding Patterns in a Text

17. What do you mean by equivalence and minimization of DFA?

For each DFA it is possible to find an equivalent DFA which contains as few any

DFA accepting states as the same language.

18.

19.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

10

20.

21.

22.

23.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

11

24.

25.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

12

FORMAL LANGUAGE AND AUTOMATA THEORY

UNIT-III PROPERTIES OF REGULAR LANGUAGES

1. What are the applications of pumping lemma?

Pumping lemma is used to check if a language is regular or not.

(i) Assume that the language (L) is regular.

(ii) SeAP a constant ‘n’.

(iii) SeAP a string(z) in L, such that |z|>n.

(iv) Split the word z into u,v and w such that |uv|<=n and |v|>=1.

(v) You achieve a contradiction to pumping lemma that there exists an

2.What are the applications of Regular expressions?

Lexical analyzers and Text editors are two applications.

Lexical analyzers: The tokens of the programming language can be expressed

using regular expressions. The lexical analyzer scans program and separates the tokens.

For eg identifier can be expressed as a regular expression as:

(letter)(letter+digit)*

If anything in the source language matches with this reg exp then it is recognized as an

identifier.The letter is{A,B,C,………..Z,a,b,c….z} and digit is

{0,1,…9}.Thus reg exp identifies token in a language. the input

Text editors: These are programs used for processing the text. For example UNIX text

editors uses the reg exp for substituting the strings such as: S/bbb*/b/

3. What are the applications of Finite automata?

Gives the substitute a single blank for the first string of two or more blanks in a given line.

In UNIX text editors any reg exp is converted to an NFA with ε - transitions, this NFA can

be then simulated directly.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

13

4. What is Arden’s Theorem?

Arden’s theorem helps in checking the equivalence of two regular expressions.

Let P and Q be the two regular expressions over the input alphabet Σ. The regular

expression R is given as :R=Q+RP Which has a unique solution as R=QP*.

5. Define Homomorphisms.

A string homomorphism is a function on string that works by substituting a

particular string for each symbol.

6.. Define Inverse Homomorphisms

Homomorphisms may also be applied “backwards” and this mode they also preserve regular

language.

7. What are the closure properties of regular languages?

i. Union

ii.

iii.

iv.

v.

vi.

vii.

viii.

Intersection

Complement

Difference Reversal

Closure.

Concatenation.

Homomorphism.

Inverse Homomorphism.

8. prove that if L1 and L2 are two languages then L1 U L2 is regular.

Proof : if L1 and L2 are regular then they have regular expression L1 = L(R1) and L2= L(R2).

Then L1 U L2 = L(L1+L2) thus we get L1 U L2 as regular language.

( Any language given by some regular expression is regular).

9. State Pumping Lemma for Regular Languages.

• Pumping Lemma relates the size of string accepted with the number of states in a DFA

• Lemma: (the pumping lemma)

Let M be a DFA with |Q| = n states. If there exists a string x in L(M), such that |x| ≥ n, then

there exists a way to write it as x = uvw, where u,v, and w are all in Σ* and:

– 1≤ |uv| ≤ n

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

14

– |v| ≥ 1

– such that, the strings uvi

w are also in L(M), for all i ≥ 0

10. State that Let M = (Q, Σ, δ, q0, F) be a DFA. Then L(M) is finite iff |x| < |Q| for all x in

L(M).

Proof:

(if) Suppose that |x| < |Q| for all x in L(M). Since the number of states |Q| and the number of

input symbols |Σ| are both fixed, it follows that there are at most a finite number of strings of

length less than |Q|. It follows that L(M) is finite (exercise: give an upper bound on the number

of such strings).

(only if) By contradiction. Suppose that L(M) is finite, but that |x| ≥ |Q| for some x in L(M).

From the pumping lemma it follows that x=uvw, |v| ≥ 1 and uvi

w is in L(M) for all i ≥ 0. But then

L(M) would be infinite, a contradiction.

11. State that Let M = (Q, Σ, δ, q0, F) be a DFA. Then L(M) is infinite iff there exists an x in L(M)

such that |x| ≥ |Q|.

• Proof:

(if) Suppose there exists an x in L(M) such that |x| ≥ |Q|. From the pumping lemma it follows

that x=uvw, |v| ≥ 1 and uvi

w is in L(M) for all i ≥ 0. Therefore L(M) is infinite.

(only if) By contradiction. Suppose that L(M) is infinite, but that there is no x in L(M) such

that |x| ≥ |Q|. It follows that each x in L(M) has length less than |Q|. Since the number of states

|Q| and the number of input symbols |Σ| are both fixed, it follows that there are at most a finite

number of strings of length less than |Q|. It follows that L(M) is finite. A contradiction. �

• Note that the above also follows directly from the previous theorem.

12. Proving that the complement of a regular language is also regular.

� Let L=L(A) for some DFA A

� Where A= (Q, S,d, q0,F)

� Then Ľ=L(B) where B=(Q, S,d, q0,Q-F)

� Then A and B are same other than the fact that their accepting states are different

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

15

� Then any string w is in L(B) if and only if d*(q0,w) is in Q-F which occurs only if w is not in

L(A). Hence Ľ is regular.

13. prove that the Closure under Intersection is regular.

� If L is regular, then complement of L is also regular.

� If M is regular, then complement of M is also regular.

� Also union of two regular languages is proved to be regular

� Hence intersection of two regular languages is also regular.

14.prove that the Closure under Difference is regular.

� L-M = set of all strings that are in L and not in M

� i.e. L-M = L ∩ M

� Since Complement of M is regular as M is regular, Intersection of L and M is also regular

� Hence the difference of two regular languages is regular

15. What is the Homomorphism to a language.

� Homomorphism to a language is applied by applying it to each of the strings in the language

� h(L) = {h(w) | w is in L}

� Let L= 10*1

� i.e. L={11,101,1001,…}

� Then h(L) = {єє, єabє, єababє,…} or (ab)*

16. prove that If L is regular then h(L) is also regular

� Let

L=L( R) for regular expression R

� Let E be an expression over S

� Then let h(E) be an expression obtained by replacing each symbol a of S in E by h(a), Then

h(R) defines the language h(L).

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

16

17. Define Decision Properties of Regular language.

A decision property for a class of languages is an algorithm that takes a formal description of a

language (e.g., a DFA) and tells whether or not some property holds.

Example: Is language L empty?

18. Define the Equivalent states.

Two states p and q are said to be equivalent if for all input strings w, d (p,w) is an accepting state if

and only if d (q,w) is an accepting state.

If two states are not equivalent then we say they are distinguishable (i.e. if they are not equivalent

for at least one w.

19. What is the Equivalence and Minimization of Automata?

Testing whether two descriptors for regular languages are equivalent, in the sense that they

define the same languages. This gives a method to minimize a DFA.

20. prove that The language: L = {0k

1k

2k

| k ≥ 0} (1) is not regular.

• Proof: (by contradiction) Suppose that L is regular. Then there exists a DFA M such that:

L = L(M)

We will show that M accepts some strings not in L, contradicting .

Since |x| = m >> n, it follows from the pumping lemma that:

– x = uvw

– 1 ≤ |uv| ≤ n

– 1 ≤ |v|, and

– uvi

w is in L(M), for all i ≥ 0

Since 1 ≤ |uv| ≤ n and n<<m, it follows that 1 ≤ |uv| ≤ m.

Also, since x = 0m

1m

2m

it follows that uv is a substring of 0m

.

In other words v=0j

, for some j ≥ 1.

Since uvi

w is in L(M), for all i ≥ 0, it follows that 0m+cj

1m

2m

is in L(M), for all c ≥ 1.

But by (1) and (2), 0m+cj

1m

2m

is not in L(M), for any c ≥ 1, a contradiction. �

• Note that the above proof is almost identical to the previous proof.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

17

21. Write the example for non regular language.

22.

23.Is the following language regular? Justify your answer L={02n / n>= 1}.

This is a language length of string is always even.

n =1 , L= 00

n =2 , L = 00 00 and so on.

Let L = uvw

L = 02n

I Z I = 4n =u v. v w

= even length of string.

Thus even after pumping 2n to the string we get the even length. So the language L is regular language.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

18

24. Define Regular Language:

A Language can be described by DFA or NFA.

Context free language cannot be described by DFA (or) NFA – since there is no memory.

25. prove that the Closure under Difference is regular.

� L-M = set of all strings that are in L and not in M

� i.e. L-M = L ∩ M

� Since Complement of M is regular as M is regular, Intersection of L and M is also regular

� Hence the difference of two regular languages is regular.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

19

FORMAL LANGUAGE AND AUTOMATA THEORY

UNIT-IV

CONTEXT FREE LANGUAGES

1. Define a context free grammar

A context free grammar (CFG) is denoted as G=(V,T,P,S) where V and T are finite set

of variables and terminals respectively. V and T are disjoint. P is a finite set of productions each is

of the form A-> α where A is a variable and α is a string of symbols from (V U T)*.

2. What are the uses of Context free grammars?

� Construction of compilers.

� Simplified the definition of programming languages.

� Describes the arithmetic expressions with arbitrary nesting of balanced parenthesis {

(, ) }.

� Describes block structure in programming languages.

Model neural nets.

3. The language generated by G ( L(G) ) is {w | w is in T* and S =w .That is a G

String is in L(G) if:

(1) The string consists solely of terminals.

(2) The string can be derived from S.

4. What is (a) CFL (b) Sentential Form?

L is a context free language (CFL) if it is L(G) for some CFG G. A

string of terminals and variables α is called a sentential form if:

S => α, where S is the start symbol of the grammar.

5. What is the language generated by the grammar G=(V,T,P,S) where P={S->aSb, S->ab}?

S=> aSb=>aaSbb=>…………………………..=>anbn

Thus the language L(G)={ anbn| n>=1}.The language has strings with equal number

of a’s and b’s.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

20

6. If S->aSb | aAb , A->bAa , A->ba .Find out the CFL

Ans :

S->aAb=>abab

S->aSb=>a aAb b =>a a ba b b(sub S->aAb)

S->aSb =>a aSb b =>a a aAb b b=>a a a ba b bb

Thus L={an bm am bn, where n,m>=1}

7. What is an ambiguous grammar?

A grammar is said to be ambiguous if it has more than one derivation trees for a sentence or

in other words if it has more than one leftmost derivation or more than one rightmost derivation.

8.Give the context free grammar for generating the ;amgiage

L={anb2n;n≥1}

S→Sbb S→abb_

9. Consider G whose productions are S→aAS_a, A→SbA_SS→ba. Show that S=>aabbaa

S=>Aas

=>aSbAS

=>aabAS

=>aabbaS

=>aabbaa

10. Find the language generated by a CFG. G=({S},{0,1},{S→0|1| ε , S→0S0|1S1|S)

S =>0S0

=>01S

10

=>0I0I0

S =>1S1

=>10S01

=>10001

L= { w;w is a palindrome}

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

21

11. Differentiate sentences Vs sentential forms

A sentence is a string of terminal symbols.

A sentential form is a string containing a mix of variables and terminal symbols or all

variables. This is an intermediate form in doing a derivation.

12 .Define Pushdown Automata.

A pushdown Automata M is a system (Q, Σ, Ѓ , δ ,q0, Z0,F) where

Q is a finite set of states.

Σ is an alphabet called the input alphabet.

Ѓ is an alphabet called stack alphabet. q0 in Q is called initial state.

Zo in Ѓ is start symbol in stack. F is the set of final states.

Σ is a mapping from Q X (Σ U { ε } ) X Ѓ to finite subsets of Q X Ѓ *.

13. Compare NFA and PDA.

NFA

1. The language accepted by NFA is the regular language.

2. NFA has no memory.

3. It can store only limited amount of information

4. A language/string is accepted only by reaching the final state.

PDA

1.The language accepted by PDA is Context free language.

2. PDA is essentially an NFA with a stack(memory).

3 It stores unbounded limit of information.

4. It accepts a language either by empty Stack or by reaching a final state.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

22

14. What are the different types of language acceptances by

PDA and define them, Two types

1. Acceptance by final state

2. Acceptance by empty stack

15.Is it true that the language accepted by a PDA by empty stack and final states are

different languages.

No, because the languages accepted by PDA ‘s by final state are exactly the

languages accepted by PDA’s by empty stack.

16. Give examples of languages handled by PDA.

(1) L={ anbn | n>=0 },here n is unbounded , hence counting

cannot be done by finite memory. So we require a PDA ,a

machine that can count without limit.

(2) L= { wwR | w €{a,b}* } , to handle this language we need unlimited counting

Capability.

17. Is it true the nondeterministic PDA is more powerful than that of deterministic PDA?

justify your answer.

Yes, wwR is accepted by NPDA but not any DPDA in the sense of language

acceptance.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

23

18. What is the additional feature of PDA has when compared with NFA? Is PDA

superior over NFA? Is PDA superior over NFA in the

Justify your answer:

Additional features of PDA:

a) PDA is eventually a FA with a stack.

b) PDA can accept context free languages.

c) PDA can recognize the context free languages

which are not regular.

Yes, PDA is superior over NFA in the sense of

languages.

19. Regular Language:

A Language can be described by DFA or NFA.

Context free language cannot be described by DFA

(or) NFA – since there is no memory.

Pushdown Automata has a memory, which can be

used to count the number.

Pushdown Automata can accept context free

languages. It is essentially an NFA with a stack.

Acceptance of language.

20. A pushdown automata G=(Q, ,G,d,q0,z,F) is said to be deterministic if

1. d(q,a,b)contains almost one element.

2. If d(q,l,b) is not empty, then d(q,c,b) must be empty for overy c_ , q_Q, b_G

The first condition says that for any given input symbol

and any stack top, at move can be made.

most one

The second condition say that when a l move is possible for some configuration, no input

consuming alternative is available

21. What are the properties of the CFL generated by a CFG?

Each variable and each terminal of G appears in the derivation of some word in L There are no productions of the form A->B where A and B are variables.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

24

22 Is NPDA (Nondeterministic PDA) and DPDA (Deterministic PDA)equivalent?

The languages accepted by NPDA and DPDA are not equivalent.

For example: wwR is accepted by NPDA and not by any DPDA.

23. State the equivalence of acceptance by final state and empty stack.

If L = L(M2) for some PDA M2 , then L = N(M1) for some PDA M1.

If L = N(M1) for some PDA M1 ,then L = L(M2) for some PDA M2.

where L(M) = language accepted by PDA by reaching a final state.

N(M) = language accepted by PDA by empty stack.

24. State the equivalence of PDA and CFL.

If L is a context free language, then there exists a PDA M such that

L=N(M). If L is N(M) for some PDA m, then L is a context free language.

25. Define Deterministic PDA.

A PDA M =( Q, Σ, Ѓ , δ ,q0, Z0 ,F ) is deterministic if:

For each q in Q and Z in Ѓ , whenever δ (q, ε ,Z) is nonempty ,then

δ (q,a,Z) is empty for all a in Σ.

For no q in Q , Z in Ѓ , and a in Σ U { ε} does δ (q,a,Z) contains more than one element.

(Eg): The PDA accepting {wcwR | w in ( 0+1 ) * }.

26. State the equivalence of acceptance by final state and empty stack.

If L = L(M2) for some PDA M2 , then L = N(M1) for some PDA M1. If L = N(M1) for

some PDA M1 ,then L = L(M2) for some PDA M2. where L(M) = language accepted by

PDA by reaching a final state. N(M) = language accepted by PDA by empty stack.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

25

FORMAL LANGUAGE AND AUTOMATA THEORY

UNIT-V

PROPERTIES OF CONTEXT FREE LANGUAGES

1. What is a formal language?

Language is a set of valid strings from some alphabet. The set may be

empty,finite or infinite. L(M) is the language defined by machine M and L( G) is the

languagedefined by Context free grammar. The two notations for specifying formal

languages are:

Grammar or regular expression(Generative approach) Automaton(Recognition

approach)

2. What are all the normal forms for CFG?

Normal forms for CFG are:

i. Chomsky normal form. ii. ii. Greiback normal form.

3. What are the three ways to simplify a context free grammar?

By removing the useless symbols from the set of productions. By eliminating the

empty productions. By eliminating the unit productions.

3.. What are the properties of the CFL generated by a CFG?

Each variable and each terminal of G appears in the derivation of some word in L

There are no productions of the form A->B where A and B are variables.

4. (a)CFL are not closed under intersection and complementation –True.

(b)A regular grammar generates an empty string –True.

(c) A regular language is also context free but not reverse–True.

(d)A regular language can be generated by two or more different grammar True.

(e) Finite State machine (FSM) can recognize only regular grammar-True.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

26

5. What is Backus-Naur Form (BNF)?

Computer scientists describes the programming languages by a notation called

Backus- Naur Form. This is a context free grammar notation with

minor format and some shorthand.

changes in

6. What are the closure properties of CFL?

CFL are closed under union, concatenation and Kleene closure.

CFL are closed under substitution, homomorphism.

CFL are not closed under intersection, complementation.

Closure properties of CFL’s are used to prove that certain languages are

Not Context free.

7. State the pumping lemma for CFLs.

Let L be any CFL. Then there is a constant n, depending only on L, such that if z is in L

and |z| >=n, then z=uvwxy such that :

(i) |vx| >=1

(ii) |vwx| <=n and

(iii) for all i>=0 uviwxiy is in L.

8. What is the main application of pumping lemma in CFLs?

The pumping lemma can be used to prove a variety of languages are not context

free . Some examples are:

L1 ={ ai c i i>=1} is not a CFL.

L2= { aibjcidj | i>=1 and J>=1 } is not a CFL

9. Define Chomsky normal form.

A grammar in which all productions are the form A→BC or A→α where A,B are variables and a is a terminal.

10. Define Grieback normal form?

A grammar for which every productions is of the form A→aα where A is a

variable ,a is a terminal and α is a string of variables.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

27

11 Definition

A language L is said to be deterministic context free language, if and only if there exists a

deterministic pushdown automata (dpda) M such that L = L (M)

12. what are the Properties of Context Free Languages?

Let L1 and L2 be CFL’s.

(1) L1 ∪ L2 (the union) is CFL.

(2) L1L2 (the concatenation) is CFL.

(3) L1 *

(the Kleene star) and L1+

(the Kleene plus) are CFL.

(4) L1R

(the reversed language) is CFL.

(5) L1 ∩ L2 (the intersection) is not necessarily CFL.

(6) L1 (the complement) is not necessarily CFL.

13. Definition for normal forms.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

28

14. Define unit production.

15.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

29

16.

17. Define pumping lemma for CFL.

18.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

30

19. Define union of CFL.

20. Define homomorphism of CFL.

21.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

31

22.

23. Decision properties of CFL.

- Algorithm for CFL.

- Converting PDA acceptance form.

- Converting CFG to PDA

- Converting PDA to CFG.

- Eliminating useless symbols.

- Eliminating unit production.

- Eliminating € - production.

24. define set deference in CFL.

Prepared by : A.MANI , AP/CSE/Chettinad college of Engg & Technology

32

25. prove that Let L1 and L2 be CFL and L1 ∩ L2 is not context free language.

************ALL THE BEST **********