Unit 1
Unit 1
Unit 1
III SEMESTER
SYLLABUS
Course Outcomes:
After completion of the course, the students will be able to
CO1 – Understand the concept of Finite Automata, NFA and DFA.
CO2 – Understand about Context Free Language and Push Down Automata.
CO3 – Construct a Turing Machine.
CO4 – Explain the concept of Phases of a Compiler, Lexical Analysis and Syntax Analysis.
CO5 – Describe the Intermediate code generation, Code Optimization and Code Generation.
UNIT – I
Finite Automata and Regular Expressions: Finite Automata - Examples and Definitions - Accepting the
Union, Intersection, or Difference of Two Languages. Regular Expressions: Regular Languages and
Regular Expressions – Conversion from Regular Expression to Deterministic Finite Automata.
UNIT – II
Context-Free Grammar And Languages And Pushdown Automata: Definitions and More Examples -
Regular Languages and Regular Grammars - Derivation Trees and Ambiguity - Simplified Forms and
Normal Forms - Chomsky Normal Form – Greibach Normal Form. Pushdown Automata: Definitions and
Examples - A PDA from a Given CFG - A CFG from a Given PDA. Pumping Lemma.
UNIT – III
Turing Machines: Turing Machines as Language Acceptors – Turing Machines for Accepting Regular
Languages – Turing Machine for Addition and Subtraction.
UNIT – IV
Lexical Analysis And Syntax Analysis: The Phases of compiler – Lexical analysis - The role of the lexical
analyser - Input buffering - Specification of tokens - Recognition of tokens - A language for specifying
lexical analyzers - design of a lexical analyzer. Parser: Top Down Parser- Predictive Parser, Bottom up
Parser- SLR Parser - Syntax directed definitions - construction of syntax trees.
UNIT – V
Intermediate Code Generation, Code Optimization And Code Generation : Declarations-Assignment
statements-Boolean expressions- Procedure calls. Code Optimization: Principle sources of optimization –
Loop Optimization. Code Generation: Issues in the design of code generator - Simple code generator -
Basic blocks and flow graphs - The DAG representation of Basic Block - Generating code form DAGs -
Peephole optimization.
Text Books:
1. John E. Hopcroft and Jeffrey D. Ullman, ‘Introduction to Automata Theory, Languages, and Computation, 3rd
Edition, Pearson Edition.
2. Alfred Aho, V. Ravi Sethi, and D. Jeffery Ullman, “Compilers Principles, Techniques and Tools”, Addison-
Wesley, 2nd Edition, 2007.
3. John C. Martin, ‘Introduction to Languages and the Theory of Computations’, McGraw Hill, 3rd Edition,
2007.
Prepared By:
Mr.M.Shanmugam, AP/CSE
Verifiedby: Approvedby:
UNIT-I
Finite Automata and Regular Expressions: Finite Automata - Examples and Definitions -
Accepting the Union, Intersection, or Difference of Two Languages. Regular Expressions: Regular
Languages and Regular Expressions – Conversion from Regular Expression to Deterministic Finite
Automata.
2 MARKS
Computationisthesequenceofstepsthatcanbeperformedbycomputer.
Thecomputerwhichperformscomputationisnotactualcomputerstheyare“abstractmachines”.It can
be definedmathematically.
3. What is a formallanguage?
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 language defined by context free grammar. The two
notations for specifying formal languages are:
Grammar or regular expression (Generativeapproach)
Automaton (Recognitionapproach)
5. What is AutomataTheory?
Automata theory is the study of abstract machines (or abstract 'mathematical' machines or systems)
and the computational problems that can be solved using these machines. These abstract machines
are calledautomata.
Example:
1. x=00 y=1
xy=001, yx=100
x=AL y=GOL
xy=ALGOL
2. Empty string is the identity element for concatenation operator. i.e
w Є= Єw=w
Reverse of a string
The reverse of a string is obtained by writing the symbols in reverse order.
Let w is the string
Reverse is wR
i.e w=a1,a2,……am
wR=am,……a2,a1
Example:
Let u=010111
uR=1101010
Example:
If Σ ={a} the Σ*={ Є,a,aa,aaa,………}
If Σ ={0,1} theΣ*={Є,0,1,00,10,10, ........................... }
Σ0={Є}
Σ1={a}
Σ2={aa}
Therefore Σ*= Σ0U Σ1U Σ2,……………..
Present State Next State for Input 0 Next State for Input 1
a a b
b c a
c b c
27. What are the difference between NFAandDFA? (APR2015, 2016,2017) ( NOV2015)
DFA NFA
i. For each and every state and for each and i. For each and every state and for each and everyinput
every input symbol there exists at most one symbol there exists more than onetransition.
transition. ii. The transition mapping for NFA is Q × (Σ U {ε})2Q.
ii. The transition mapping for DFA isQ×ΣQ. iii. The language accepted by NFA is denoted byL(M’).
iii. The language accepted by DFA is denoted iv. Epsilon transition ispossible.
as L(M).
iv. Epsilon transition is notpossible.
Text Editors
Certain text editor and similar programs permits substitution of string for any string matching given
regularexpression.
For example: the UNIX text editor allows a command suchas
s /bbb*/b*
36. Construct DFA that accepts input stings of 0’s and 1’s that end with11. (APR-22)
0 0 1
Start
q2
q0 q1
The language accepted by this automaton is L = {11, 011, 01011, and 000111}
1. Machine will be in start stateqo.
2. It will remain unchanged until it sees the input symbol‘1’.
3. On getting ‘1’ goes toq1.
4. From q1, on input symbol ‘0’ goes to qo. From q1, one i/p symbol ’1’ goes to q2(acceptancestate).
5. From q2, any number of 1 is accepted and if any 0 comes it goes to startstate.
TransitionDiagram
δ (q0, 0) ={q0}
δ (q0, 1) ={q1}
δ (q1, 1) ={q2}
δ (q2, 1) ={q1}
Here {q1} is the final state. Hence the given input string 0111 is accepted by DFA.
43. State the relations, among regular expression, deterministic finite automaton,non-deterministic
finite automaton and finite automatonwithepsilontransitions. (APR2015)
10 MARKS
Alphabets:
An alphabet is a finite, non-empty set no of symbols. It is denoted by Σ.
Example:
Σ = {a, b}, an alphabet of 2 symbols a andb.
Σ = {0, 1, 2} an alphabet of 3 symbols 0, 1, and2.
Strings:
A String or Word is a finite sequence of symbols from Σ. The group of characters also referred as a String.
Example:
a, b, and c are symbols and abcbis astring.
If Σ = {a,b} then abab,aabbb,aaabb,…… are all strings over the alphabet Σ={a,b}.
0, 1, 11, 00, and 01101 are strings over{0,1}.
Substring:
Let x and y be strings over an alphabet Σ.
The string x is a substring of y if there exist strings w and z over Σ such that y = w x z.
ε is a substring of everystring.
For every string x, x is a substring of xitself.
Example:
ε, comput and computation are substrings ofcomputation.
Reversal:
Let x be a string over an alphabet N.The reversal of the string x, denoted by x r, is a string such that
ifx is ε, then xrisε.
If a is in Σ, y is in Σ* and x = a y, then xr= yra.
Length of string:
Let w is a string. Length of the string is |w|=> number of symbols composing the string.
Example:
1) If w=abcd then |w|=4
2) If x=01010110 the |x|=8
3) If y= 0101 the |y|=4
4) If |Є| = 0
Concatenation of string
Appending the strings (2) referred as concatenation of strings.
i.e w=a1,a2,….am
v=b1,b2,b3,……bn
then wv=a1,a2,….amb1,b2,…..bn
Example:
1. x=00 y=1
xy=001, yx=100
x=AL y=GOL
xy=ALGOL
Reverse of a string
The reverse of a string is obtained by writing the symbols in reverse order.
Let w is the string
Reverse is wR
i.e w=a1,a2,……am
wR=am,……a2,a1
Example:
Let u=010111
uR=1101010
Powers of an alphabet:
Let Σ be the alphabet
Σ * is the set of all strings over alphabet Σ.
Σ m denotes the set of all strings over alphabet Σ of length m.
Example:
Σ = {0,1}
Σ0= {Є} empty string of length0.
Σ1= {0, 1} is the set of all strings of length one over Σ = {0,1}
Σ2={00,01,10,11}isthesetof allstringsof lengthtwooverΣ={0,1}.
Kleen Closure:
Let Σ be the alphabet
“ Kleen Closure”-> Σ* denotes the set of all strings (Σ) over the alphabet
Example:
If Σ ={a} the Σ*={ Є,a,aa,aaa,………}
If Σ ={0,1} theΣ*={Є,0,1,00,10,10, ........................... }
Σ0={Є}
Σ1={a}
Σ2={aa}
Therefore Σ*= Σ0U Σ1U Σ2,……………..
FINITE AUTOMATA:
Afiniteautomaton(FA)consistsofafinitesetofstates andasetoftransitions fromstatetostatethat occur on
input symbols chosen from an alphabetΣ.
Eachinputsymbolthereis exactlyonetransition outofeachstate(possiblybacktothestateitself).
OneState,usuallyq0,istheinitialstate,inwhichtheautomatonstarts.
Some states are designated as final or acceptingstates.
Finite automata are computing devices that accept/recognize regular languages and are used to model
operations of many systems we find in practice. Their operations can be simulated by a very simple.
Transition diagram:
A directed graph, called a transition diagram, is associated with an FA as follows:
The vertices of the graph correspond to the states of theFA.
If there is a transition from state q to state p on input a, then there is an arc labeled a from state q to
state p in the transitiondiagram.
The FA accepts a string x if the sequence of transitions corresponding to the symbols of x leads from
the start state to an acceptingstate.
Finite Control
A finite automaton as a machine can also be thought of as the device shown below consisting of a tape and a
control circuit which satisfy the following conditions:
1. The tape has the left end and extends to the right without anend.
2. Thetapeis divideintosquares in eachofwhichasymbolcan bewrittenpriortothestart ofthe
operation of theautomaton.
3. The tape has a read onlyhead.
4. The head is always at the leftmost square at the beginning oftheoperation.
5. The head moves to the right one square every time it reads a symbol.
It never moves to the left. When it sees no symbol, it stops and the automaton terminates its
operation.
6. There is a finite control which determines the state of the automaton and also controls the
movement of the head.
Example:
Consider the formal notation this FA is denoted M= (Q, Σ, δ, q0, F), where Q= {q0, q1, q2, q3}, Σ= {0, 1},
F= {q0} and δ is shown as
Transition Diagram:
Transition Table:
Inputs
States
0 1
* q0 q2 q1
q1 q3 q0
q2 q0 q3
q3 q1 q2
Solution:
The given input string is 110101 to machine M. We denote that
δ (q0, 1) ={q1}
δ (q1, 1) ={q0}
δ (q0, 0) ={q2}
δ (q2, 1) ={q3}
δ (q3, 0) ={q1}
δ (q1, 1) ={q0}
Therefore q0 is the accepting or final state.
Hence the given input string 110101 is accepted by DFA.
Examples:
Consider the given NFA to check whether the string is accepted or not W=01001.
Transition diagram:
Transition table:
Input
States
0 1
q0 {q0,q3} {q0,q1}
q1 Ф {q2}
* q2 {q2} {q2}
q3 {q4} Ф
* q4 {q4} Ф
Method1:
The given input string is 01001
δ(q0,0) = {q0,q3}
For example, the string ω= 002 is accepted by NFA along the path q0, q0, q0, q1, q2, q2 with arcs labeled
0, 0, ε, ε, 2.
The Non-deterministic finite automaton with ε-moves to be a quintuple (Q, Σ, δ, q0, F) with all
components as before, but δ, the transition function, maps δ: Q × (Σ U {ε}) 2Q.
Theintentionis thatδ(q,a)willconsistsofallstatespsuchthatthereis atransitionlabeledafromq
top, where a is either ε or a symbol in Σ.
ε- closure (q) denotes the set of all vertices P such that there is path from q to Plabeledε.
Thetransitionfunction δtoafunctionδ^that mapsQ×Σ*to2Q.In thatδ^(q,w) willbeallstatespsuch that one
can go from q to palong labeled ω, perhaps including edges labeledε.
Example:
Consider the NFA with ε given below and convert it into NFA without ε.
Solution:
Consider Non-Deterministic Finite Automata (NFA), Let a machine M= (Q, Σ, δ, q0, F),
Where,
Q = {q0, q1, q2}
Σ= {0, 1, 2}
{q0}=start state
F = {q2}
Inputs
States
0 1 2 ε
q0 {q0} φ φ {q1}
q1 φ {q1} φ {q2}
* q2 φ φ {q2} φ
The ε-closure as
ε closure {q0} ={q0,q1,q2}
ε closure{q1} = {q1,q2}
ε closure{q2} = {q2}
ε closure(state) -> denotes wherever the ε state travelling from the given state continuously. We should
consider all the state. If we don’t have continuity, we have to stop the previous state.
The formula is
δ’(q0,ε) =ε-closure(q0)
= {q0, q1, q2}
δ'(q0,0) =δ^(q0,0)
= ε closure (δ (δ^ (q0, ε),0))
=εclosure(δ{q0, q1, q2},0)
= ε closure (δ (q0, 0) U δ (q1, 0) U δ (q2, 0))
= ε closure ({q0} U {φ} U {φ})
= ε closure ({q0})
= {q0, q1, q2}
δ'(q0,1) =δ^(q0,1)
= ε closure (δ (δ^ (q0, ε),1))
=εclosure(δ{q0, q1, q2},0)
= ε closure ({φ} U {q1} U {φ})
= ε closure ({q1})
= {q1, q2}
δ'(q0,2) =δ^(q0,2)
= ε closure (δ (δ^ (q0, ε),2))
=εclosure(δ{q0, q1, q2},2)
= ε closure (δ (q0, 2) U δ (q1, 2) U δ (q2, 2))
= ε closure ({φ} U {φ} U q2)
= ε closure ({q2})
= {q2}
δ'(q1,0) =δ^(q1,0)
= ε closure (δ (δ^ (q1, ε), 0))
= ε closure (δ {q1, q2}, 0)
= ε closure (δ (q1, 0) U δ (q2, 0))
= ε closure ({φ} U {φ})
= ε closure (φ)
= {φ}
δ'(q1,2) =δ^(q1,2)
= ε closure (δ (δ^ (q1, ε), 2))
= ε closure (δ {q1, q2}, 2)
= ε closure (δ (q1, 2) U δ (q2, 2))
= ε closure ({φ} U {q2})
= ε closure ({q2})
= {q2}
δ'(q2,0) =δ^(q2,0)
= ε closure (δ (δ^ (q2, ε), 0))
= ε closure (δ {q2},0)
= ε closure (δ (q2,0))
= ε closure ({φ})
= {φ}
δ'(q2,1) =δ^(q2,1)
= ε closure (δ (δ^ (q2, ε), 1))
= ε closure (δ {q2},1)
= ε closure (δ (q2,1))
= ε closure ({φ})
= {φ}
δ'(q2,2) =δ^(q2,2)
= ε closure (δ (δ^ (q2, ε), 2))
= ε closure (δ {q2},2)
= ε closure (δ (q2,2))
= ε closure ({q2})
= {q2}
Inputs
States
0 1 2
* q0 {q0,q1,q2} {q1,q2} {q2}
* q1 {φ} {q1,q2} {q2}
* q2 {φ} {φ} {q2}
6. Construct a DFA equivalent to NFA, where M = ({q0, q1, q2}, {0, 1, 2}, δ, q0, {q0, q1, q2}).
The Transition is given by the transition diagramandtransitiontable. (10MARKS)
Transition Table:
Inputs
States
0 1 2
* q0 {q0,q1,q2} {q1,q2} {q2}
* q1 {φ} {q1,q2} {q2}
* q2 {φ} {φ} {q2}
Transition Diagram:
Transition Function:
δ'(q0,0) = [q0q1q2]
δ'(q0,1) = [q1q2]
δ'(q0,2) = [q2]
δ'(q1,0) = [φ]
δ'(q1,1) = [q1q2]
δ'(q1,2) = [q2]
δ'(q2,0) =[φ]
δ'(q2,1) =[φ]
δ'(q2,2) = [q2]
Inputs
States
0 1 2
[q0] [q0q1q2] [q1q2] [q2]
[q1] φ [q1q2] [q2]
* [q2] φ φ [q2]
[q0q1] [q0q1q2] [q1q2] [q2]
[q0q2] [q0q1q2] [q1q2] [q2]
*[q1q2] φ [q1q2] [q2]
*[q0q1q2] [q0q1q2] [q1q2] [q2]
Transition Diagram:
LEXICAL ANALYZERS:
Tokens of a programming language are regularsets.
Forexample:ALGOLidentifiers,whichareupper-orlower-caselettersfollowedbyanysequenceof
letters and digits with no limit on length, expressedas,
(letter)(letter + digit)*
where
“letter“ stands for A + B + …… + Z + a + b + …… +zand
“digit“ stands for 0 + 1 + ….. +9
FORTRANidentifiers,withlengthshouldlimitedofsixandlettersrestrictedtouppercaseand
symbol $, may be expressedas
(letter)(+ letter + digit)*
where, “letter” stands for ($ + A + B + ……. + Z).
SNOBOL arithmetic constants ( which do not permit exponential notation present in many other
languages) can be expressedas
(+ -)(digit+ (.digit* + )+ .digit+)
Anumberoflexicalanalyzerstakesinputassequenceofregularexpressionsdescribingthetokens and
produce a single finite automaton recognizing the anytoken.
Usually, they convert the regular expression to an NFA with -transitions and then constructsubset
of states to produce a DFA directly rather than first eliminating -transitions.
Eachfinalstateindicates theparticulartoken found,sotheautomatonis reallyaMooreMachine.
The transition function of the FA is encoded in one of several ways to take less space than the
transition table represented as a two-dimensionalarray.
The lexical analyzer produced by the generator is a fixed program that interprets coded tables,
together with the particular table that represents the FA recognizing thetokens.
This lexical analyzer can be used as a module inacompiler.
A Logic Circuit
Deterministic finite automata have many practical applications:
1. Almost all compilers and other language-processing systems use DFA-like code to divide an input
program into tokens like identifiers, constants, and keywords and to remove comments and white
space.
2. For many applications that accept typed commands, the command language is quite complex, almost
likealittleprogramminglanguage.SuchapplicationsuseDFA-likecodetoprocesstheinputcommand.
Proof:
We prove by induction on the number of operators in the regular expression r that there is an NFA M with
ε-transition, having one final state and no transitions out of this final state, such that L(M)= L(r).
Case (1):
Let r= r1+ r2. Both r1 and r2 must have fewer than i operators.
Thus there are NFA’s,
M1 = (Q1, Σ1, δ1, q1, {f1}) and M2 = (Q2, Σ2, δ2, q2, {f2}) with L(M1)= L(r1) and L(M2)= L(r2).
Assume Q1 and Q2 are disjoint. Let q0 be a new initial and f0 a new final state.
Construct M = (Q1 Q2 {q0, f0}, Σ1 Σ2, δ, {q0}, {f0}), where δ is defined by
(a).Union
All the moves of M1 and M2 are present in M any path in the transition diagram of M from q0 to f0 must
begin by going to either Q1 or Q2 on ε. If the path goes to Q1, it may follow any path in M1 to f1 and go to f0
on ε. Similarly paths begins by going to Q2 may follow any path in M2 to f2 and then go to f0 on ε. These are
the only paths from g0 to f0. If there is a path labeled ‘x’ in M1, from Q1 to f1 or a path in M2 from q2 to f2.
Hence L(M)= L(M1) L(M2).
Case (2):
Let r= r1r2.
Let M1 = (Q1, Σ1, δ1, q1, {f1}) and M2 = (Q2, Σ2, δ2, q2, {f2}) with L(M1) = L(r1) and L(M2) = L(r2).
(b).Concatenation
Construct M = (Q1 Q2, Σ1 Σ2, δ, {q1}, {f2}),
where δ is defined as,
1. δ(q, a) = δ1(q, a) for q in Q1{f1}, a in Σ { ε}
2. δ(f1, ε) = {q2}
3. δ(q, a) = δ(q, a) for q in Q2 and a in Σ2 { ε}
Every path in M from q1 to f2 is a path labeled by some string ‘x’ from q1 to f1, followed by some string ‘y’
from q2 to f2. Thus L(M) = {xy | x is in L(M1) and y is in L(M2)}. And L(M)= L(M1)L(M2).
(c).Closure
Where δ is given by
1. δ(q0, ε) = δ(f1, ε) = {q1, f0}
2. δ(q, a) = δ1(q, a) for q in Q1 {f1} and a in Σ1 { ε}.
Any path from q0 to f0 consists either of a path from q0 to f0 or a path from q0 to q1 on ε followed by same
no. of paths from q1 to f1, then back to q1 on ε. There is a path in M from q0 to f0 labeled ‘x’ if we write
x= x1, x2, ……xj for some j≥ 0 such that each xi belongs to L(M1). Hence L(M)= L(M1*).
Example
Consider a NFA with the transition diagram
Transition Table
δ a b
q0 {q0,q1} {q1}
q1 {q2} {q1,q2}
q2 φ {q2}
q φ {p} φ
Solution:
11. Prove: A language L is accepted by some ε-NFA if and only if L is accepted by some DFA.
(5 MARKS) (APR, NOV 2015, 2017) (APR2016)
To Prove:
The Language accepted by NFA is equal to the language set accepted by DFA.
i.e. L(M)=L(M´) ,
Where M is the NFA and M´ is the DFA.
Proof:
Let M= (Q, Σ, δ, q0, F) be an NFA, accepting L and we can define a DFA
M´ = (Q, Σ, δ´, q0, F´) as follows.
The states of M´ are all the subsets of the set of states of M.
That is, Q´ = 2Q
M´willkeep trackinitsstates ofallthestates Mcouldbein at anygiven time.F´isthesetallthestates in
Q´containingthefinalstateofM.An elementofQ´willbedenotedby[q1,q2,q3 ......................qi] are inQ.
Observe that, [q1,q2,q3 .... qi] is a single state of DFA corresponding to the states of theNFA.
Note q0´= [q0]
It is easy to show by induction for the length of the input string x,that
δ´( q0´, x) =[q1,q2,q3........ qi]
if and only if,
δ( q0, x) ={q1,q2,q3 ....... qi}
Basis
Consider |x|=0 then x must be since q0´= [q0]
Then
δ´( q0, ε )=[q0]
if and only if
δ( q0, ε )= { q0}
Hence the result is trivial.
Induction
Let us assume that the hypothesis is true for inputs of length m, Let xa be a string of length m+1 with a in
Σ, then
δ´( q0’,xa ) = δ´( δ´( q0’,x),a)
By the inductive hypothesis,
δ´( q0’, x) = [P1,P2,P3 ........Pj]
If and only if ,
δ( q0, x) = {P1,P2,P3........ Pj}.
But by the definition of δ´,
δ´[(P1, P2, P3 .... Pi), a] = [r1,r2,r3 ........ rk]
If and only if,
δ({P1, P2, P3 .... Pi}, a) = [r1,r2,r3 ........ rk]
Thus,
δ´( q0, xa)= [r1,r2,r3 ....... rk]
12. Construct a NFA that accept the set of all strings {a, b} ending with “aba” as substringand
constructsDFA. (5MARKS) (NOV2015) (OCT-22)
In NFA , which can formally be specified as follows
13. Prove the equivalence of NFA and DFA using subset construction with anexample.
(5 MARKS) (NOV2015)
Since every DFA is an NFA, that the class of languages accepted by NFA’s includes the regular sets (the
languages accepted by DFA’s). The DFA’s can simulate NFA’s; that is for every NFA can construct an
equivalent DFA (one which accepts the same language). The way a DFA simulates an NFA is to allow the
states of the DFA to correspond to set of states of the NFA. The constructed DFA keeps track in its finite
control of all states that the NFA could be in after reading the same input as the DFA has read.
Two finite automata M1 and M2 are equivalent if L(M1) = L(M2), that is, if they both accept the same
language.
Proof strategy
Toshowthat anylanguageaccepted byaNFAisalso accepted bysomeDFA,wedescribeanalgorithm that
takes any NFA and converts it into a DFA that accepts thesamelanguage.
The algorithm is called the “subset constructionalgorithm”.
Wecanusemathematicalinduction(onthelengthofastringacceptedbytheautomaton)toprovethat the
DFA that is constructed accepts the same language as theNFA.
Example
The start state of the DFA is the set of states the NFA can be in before reading any input. This includes the
start state of the NFA and any states that can be reached by a ε -transition.
For state {0,1}, we create a transition for each possible input, a and b. In the process, we create state {2}.
For state {2}, we create a transition for each possible input, a and b. In the process, we create another state,
{1,2}.
Thelaststep istomarkthefinalstatesoftheDFA.
This DFA accepts all the string starting with a and ending with b. Here, State A is initial state and
state C is final state.
This DFA accepts all the string starting with b and ending with a. Here, State A is initial state and
state C is final state.
Now, Taking the union of L1 and L2 language which gives the final result of the language which starts
and end with different elements.
Thus as we see that L1 and L2 have been combined through union process and this final DFA accept all
the language containing strings starting and ending with a different symbols.
Note: From above example we can also infer that regular languages are closed under union(i.e Union
of two regular languages is also regular).
It accepts all the string that accept with even number of 1’s.
Thus as we see that L1 and L2 have been combined through intersection process and this final DFA
accept all the language that has even number of 1’s and is ending with 01.
2 MARKS
1. Construct NFA equivalent to the regular expression: (0+1)01. (APR 2015) (Ref.Qn.No.49,
Pg.no.18)
2. Difference between DFA and NFA? ( APR 2015, 2016, 2017) (NOV 2015) (Ref.Qn.No.27,
Pg.no.11)
3. State the relations, among regular expression, deterministic finite automaton, non-deterministic
finite automaton and finite automaton with epsilon transitions. (APR 2015) (Ref.Qn.No.52,
Pg.no.18)
4. What are Finite Automata? Give an example. (NOV 2015) (Ref.Qn.No.18,Pg.no.8)
5. Give the applications of finite automata? (APR 2016, NOV 2017) (Ref.Qn.No.41,Pg.no.15)
6. Define DFA. (NOV 2016) (Ref.Qn.No.23,Pg.no.10)
7. List out the applications of automata theory? (APR 2017) (Ref.Qn.No.17,Pg.no.8)
8. WhatisRegularLanguage?(APR2017)(Ref.Qn.No.50,Pg.no.18)
9. Define Induction principle. (APR 2017)(Ref.Qn.No.51,Pg.no.18)
10 MARKS
q Φ {p} φ
(b). Give Deterministic finite automata accepting the following language over the alphabet number
of 1’s is a multiple of 3. (5 MARKS) (Ref.Qn.No.17, Pg.no.56)
Also check whether the minimized DFA accepts the string “000101”.
p {p, q} {p}
q {r, s} {t}
r {p, r} {t}
*s Φ φ
*t Φ φ
(OR)
2. Prove the following: “A language L is accepted by some DFA if and only if L is accepted bysomeNFA”.
(Ref.Qn.No.14, Pg.no.51)
MAY 2018
1. Convert the following regular expressions to DFA (0+1)*(0+1)(10 Marks)
(OR)
2. Provethat“ifthereisalanguageL,suchthat L=L(A)forsomeDFAA.then thereis aregular
Expression. R such that L=L(R).(10Marks)
MAY 2019
1. Explain the steps for minimizing the states of a DFA(10Marks)
(OR)
2. Explain the method for designing a NFA from a regularexpression.(10Marks)