71
1 Other Models of Computation

1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

  • View
    215

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

1

Other Models of Computation

Page 2: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

2

Models of computation:

•Turing Machines•Recursive Functions•Post Systems•Rewriting Systems

Page 3: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

3

Church’s Thesis:

All models of computation are equivalent

Turing’s Thesis: A computation is mechanical if and only if it can be performed by a Turing Machine

Page 4: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

4

Church’s and Turing’s Thesis are similar:

Church-Turing Thesis

Page 5: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

5

Recursive Functions

An example function:

1)( 2 nnfDomain Range

3 1010)3( f

Page 6: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

6

We need a way to define functions

We need a set of basic functions

Page 7: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

7

Zero function: 0)( xz

Successor function: 1)( xxs

Projection functions: 1211 ),( xxxp

2212 ),( xxxp

Basic Primitive Recursive Functions

Page 8: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

8

Building complicated functions:

Composition: )),(),,((),( 21 yxgyxghyxf

Primitive Recursion:

)),(),,(()1,( 2 yxfyxghyxf

)()0,( 1 xgxf

Page 9: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

9

Any function built fromthe basic primitive recursive functionsis called:

Primitive Recursive Function

Page 10: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

10

A Primitive Recursive Function: ),( yxadd

xxadd )0,( (projection)

)),(()1,( yxaddsyxadd

(successor function)

Page 11: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

11

5

)4(

))3((

)))0,3(((

))1,3(()2,3(

s

ss

addss

addsadd

Page 12: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

12

),( yxmult

0)0,( xmult

)),(,()1,( yxmultxaddyxmult

Another Primitive Recursive Function:

Page 13: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

13

Theorem: The set of primitive recursive functions is countable

Proof: Each primitive recursive function can be encoded as a string

Enumerate all strings in proper order

Check if a string is a function

Page 14: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

14

Theorem there is a function that is not primitive recursive

Proof:

Enumerate the primitive recursive functions

,,, 321 fff

Page 15: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

15

Define function

1)()( ifig i

g differs from every if

g is not primitive recursive

Page 16: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

16

A specific function that is notPrimitive Recursive:

Ackermann’s function:

)),(,1()1,(

)1,1()0,(

1),0(

yxAxAyxA

xAxA

yyA

Grows very fast, faster than any primitive recursive function

Page 17: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

17

Recursive Functions

0),(such that smallest )),(( yxgyyxgy

Accerman’s function is a

Recursive Function

Page 18: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

18

Primitive recursive functions

Recursive Functions

Page 19: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

19

Post Systems

• Have Axioms

• Have Productions

Very similar with unrestricted grammars

Page 20: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

20

Example: Unary Addition

Axiom: 1111

Productions:

11

11

321321

321321

VVVVVV

VVVVVV

Page 21: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

21

111111111111111111

11 321321 VVVVVV

11 321321 VVVVVV

A production:

Page 22: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

22

Post systems are good for proving mathematical statements from a set of Axioms

Page 23: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

23

Theorem: A language is recursively enumerable if and only if a Post system generates it

Page 24: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

24

Rewriting Systems

•Matrix Grammars

•Markov Algorithms

•Lindenmayer-Systems

They convert one string to another

Very similar to unrestricted grammars

Page 25: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

25

Matrix Grammars

Example:

213

22112

211

,:

,:

:

SSP

cbSSaSSP

SSSP

A set of productions is applied simultaneously

Derivation:

aabbccccbbSaaScbSaSSSS 212121

Page 26: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

26

213

22112

211

,:

,:

:

SSP

cbSSaSSP

SSSP

}0:{ ncbaL nnn

Theorem: A language is recursively enumerable if and only if a Matrix grammar generates it

Page 27: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

27

Markov Algorithms

Grammars that produce

Example:

.

S

SaSb

Sab

Derivation:

SaSbaaSbbaaabbb

Page 28: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

28

.

S

SaSb

Sab

}0:{ nbaL nn

Page 29: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

29

In general: }:{*

wwL

Theorem:

A language is recursively enumerable if and only if a Markov algorithm generates it

Page 30: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

30

Lindenmayer-Systems

They are parallel rewriting systems

Example: aaa

aaaaaaaaaaaaaaa Derivation:

}0:{ 2 naLn

Page 31: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

31

Lindenmayer-Systems are not generalAs recursively enumerable languages

Extended Lindenmayer-Systems: uyax ),,(

Theorem: A language is recursively enumerable if and only if an Extended Lindenmayer-System generates it

Page 32: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

32

Computational Complexity

Page 33: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

33

•Time Complexity:

•Space Complexity:

The number of steps during a computation

Space used during a computation

Page 34: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

34

Time Complexity

•We use a multitape Turing machine

•We count the number of steps until a string is accepted

•We use the O(k) notation

Page 35: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

35

Example: }0:{ nbaL nn

Algorithm to accept a string :w

•Use a two-tape Turing machine

•Copy the on the second tape

•Compare the and

a

a b

Page 36: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

36

|)(| wO•Copy the on the second tape

•Compare the and

a

a b

Time needed:

|)(| wO

Total time: |)(| wO

}0:{ nbaL nn

Page 37: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

37

For string of length

time needed for acceptance:

}0:{ nbaL nn

n

)(nO

Page 38: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

38

Language class: )(nDTIME

A Deterministic Turing Machine accepts each string of length in time

)(nDTIME

1L2L 3L

)(nOn

Page 39: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

39

)(nDTIME

}0:{ nba nn

}{ww

Page 40: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

40

In a similar way we define the class

))(( nTDTIME

)(nTFor any time function:

Examples: ),...(),( 32 nDTIMEnDTIME

Page 41: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

41

Example: The membership problem for context free languages

}grammar by generated is :{ GwwL

)( 3nDTIMEL (CYK - algorithm)

Polynomial time

Page 42: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

42

Theorem:

)( knDTIME

)( 1knDTIME

)()( 1 kk nDTIMEnDTIME

Page 43: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

43

Polynomial time algorithms:

)( knDTIME

Tractable algorithms

For small we can compute theresult fast

k

Page 44: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

44

)( knDTIMEP for all k

The class P

•All tractable problems

•Polynomial time

Page 45: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

45

P

CYK-algorithm}{ nnba

}{ww

Page 46: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

46

Exponential time algorithms:

)2( nDTIME

Intractable algorithms

Some problem instancesmay take centuries to solve

Page 47: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

47

Example: the Traveling Salesperson Problem

problem} TSP in the pathsshortest {L

)2()!( nDTIMEnDTIMEL

Exponential time

Intractable problem

Page 48: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

48

Example: The satisfiability Problem

Boolean expressions inConjunctive Normal Form:

ktttt 321

pi xxxxt 321

Variables

Question: is expression satisfiable?

Page 49: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

49

)()( 3121 xxxx

Satisfiable: 1,1,0 321 xxx

1)()( 3121 xxxx

Example

Page 50: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

50

2121 )( xxxx

Not satisfiable

Example

Page 51: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

51

e}satisfiabl is expression :{ wwL

)2( nDTIMELFor variables: n

Algorithm: search exhaustively all the possible binary values of the variables

exponential

Page 52: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

52

Non-Determinism

Language class: )(nNTIME

A Non-Deterministic Turing Machine accepts each string of length in time

)(nNTIME

1L2L 3L

)(nOn

Page 53: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

53

Example: }{wwL

Non-Deterministic Algorithmto accept a string :ww

•Use a two-tape Turing machine

•Guess the middle of the string and copy on the second tape

•Compare the two tapes

w

Page 54: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

54

|)(| wO

Time needed:

|)(| wO

Total time: |)(| wO

}{wwL

•Use a two-tape Turing machine

•Guess the middle of the string and copy on the second tape

•Compare the two tapes

w

Page 55: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

55

)(nNTIME

}{wwL

Page 56: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

56

In a similar way we define the class

))(( nTNTIME

)(nTFor any time function:

Examples: ),...(),( 32 nNTIMEnNTIME

Page 57: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

57

Non-Deterministic Polynomial time algorithms:

)( knNTIMEL

Page 58: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

58

)( knNTIMEP for all k

The class NP

Non-Deterministic Polynomial time

Page 59: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

59

Example: The satisfiability problem

Non-Deterministic algorithm:

•Guess an assignment of the variables

e}satisfiabl is expression :{ wwL

• Check if this is a satisfying assignment

Page 60: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

60

Time for variables: n

)(nO

e}satisfiabl is expression :{ wwL

Total time:

•Guess an assignment of the variables

• Check if this is a satisfying assignment )(nO

)(nO

Page 61: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

61

e}satisfiabl is expression :{ wwL

NPL

The satisfiability problem is an -ProblemNP

Page 62: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

62

Observation:

NPP

DeterministicPolynomial

Non-DeterministicPolynomial

Page 63: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

63

Open Problem: ?NPP

WE DO NOT KNOW THE ANSWER

Page 64: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

64

Example: Does the Satisfiability problem have a polynomial time deterministic algorithm?

Open Problem: ?NPP

WE DO NOT KNOW THE ANSWER

Page 65: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

65

NP-Completeness

A problem is NP-complete if:

•It is in NP

•Every NP problem is reduced to it

(in polynomial time)

Page 66: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

66

Observation:

If we can solve an NP-complete problemin Deterministic Polynomial Time (P time)then we know:

NPP

Page 67: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

67

Observation:

If prove thatwe cannot solve an NP-complete problemin Deterministic Polynomial Time (P time)then we know:

NPP

Page 68: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

68

Cook’s Theorem: The satisfiability problem is NP-complete

Page 69: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

69

Cook’s Theorem: The satisfiability problem is NP-complete

Proof:

Convert a Non-Deterministic Turing Machineto a Boolean expressionin conjunctive normal form

Page 70: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

70

Other NP-Complete Problems:

•The Traveling Salesperson Problem

•Vertex cover

•Hamiltonian Path

All the above are reducedto the satisfiability problem

Page 71: 1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems

71

Observations:

It is unlikely that NP-complete problems are in P

The NP-complete problems have exponential time algorithms

Approximations of these problems are in P