FLAT unit _I
FLAT unit _I
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
● 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.
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.
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.
(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.
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
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
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
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)
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.
For Example,
S –> AB
AB –> abc
B –> b
For example,
S –> AB
A –> a
B –> b
PART A & B
1. a) Consider the below finite automata and check the strings are accepted or not
FLAT Page 1
2. Convert the following NFA with ε moves to DFA without ε moves.
FLAT Page 2
4. Convert the following Mealy machine into its equivalent Moore machine.
A C 0 B 0
B A 1 D 0
C B 1 A 1
D D 1 C 0
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
FLAT Page 4