Document Sample

```					    Theory of Computation

Shyh-Kang Jeng
Department of Electrical Engineering/
National Taiwan University

1
Chapter Goal

   Investigate the capabilities of computers
   Understand what machines can and
cannot do and what features are required
for machines to reach their full potential

2
Functions and Their Computation
   Function
   A correspondence between a collection of
possible input values and a collection of
output values
   Each possible input is assigned a unique
output
   Computing the function
   Process of determining the particular output
value that assigns to a given input

3
Function Computing through Table
Lookup

4
Computable and Non-computable
Functions
   Computable functions
   Functions whose output values can be
determined algorithmically from their input
values
   Non-computable functions
   Functions that are so complex that there is no
well-defined, step-by-step process for
determining their output based on their input
values
   The computation of these functions lies
beyond the abilities of any algorithmic system
5
A Turing Machine

6
A Turing Machine
   Control unit
   Tape and cells
   Alphabet and symbols
   States
   Start state
   Halt state

7
A Turing Machine
   Steps executed by the control unit
   Observe the symbol in the current tape cell
   Write a symbol in the current tape cell
left
right
   Can be implemented in a variety of
forms
   Today’s general-purpose computer (CPU,
memory, bit patterns of registers, 0 and 1)
8
A Turing Machine for
Incrementing a Value

*      1      0   1   *

state = START

*        1   0   1   *

9
A Turing Machine for
Incrementing a Value
*     1      0   0   *

state = CARRY

*     1     1   0   *

state = RETURN
10
A Turing Machine for
Incrementing a Value
*     1       1   0   *

state = RETURN

*        1   1   0   *

state = HALT

11
A Turing Machine for
Incrementing a Value

12
Church-Turing Thesis
   Turing Computable Functions
   Functions that can be computed by a
Turing machine
   Church-Turing Thesis
   The computable functions and the Turing
computable functions are considered one
and the same
   Widely accepted conjecture

13
A Turing Machine
   Captures the essence of computational
process
   Its computational power is as great as
any algorithmic system
   If a problem can not be solved by a
Turing machine, it can not be solved by
any algorithmic system
   Represents a theoretical bound on the
capabilities of actual machines

14
Universal Programming Language
   Most features in high-level languages
merely enhance convenience rather than
contribute to the fundamental power of
the language
   Universal programming language
   Rich enough to express programs for
computing all computable functions
   If a problem can not be solved using this
language, it will be that there is not an
algorithm for solving the problems

15
A Bare Bones
Programming Language
   Language that isolates a minimal set of
requirements of a Universal programming
   Data Description Statements
   bit pattern of any length
   variable name and value
   Imperative Statements
   clear name
   incr name
   decr name
   while name not 0 do
   end

16
Copying Today to Tomorrow

17
Computing Z = X + Y
copy Y to Z;
while X not 0 do;
incr Z;
decr X;
end;

18
Computing X*Y

19
Universality of Bare Bones
   Using Turing machine to compute
incr X
   Bare Bones program for the addition
function
   Bare Bones language can be used to
express algorithms for computing all
Turing-computable functions
   Any computable function can be
computed by a program written in Bare
Bones
20
Halting Problem
   Problem of trying to predict in advance
whether a program will terminate (or halt)
if started under certain conditions
   Example
while X not 0 do;
incr X;
end;

21
Testing a Program for
Self-Termination

22
The Halting Problem
   Define a function
   Input of encoded self-terminating
programs produce the output 1
   Input of encoded non-self-terminating
programs produce the output 0
   Halting problem
   Calculating whether programs ultimately
terminate after being started from a
particular initial state

23
The Halting Problem

24
The Halting Problem

25
The Halting Problem

26
Complexity of a Problem
   Considered to be the complexity of the
best algorithm for solving the problem
   Algorithm’s time complexity
   Time required for its execution
   Proportional to the number of steps
   Not the same as number of instructions in
the program
   Algorithm’s space complexity

27
Time Complexity of a Problem
   Big theta notation for algorithm
efficiency
   Big oh notation
   The problem is in O(f(n)) if it has a
solution whose complexity is Q(f(n)) but
could possibly have a better solution
   Searching and sorting a list of length n:
O(lg n)
   Binary search is an optimal solution
   Insertion sort is not an optimal solution
28
Algorithm for Merging Lists

29
Algorithm MergeSort

30
Hierarchy by MergeSort

31
Polynomial Problems
   Problem in O(f(n)), where f(n) is either
a polynomial or bounded by a
polynomial
   The collection of all polynomial
problems: P (Having practical solutions)
   Problems outside P have extremely long
execution time
   e.g. O(2n) problems: listing all
subcommittees that can be formed from a
group of n people
32
Checking Bounds

33
Traveling Salesman Problem
Find a path whose total length does not exceed his allowed mileage

34
Traveling Salesman Problem
   List and compare paths systematically
   Not produce a polynomial time solution
   Nondeterministic algorithm
pick one of the possible paths, and compute
its total distance
if this distance is not greater than the
allowable mileage then declare a success
else declare nothing

35
NP Problem
   A problem that can be solved in
polynomial time by a nondeterministic
algorithm
   The class of NP problems: NP
   All problems in P are also in NP
   NP-complete problems
   Problems having the property that a
polynomial time solution for any of them
would provide a polynomial time solution
for all the other problems in NP as well
36
Problem Classification

37
Public Key Cryptography
   Keys used for data encryption are not
the same as those used to decode the
encrypted information
   Encryption key
   Can be widely distributed
   Decoding key
   Required to decode encrypted message

38
Public key cryptography
   Key = specially generated set of values
used for encryption
   Public key: used to encrypt messages
   Private key: used to decrypt messages
   RSA = a popular public key cryptographic
algorithm
   Relies on the (presumed) intractability of the
problem of factoring large numbers

39
Encrypting the message 10111

   Encrypting keys: n = 91 and e = 5
   10111two = 23ten
   23e = 235 = 6,436,343
   6,436,343 ÷ 91 has a remainder of 4
   4ten = 100two
   Therefore, encrypted version of 10111 is
100.
40
Decrypting the message 100

   Decrypting keys: d = 29, n = 91
   100two = 4ten
   4d = 429 = 288,230,376,151,711,744
   288,230,376,151,711,744 ÷ 91 has a
remainder of 23
   23ten = 10111two
   Therefore, decrypted version of 100 is
10111.
41
Public key cryptography

42
Establishing a RSA public key
encryption system

43

```
DOCUMENT INFO
Shared By:
Categories:
Stats:
 views: 148 posted: 10/30/2008 language: English pages: 43
How are you planning on using Docstoc?