Upcoming SlideShare
×

# Theory of Computation: Lecture 22: Universal Programs, Universality Theorem

771 views

Published on

1) Universal Programs
2) Execution of Conditional Dispatch in a Universal Program
3) Execution of No-Op, Subtraction, and Addition in a Universal Program
4) Universality Theorem

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
771
On SlideShare
0
From Embeds
0
Number of Embeds
286
Actions
Shares
0
0
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Theory of Computation: Lecture 22: Universal Programs, Universality Theorem

1. 1. Theory of Computation Execution of Conditional Dispatch, No-Op, Subtraction, & Addition in Universal Programs; Program Simulation Vladimir Kulyukin Department of Computer Science Utah State Universityhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
2. 2. Outline ● Review ● Developing Universal Programs – Part 05: Executing Conditional Dispatch – Part 06: Executing No-Op, Subtraction, and Addition ● Program Simulationhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
4. 4. Review: The Big Picture Number GÖDEL Coder L Program Number Universal Program GÖDEL Decoder ??? GÖDEL Coder = Compiler GÖDEL Decoder = Reverse Compiler Universal Program = Operating System/VM/Interpreterhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
5. 5. Review: Developing Universal Programs ● Part 01: Extraction Source Code, Encoding Program State, Initializing Instruction Counter ● Part 02: Establishing Termination Condition ● Part 03: Decoding Next Instruction ● Part 04: Determining Next Instructions Typehttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
6. 6. Review: Un Construction So Farhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
7. 7. Developing Universal Programs Part 05: Executing Conditional Dispatchhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
8. 8. Review: Coding Conditional Dispatch IF K - th instruction is of the form IF V ≠ 0 GOTO L, then b = # ( L ) + 2.http://www.youtube.com/vkedco http://www.vkedco.blogspot.com
9. 9. Un Construction: Part 5 I = ( Z ) K = a , b, c ; U = r ( ( Z ) K ) = b, c . IF l (U ) > 2 and P | S , then the current instruction is of the form IF V ≠ 0 GOTO L and # ( L ) = l (U ) − 2.http://www.youtube.com/vkedco http://www.vkedco.blogspot.com
10. 10. Un Construction: Part 5 l (U ) = l ( b, c ) = b = l (U ) + 2 =# ( L ) + 2. So # ( L ) = b − 2. Thus, we need to look for the earliest instruction ( Z ) i = ai , bi , ci , such that ai = b − 2, or, equivalently, ai + 2 = b = l (U ) + 2.http://www.youtube.com/vkedco http://www.vkedco.blogspot.com
11. 11. Un Construction: Part 5 // I = ( Z ) K = a, b, c ;U = r ( ( Z ) K ) = b, c . K ← min [ l ( ( Z ) i ) + 2 = l (U ) ] i ≤ Lt ( Z ) GOTO C // Note that if there is no such label, K = 0. // This is the only place in the code where K can become 0.http://www.youtube.com/vkedco http://www.vkedco.blogspot.com
12. 12. Un Construction: So Farhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
13. 13. Developing Universal Programs Part 06: Executing No-Op, Subtraction, & Additionhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
14. 14. Un Construction: Part 6 • All there is left to do is to code what Un must do at each of the following labels: – [N] – do nothing – [M] – subtract – [A] – addhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
15. 15. Un Construction: Part 6 // Doing Nothing [N] K ← K + 1 // Increment instruction counter. GOTO C // Go back C.http://www.youtube.com/vkedco http://www.vkedco.blogspot.com
16. 16. Un Construction: Part 6 // Subtraction S  [M ] S ←   P //For example, S = 63 = ( [ 0,2,0,1] ). //Suppose ( Z )1 =# ( X 1 ← X 1 −1). X 1 is the second variable //in our variable sequence. Thus, P = p2 = 3. Then the new state,  S   63  //after the subtraction is executed, is   =   = 21 = 3 ⋅ 7 = ( [ 0,1,0,1] ). P  3 http://www.youtube.com/vkedco http://www.vkedco.blogspot.com
17. 17. Un Construction: Part 6 // Addition [ A] S ← S ⋅ P For example, suppose S = 63 = [ 0,2,0,1]. Suppose K = i. Suppose ( Z ) i =# ( X 2 ← X 2 + 1). X 2 is the 4 - th variable in our sequence. Thus, P = p4 .Then the new state S = [ 0,2,0,2] = 63 ⋅ 7 = S ⋅ P.http://www.youtube.com/vkedco http://www.vkedco.blogspot.com
18. 18. Putting It All Together: Part 7http://www.youtube.com/vkedco http://www.vkedco.blogspot.com
19. 19. Remember What We Just Proved? :-)http://www.youtube.com/vkedco http://www.vkedco.blogspot.com
20. 20. Remember What We Proved? Theorem 3.1 (Universality Theorem) : For each n > 0, the function Φ (n) ( x1 ,..., xn , y ) is partially computable.http://www.youtube.com/vkedco http://www.vkedco.blogspot.com
21. 21. Back to The Big Picture Number GÖDEL Coder Theorem 3.1 (Ch. 4) L Program Number Universal Program GÖDEL Decoder ??? GÖDEL Coder = Compiler GÖDEL Decoder = Reverse Compiler Universal Program = Operating System/VM/Interpreterhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
22. 22. One More Point • If you look at the proof of Theorem 3.1 (Ch. 4) as a programmer and a computer scientist, you notice that we have constructed an interpreter (a mini-OS) for L in L itself • Thus, it should be feasible (and it is!) to write – Java interpreter/compiler in Java – Python interpreter/compiler in Python – Lisp interpreter/compiler in Lisp – C interpreter/compiler in C – Etc.http://www.youtube.com/vkedco http://www.vkedco.blogspot.com
23. 23. On To Program Simulation ● Suppose a universal program runs a program on some inputs ● We can expect two mutually exclusive outcomes: – The program terminates (halts) after some finite number of steps and produces an output (a number); – The program does not terminate at all (e.g., it has an infinite loop) ● In many situations, we would like to know if a program terminates within a given number of steps without running the program ● Enter Simulationhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
24. 24. Reading Suggestions nd ● Ch. 4, Computability, Complexity, and Languages, 2 Edition, by Davis, Weyuker, Sigalhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
25. 25. Feedback Errors to vladimir dot kulyuki at gmail dot comhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com