# Introduction

Why do we study Theory of Computation ?

Outline
 Importance of Theory of Computation  Languages  Languages and Problems

Jaruloj Chongstitvatana

2301379

Chapter 1 Introduction

2

What is Computation ?
 Sequence of mathematical operations ?
± What are, and are not, mathematical operations?

 Sequence of well-defined operations
± How many operations ?
 The fewer, the better.

± Which operations ?
 The simpler, the better.

Jaruloj Chongstitvatana

2301379

Chapter 1 Introduction

3

What do we study in Theory of Computation ?  What is computable. and what is not ?  What a computer can and cannot do  Are you trying to write a non-existing program?  Basis of ± Algorithm analysis ± Complexity theory ± Can you make your program more efficient? Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 4 .

What do we study in Complexity Theory ?  What is easy. to compute ?  What is easy. and what is difficult. and what is hard for computers to do?  Is your cryptograpic scheme safe? Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 5 .

Applications in Computer Science  Analysis of algorithms  Complexity Theory  Cryptography  Compilers  Circuit design Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 6 .

History of Theory of Computation  1936 Alan Turing invented the Turing machine.  1943 McCulloch and Pitts invented finite automata.  1956 Kleene invented regular expressions and proved the equivalence of regular expression and finite automata.  1940¶s Stored-program computers were built. Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 7 . and proved that there exists an unsolvable problem.

grammars.History of Theory of Computation  1956 Chomsky defined Chomsky hierarchy.  1950¶s-1960¶s More works on languages. and compilers Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 8 . which organized languages recognized by different automata into hierarchical classes.  1959 Rabin and Scott introduced nondeterministic finite automata and proved its equivalence to (deterministic) finite automata.

 1972 Karp Showed many other NP-complete problems. and Lewis. Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 9 . the satisfiability prooblem. Hartmantis and Stearns defined space complexity.  1971 Cook showed the first NP-complete problem.History of Theory of Computation  1965 Hartmantis and Stearns defined time complexity.

