Session 3
Session 3
languages
1. Course Description
The course introduces on fundamental concepts of Computer science and formal methods of
computation like automata theory and formal languages including grammar, finite automaton, regular
expression, formal language, pushdown automaton, and Turing machine. Not only do they form basic
models of computation, they are also the foundation of many branches of computer science, e.g.
compilers, software engineering, concurrent systems, etc. The properties of these models will be
studied and various rigorous techniques for analyzing and comparing them will be discussed, by using
both formalism and examples.
2. Aim
Study various automata, such as deterministic and nondeterministic finite-state machines,
pushdown automata, and Turing machines.
Study formal languages of different kinds, such as regular and context-free languages.
Understand the connections between languages and automata, and related algorithms for
transformations.
Understand the basic results on computability, including undecidable problems such as the halting
and Post correspondence problems, and their significance.
Study the basics of intractability, including NP-completeness and related topics.
Make connections between theoretical results and topics in practical software development, such
as finite automata and regular-expression libraries.
Improve programming skills, with emphasis on connections between theoretical results and
practical software.
3. Instructional Objectives
The objective of this course is to classify machines by their power to recognize languages and
comprehend the hierarchy of problems arising in the computer sciences
4. Learning Outcomes
Make use of Finite State Machines for Modeling and Solving computing problems for different
languages
Construct regular expressions for different languages
Model Push Down Automata for CFLs and constructs a PDA for different CFLs
Make use of Context-Free languages and Turing Machines for different unrestricted languages
5. Module Description
CO1: Introducing the concepts of automata theory Understand NFA and DFA Conversions and Equivalence of
Different finite automata
CO2: Introducing the concepts of Regular Languages Understand Pumping lemma of regular sets, closure
properties of regular sets Equivalence between regular linear grammar and FA, interconversion.
CO3: Introducing the concepts of Context-Free Grammars Understanding Chomsky Normal Form (CNF) and
Greibach Normal Form (GNF) Push down automata model and its equivalence
CO4: Introducing the concepts of Types of PDA Understand Turing Machine Concepts Counter machine and
Restricted Turing Machines
Session Introduction:
Finite Automata(FA) is the simplest machine to recognize patterns. The finite automata or finite state
machine is an abstract machine that has five elements or tuples. It has a set of states and rules for
moving from one state to another but it depends upon the applied input symbol.
Session Description:
Finite Automata is mainly classified into two types
1. Deterministic Finite Automata (DFA) : There is exactly one transition from each input symbol
2. Non Deterministic Finite Automata (NFA): There are Zero, one or more transitions from each input
symbol (There may not be transition for an input symbol)
L={00,11,000,111,001,110, …….}
4. Construct DFA, L={w|w conatains even number of ‘0’s’ and even number
of ‘1’s ,∑={0,1}}
L={0011,1010,1100,0101,..................}
5. Construct DFA , L={w|w conatains even number of a’s, ∑={a,b}}
L={ε,aa,b,baa,aab,aba,bbaa,.............}
L={bab,ababaa,babbb,bbb,bbab,aabab….}
L={ ba,aaaa,aabb,aaab…..}
11. Design a DFA which accepts set of strings that does not contain “010” as
substring over an alphabet ∑ = {0, 1}.
Step 2: Creating the DFA that does not contains “010” as substring
12.Design a DFA which accepts set of strings that starts and ends with ‘b’
(same symbol) over an alphabet ∑ = {a, b}.
6. Activities
1.Design the DFA for the following Languages and complete the Cross word Puzzle given below
1. L={w| w starts with ‘a’ where ∑={a,b} }
2. L={w| |w|=2 over input alphabet ∑={a,b,c} ; |w| indicates length of string}
4. L={w| |w| mod 5 !=0 over input alphabet ∑={a, b} ; |w| indicates length of string; ‘mod’ gives
remainder}
3. Design the PDAs for the following Languages and complete the Cross word Puzzle given below
n n m m
1. L={a b c d | n>0,m>0 }
2. L={language of balanced parenthesis eg: (())()() }
3. L={w| w contains equal number of a’s and b’s where ∑={a,b} }
7. Examples
1. Design NFA for the following languages: a) L={w/w contains three consecutive one’s } Σ={0,1} b)
L={w/w contains exactly two occurances of ‘00’ } Σ={0,1} c) L={xЄ{a,b,c}* / x contains exactly one ‘b’
immediately followed by ‘c’} Σ={a,b,c} d) L={w/w contains mod 5 not equal to 0 } Σ={a,b}
2. Convert the following NFA to DFA
a)
b)
c)
a) Strings of 0’s and 1’s containing odd number of 1’s or even number of 0’s over {0,1}.
b) Set of strings of 0’s and 1’s of length less than 6 over {0,1}.
c) Set of strings of 0’s and 1’s that ends with 1 and does not contain substring 00 over {0,1}.
d) Set of strings of a’s and b’s that begins and ends with same symbol over {a,b}.
e) The language of all strings 0’s and 1’s in which every 0 is followed immediately by 11 over {0,1}.
f) The language of all string containing atleast two 0’s over {0,1}.
g) The language of all strings that do not end with 01 over {0,1}.
4. The following languages are regular or not. Justify the answer.
a) L = { 0n102n |n>=0}
b) L = { 0i1j| j = i or j = 2i }
c) L = { a2nb3m | n>=1, m>=1}
d) L = { 0i1j | j is a multiple of i }
e) L = { xy | x,y ϵ { 0, 1}* and y is either x or x r }
5. Minimize the DFA shown below.
8. Self-Assessment Questions
35. Consider the following finite automata. The regular expression for this FA is [
]
A)ε B) a C) aa D) a*
36. The union of two regular expressions R1 and R2, written as R1 + R2 is also a regular expression. [ ]
A) True B)False C) True of False D) Can’t say
37. Let the input alphabet be ∑ = {0}, then ∑* = [ ] A) {ε}
B) {ε, 0} C) {0} D) {ε, 0, 00, 000, …….}
38. In transition diagram the final state is represented as [ ]
A) Single Circle B) Star C) Double Circle D)Arrow
39. The regular expression for the regular set { 2,22,222,........ } is . [ ]
A) 2* B) 2+ C) 2(2) * D) both (B) & (C)
40. DFA stands for [ ]
A) Deterministic Finite Authorization B) Deterministic Finite Acceptance
C) Deterministic Finite Automaton D) Deterministic Finite Analysis
9. Summary
Formal Languages and Automata Theory introduces you to the concepts associated languages, computation and
machines. It uses mathematical structure, and certain axiomatic rules (formal grammar) to describe translation of
programs written in computer languages. The notions and methods of formal language are analogous to those used
in number theory and in logic. This brought in latest developments in computer technology such as the recognition
neurons in artificial intelligence and robotic programming. The content of the course material was planned and
written to ensure that you acquire the proper knowledge and skills, Real-life situations have been created to enable
you identify with and create some of your own. The essence is to help you in acquiring the necessary knowledge
and competence by equipping you with the necessary tools to accomplish this.
10. Terminal Questions
1. A. Write about Finite Automata & String Acceptance
B. Design DFA for the following Language L= {x01y/ x and y are strings of 0’sand 1’s} Define all the elements of
DFA
C. Give an example of Transition Diagram and Transition Table of FA
2. A. Specify some applications of Finite Automata
B. State and Prove the Equivalence of NFA and DFA
C. Design an equivalent DFA from the following NFA, where the transition function of NFA is given by δ (q0,
0) = {q0, q3}, δ(q0,1)={q0,q1}, δ(q1,0)=Ф, δ(q1,1)= q2, δ(q2,0)=q2, δ(q2,1)=q2, δ(q3,0) =q4, δ(q3,1) =Ф,
δ(q4,0) =q4, δ(q4,1) =q4, q0 is an initial state and q2 & q4 are the final states.
3. A. Write Regular Expression for the following languages
i. Set of Strings that consists of alternate 0’s and 1’s
ii. Set of Strings of a's and b's that ends with 'ab' or 'bb'
iii. Set of strings of a's and b's that begins with 'ab' and contains the substring 'ba'
B. Design NFA with ε-transitions for the following Regular Expression
i. a (a+b)*a + b (a+b)*b ii. (0+1)*(00+11)
4. A. Minimize the following DFA, where q0 and q4 are the initial and final states respectively
State
q0 q1 q3
q1 q2 q4
q2 q1 q4
q3 q4 q2
q4 q4 q4
B. State and Prove any Three Closure Properties of Regular Sets
5. A. Define PDA (Push Down Automata). Give its Mathematical Representation
B. Design PDA for the following Language
L = {Set of Equal Number of 0's and 1's over {0, 1}}
C. When do you say that a CFG is Unambiguous? Is the following CFG ambiguous or not? Justify your answer
with an example with V = {S, E} T = {if, then else, other}, P, {S}
S if E then S S if E then S else S E other
6. A. Define a. Useless symbol b. Null Production c. Unit Production
B. Find a Grammar equivalent to S AB/AC A
aA/bAa/a B bbA/aB/AB CaCa/aD D aD/bC with no use less symbols
7. A. Define Turing Machine. Give its Mathematical Representation
B. Design Turing Machine for the following language. Represent all the elements
L = {Set of Equal number of a's and b's over {a, b}}
C. Define Recursively Enumerable Languages. Give any three examples
8. A. Define the following
i. CNF (Chomsky Normal Form) ii. GNF (Griebach Normal Form)
Find an equivalent grammar in CNF from the following CFG S ABa
A aab B Ac
B. Consider the following CFG
S AB/BC ABA/a BCC/b CAB/a
Find whether the given string 'baaba' is a part of the language generated by the CFG using CYK algorithm.
9. A. Design DFA for the set of all strings such that the third symbol from the right end is '1' over Σ = {0,1}.
Represent all the elements of DFA.
B. The following are two finite automata M1(Q1, {0,1}, q0, δ1, {q0, q1}) and M2(Q2, {0,1}, p0, δ2, {p2})
corresponding to regular languages L1 and L2 with the transition functions given below. For machine M1,
δ1(q0,0)=q1, δ1(q0,1)=q0, δ1(q1,0)=q2, δ1(q1,1)=q0, δ1(q2,0)=q2, δ1(q2,1)=q2, where q0 is an initial and a
final state and q2 is a final state respectively. For machine M2, δ2(p0,0)=p1, δ2(p0,1)=p0, δ2(p1,0)=p1,
δ2(p1,1)=p2, δ2(p2,0)=p1, δ2(p2,1)=p0. Here p0 is an initial state and p2 is a final state. Draw transition
diagram & transition table for M1 and M2
10. A. Differentiate between NFA & DFA
B. Design NFA for the language L={an U bn / n>=1}. Represent all the elements of NFA
C. Define NFA with ε- transitions and give its Mathematical Representation
11. References of books, Sites, Links
Text Books :
T1. John E. Hopcroft, Rajeev Motwani, and Jeffery D. Ullman, “Introduction to Automata Theory, Languages and
Computation”, 3rd Edition, Pearson Education, 2008.
T2. Linz, Peter, “An Introduction to Formal Languages and Automata”, Sixth Edition—2016,Jones and Bartlett.
Reference Books :
R1. Sipser J Michael, “Introduction to Theory of Computation”, Third Edition—2015, Cengage.
R2. Martin Jhon, “Introduction to Languages and Theory of Computation”, Third Edition—2016, PHI.
Web Links :
1. Theory Of Computation and Automata Tutorials: https://www.geeksforgeeks.org/theory-of- computation-
automata-tutorials/
2. Automata Tutorial: https://www.javatpoint.com/automata-tutorial
3. Automata Theory Tutorial: https://www.tutorialspoint.com/automata_theory/index.htm
4. Automata Tutorial: https://www.tutorialandexample.com/automata-tutorial
12. Keywords
NFA, DFA, Pushdown Automata, Pumping Lemma, Grammar, CFG, Turing Machine, Chomsky Hierarchy,
Derivation Keys.