Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1...
Transcript of Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1...
![Page 1: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/1.jpg)
Chapter 11
Theory of Computation
© 2007 Pearson Addison-Wesley.All rights reserved
![Page 2: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/2.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-2
Chapter 11: Theory of Computation
• 11.1 Functions and Their Computation• 11.2 Turing Machines• 11.3 Universal Programming Languages• 11.4 A Noncomputable Function• 11.5 Complexity of Problems• 11.6 Public-Key Cryptography
![Page 3: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/3.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-3
Functions
• Function: A correspondence between a collection of possible input values and a collection of possible output values so that each possible input is assigned a single output– Computing a function: Determining the output
value associated with a given set of input values– Noncomputable function: A function that cannot
be computed by any algorithm
![Page 4: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/4.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-4
Figure 11.1 An attempt to display the function that converts measurements in yards into meters
![Page 5: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/5.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-5
Figure 11.2 The components of a Turing machine
![Page 6: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/6.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-6
Turing Machine Operation
• Inputs at each step– State– Value at current tape position
• Actions at each step– Write a value at current tape position– Move read/write head– Change state
![Page 7: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/7.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-7
Figure 11.3 A Turing machine for incrementing a value
![Page 8: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/8.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-8
Church-Turing Thesis
The functions that are computable by a Turing machine are exactly the functions that can be computed by any algorithmic means.
![Page 9: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/9.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-9
Universal Programming Language
A language with which a solution to any computable function can be expressed– Examples: “Bare Bones” and most popular
programming languages
![Page 10: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/10.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-10
The Bare Bones Language
• Bare Bones is a simple, yet universal language.• Statements
– clear name;– incr name;– decr name;– while name not 0 do; … end;
![Page 11: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/11.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-11
Figure 11.4 A Bare Bones program for computing X x Y
![Page 12: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/12.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-12
Figure 11.5 “copy Today to Tomorrow”in Bare Bones
![Page 13: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/13.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-13
The Halting Problem
• Given the encoded version of any program, return 1 if the program is self-terminating, or 0 if the program is not.
![Page 14: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/14.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-14
Figure 11.6 Testing a program for self-termination
![Page 15: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/15.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-15
Figure 11.7 Proving the unsolvability of the halting program
![Page 16: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/16.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-16
Complexity of Problems
• Time Complexity: The number of instruction executions required– Unless otherwise noted, “complexity” means “time
complexity.”• A problem is in class O(f(n)) if it can be solved
by an algorithm in Θ(f(n)).• A problem is in class Θ(f(n)) if the best
algorithm to solve it is in class Θ(f(n)).
![Page 17: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/17.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-17
Figure 11.8 A procedure MergeLists for merging two lists
![Page 18: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/18.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-18
Figure 11.9 The merge sort algorithm implemented as a procedure MergeSort
![Page 19: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/19.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-19
Figure 11.10 The hierarchy of problems generated by the merge sort algorithm
![Page 20: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/20.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-20
Figure 11.11 Graphs of the mathematical expression n, lg, n, n lg n, and n2
![Page 21: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/21.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-21
P versus NP
• Class P: All problems in any class Θ(f(n)), where f(n) is a polynomial
• Class NP: All problems that can be solved by a nondeterministic algorithm in polynomial time– Nondeterministic algorithm = an “algorithm” whose steps
may not be uniquely and completely determined by the process state
• Whether the class NP is bigger than class P is currently unknown.
![Page 22: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/22.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-22
Figure 11.12 A graphic summation of the problem classification
![Page 23: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/23.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-23
Public-Key Cryptography
• Key: A value used to encrypt or decrypt a message– 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
![Page 24: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/24.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-24
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.
![Page 25: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/25.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-25
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.
![Page 26: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/26.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-26
Figure 11.13 Public key cryptography
![Page 27: Theory of Computation - University of Iceland · Chapter 11: Theory of Computation • 11.1 Functions and Their Computation • 11.2 Turing Machines • 11.3 Universal Programming](https://reader031.fdocuments.us/reader031/viewer/2022013117/5b1427037f8b9a487c8b8856/html5/thumbnails/27.jpg)
© 2007 Pearson Addison-Wesley. All rights reserved 0-27
Figure 11.14 Establishing a RSA public key encryption system