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

FLAT unit _I

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

FLAT unit _I

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

FORMAL LANGUAGE & AUTOMATA THEORY

UNIT – I
1. Define Finite Automata (FA) Remembering
A finite automaton (FA) is a simple idealized machine used to recognize patterns within
input taken from some character set (or alphabet) C. The job of an FA is to accept or reject
an input depending on whether the pattern defined by the FA occurs in the input.
A finite automaton is a collection of 5-tuple (Q, ∑, δ, q0, F), where:
Q: finite set of states
∑: finite set of the input symbol
q0: initial state
F: final state
δ: Transition function

2. Define Transition Diagram Remembering

A transition diagram or state transition diagram is a directed graph which can be


constructed as follows:
o There is a node for each state in Q, which is represented by the circle.
o There is a directed edge from node q to node p labeled a if δ(q, a) = p.
o In the start state, there is an arrow with no source.
o Accepting states or final states are indicating by a double circle.
Some Notations that are used in the transition diagram:
3. What are the use of productions? Or What is derivation? Give one example. Remembering
A production or production rule in computer science is a rewrite rule specifying a symbol
substitution that can be recursively performed to generate new symbol sequences. It is of the
form α-> β where α is a Non-Terminal Symbol which can be replaced by β which is a string
of Terminal Symbols or Non-Terminal Symbols
Example
A□aSb ---(1)
S□ab ---(2)
The above two are the production, this can be used to test the string is accepted are not for
example if you want to test the string “aabb” is accepted or not through derivation from the
above production
Solution
A□aSb ---(1)
Substitute the second production S to ab in the e\production (1) then we will get
A□aabb
So the given string is accepted form the productions.

4. Define alphabets, Language and Grammar. Remembering


5.
o Alphabet
An alphabet is any finite set of symbols.
Example − ∑ = {a, b, c, d} is an alphabet set where ‘a’, ‘b’, ‘c’, and ‘d’ are symbols.
o String
A string is a finite sequence of symbols taken from ∑.
Example − ‘cabcad’ is a valid string on the alphabet set ∑ = {a, b, c, d}
o Language
A language is a subset of ∑* for some alphabet ∑. It can be finite or
infinite.
Example − If the language takes all possible strings of length 2 over ∑ =
{a, b}, then L = { ab, aa, ba, bb }

● Grammar:
Grammar in theory of computation is a finite set of formal rules that are generating syntactically
correct sentences. The formal definition of grammar is that it is defined as four tuples −
G=(V,T,P,S) G is a grammar, which consists of a set of production rules. It is used to
generate the strings of a language.
According to Chomsky hierarchy, grammars are divided of 4 types:
Type 0 known as unrestricted grammar.
Type 1 known as context sensitive
grammar. Type 2 known as context free
grammar.
Type 3 Regular Grammar.

6. What is transition table? Remembering

The transition table is basically a tabular representation of the transition function. It takes two
arguments (a state and a symbol) and returns a state (the "next state").
A transition table is represented by the following things:
o Columns correspond to input symbols.
o Rows correspond to states.
o Entries correspond to the next state.
o The start state is denoted by an arrow with no source.
o The accept state is denoted by a star.

7. What is Transition function? Remembering

The transition function can be represented as T(current state, current input symbol) next state.
For instance if q0 is the current state and 0 is the current input symbol, then the transition
function is T(q0, 0) q1.

8. Identify the types of the following grammar Apply


A□BCD □(1)
BA□BaC □(2)
abB□bC □ (3)

(1) is a type two category grammar because it is in the form of A□( Σ U V) production where A
is LHS which is Non Terminal and (ΣUV) is combination of terminal and non terminal
(2) is type 1 category grammar because it is in the form of (Σ U V)* □ (Σ U V)* here LHS and
RHS consist of terminal and non terminal and string size of RHS greater than or equal to
string size of LHS
(3) is type zero category grammar because it is in the form of (Σ U V)* □ (Σ U V)* production
type and there is no restriction in the string size of Both LHS and RHA.

9. Construct the finite automation for the language L={a,aa,aaa,….} Apply

10, Construct the finite automata for the regular expression (ab)* Apply

11. Construct the finite automation for the regular expression (a+b)*cd*e Apply

12. Design a grammar for a language of all palindromes over {a,b} Creating
Solution :
The basis of our grammar is as follows
An alphabet a or b is a palindrome. If a string ax is palindrome then the string axa and bxb is
a also a palindrome
Thus the grammar can be designed as follows
S□aSa
S□bS
b S□a
S□b
S□aa
S□bb
Then we derive it for getting some palindrome like aaaa, bbabb, baab
S□aSa
Substitute s□aa then we will get S□aaaa
S□bSb
Substitute S□ bSb
Then we will get
S□bbSbb

Again substitute s□ a then we will get


S□bbabb

Third one
S□bsb
Substitute S□aa then we will get
S□baab

13. Design a grammar for a language over L {a,b} such that each string in L
contains equal number of a’s and b’s
Creating

The string can be either a or be then the production is


S□ aX and S□bY

Now the design of X should be such that insert one b more than a in the input string.
Similarly design of Y should be such that it insert one a more than b then b in the output
string, thus we have
X□ b
X□aXX
X□bS

