module8-print

# module8-print - Module 8 Turing machines How can we...

This preview shows pages 1–3. Sign up to view the full content.

Module 8 Turing machines How can we simplify computers down to automata? CS 360: Introduction to the Theory of Computing Daniel G. Brown, University of Waterloo 8.1 Topics for this module Introduction to the limits of programs. Turing machines How to program a Turing machine Variations on Turing machines Turing machines, and the theorems about them, are the major contributions of computer science to Western thought. 8.2 1 Introduction to the limits of programs Why might some problems be hard to solve? Our primary goal in this module of the course: Are there problems computers can’t solve? What sorts of problems? It turns out that the class of languages computers can’t decide membership in is very large . In fact, almost every language is not the language of a program written in a normal computer language. Let’s think for a bit about what might be a hard problem to solve. Given a function, does it return 1? Why would that be hard to test? 8.3 Some programs are easy, some aren’t. def easy(): return 1 def hard(): i = 0 while i >= 0: for j in range (i+1): for k in range (j+1): for n in range (3,k+1): if i ** n== j ** n+k ** n: return 1 i = i+1 Does this program return 1? No, because Fermat’s Last Theorem is true. Instead, it runs forever. 8.4 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Simple properties can be arbitrarily hard to test Suppose there’s an interesting fact in number theory, or combinatorics, or whatever, and we want to know if it’s always true, for all integers i , j , k . Write a test for that property. Enumerate over all possible choices of i , j , k . If the test is false, return 1. If the function ever returns, then the property is false. If we could write a program that can test other functions for a speciﬁc result, then it can verify any math result. 8.5 Another reason it’s not easy to solve Suppose we have a Python function, H that determines if a computer program, P will return 1, when it’s run with the input I . If P does return 1, H does, too. If not, H returns 0. P,I H 1 or 0 Here’s a new program, H 1 , which uses H : def H1 (program, input): if H (program, input): return 0 else: return 1 8.6 What’s so weird about H 1 ? Our program H 1 , when run on a program P and an input I , returns either 0 or 1, depending on whether P returns 1 or not. If P does return 1 on input I , H 1 doesn’t. If P doesn’t return 1 on input I , H 1 does. Let’s have one more program, H 2 : def H2 (program): if H (program, program): return 0 else: return 1 Here, H 2 behaves just like H 1 , except that the program P is used as the input. That’s okay. 8.7 Now, we reach the end What happens when we call H2 (H2) ? Consider the test in the
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 17

module8-print - Module 8 Turing machines How can we...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online