Theory of Computation - Lec1

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 72

Theory of Computation

Lec-1 - Alphabet, String, Language


What is Theory Of Computation?
Alan Turing
Source: wikipedia

Alan Mathison Turing OBE FRS (/ˈtjʊərɪŋ/; 23 June 1912 – 7 June 1954)
was an English mathematician, computer scientist, logician,
cryptanalyst, philosopher and theoretical biologist.[5] Turing was highly
influential in the development of theoretical computer science,
providing a formalisation of the concepts of algorithm and computation
with the Turing machine, which can be considered a model of a
general-purpose computer.[6][7][8] He is widely considered to be the
father of theoretical computer science and artificial intelligence.[9]
What is Theory Of Computation?
• Study of mathematical machines called AUTOMATA and the
computational problems that can and can not be solved using these
automata.

• Data are encoded in the computers’ memory as strings of bits or


other symbols appropriate for manipulation
• The mathematical study of the Theory of Computation begins with
understanding of mathematics of manipulation of strings of symbols
Objective of TOC
The primary objectives of the theory of computation are:

1. To Classify Problems

2. To Understand Limits of Computation

3. To Develop Efficient Algorithms

4. To Provide a Foundation for Other Disciplines


Objective of TOC
1. To Classify Problems

PROBLEM

Solvable Unsolvable

Algorithm exist Algorithm doesn’t exist


Objective of TOC
2. To Understand Limits of Computation

Can Computer solve all Problems?


Limitation of Computations
Problem 1- “ Is a given program valid?”

Problem 2- “ Will a program Halt?”

Problem 3- “Finding maximum in list of n numbers”


Aim of TOC

• What can and can not be done by digital computers


What we will Study in TOC?
• Automata
• Formal Languages
• Regular Expressions
• Grammar
Chomsky hierarchy
Formal Languages
Basic Concepts
• Alphabet
• Operations on Alphabet
• String
• Operations on Strings
• Language
• Operations on Language
Alphabet
• Def: a finite, nonempty set of symbols, called the Alphabet( Σ ).

• Elements of the alphabet are called symbols of the alphabet

• We typically denote elements of Σ by using the lowercase letters a,b,c,d.

• An alphabet is called unary if it consists of a single symbol.


eg. Σ = { a }
• An alphabet is called Binary if it consists of two symbols.
eg. Σ = { a,b }
• An alphabet is called Ternary if it consists of three symbols.
eg. Σ = { a,b,c }
Can Alphabet contains any Symbol?

• Σ = {‡, §, ∂, 0,a, Ψ, ∇}
Power of an Alphabet
Kleen Star, kleen Plus
String
• Def: finite sequences of symbols from the alphabet is called STRING.

• Empty String ( ϵ ): string with zero occurrences of symbols.


Length of a String:
• The number of symbols it contains
• denoted by |w|
Let Σ = {a, b}
How many are there all possible words of length 5 over Σ ?
Total no of string of length n: 2n ?
Operations on String
• Concatenation of two strings:
• The concatenation of two strings s and t is the string formed by
appending t to s.
• (not commutative)
• associative property holds, x(yz) = (xy)z
• |xy| = |x|+|y|
Operations on String
• Reverse of Strings :
• w = a1a2...an , wR = anan-1...a2a1
Relations on Strings: Prefix, Sufix, Substring

• Prefix: x is a prefix of w if there exists y such that w = xy.

• Sufix: x is a sufix of w if there exists y such that w = yx.

• Substring: a string y is a substring of a string w if there exist strings x,z


such that w = xyz
Q. The set of all proper substring of the string 1001?
No of substrings that can be formed from a string of length n:
Q. How many substrings aab are in wwRw, where w = aabbab?
Q. Use induction on n to show that |u n| = n |u| for all strings u and all n.
Q. The reverse of a string, introduced informally above, can be defined more precisely by the
recursive rules aR = a, (wa)R = awR,for all a ∈ Σ, w ∈ Σ*.
Use this to prove that (uv)R = vRuR, for all u, v ∈ Σ+.
Language
Examples of Languages:
L ⊆ Σ∗
How Many Languages Are There?
Let ∑ be an alphabet. How many different languages are there that are
defined on L?

Theorem: If ∑ ∅, then the set of languages over ∑ is uncountably infinte.


Operations on Language:
• Concatenation of Languages:
Note:
L∅ = ∅L = . Why?

from the de finition of the concatenation of two languages

as the set consisting of all strings that can be formed by selecting some
string s from the first language and some string ( from the second
language and then concatenating them together. There are no ways to
select a string from the empty set.
Operations on Language:
• Power of a Language:
Q. Let L = {ab, aa, baa}. Which of the following strings are in L*:
abaabaaabaa, aaaabaaaa, baaaaabaaaab, baaaaabaa? Which strings are
in L4?
Operations on Language:
• Reverse of a Language:
LR = {w ∑* : w = xR for some x L}.

• Theorem: lf L1 and L2 are languages, then (L1L2)R = L2RL1R.


Problems:
1. Consider the language L = {1n 2n : n > 0}. Is the string 122 in L?
2. Let L1 = {anbn: n > 0}. Let L2 = {cn : n > 0}. For each of the following strings, state
whether or not it is an element of L1 L2:
a. ϵ.
b. aabbcc.
c. abbcc.
d. aabbcccc.
3. Let L1 = {peach, apple, cherry} and L2 = {pie, cobbler, ϵ}. List the elements of L 1 L 2
in lexicographic order.
4. Let L = {W {a, b} * : Iw| mod 3 = 0}. List the first six elements in a lexicographic
enumeration of L.
5. Consider the language L of all strings drawn from the alphabet {a, b} with at
least two different substrings of length 2.

You might also like