Y□a
Y□bYY
Y□aS

Let us see the derivation of some string in the Language L such as


abba, baab, bbaa, aabb
S□aX□abS□abbY□abb
a S□bY□baS—
baaX□baab
S□bY□bbYY□bbaY□b
baa
S□aX□aaXX□aabX□a
abb

14. Find the language generated by the following grammars bb Remembering


1. S□aSb | aXb X□bX | b
2. S□aA | bS | a | b A□bA | bS |b

1) The language generate by the grammars for the below


one S□aSb | aXbX□bX | b
The given production
are S□aSb
S□aX
b
X□b
X
X□b

So we can derive the following language as follows

2) S□aSb□aaXbb□aabXbb□
aabbbb S□aSb□aaXbb□aabbb
The language generated by the above grammars are L=( aabbbb, aabbb )

14. Identify the types of the following grammars and explain it Apply
A□BCD (Type 2 grammar) see the
rules BA□BaC (Type 1)
abB—AC (Type 0)
A□c ((Type 3)
B—Bb ( Type
2) BA□b (Type
0)
BbB□BBAc (Type 1)
A□bB (Type 3))
B□bA ( Type 3)

15. Explain Chomsky Hierarchy Understanding


According to Chomsky hierarchy, grammars are divided of 4
types: Type 0 known as unrestricted grammar.
Type 1 known as context sensitive
grammar. Type 2 known as context free
grammar.
Type 3 Regular Grammar.
Type 0: Unrestricted Grammar:
In Type 0
Type-0 grammars include all formal grammars. Type 0 grammar language are recognized
by turing machine. These languages are also known as the Recursively Enumerable
languages.
Grammar Production in the form of
Alpha → Beta
where
Alpha is (V + T)* V ( V + T)*
V : Variables
T : Terminals.

Beta is (V + T )*.
In type 0 there must be at least one variable on Left side of production.

For example,
Sab –> ba
A –> S.
Here, Variables are S, A and Terminals a, b.

Type 1: Context Sensitive Grammar)


Type-1 grammars generate the context-sensitive languages. The language generated by the
grammar are recognized by the Linear Bound Automata
In Type 1
I. First of all Type 1 grammar should be Type 0.
II. Grammar Production in the form
of Alpha → Beta
|Alpha| <= |Beta|
i.e count of symbol in Alpha is less than or equal to Beta

For Example,
S –> AB
AB –> abc
B –> b

Type 2: Context Free Grammar:


Type-2 grammars generate the context-free languages. The language generated by the
grammar is recognized by a Pushdown automaton.
In Type 2,
1. First of all it should be Type 1.
2. Left hand side of production can have only one variable.
|Alpha| = 1.
There is no restriction on Beta.

For example,
S –> AB
A –> a
B –> b

Type 3: Regular Grammar:


Type-3 grammars generate regular languages. These languages are exactly all languages that
can be accepted by a finite state automaton.
Type 3 is most restricted form of grammar.
Type 3 should be in the given form only :
V –> VT / T (left-regular grammar)
(or)
V –> TV /T (right-regular grammar)
for example:
S –> a
The above form is called as strictly regular grammar.
There is another form of regular grammar called extended regular grammar. In this form :
V –> VT* / T*. (extended left-regular grammar)
(or)
V –> T*V /T* (extended right-regular grammar)
for example :
S –> ab

PART A & B

1. a) Consider the below finite automata and check the strings are accepted or not

(i) 1110 (ii) 0001 (iii) 1010


b) Define NFA. What are the differences between DFA & NFA?

FLAT Page 1
2. Convert the following NFA with ε moves to DFA without ε moves.

3. Minimize the following finite automata.

FLAT Page 2
4. Convert the following Mealy machine into its equivalent Moore machine.

Present I/P=0 I/P=1


State
Next State O/P Next State O/P

A C 0 B 0
B A 1 D 0
C B 1 A 1
D D 1 C 0

5. a) Write about relations on sets.


b) Define Grammar? What are the tuples?
c) Define Finite Automaton.
d) Show that (0*1*)* = (0+1)*.
e) Define Mealy machine and Moore machine.
6. a) Discuss Chomsky’s Hierarchy of formal languages.
b) Explain briefly about DFA and NFA?

7. a) Define Moore machine? Construct Mealy machine corresponding to Moore machine?

b) Prove i) R=(1+00*1) + (1+00*1) (0+10*1)* (0+10*1)* = 0*1(0+10*1)*


ii) R= Є+1*(011)*(1*(011)*)*= (1+011)*
Write down procedure for Myhill- Nerode theorem with a given example.
(‘*’ means final states).
Next State
I/P=a I/P=b
Present State
A B F
B A F
C G A
D H B
E A G
*F H C
*G A D
*H A C

FLAT Page 3
8. a) Define relations on set and explain its property with an example
b) Define NFA and DFA. Construct DFA for the given NFA

9. a) List out the identities of Regular expression.


b) From the identities of RE, prove that
i) 10+(1010)*[^+(1010)*]=10+(1010)* ii)
(0+011*)+(0+011*)(01+0100*)(01+0100*)*=01*(010*)*
c) Define finite automata? Explain detail about the tuples.

FLAT Page 4

You might also like