CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 1: Introduction to Theory of Computation
Raghunath Tewari
1
IIT Kanpur
Introduction
Introduce myself name, background, research interests, contact information
Course syllabus
1. Homework assignmen

CS 340
Homework 2
Semester I, 2015-16
Due Date: Tuesday, 8th September
Total Points: 40
Submit the assignment before beginning of class on or before the due date.
Yours answers should be precise and clearly legible. Illegible answers will get no credit

CS 340
Homework 3
Semester I, 2015-16
Due Date: Thursday, 15th September
Total Points: 55
Submit the assignment before beginning of class on or before the due date.
Yours answers should be precise and clearly legible. Illegible answers will get no credi

CS 340
Homework 4
Semester I, 2015-16
Due Date: Tuesday, 10th November
Total Points: 55
Submit the assignment before beginning of class on or before the due date.
Yours answers should be precise and clearly legible. Illegible answers will get no credit

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 6: Non-regular languages
Raghunath Tewari
IIT Kanpur
Limitations of nite automata.
1. Not all languages are regular.
2. Intuitively languages that require some sort of counting are generally not reg

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 8: Context-Free Grammar
Raghunath Tewari
IIT Kanpur
So far we have studied the class of languages known as regular languages. They can be expressed
using a nite automata or regular expressions (both

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 15: Closure Properties of Decidable Languages
Raghunath Tewari
IIT Kanpur
We will study the closure properties of decidable and Turing recognizable languages under some
of the standard operations on

Homework 2 Solutions
Raghunath Tewari
September 9, 2015
1. (Points: 5) Give a regular expression for the following language.
B = cfw_x cfw_0, 1 | x does not contain the substring 101
Solution:
0 (1 000 ) 1 0
The expression in bracket encodes the fact that

Homework 4 Solutions
Raghunath Tewari
November 10, 2015
1. (Points: 5 + 5 + 5 + 5) Which of the following languages are decidable/undecidable? Prove your
answer by either giving an algorithm or a proof of undecidability.
(a) L1 = cfw_ M, N | M, N are two

Homework 3 Solutions
Raghunath Tewari
October 16, 2015
1. (Points: 5 + 8) Design PDAs for the following languages (give the transition diagram only).
(a) L1 = cfw_ai bj ck dl | i = l and j = 2k.
Solution:
a, A
, #
b, B
,
,
c, B
start
,
d, A
,#
,B
(

Practice Problem, Set 1
CS340, Semester I, 2013-14
September 16, 2013
1. Construct a DFA and a RE for the language
L = cfw_w cfw_0, 1 | every 1 in w is immediately preceded and followed by a 0.
Example: The strings 00 and 0010100010 are in L whereas, 0110

Name:
Rollno:
CSE340: Theory of Computation (Mid Semester Exam)
13th September, 2015
Total Number of Pages: 7
Total Points 75
Instructions
Question
Points
1. Read these instructions carefully.
1
10
2. Write you name and roll number on all the
pages of the

CS 340
Mid Semester Exam Solution
Semester I, 2013-14
1. Short answer type question. Please give appropriate reason wherever necessary.
(a) (1 mark) What is language recognised by the regular expression ?
(b) (2 marks) Every language recognised by a regul

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 20: Space Complexity
Raghunath Tewari
IIT Kanpur
Recall the following denitions.
SPACE(f (n) = cfw_L | L = L(M ) for some det. TM M that uses O(f (n) amount of space
NSPACE(f (n) = cfw_L | L = L(N )

CS 340
Homework 1
Semester I, 2015-16
Due Date: Monday, 17th August
Submit the assignment before beginning of class on or before the due date.
Yours answers should be precise and clearly legible. Illegible answers will get no credit even if they are
com

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 2: Deterministic Finite Automata
Raghunath Tewari
1
IIT Kanpur
Deterministic Finite Automaton
Consider the following language,
L = cfw_x cfw_0, 1 |x has an even no. of 1s
0
1
start
q0
0
q1
1
State d

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 4: Regular Expressions
Raghunath Tewari
1
IIT Kanpur
Regular Expression
- An algebraic way to represent regular languages.
- Some practical applications: pattern matching in text editors, used in co

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 5: Properties of regular languages
Raghunath Tewari
1
IIT Kanpur
Closure Properties
We have already seen that regular languages are closed under union, concatenation and star
operations. We will dis

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 3: Nondeterministic Finite Automaton
Raghunath Tewari
1
IIT Kanpur
Nondeterminism
- From a state q on an input symbol a there can be 0 or more transitions to other states
(outgoing edges).
- The aut

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 7: DFA Minimization
Raghunath Tewari
IIT Kanpur
Given a DFA D = (Q, , , q0 , F ) we dene a equivalence relation on the states of the DFA. For
any two states p, q Q, we say that p p if for all string

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 9: Chomsky Normal Form
Raghunath Tewari
IIT Kanpur
Normal forms are CFGs whose substitution rules have a special form. Usually normal forms are
general enough in the sense that any CFL will have a C

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 12: Properties of Context-free Languages
Raghunath Tewari
1
IIT Kanpur
Closure Properties
Let us study the various closure properties of CFLs.
1. Union
Let L1 and L2 be two CFLs accepted by the CFGs

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 13: Deterministic Pushdown Automata
Raghunath Tewari
1
IIT Kanpur
Deterministic Pushdown Automata
Denition 1.1. A deterministic pushdown automaton (in short DPDA), M = (Q, , , , q0 , F ) is
a PDA su

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 10: Non Context-Free Languages
Raghunath Tewari
1
IIT Kanpur
Pumping Lemma for Context-free Languages
We will prove a pumping lemma for context-free languages. Let L be a CFL and G = (V, , P, S)
be

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 11: Pushdown Automata
Raghunath Tewari
1
IIT Kanpur
Pushdown Automata
It is an -NFA appended with a stack.
1.1
Reviewing a Stack
A stack is a data structure that allows addition/deletion/access of a

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 16: Decidable Properties of Regular and CFLs
Raghunath Tewari
1
IIT Kanpur
Decidability Properties of Regular Languages
We will look at some properties of regular languages that are decidable, such

CS340: Theory of Computation
Sem I 2015-16
Lecture Notes 14: Turing Machines
Raghunath Tewari
IIT Kanpur
So far we have seen the following:
Finite Automaton: Finite control (set of states). Input is read in one direction. No memory.
Pushdown Automaton: Fi