Sunteți pe pagina 1din 45

Theory of Computation Subject code: 160704

Text and Reference book


Text Book
Introduction To Languages And Theory Of Computation By John C !artin" Third #dition" T!$ Reference Books % Automata Theory" Languages and Computation" $opcroft" !ot&ani" '((man" )earson #ducation * Theory of automata" Langusges and computation" +umar" !c,ra$i(( - The Theory of Computation" !oret" )earson #ducation . Introduction to Computer Theory" Cohen" /i(ey0India
2

Computation

C)'

memory

temporary memory input memory C)' output memory )rogram memory


4

#xamp(e1
temporary memory

f ( x) = x

input memory C)' )rogram memory compute compute output memory

xx x x
2
5

f ( x) = x
temporary memory

input memory

x=2
C)' )rogram memory compute compute output memory

xx x x
2
6

temporary memory

z = 2*2 = 4 f ( x) = z * 2 = 8

f ( x) = x

input memory

x=2
C)' )rogram memory compute compute output memory

xx x x
2
7

temporary memory

z = 2*2 = 4 f ( x) = z * 2 = 8

f ( x) = x

input memory

x=2
C)' )rogram memory compute compute

f ( x) = 8
output memory

xx x x
2

Automaton
temporary memory Automaton C)' output memory )rogram memory
9

input memory

2ifferent +inds of Automata


Automata are distinguished by the temporary memory Finite Automata1 Pushdown Automata1 Turing Machines1 no temporary memory stack random access memory

10

3inite Automaton
temporary memory

3inite Automaton

input memory output memory

4ending !achines 5sma(( computing po&er6


11

)ushdo&n Automaton
Stack )ush" )op

)ushdo&n Automaton

input memory output memory

)rogramming Languages 5medium computing po&er6


12

Turing !achine
Random Access !emory

Turing !achine

input memory output memory

A(gorithms

5highest computing po&er6


13

)o&er of Automata

3inite Automata

)ushdo&n Automata

Turing !achine

14

/e &i(( sho& (ater in c(ass


$o& to bui(d compi(ers for programming (anguages 7ome computationa( prob(ems cannot be so(8ed 7ome prob(ems are hard to so(8e

15

!athematica( )re(iminaries

16

!athematica( )re(iminaries
7ets 3unctions Re(ations )roof Techni9ues

17

7#T7
A set is a co((ection of e(ements

A = {1, 2, 3} B = {train, bus, bicycle, airplane}


/e &rite

1 A ship B
18

7et Representations
C : ; a" b" c" d" e" f" g" h" i" <" k = C : ; a" b" >" k = 7 : ; *" ." ?" > =

finite set infinite set

7 : ; < 1 < @ A" and < : *k for some k@A = 7 : ; < 1 < is nonnegati8e and e8en =
19

A : ; %" *" -" ." B =

'
? C %A 'ni8ersa( 7et1 % .

A
* B E D

A(( possib(e e(ements ' : ; % " > " %A =


20

7et Operations
A : ; %" *" - = 'nion A ' B : ; %" *" -" ." B = Intersection A 2ifference A0B:;%= B 0 A : ; ." B =
A0B
21

B : ; *" -" ." B=


A B

'

B : ; *" - =

Comp(ement 'ni8ersa( set : ;%" >" C= A : ; %" *" - = . A : ; ." B" ?" C=

A
% B

A
*

A:A
22

; e8en integers = : ; odd integers = Integers %


odd

* -

e8en

? C

23

2e!organFs La&s
' A'B:A ' A B

B:A'B

24

#mpty" Gu(( 7et1


:;= 7' 7 ' :7 : :7 07: : 'ni8ersa( 7et

70

25

7ubset
A : ; %" *" -= A B B : ; %" *" -" ." B =

' '

)roper 7ubset1 A

B B

A
26

2is<oint 7ets
A : ; %" *" - = ' A B: B : ; B" ?=

27

7et Cardina(ity
3or finite sets A : ; *" B" C = HAH : -

28

)o&ersets
A po&erset is a set of sets 7 : ; a" b" c = )o&erset of 7 : the set of a(( the subsets of 7 *7 : ; " ;a=" ;b=" ;c=" ;a" b=" ;a" c=" ;b" c=" ;a" b" c= = 5 D : *- 6
29

Obser8ation1 H *7 H : *H7H

Cartesian )roduct
A : ; *" . = B : ; *" -" B =

A I B : ; 5*" *6" 5*" -6" 5*" B6" 5 ." *6" 5." -6" 5." .6 = HA I BH : HAH HBH ,enera(iJes to more than t&o sets AIBI>IK

30

3'GCTIOG7
domain A % * f 1 A 0@ B f5%6 : a b range B a c

If A : domain

then f is a tota( function other&ise f is a partia( function


31

R#LATIOG7
R : ;5x%" y%6" 5x*" y*6" 5x-" y-6" >= xi R yi e g if R : L@F1 * @ %" - @ *" - @ %

In re(ations xi can be repeated


32

#9ui8a(ence Re(ations
Ref(exi8e1 7ymmetric1 Transiti8e1 #xamp(e1 R : L:L x:x x:y x : y and y : J y:x x:J
33

xRx xRy yRx xRJ x R M and y R J

#9ui8a(ence C(asses
3or e9ui8a(ence re(ation R e9ui8a(ence c(ass of x : ;y 1 x R y= #xamp(e1 R : ; 5%" %6" 5*" *6" 5%" *6" 5*" %6" 5-" -6" 5." .6" 5-" .6" 5." -6 = #9ui8a(ence c(ass of % : ;%" *= #9ui8a(ence c(ass of - : ;-" .=
34

)ROO3 T#C$GIN'#7
)roof by induction )roof by contradiction

35

Induction
/e ha8e statements )%" )*" )-" > If &e kno& for some k that )%" )*" >" )k are true for any n @: k that )%" )*" >" )n imp(y )nO% Then #8ery )i is true
36

)roof by Induction
Inducti8e basis 3ind )%" )*" >" )k &hich are true Inducti8e hypothesis LetFs assume )%" )*" >" )n are true" for any n @: k Inducti8e step 7ho& that )nO% is true
37

#xamp(e
Theorem1 A binary tree of height n has at most *n (ea8es )roof1 (et (5i6 be the number of (ea8es at (e8e( i (5A6 : %

(5-6 : D

38

/e &ant to sho&1 (5i6 P: *i Inducti8e basis (5A6 : % 5the root node6

Inducti8e hypothesis LetFs assume (5i6 P: *i for a(( i : A" %" >" n Induction step &e need to sho& that (5n O %6 P: *nO%
39

Induction 7tep

Le8e( n nO%

hypothesis1 (5n6 P: *n

40

Induction 7tep

Le8e( n nO%

hypothesis1 (5n6 P: *n

(5nO%6 P: * Q (5n6 P: * Q *n : *nO%

41

Remark
Recursion is another thing #xamp(e of recursi8e function1 f5n6 : f5n0%6 O f5n0*6 f5A6 : %" f5%6 : %
42

)roof by Contradiction
/e &ant to pro8e that a statement ) is true &e assume that ) is fa(se then &e arri8e at an incorrect conc(usion therefore" statement ) must be true

43

#xamp(e
Theorem1 )roof1 Assume by contradiction that it is rationa(

is not rationa(

: nRm

n and m ha8e no common factors /e &i(( sho& that this is impossib(e


44

: nRm

* m * : n*

Therefore" n* is e8en

n is e8en n:*k m is e8en m:*p

* m* : .k*

m* : *k*

Thus" m and n ha8e common factor *

ontradiction!

45

S-ar putea să vă placă și