mod1-2
mod1-2
NIL
Course objectives
2
Course Outcomes
4
Syllabus
5
Text Books & References
6
Text Books & References
Text Book
Reference Books
Peter Linz, Introduction to Formal Languages and Sixth Edition, Jones &
Bartlett, 2016. ISBN: 978-9384323219
7
Tentative Assessments
CAT 1
CAT 2
Digital Assignment
8
Introduction to Theory of Computation
Most fundamental course of Computer Science.
It is branch How efficiently the problems can be solved on a model of
computation using algorithm.
Computation Transform set inputs into output(s) - finite, effective step by step
processes/procedures (algorithms).
Execution of algorithms.
Computation is simply a sequence of steps that can be performed by computer.
Programs to solve some problems. Program express algorithms.
Capabilities and limitations of computer algorithms/computation.
Theory based on the specification of actual hardware would not be useful because
of the technology proliferation.
TOC learn abstract machine or model of computation Defined mathematically.
9
Introduction to Theory of Computation
f: D R (Domain of all inputs and range of all outputs)
10
Introduction to Theory of Computation
Branches
Automata Theory Finite Automata, Pushdown Automata, Linear Bounded and
Turing Machine
Formal Languages
Computability Theory Decidable, Undecidable
Computational Complexity Theory Accept Halt, Accept Not Halt (Time and
Space)
Applications
Traffic Lights
Lifts and elevators
Vending machines
Video Games
Cryptography
Speech Recognition.
11
Natural Language Processing.
Introduction to Theory of Computation
Motivation
TOC suggests various abstract models of computation, which are represented
mathematically.
What is computable and what is not?
How to analyze an algorithm?
Whether a program/code is executable or not?
Whether a program/code is erroneous or not?
Is it possible to make a program more efficient?
What is easy, and what is difficult, to compute?
What is easy, and what is hard for computers to do?
12
Module 1
13
Overview of Computational Models
Computation Models describes how an output of a mathematical function is
computed given an input.
15
Introduction to Languages and Grammars
Strings
A string (or word) is a finite sequence of symbols chosen from
some alphabet
Example
the empty language (not the empty string is a language over any alphabet
{ }
={}
Introduction to Languages and Grammars
Different Notations of a Language
Method 1 Simple statement definition
The language accept set of all strings of n n n 0
Method 2 Set former notation
{0n1n| n 0}
Method 3
L={ * | w has n n }.
Above all definitions represent the L={ ,01,0011,000111,...}
DIY : {0i1j| 0 i j} What are the strings included in the language ???
Introduction to Languages and Grammars
Operations on Languages
Union
Intersection
Concatenation
Complementation
Reversal
Closure
Introduction to Languages and Grammars
Operations on Languages - Union
Definition
Let L1 and L2 be two languages over an alphabet . The union of L1 and L2,
(L1 L2) is denoted as follows
L1 L2 = {x | x is in L1 or L2}.
Example
L1= { x {0,1}* | x with length 2} Then L1={00,01,10,11}
L2= { x {0,1}* | x begins with 0 and its length should be 3} Then
L2={000,001,010,011}
L1 L2 = {00,01,10,11,000,001,010,011}
Introduction to Languages and Grammars
Operations on Languages Intersection
Definition
Let L1 and L2 be languages over an alphabet . The intersection of L1 and L2,
denoted by L1 L2, is { x | x is in L1 and L2}.
Example
L1 = { x {0,1}* | x begins with 0 and its length should be 3}
Then L1={000,001,010,011}
L2 = { x {0,1}* | x ends with 0 and its length should be 3}
Then L2={000,010,100,110}
L1 L2 = {000,010} means L1 L2 = { x {0,1}*| x begins and ends with
0 and its length should be 3}
Introduction to Languages and Grammars
Operations on Languages Concatenation
Definition
Let L1 and L2 be languages over an alphabet . The concatenation of L1 and L2,
denoted by L1.L2, is {w1 w2| w1 is in L1 and w2 is in L2}.
Example
L1 = { x {0,1}* | x begins with 0 and its length should be 3}
Then L1={000,001,010,011}
L2 = { x {0,1}* | x ends with 0 and its length should be 3}
Then L2={000,010,100,110}
L1.L2={000000,000010, 000100, 000110,...}
L1.L2={ x {0,1}*| x begins and ends with 0 and length(x) is equal to 6}
Introduction to Languages and Grammars
Operations on Languages Complementation
Definition
Let L be a language over an alphabet . The complementation of L, denoted by
L , is * L.
Example
Let = {0, 1} be the alphabet.
L= { * | the number of 1 s in is even}.
Note: Here we considered zero occurrence of even ones as even.
L= { 0, 00, 11, 000, 110, 101, 011, 0000, 1100, 1010, 1001, 0110, 0101, 0011, }
L = * L = {1,01,10,001,010,....
Introduction to Languages and Grammars
Operations on Languages Reversal
Definition
Let L be a language over an alphabet . The reversal of L, denoted by LR, is
{wR|w is in L}.
Example
L = {x {0,1}*| x begins with 0}
L = {0,00,01,000,001,010,011,...}
LR = {0,00,10,000,100,010,110,...} = {x {0,1}*| x ends with 0}
Introduction to Languages and Grammars
Operations on Languages Closure
Kleene closure of L - L* - zero or more concatenations of L
L* = L0 L1 L2 ...
L0 = { }, L1 = L, L2 = LL
Ln = L concatenated with itself n times.
Positive closure of L L+ - one or more concatenations of L
Example
L={ x {0,1}* | x with length 2} Then L={00,01,10,11}
L* = { {00,01,10,11} {0000,0001,0010,0011,0100,0101,0110,0111,...}
L+ = {00,01,10,11} {0000,0001,0010,0011,0100,0101,0110,0111,...}
Introduction to Languages and Grammars
Some More Examples Language and String
Eg1.: The language L consists of strings over {a,b} in which each string begins
with an a should have an even length.
Eg2.: The language L consists of strings over {a,b} in which each occurring of b is
immediately preceded by an a.
Introduction to Languages and Grammars
Some More Examples Language and String
Eg3.:
Eg4.:
Introduction to Languages and Grammars
Some More Examples Language and String
Eg5.:
Eg6.:
Introduction to Languages and Grammars
Some More Examples Language and String
Eg7.:
Eg8.:
Introduction to Languages and Grammars
Grammar
A grammar of a language, G is defined as G = (V, T, S, P)
Where,
V or N Finite set of objects called variables/ Non-terminals
T Finite set of objects called terminals
S V Start Symbol
P Finite set of productions
Note: N T
Introduction to Languages and Grammars
Types of Grammar - Chomsky Hierarchy
Homework
{0i1j| 0 i j} Write some strings that satisfies the given language.