17. Slide 3
Theory of Computation
• What are the capabilities /Problems solved /
Limitations of machine?
• What are the concepts of machine?
Theory
18. Slide 4
Theory of Computation
• Model or devices that perform some computation.
• Any task done by any machine like calculator,
computer, etc.,
Computation
19. Slide 5
Computation
•Computation is a general term for any type of information
processing that can be represented as an algorithm
precisely (mathematically).
Examples:
• Adding two numbers in our brains, on a piece of paper or
using a calculator.
• Converting a decimal number to its binary presentation or
vise versa.
• Finding the greatest common divisors of two numbers.
20. Slide 6
Computation
• These computations are used to represent
various mathematical models.
• Finite automate
• Pushdown automate
• Turning machine
21. Slide 7
1/24/2023 Chapter 1 Introduction
Theory of Computation
•TOC is a subject in which we study mathematical models
(abstract machines) as well as the computational problems
that can be solved by using these models.
•TOC can be considered as the study of all kinds of
computational model in the field of computer science and it
also how efficiently the problem can be solved .
22. Slide 8
Branches of TOC
• Automata Theory
It deals with definitions and properties of various mathematical
models/devices
• Computability Theory
– It deals with what can and cannot be computed by the model
• Complexity Theory
– It deals with computable problem based on the hardness. To calculate the
efficiency.
23. Slide 13
Problem
•Now a days machines (digital, analog,
mechanical) play a very important role in
the development of human, we need
some mechanism (language) to
communicate with the machines.
24. Slide 14
Solution
• We need a language for communication with machines.
• Languages can be two types formal and informal languages.
• We will only study formal languages
• Dictionary defines the term informally as ‘a system suitable for
the expression of certain ideas, facts or concepts including a
set of symbols for their manipulation’.
25. Slide 15
Methods to define language
•In natural language we define the list of words in a
dictionary because they are finite and predefined, but
we cannot list all the sentence which can be formed
using these words as they are infinite.
•So we have a mechanism called grammar/rules using
which we can decide which sentence is valid and
which is invalid.
26. Slide 16
Symbols, Alphabet, strings
• Symbols – An individual part of input symbol or single character is
known as symbol (in engish we call them as letters)
– Example: Digit - 0,1,2,…. 9
Alphabets- a,b,c ….z , A, B, …….,Z
Special symbols !@#$< >….
Symbols are used to build language for machine.
• Alphabet (∑)– It is a finite non empty set of input symbols (every
language has its own alphabet). We use symbol ∑ for depicting
alphabet.
∑ = {0,1,2}
∑ = {0,1} Binary alphabet
∑ = { a,b,c}
27. Slide 17
String
• String - It is a sequence of input symbols from the alphabet(∑)
( in English we called them as words)
∑ = {0,1} w= 01101 ( it is a string from binary )
∑ = {a,b} w= abbab ( it is a string from the alphabet)
28. Slide 18
Length of the string
• Definition − It is defined as number of symbol in the string.
(Denoted by |S|).
• Examples −
• If S = ‘cabcad’, |S|= 6
• If S = ε |S|= 0, it is called an empty string
29. Slide 19
1/24/2023 Chapter 1 Introduction
Empty String
• The string with zero occurrence of symbols.
It is denoted by , | | =0 .
30. Slide 20
1/24/2023 Chapter 1 Introduction
Concatenation of string
• Let x and y be two strings, then
concatenation is defined as the string
formed by making a copy of string x followed
by a copy of string y.
• Example: w= ab x=ba wx= abba
31. Slide 21
1/24/2023 Chapter 1 Introduction
Substring
A string of consecutive symbols in some string ‘w’ can
be collectively said as a substring.
Example. W = abab its substrings can be ab,a, ba…etc.,
– ε is a substring of every string.
Example
– ε, comput and computation are substrings of
computation.
32. Slide 22
1/24/2023 Chapter 1 Introduction
Reversal
If there is a string w then reverse of a string a
denoted by wr is just the same string but
written in reverse order.
W= w1 w2 w3 …wn
Wr = wn , wn-1 , …. ..w3,w2,w1
33. Slide 23
1/24/2023 Chapter 1 Introduction
Example of Reversal
(automata)r
= (utomata)r a
= (tomata)r ua
= (omata)r tua
= (mata)r otua
= (ata)r motua
= (ta)r amotua
= (a)r tamotua
= ()r atamotua
= atamotua
34. Slide 24
Power of Alphabet
• ∑ - Alphabet – set of symbols
• ∑k = set of all strings of length k
• Example ∑ = { 0, 1}
∑0 = {ɛ }
∑1 = {0,1}
∑2 = { 00,01,10,11}
∑3 = ∑2 ∑
= {00,01,10,11} { 0,1}
= { 000,001,010,011,100,101,110,111}
35. Slide 25
Kleene star – (∑* )
• It is a unary operator on a set of symbols or string, ∑ that
gives the infinite set of all possible strings of all possible
lengths over ∑ including ɛ.
∑* = ∑o ꓴ ∑1 ꓴ ∑2 ꓴ ….
Example: ∑ = {a, b}
∑* = { ɛ, a,b,aa,ab,ba,bb … }
36. Slide 26
1/24/2023 Chapter 1 Introduction
Σ*
• The set of strings created from any number (0
or 1 or …) of symbols in an alphabet is
denoted by *.
• That is, * = i=
0 i
– Let = {0, 1}.
– * = {, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, … }.
37. Slide 27
Kleene closure / Plus (∑+ )
• It is the infinite set of all possible strings of all possible length
over ∑ excluding ɛ.
• ∑+ = ∑1 ꓴ ∑2 ꓴ ∑3 ꓴ …
• ∑* = ∑* - { ɛ }
• Example:
• ∑ = {a , b}
• ∑+ = {a,b,aa,ab,ba,bb……}
38. Slide 28
1/24/2023 Chapter 1 Introduction
Σ+
• The set of strings created from at least one symbol
(1 or 2 or …) in an alphabet is denoted by +.
• That is, + = i=
1 i
= i=0.. i
- 0
= i=0.. i
- {}
• Let = {0, 1}. + = {0, 1, 00, 01, 10, 11, 000, 001, 010, 011,
… }.
* and + are infinite sets.
39. Slide 29
Language
• A Language is defined as a set of strings. ( in natural language
set of words(predefined) and grammar) we apply this model
from words to sentence).
• In the next level we consider programs as a string and
programming constructs/ tokens like int, floats as
letters/symbols.
40. Slide 30
Language
• A language is a collection of strings over ∑
• Example ∑ = {a,b}
1. L = set of all string of length 2
L= {aa, ab, ba, bb}
Here, L is a finite set
2. L = set of all string of length 3
L = {aaa,aab, aba, abb, baa,bab,bba,bbb}
Here L is also finite set
3. L = set of all strings where each string start with an ‘a’
L = {a,aa,ab, aab,aba,abb……}
Here L is an infinite set.
So, A Language which can be formed over an alphabet can be finite or infinite set.