History of Theory of Computation  1976 Diffie and Helllman defined Modern Cryptography based on NP-complete problems.  1978 Rivest. Shamir and Adelman proposed a public-key encryption scheme. Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 10 . RSA.

 A string over an alphabet 7 is a sequence of any number of symbols from 7.1 } is a binary alphabet. CAT. Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 11 . «. z } is an English alphabet. ± 0. ± {0. and 01101 are strings over {0. Z. b. «. 1 }. 11. ± { A. 1. ± Cat. and compute are strings over the English alphabet.Alphabet and Strings  An alphabet is a finite. non-empty set of symbols. 00. a. B.

Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 12 . is a string containing no symbol. ± Iis a string over any alphabet.Empty String  An empty string. denoted by I.

for 1e i e length(x). 2301379 Chapter 1 Introduction 13 Jaruloj Chongstitvatana . «. Let = {a. denotes the symbol in the ith position of a string x. denoted by length(x). is the number of positions of symbols in the string. b.Length  The length of a string x. z} length(automata) = 8 length(computation) = 11 length( ) = 0  x(i).

String Operations  Concatenation  Substring  Reversal Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 14 .

is a string z such that: ± z(i) = x(i) for 1 e i e length(x) ± z(i) = y(i) for length(x)<ielength(x)+length(y)  Example ± automatacomputation = automatacomputation Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 15 . denoted by xy or x y.Concatenation  The concatenation of strings x and y.

where nu0.Concatenation The concatenation of string x for n times. is denoted by xn ± x0 = I ± x1 = x ± x2 = x x ± x3 = x x x ± « Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 16 .

Example ± . x is a substring of x itself. Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 17 .Substring Let x and y be strings over an alphabet The string x is a substring of y if there exist strings w and z over such that y = w x z. comput and computation are substrings of computation. ± is a substring of every string. ± For every string x.

is a string such that ± if x is . Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 18 . then xr = yr a. then xr is . denoted by x r. y is in * and x = a y. ± If a is in .Reversal Let x be a string over an alphabet The reversal of the string x.

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 = (I)r atamotua = atamotua Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 19 .

010. « }. 000. 00.*  The set of strings created from any number (0 or 1 or «) of symbols in an alphabet 7 is denoted by 7*.  Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 20 . 1}. 01. 10. 7* = i=g0 7i ± Let 7= {0. ± 7* = {I. 011. 11. That is. 1. 0. 001.

01.. « }. Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 21 . 7+ = i=g1 7i = i=0.70 =  i=0.  7* and 7+ are infinite sets.g 7i .. 000. 11. 1}. 010. 001. 10.+  The set of strings created from at least one symbol (1 or 2 or «) in an alphabet 7 is denoted by 7+. 7+ = {0.{I}  Let 7= {0. 1. 00.g 7i . 011. That is.

0101. is a set of ± Le = {[ * | the number of 1¶s in [ is even}. 011. 101. 00. I. 0. 1010. 1001. 000. 0110.Languages  A language over an alphabet strings over . 1100. ± Let = {0. 0011. 11. 110. 0000. 1} be the alphabet. « are in Le Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 22 .

Operations on Languages       Complementation Union Intersection Concatenation Reversal Closure Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 23 .

DLe= {[ * | the number of 1¶s in [ is not even}. 1} be the alphabet. denoted byDL. Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 24 . DLe= {[ * | the number of 1¶s in [ is odd}. The complementation of L. Example: Let = {0. is *± L. Le = {[ * | the number of 1¶s in [ is even}.Complementation Let L be a language over an alphabet .

Example: {x{0.1}*|x ends with 0} = {x  {0.1}*| x begins or ends with 0} Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 25 . denoted by L1L2.Union Let L1 and L2 be languages over an alphabet . The union of L1 and L2. is {x | x is in L1 or L2}.1}*|x begins with 0}  {x{0.

is { x | x is in L1 and L2}.Intersection Let L1 and L2 be languages over an alphabet .1}*| x begins and ends with 0} Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 26 .1}*| x begins with 0}  { x{0. denoted by L1L2. Example: { x{0.1}*| x ends with 0} = { x{0. The intersection of L1 and L2.

denoted by L1L2.1}*| x ends with 0} = { x  {0.1}*| x begins and ends with 0 and length(x) u 2} { x  {0. is {w1w2| w1 is in L1 and w2 is in L2}.1}*| x has 00 as a substring} Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 27 .1}*| x begins with 0}{x  {0.Concatenation Let L1 and L2 be languages over an alphabet . Example { x  {0. The concatenation of L1 and L2.1}*| x begins with 0} = { x  {0.1}*| x ends with 0}{x  {0.

denoted by Lr. The reversal of L.1}*| x has 00 as a substring} r = {x  {0. is {wr| w is in L}. Example {x  {0.1}*| x begins with 0} r = {x  {0.1}*| x has 00 as a substring} Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 28 .1}*| x ends with 0} {x  {0.Reversal Let L be a language over an alphabet .

L* = ig= 0 Li Example: Let = {0. That is. is {x | for an integer n u 0 x = x1 x2 « xn and x1.Kleene¶s closure Let L be a language over an alphabet .1} and Le = {[ * | the number of 1¶s in [ is even} Le* = {[ * | the number of 1¶s in [ is even} (DLe)* = {[ *| the number of 1¶s in [ is odd}* = {[ *| the number of 1¶s in [ > 0} Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 29 . xn are in L}. The Kleene¶s closure of L. x2 . denoted by L*. «.

The closure of L. Le = {[ * | the number of 1¶s in [ is even} + = {[ LChongstitvatana *2301379 number of 1¶s1in [ is even} = Le* | the Jaruloj e Chapter Introduction 30 . xn are in L} That is. «. L+ = ig= 1 Li Example: Let = {0.Closure Let L be a language over an alphabet . x2 . denoted by L+. 1} be the alphabet. is { x |for an integer n u 1. x = x1x2«xn and x1.

Observation about Closure L+ = L*  { } ? Example: L = {[ * | the number of 1¶s in [ is even} L+ = {[ * | the number of 1¶s in [ is even} = Le* Why? L* = L+  { } ? Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 31 .

«} Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 32 . 31. 29.Languages and Problems  Problem ± Example: What are prime numbers > 20?  Decision problem ± Problem with a YES/NO answer ± Example: Given a positive integer n. is n a prime number > 20?  Language ± Example: {n | n is a prime number > 20} = {23. 37.

± If a string represents an integer i in {m | m is a prime number > 20} . is n a prime number > 20?´ be the problem P.  a string is in a language = the answer of the corresponding problem for the string is ³YES´ ± Let ³Given a positive integer n. then the answer for the problem P for n = i is true.Language Recognition and Problem  A problem is represented by a set of strings of the input whose answer for the corresponding problem is ³YES´. Jaruloj Chongstitvatana 2301379 Chapter 1 Introduction 33 .

Common misconception Beware .

A language is a set. 1 01 001 0001 00001 L1 Jaruloj Chongstitvatana 2301379 1 10 100 1000 10000 L2 Chapter 1 Introduction 35 .

And. A class of language 1 01 L1 001 0001 00001 L1 Jaruloj Chongstitvatana 2301379 1 10 L2 100 1000 10000 L2 Chapter 1 Introduction 36 . there is also a set of languages.