1 csci-2400 models of computation. 2 computation cpu memory

36
1 CSCI-2400 Models of Computation

Post on 19-Dec-2015

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

1

CSCI-2400

Models of Computation

Page 2: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

2

Computation

CPU memory

Page 3: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

3

CPU

input memory

output memory

Program memory

temporary memory

Page 4: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

4

CPU

input memory

output memoryProgram memory

temporary memory

3)( xxf

compute xx

compute xx 2

Example:

Page 5: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

5

CPU

input memory

output memoryProgram memory

temporary memory

3)( xxf

compute xx

compute xx 2

2x

Page 6: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

6

CPU

input memory

output memoryProgram memory

temporary memory3)( xxf

compute xx

compute xx 2

2x

42*2 z82*)( zxf

Page 7: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

7

CPU

input memory

output memoryProgram memory

temporary memory3)( xxf

compute xx

compute xx 2

2x

42*2 z82*)( zxf

8)( xf

Page 8: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

8

Automaton

CPU

input memory

output memory

Program memory

temporary memory

Automaton

Page 9: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

9

Different Kinds of Automata

Automata are distinguished by the temporary memory

• Finite Automata: no temporary memory

• Pushdown Automata: stack

• Turing Machines: random access memory

Page 10: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

10

input memory

output memory

temporary memory

Finite

Automaton

Finite Automaton

Example: Vending Machines

(small computing power)

Page 11: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

11

input memory

output memory

Stack

Pushdown

Automaton

Pushdown Automaton

Example: Compilers for Programming Languages

(medium computing power)

Push, Pop

Page 12: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

12

input memory

output memory

Random Access Memory

Turing

Machine

Turing Machine

Examples: Any Algorithm

(highest computing power)

Page 13: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

13

Finite

Automata

Pushdown

Automata

Turing

Machine

Power of Automata

Less power More power

Solve more

computational problems

Page 14: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

14

Languages

Page 15: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

15

A language is a set of strings

String: A sequence of letters

Examples: “cat”, “dog”, “house”, …

Defined over an alphabet: zcba ,,,,

Page 16: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

16

Alphabets and StringsWe will use small alphabets:

Strings

abbaw

bbbaaav

abu

ba,

baaabbbaaba

baba

abba

ab

a

Page 17: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

17

String Operations

m

n

bbbv

aaaw

21

21

bbbaaa

abba

mn bbbaaawv 2121

Concatenation

abbabbbaaa

Page 18: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

18

12aaaw nR

naaaw 21 ababaaabbb

Reverse

bbbaaababa

Page 19: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

19

String Length

Length:

Examples:

naaaw 21

nw

1

2

4

a

aa

abba

Page 20: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

20

Length of Concatenation

Example:

vuuv

853

8

5,

3,

vuuv

aababaabuv

vabaabv

uaabu

Page 21: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

21

Empty StringA string with no letters:

Observations:

abbaabbaabba

www

0

Page 22: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

22

SubstringSubstring of string:

a subsequence of consecutive characters

String Substring

bbab

b

abba

ab

abbab

abbab

abbab

abbab

Page 23: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

23

Prefix and Suffix

Prefixes Suffixesabbab

abbab

abba

abb

ab

a

b

ab

bab

bbab

abbab uvw

prefix

suffix

Page 24: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

24

Another Operation

Example:

Definition:

n

n wwww

abbaabbaabba 2

0w

0abba

Page 25: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

25

The * Operation : the set of all possible strings from alphabet

*

,,,,,,,,,*

,

aabaaabbbaabaaba

ba

Page 26: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

26

The + Operation : the set of all possible strings from alphabet except

,,,,,,,,,*

,

aabaaabbbaabaaba

ba

*

,,,,,,,, aabaaabbbaabaaba

Page 27: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

27

LanguagesA language is any subset of

Example:

Languages:

*

,,,,,,,,*

,

aaabbbaabaaba

ba

},,,,,{

,,

aaaaaaabaababaabba

aabaaa

Page 28: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

28

Note that:

}{}{

0}{

1}{

0

Sets

Set size

Set size

String length

Page 29: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

29

Another Example

An infinite language }0:{ nbaL nn

aaaaabbbbb

aabb

ab

L Labb

Page 30: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

30

Operations on LanguagesThe usual set operations

Complement:

aaaaaabbbaaaaaba

ababbbaaaaaba

aaaabbabaabbbaaaaaba

,,,,

}{,,,

},,,{,,,

LL *

,,,,,,, aaabbabaabbaa

Page 31: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

31

Reverse

Definition:

Examples:

}:{ LwwL RR

ababbaabababaaabab R ,,,,

}0:{

}0:{

nabL

nbaL

nnR

nn

Page 32: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

32

Concatenation

Definition:

Example:

2121 ,: LyLxxyLL

baaabababaaabbaaaab

aabbaaba

,,,,,

,,,

Page 33: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

33

Another OperationDefinition:

Special case:

n

n LLLL

bbbbbababbaaabbabaaabaaa

babababa

,,,,,,,

,,,, 3

0

0

,, aaabbaa

L

Page 34: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

34

More Examples

}0:{ nbaL nn

}0,:{2 mnbabaL mmnn

2Laabbaaabbb

Page 35: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

35

Star-Closure (Kleene *)

Definition:

Example:

210* LLLL

,,,,

,,,,

,,

,

*,

abbbbabbaaabbaaa

bbbbbbaabbaa

bbabba

Page 36: 1 CSCI-2400 Models of Computation. 2 Computation CPU memory

36

Positive Closure

Definition:

*

21

L

LLL

,,,,

,,,,

,,

,

abbbbabbaaabbaaa

bbbbbbaabbaa

bba

bba