Notes on Turing s Theorem and Computability

Size: px
Start display at page:

Download "Notes on Turing s Theorem and Computability"

Transcription

1 Notes on Turing s Theorem and Computability Walter Neumann About 60 years ago there was a revolution in mathematics and philosophy. First Gödel and then Turing showed that there are impossible problems in mathematics. Gödel showed that there are true theorems that can t be proved (his famous Incompleteness Theorem ). Turing showed, before the first electronic computer had even been built, that there is no systematic way of deciding if any given computer calculation will stop with an answer or go into an endless loop (i.e., crash ). One consequence of these results is the fact that there are easily stated problems with impossibly difficult answers. This fact is fundamental to the existence of public key cryptosystems like the one discussed in class. These notes are a very brief introduction to the theorems of Turing and Gödel. If you want to find out more, not just about Turing and Gödel, but also about quantum mechanics and lots more, an excellent reference is the 1989 best-seller: The Emperor s New Mind by Roger Penrose, published by Oxford University Press. Computable sequences. We shall study infinite sequences of numbers like: sequence 1: 1, 1, 1, 1, 1, 1,... sequence 2: 1, 2, 3, 4, 5, 6,... sequence 3: 0, 1, 0, 1, 0, 10,... sequence 4: 3, 14, 159, 2653, 58979, ,... A sequence may have an obvious pattern, like the first three of these examples, or a less obvious pattern, like sequence 4. The issue that Turing studied in the 1930 s is: We shall say a sequence When is such a sequence computable? a(1), a(2), a(3),... is computable if a competent programmer can write a program in his or her favourite computer language which does the following: 1. It asks you to input a number n. 2. It then computes a(n) and prints it out. One of Turing s conclusions was that there exist sequences that are not computable in this sense. But as we shall see, he actually proved rather more.

2 2 Undergraduate Math. Society Before we discuss this, it is important to stress that the concept of computability does not depend on what computer language or computer we choose to work with, so long as the language is not too primitive. We shall not need to worry much about exactly what the computer looks like, or what language it uses. You can think of it as being like any of the computers one sees around nowadays. However, we do need to assume it has one idealized feature that your favourite real computer does not yet have: it should be able to work with numbers of any size, and therefore, in particular, it should have unlimited memory space. Turing went to some trouble to design an idealized computer and referred all his arguments to this. In this way he was confident that he had a rigorous mathematical interpretation of what computable meant. At the time, electronic computers had not yet been invented, so ideas related to them were very unfamiliar. Nowadays we are much more comfortable with them. In particular, you may be familiar with such software as SoftWindows, which allows you to run Windows software on Macintosh or Sun computers, and thus make your Mac or Sun act like a PC. Since one computer can simulate another computer the first computer can do any computation that the second can do. This is why the concept of computability robust: it doesn t depend on the specifics of the computer and computer language you imagine doing the computations. A baby Turing theorem. We shall first prove a baby version of Turing s theorem. Theorem. Non-computable sequences exist. In fact, there is a non-computable sequence b(1), b(2), b(3),... which eventually grows faster than any computable sequence in the following sense. If a(1), a(2), a(3),... is a computable sequence, then it is smaller than the b-sequence from some point on, that is, there is some number N such that b(n) > a(n) for n N. Proof. The proof depends on the basic fact that we can list all computable sequences in some order. Since we need infinitely many names to list them all, we shall call them a 1, a 2, and so on. Thus the first computable sequence is and the second is a 1 (1), a 1 (2), a 1 (3),..., a 2 (1), a 2 (2), a 2 (3),..., and so on. How do we list them? Well, we know that a computable sequence is computed by some computer program P. When stored in computer memory, this computer program is just a string of (binary) digits. We can think of this string of digits as the digits for some (large) number. Thus in computer memory the program is really indistinguishable from a number. Not every number stored in computer memory will be a proper computer program; in fact, very few of them will just as very few strings of letters of the alphabet spell out grammatical sentences. We do not care about this. All we need is that every program is a number in computer memory.

3 Turing s Theorem and Computability 3 Since each computable sequence is determined by a program and hence by a number in this way, we can just list computable sequences in order of the numbers that determine them. Thus a 1 (1), a 1 (2), a 1 (3),... would be the sequence determined by the simplest program (in the sense of smallest number). This program would quite likely be the one that ignores your input and just immediately prints 0 so this sequence is probably 0, 0, 0,.... But it is not important whether this is really what it is. The order of listing computable sequences does of course depend on what computer hardware and software we imagine we are using, but this does not matter to our arguments. So here is our list of computable sequences: a 1 (1), a 1 (2), a 1 (3), a 1 (4), a 1 (5), a 1 (6),... a 2 (1), a 2 (2), a 2 (3), a 2 (4), a 2 (5), a 2 (6),... a 3 (1), a 3 (2), a 3 (3), a 3 (4), a 3 (5), a 3 (6),... a 4 (1), a 4 (2), a 4 (3), a 4 (4), a 4 (5), a 4 (6),... a 5 (1), a 5 (2), a 5 (3), a 5 (4), a 5 (5), a 5 (6),... a 6 (1), a 6 (2), a 6 (3), a 6 (4), a 6 (5), a 6 (6), We now construct our new sequence b as follows. b(1) = a 1 (1) + 1 b(2) = max(a 1 (2), a 2 (2)) + 1 b(3) = max(a 1 (3), a 2 (3), a 3 (3)) + 1 and so on. That is, the n-th term of the sequence b is 1 more than the largest of the n-th terms of the sequences a 1, a 2,..., a n. Now if a is any computable sequence then we want to show that the sequence b is eventually larger than sequence a. Sequence a is one of the sequences in our list of computable sequences. It might be a 37 for example. But b is constructed so that from the 37-th term on, all its terms are at least 1 larger than each of a 1 (n), a 2 (n),..., a 37 (n),..., a n (n). Thus b(n) > a 37 (n) when n 37. This completes the proof. Is our sequence b computable? Before we discuss the above question, a note about terminology. Rather than speaking of the sequence b, mathematicians usually speak of the function b. This function is the rule that generates the sequence b(1), b(2),.... This is no more than a linguistic difference, reflecting the two different views we have of b, a rule for generating a list of numbers or the list of numbers itself. It is not an important difference, but from now on we will stick to mathematical terminology and call b a function. At this point it looks as if we are faced with a paradox. In the previous section we constructed a non-computable function b. But on the other hand, it looks as if we gave a perfectly good procedure to compute it. Is it computable or is it not? The answer must be that it is not computable, since we carefully constructed it not to be. Thus the procedure must have a non-computable aspect in it somewhere. Where is it? The answer depends on something that is familiar to any computer programmer that programs don t always stop and give you an answer for example, they can get trapped in endless loops.

4 4 Undergraduate Math. Society To illustrate this, suppose we have a simple computer that has an input/output store and working memory and operates as follows. We load our program into working memory, put a number n in the input/output store and press the start key. The answer is whatever is in the input/output store once the program stops. Consider the following program: Program A 1. Replace n n If n = 100 stop, otherwise goto step 1. If the input is less than 100 this eventually stops with 100 in the input/output store. But if the input is 100 or more this program just keeps running for ever. Sometimes it can be hard to decide if a program will stop. For example: Program B 1. If n is a power of 2 then stop, 2. If n is even then replace n by 3n/2+1, while if n is odd replace n by (n 1)/2, 3. Goto step 1. For example, the input n = 14 results in this program computing the numbers 22, 34, 52, 79, 39, 19,9, 4 and then stopping. Thus if the function that this program computes is called f then f(14) = 4. You can check that the first few values of f(n) for n = 1, 2,..., 14 are 1, 2, 1, 4, 2, 16, 1, 16,4, 16,2, 4, 16, 4. If we gave this program a large number and it did not stop for several hours, how would we decide if the program will continue working for ever or if it will eventually stop with an answer? Is there some general way of deciding this, whatever the program? If you think very carefully about this, you will realise that the answer must be no, because if it were yes then the function b that we constructed above would indeed be computable, but we made sure that it is not. To compute b we need to decide which computer programs really define sequences, which means being able to decide by computation which programs always stop, no matter what the input. If we could do this, then we could actually compute the list of all computable sequences and hence compute b. This will become clearer if we make it more precise, which we now do. Turing s halting theorem We shall work with a computer like the one we described above. Remember that a program is just stored as a string of digits in the computer s working memory. Any string of digits can be stored there, and it may make sense as a program or not. If it does not make sense, then when we push the start button the computer will probably stop immediately with some cryptic message like illegal op code in location H0000A0. Since it won t have changed the number in the input/output store, we can think of such a nonsense program as being a program that computes the trivial counting function f(n) = n. A string of digits in working memory is just a number. Interpreting numbers to be programs in this way, every number represents a program, but most programs are rather boring in that they compute this function f(n) = n. We shall give the program corresponding to the number j the name P j.

5 Turing s Theorem and Computability 5 Instead of trying to list computable sequences, we list the output of every program as follows: p 1 (1), p 1 (2), p 1 (3), p 1 (4), p 1 (5), p 1 (6),... p 2 (1), p 2 (2), p 2 (3), p 2 (4), p 2 (5), p 2 (6),... p 3 (1), p 3 (2), p 3 (3), p 3 (4), p 3 (5), p 3 (6),... p 4 (1), p 4 (2), p 4 (3), p 4 (4), p 4 (5), p 4 (6),... p 5 (1), p 5 (2), p 5 (3), p 5 (4), p 5 (5), p 5 (6),... p 6 (1), p 6 (2), p 6 (3), p 6 (4), p 6 (5), p 6 (6), Here p j (n) means the output of program P j when started with n in the input/output buffer. Thus the first few rows of this table almost certainly belong to nonsense programs that never change the input and are thus 1, 2, 3, 4, 5, 6,.... We need some symbol to represent the situation that program P j never stops if started with n in the input/output buffer. In this case we write p j (n) =. Thus if the number 27 happens to represent the instruction goto step 1 then p 27 (n) = for any n since program P 27 will just keep repeating its first instruction and never stop. Thus the 27-th row of the table would be,,,,,,,.... We can now make very precise the statement that we can not decide whether a program stops. We shall give two versions. Define: { 0 if program Pj fails to stop for some input H 1 (j) := 1 if program P j stops for every input. H 2 (j, n) := { 0 if program Pj fails to stop for input n 1 if program P j stops for input n. Turing s Halting Theorem. The functions H 1 and H 2 are non-computable functions. The argument given briefly in the previous section is really an argument that shows that H 1 is non-computable. For if it were, then we could use it to discard programs that do not define sequences and thus construct by computation enough of our list of computable sequences to compute any desired value b(n) of the function b. However, it is maybe not really so surprising that H 1 is non-computable, since to decide that the j-th computer program P j stops whatever its input appears to involve deciding infinitely many things all at once 1). But it is more surprising that the function H 2 is non-computable. That is, there is no program which, given both j and n as input, will infallibly compute H 2 (j, n) and thus tell us whether program number j will stop if run with input n. 1) Of course we often do this for example, when we prove a theorem by induction we are proving infinitely many cases of some statement all at once.

6 6 Undergraduate Math. Society To prove this, let us assume instead that there is such a program. Let us call this program D (for decision ). For each j we now write a new computer program: Program Q j 1. Look at the number n in the input/output store and run program D with input j and n to compute H 2 (j, n). 2. If H 2 (j, n) = 0 then put 0 in the input/output buffer and stop, otherwise 3. Run program P j. Notice that this program always stops, since it only gets to step 3 once it knows that step 3 will stop. It stops with value 0 in the input/output buffer if program P j does not stop with input n and otherwise it moves on to step 3 which eventually stops with output p j (n). We list the output of the programs Q j in a table: q 1 (1), q 1 (2), q 1 (3), q 1 (4), q 1 (5), q 1 (6),... q 2 (1), q 2 (2), q 2 (3), q 2 (4), q 2 (5), q 2 (6),... q 3 (1), q 3 (2), q 3 (3), q 3 (4), q 3 (5), q 3 (6),... q 4 (1), q 4 (2), q 4 (3), q 4 (4), q 4 (5), q 4 (6),... q 5 (1), q 5 (2), q 5 (3), q 5 (4), q 5 (5), q 5 (6),... q 6 (1), q 6 (2), q 6 (3), q 6 (4), q 6 (5), q 6 (6), The only difference between this table and the previous one is that every time a p j (n) equals it is replaced by 0. Now every computable sequence occurs as a row of this table, since every computable sequence occurred already in the table of p j (n) and is unchanged in this table. In fact, each computable sequence will probably occur many times in this table, but we do not care about this. The whole table is computable, since we have given an explicit way of computing each entry: run program Q j with input n. We now use this table as our list of computable sequences to create a version of the function b that we constructed earlier. Thus now b(n) = max(q n (1), q n (2),..., q n (n)) + 1. Now we really do have a contradiction: our function b is definitely computable since we have carefully constructed it to make sure it can be computed at every stage. But it also eventually grows faster than any row of the table and therefore eventually grows faster than any computable function. So it can t be computable. This contradiction shows that the assumption on which this argument was based that H 2 is a computable function must have been wrong after all. We have proved Turing s theorem. Gödel s Theorem. One of Gödel s famous theorems says loosely that in any formal mathematical system sufficiently strong to do elementary arithmetic there exist theorems that are true but cannot be proved. Turing s theorem implies a version of this. We first note that if every true theorem were provable then we could give a formal algorithm to actually find a proof. We assume a formal mathematical system in which we can write down proofs and check, step by

7 Turing s Theorem and Computability 7 step, that they are indeed logically correct that each step follows from the preceding ones. Since proofs are just strings of words, we can list all possible strings of words in dictionary order and then read through thme one by one and check each one whether it is logically correct and whether the final sentence is the theorem we are interested in. Since we are assuming our theorem has a proof, and this proof must be somewhere on our list of all possible strings of words, we must eventually get to it and find it. But now we have a way of computing H 2 (j, n): we read our proofs as above one by one until we find one that either proves the theorem H 2 (j, n) = 0 or one that proves the theorem H 2 (j, n) = 1. Since one of these two must be true, this procedure eventually finds which one it is. Thus if Gödel s theorem were false then the function H 2 would, after all, be computable, but we know it is not. Gödel in fact proved much more than what we have just proved. Our proof does not exhibit an explicit theorem that is not provable, it just shows it must exist. Gödel actually gives an explicit theorem with this property. This is also only one of two famous theorems he proved, the other of which says roughly that it is impossible to prove that the formal mathematical system in question is consistent, i.e., cannot lead to any internal contradictions.

Diagonalization. The cardinality of a finite set is easy to grasp: {1,3,4} = 3. But what about infinite sets?

Diagonalization. The cardinality of a finite set is easy to grasp: {1,3,4} = 3. But what about infinite sets? Diagonalization Cardinalities The cardinality of a finite set is easy to grasp: {1,3,4} = 3. But what about infinite sets? We say that a set S has at least as great cardinality as set T, written S T, if

More information

CSCI 270: Introduction to Algorithms and Theory of Computing Fall 2017 Prof: Leonard Adleman Scribe: Joseph Bebel

CSCI 270: Introduction to Algorithms and Theory of Computing Fall 2017 Prof: Leonard Adleman Scribe: Joseph Bebel CSCI 270: Introduction to Algorithms and Theory of Computing Fall 2017 Prof: Leonard Adleman Scribe: Joseph Bebel We will now discuss computer programs, a concrete manifestation of what we ve been calling

More information

Lecture 5: The Halting Problem. Michael Beeson

Lecture 5: The Halting Problem. Michael Beeson Lecture 5: The Halting Problem Michael Beeson Historical situation in 1930 The diagonal method appears to offer a way to extend just about any definition of computable. It appeared in the 1920s that it

More information

What if current foundations of mathematics are inconsistent? Vladimir Voevodsky September 25, 2010

What if current foundations of mathematics are inconsistent? Vladimir Voevodsky September 25, 2010 What if current foundations of mathematics are inconsistent? Vladimir Voevodsky September 25, 2010 1 Goedel s second incompleteness theorem Theorem (Goedel) It is impossible to prove the consistency of

More information

Chapter 12. Computability Mechanizing Reasoning

Chapter 12. Computability Mechanizing Reasoning Chapter 12 Computability Gödel s paper has reached me at last. I am very suspicious of it now but will have to swot up the Zermelo-van Neumann system a bit before I can put objections down in black & white.

More information

What computers just cannot do. COS 116: 2/28/2008 Sanjeev Arora

What computers just cannot do. COS 116: 2/28/2008 Sanjeev Arora What computers just cannot do. COS 116: 2/28/2008 Sanjeev Arora Administrivia In class midterm in midterms week; Thurs Mar 13 (closed book;? No lab in midterms week; review session instead. What computers

More information

Material from Recitation 1

Material from Recitation 1 Material from Recitation 1 Darcey Riley Frank Ferraro January 18, 2011 1 Introduction In CSC 280 we will be formalizing computation, i.e. we will be creating precise mathematical models for describing

More information

AXIOMS FOR THE INTEGERS

AXIOMS FOR THE INTEGERS AXIOMS FOR THE INTEGERS BRIAN OSSERMAN We describe the set of axioms for the integers which we will use in the class. The axioms are almost the same as what is presented in Appendix A of the textbook,

More information

MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015

MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015 CS161, Lecture 2 MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015 1 Introduction Today, we will introduce a fundamental algorithm design paradigm, Divide-And-Conquer,

More information

Cardinality of Sets MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Cardinality of Sets Fall / 15

Cardinality of Sets MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Cardinality of Sets Fall / 15 Cardinality of Sets MAT Transition to Higher Mathematics Fall 0 MAT (Transition to Higher Math) Cardinality of Sets Fall 0 / Outline Sets with Equal Cardinality Countable and Uncountable Sets MAT (Transition

More information

Recursively Enumerable Languages, Turing Machines, and Decidability

Recursively Enumerable Languages, Turing Machines, and Decidability Recursively Enumerable Languages, Turing Machines, and Decidability 1 Problem Reduction: Basic Concepts and Analogies The concept of problem reduction is simple at a high level. You simply take an algorithm

More information

Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5

Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5 Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5 [talking head] This lecture we study theory design and implementation. Programmers have two roles to play here. In one role, they

More information

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions): CS 70 Discrete Mathematics for CS Fall 2003 Wagner Lecture 7 This lecture returns to the topic of propositional logic. Whereas in Lecture 1 we studied this topic as a way of understanding proper reasoning

More information

14.1 Encoding for different models of computation

14.1 Encoding for different models of computation Lecture 14 Decidable languages In the previous lecture we discussed some examples of encoding schemes, through which various objects can be represented by strings over a given alphabet. We will begin this

More information

In this section we will study problems for which we can prove that there is no algorithm solving them.

In this section we will study problems for which we can prove that there is no algorithm solving them. 8 Uncomputability In this section we will study problems for which we can prove that there is no algorithm solving them. 8.1 What is an algorithm? The notion of algorithm is usually defined as Turing machines

More information

Chapter 3. Set Theory. 3.1 What is a Set?

Chapter 3. Set Theory. 3.1 What is a Set? Chapter 3 Set Theory 3.1 What is a Set? A set is a well-defined collection of objects called elements or members of the set. Here, well-defined means accurately and unambiguously stated or described. Any

More information

Course notes for Data Compression - 2 Kolmogorov complexity Fall 2005

Course notes for Data Compression - 2 Kolmogorov complexity Fall 2005 Course notes for Data Compression - 2 Kolmogorov complexity Fall 2005 Peter Bro Miltersen September 29, 2005 Version 2.0 1 Kolmogorov Complexity In this section, we present the concept of Kolmogorov Complexity

More information

Typing Control. Chapter Conditionals

Typing Control. Chapter Conditionals Chapter 26 Typing Control 26.1 Conditionals Let s expand our language with a conditional construct. We can use if0 like before, but for generality it s going to be more convenient to have a proper conditional

More information

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and Computer Language Theory Chapter 4: Decidability 1 Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

More information

The Undecidable and the Unprovable

The Undecidable and the Unprovable The Undecidable and the Unprovable Jeff Sanford Russell Spring 2017 The main purpose of these notes is to help you understand some beautiful and important facts about the limits of computation and logic.

More information

MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: September 28, 2016 Edited by Ofir Geri

MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: September 28, 2016 Edited by Ofir Geri CS161, Lecture 2 MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: September 28, 2016 Edited by Ofir Geri 1 Introduction Today, we will introduce a fundamental algorithm design paradigm,

More information

Lecture T4: Computability

Lecture T4: Computability Puzzle ("Post s Correspondence Problem") Lecture T4: Computability Given a set of cards: N card types (can use as many of each type as possible) Each card has a top string and bottom string Example : N

More information

Elementary Recursive Function Theory

Elementary Recursive Function Theory Chapter 6 Elementary Recursive Function Theory 6.1 Acceptable Indexings In a previous Section, we have exhibited a specific indexing of the partial recursive functions by encoding the RAM programs. Using

More information

n! = 1 * 2 * 3 * 4 * * (n-1) * n

n! = 1 * 2 * 3 * 4 * * (n-1) * n The Beauty and Joy of Computing 1 Lab Exercise 9: Problem self-similarity and recursion Objectives By completing this lab exercise, you should learn to Recognize simple self-similar problems which are

More information

An Interesting Way to Combine Numbers

An Interesting Way to Combine Numbers An Interesting Way to Combine Numbers Joshua Zucker and Tom Davis October 12, 2016 Abstract This exercise can be used for middle school students and older. The original problem seems almost impossibly

More information

System Correctness. EEC 421/521: Software Engineering. System Correctness. The Problem at Hand. A system is correct when it meets its requirements

System Correctness. EEC 421/521: Software Engineering. System Correctness. The Problem at Hand. A system is correct when it meets its requirements System Correctness EEC 421/521: Software Engineering A Whirlwind Intro to Software Model Checking A system is correct when it meets its requirements a design without requirements cannot be right or wrong,

More information

COMP 161 Lecture Notes 16 Analyzing Search and Sort

COMP 161 Lecture Notes 16 Analyzing Search and Sort COMP 161 Lecture Notes 16 Analyzing Search and Sort In these notes we analyze search and sort. Counting Operations When we analyze the complexity of procedures we re determine the order of the number of

More information

The Diagonal Lemma: An Informal Exposition

The Diagonal Lemma: An Informal Exposition The Diagonal Lemma: An Informal Exposition Richard G Heck, Jr At the heart of Gödel s incompleteness theorem is the so-called diagonal lemma whose purpose is to allow us to construct self-referential sentences,

More information

Reflection in the Chomsky Hierarchy

Reflection in the Chomsky Hierarchy Reflection in the Chomsky Hierarchy Henk Barendregt Venanzio Capretta Dexter Kozen 1 Introduction We investigate which classes of formal languages in the Chomsky hierarchy are reflexive, that is, contain

More information

CSE 120. Computer Science Principles

CSE 120. Computer Science Principles Adam Blank Lecture 17 Winter 2017 CSE 120 Computer Science Principles CSE 120: Computer Science Principles Proofs & Computation e w h e q 0 q 1 q 2 q 3 h,e w,e w,h w,h q garbage w,h,e CSE = Abstraction

More information

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5 Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5 [talking head] Formal Methods of Software Engineering means the use of mathematics as an aid to writing programs. Before we can

More information

How invariants help writing loops Author: Sander Kooijmans Document version: 1.0

How invariants help writing loops Author: Sander Kooijmans Document version: 1.0 How invariants help writing loops Author: Sander Kooijmans Document version: 1.0 Why this document? Did you ever feel frustrated because of a nasty bug in your code? Did you spend hours looking at the

More information

3.1 Constructions with sets

3.1 Constructions with sets 3 Interlude on sets Sets and functions are ubiquitous in mathematics. You might have the impression that they are most strongly connected with the pure end of the subject, but this is an illusion: think

More information

6.001 Notes: Section 4.1

6.001 Notes: Section 4.1 6.001 Notes: Section 4.1 Slide 4.1.1 In this lecture, we are going to take a careful look at the kinds of procedures we can build. We will first go back to look very carefully at the substitution model,

More information

The following are just some of the many possible definitions that can be written:

The following are just some of the many possible definitions that can be written: 2.1 Define in your own words the following terms: agent, agent function, agent program, rationality, autonomy, reflex agent, model-based agent, goal-based agent, utility-based agent, learning agent. The

More information

Topology and Topological Spaces

Topology and Topological Spaces Topology and Topological Spaces Mathematical spaces such as vector spaces, normed vector spaces (Banach spaces), and metric spaces are generalizations of ideas that are familiar in R or in R n. For example,

More information

Grade 6 Math Circles November 6 & Relations, Functions, and Morphisms

Grade 6 Math Circles November 6 & Relations, Functions, and Morphisms Faculty of Mathematics Waterloo, Ontario N2L 3G1 Centre for Education in Mathematics and Computing Relations Let s talk about relations! Grade 6 Math Circles November 6 & 7 2018 Relations, Functions, and

More information

THE HALTING PROBLEM. Joshua Eckroth Chautauqua Nov

THE HALTING PROBLEM. Joshua Eckroth Chautauqua Nov THE HALTING PROBLEM Joshua Eckroth Chautauqua Nov 10 2015 The year is 1928 Sliced bread is invented. Calvin Coolidge is President. David Hilbert challenged mathematicians to solve the Entscheidungsproblem:

More information

Notebook Assignments

Notebook Assignments Notebook Assignments These six assignments are a notebook using techniques from class in the single concrete context of graph theory. This is supplemental to your usual assignments, and is designed for

More information

CS61A Lecture 38. Robert Huang UC Berkeley April 17, 2013

CS61A Lecture 38. Robert Huang UC Berkeley April 17, 2013 CS61A Lecture 38 Robert Huang UC Berkeley April 17, 2013 Announcements HW12 due Wednesday Scheme project, contest out Review: Program Generator A computer program is just a sequence of bits It is possible

More information

Order from Chaos. University of Nebraska-Lincoln Discrete Mathematics Seminar

Order from Chaos. University of Nebraska-Lincoln Discrete Mathematics Seminar Order from Chaos University of Nebraska-Lincoln Discrete Mathematics Seminar Austin Mohr Department of Mathematics Nebraska Wesleyan University February 8, 20 The (, )-Puzzle Start by drawing six dots

More information

Variants of Turing Machines

Variants of Turing Machines November 4, 2013 Robustness Robustness Robustness of a mathematical object (such as proof, definition, algorithm, method, etc.) is measured by its invariance to certain changes Robustness Robustness of

More information

Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122

Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122 Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122 I. Logic 101 In logic, a statement or proposition is a sentence that can either be true or false. A predicate is a sentence in

More information

1 Introduction CHAPTER ONE: SETS

1 Introduction CHAPTER ONE: SETS 1 Introduction CHAPTER ONE: SETS Scientific theories usually do not directly describe the natural phenomena under investigation, but rather a mathematical idealization of them that abstracts away from

More information

Ramsey s Theorem on Graphs

Ramsey s Theorem on Graphs Ramsey s Theorem on Graphs 1 Introduction Exposition by William Gasarch Imagine that you have 6 people at a party. We assume that, for every pair of them, either THEY KNOW EACH OTHER or NEITHER OF THEM

More information

introduction to Programming in C Department of Computer Science and Engineering Lecture No. #40 Recursion Linear Recursion

introduction to Programming in C Department of Computer Science and Engineering Lecture No. #40 Recursion Linear Recursion introduction to Programming in C Department of Computer Science and Engineering Lecture No. #40 Recursion Linear Recursion Today s video will talk about an important concept in computer science which is

More information

MITOCW watch?v=4dj1oguwtem

MITOCW watch?v=4dj1oguwtem MITOCW watch?v=4dj1oguwtem PROFESSOR: So it's time to examine uncountable sets. And that's what we're going to do in this segment. So Cantor's question was, are all sets the same size? And he gives a definitive

More information

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Table of Contents Introduction!... 1 Part 1: Entering Data!... 2 1.a: Typing!... 2 1.b: Editing

More information

We will give examples for each of the following commonly used algorithm design techniques:

We will give examples for each of the following commonly used algorithm design techniques: Review This set of notes provides a quick review about what should have been learned in the prerequisite courses. The review is helpful to those who have come from a different background; or to those who

More information

If Statements, For Loops, Functions

If Statements, For Loops, Functions Fundamentals of Programming If Statements, For Loops, Functions Table of Contents Hello World Types of Variables Integers and Floats String Boolean Relational Operators Lists Conditionals If and Else Statements

More information

Lecture 3: Constructing the Natural Numbers

Lecture 3: Constructing the Natural Numbers Math/CS 120: Intro. to Math Professor: Padraic Bartlett Lecture 3: Constructing the Natural Numbers Weeks 3-4 UCSB 2014 When we defined what a proof was in our first set of lectures, we mentioned that

More information

Algorithms in Systems Engineering IE172. Midterm Review. Dr. Ted Ralphs

Algorithms in Systems Engineering IE172. Midterm Review. Dr. Ted Ralphs Algorithms in Systems Engineering IE172 Midterm Review Dr. Ted Ralphs IE172 Midterm Review 1 Textbook Sections Covered on Midterm Chapters 1-5 IE172 Review: Algorithms and Programming 2 Introduction to

More information

Divisibility Rules and Their Explanations

Divisibility Rules and Their Explanations Divisibility Rules and Their Explanations Increase Your Number Sense These divisibility rules apply to determining the divisibility of a positive integer (1, 2, 3, ) by another positive integer or 0 (although

More information

s(n) An Arithmetic Function of Some Interest, and Related Arithmetic

s(n) An Arithmetic Function of Some Interest, and Related Arithmetic s(n) An Arithmetic Function of Some Interest, and Related Arithmetic Gideon Samid, PhD samidg@tx.technion.ac.il Abstract: Every integer n > 0 є N defines an increasing monotonic series of integers: n 1,

More information

p x i 1 i n x, y, z = 2 x 3 y 5 z

p x i 1 i n x, y, z = 2 x 3 y 5 z 3 Pairing and encoding functions Our aim in this part of the course is to show that register machines can compute everything that can be computed, and to show that there are things that can t be computed.

More information

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions): CS 70 Discrete Mathematics for CS Spring 2005 Clancy/Wagner Notes 7 This lecture returns to the topic of propositional logic. Whereas in Lecture Notes 1 we studied this topic as a way of understanding

More information

6.001 Notes: Section 8.1

6.001 Notes: Section 8.1 6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything

More information

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

6.080 / Great Ideas in Theoretical Computer Science Spring 2008 MIT OpenCourseWare http://ocw.mit.edu 6.8 / 6.89 Great Ideas in Theoretical Computer Science Spring 28 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

More information

6.001 Notes: Section 15.1

6.001 Notes: Section 15.1 6.001 Notes: Section 15.1 Slide 15.1.1 Our goal over the next few lectures is to build an interpreter, which in a very basic sense is the ultimate in programming, since doing so will allow us to define

More information

2. CONNECTIVITY Connectivity

2. CONNECTIVITY Connectivity 2. CONNECTIVITY 70 2. Connectivity 2.1. Connectivity. Definition 2.1.1. (1) A path in a graph G = (V, E) is a sequence of vertices v 0, v 1, v 2,..., v n such that {v i 1, v i } is an edge of G for i =

More information

1 Introduction. 2 InsertionSort. 2.1 Correctness of InsertionSort

1 Introduction. 2 InsertionSort. 2.1 Correctness of InsertionSort CS 161, Lecture 2 MergeSort, Recurrences 101, and Asymptotic Analysis Scribes: Michael Kim (2015), Ofir Geri (2016), M. Wootters (2017) Date: September 27, 2017 Adapted From Virginia Williams lecture notes

More information

ISA 562: Information Security, Theory and Practice. Lecture 1

ISA 562: Information Security, Theory and Practice. Lecture 1 ISA 562: Information Security, Theory and Practice Lecture 1 1 Encryption schemes 1.1 The semantics of an encryption scheme. A symmetric key encryption scheme allows two parties that share a secret key

More information

AXIOMS OF AN IMPERATIVE LANGUAGE PARTIAL CORRECTNESS WEAK AND STRONG CONDITIONS. THE AXIOM FOR nop

AXIOMS OF AN IMPERATIVE LANGUAGE PARTIAL CORRECTNESS WEAK AND STRONG CONDITIONS. THE AXIOM FOR nop AXIOMS OF AN IMPERATIVE LANGUAGE We will use the same language, with the same abstract syntax that we used for operational semantics. However, we will only be concerned with the commands, since the language

More information

SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY. Lecture 11 CS2110 Spring 2016

SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY. Lecture 11 CS2110 Spring 2016 1 SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY Lecture 11 CS2110 Spring 2016 Time spent on A2 2 Histogram: [inclusive:exclusive) [0:1): 0 [1:2): 24 ***** [2:3): 84 ***************** [3:4): 123 *************************

More information

Snowflake Numbers. A look at the Collatz Conjecture in a recreational manner. By Sir Charles W. Shults III

Snowflake Numbers. A look at the Collatz Conjecture in a recreational manner. By Sir Charles W. Shults III Snowflake Numbers A look at the Collatz Conjecture in a recreational manner By Sir Charles W. Shults III For many people, mathematics is something dry and of little interest. I ran across the mention of

More information

MATH Iris Loeb.

MATH Iris Loeb. MATH 134 http://www.math.canterbury.ac.nz/math134/09/su1/c Iris Loeb I.Loeb@math.canterbury.ac.nz Office Hours: Thur 10.00-11.00, Room 703 (MSCS Building) The Limits of Formal Logic We now turn our attention

More information

Week - 01 Lecture - 03 Euclid's Algorithm for gcd. Let us continue with our running example of gcd to explore more issues involved with program.

Week - 01 Lecture - 03 Euclid's Algorithm for gcd. Let us continue with our running example of gcd to explore more issues involved with program. Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 01 Lecture - 03 Euclid's Algorithm

More information

6.001 Notes: Section 6.1

6.001 Notes: Section 6.1 6.001 Notes: Section 6.1 Slide 6.1.1 When we first starting talking about Scheme expressions, you may recall we said that (almost) every Scheme expression had three components, a syntax (legal ways of

More information

(Refer Slide Time 3:31)

(Refer Slide Time 3:31) Digital Circuits and Systems Prof. S. Srinivasan Department of Electrical Engineering Indian Institute of Technology Madras Lecture - 5 Logic Simplification In the last lecture we talked about logic functions

More information

P Is Not Equal to NP. ScholarlyCommons. University of Pennsylvania. Jon Freeman University of Pennsylvania. October 1989

P Is Not Equal to NP. ScholarlyCommons. University of Pennsylvania. Jon Freeman University of Pennsylvania. October 1989 University of Pennsylvania ScholarlyCommons Technical Reports (CIS) Department of Computer & Information Science October 1989 P Is Not Equal to NP Jon Freeman University of Pennsylvania Follow this and

More information

2SKILL. Variables Lesson 6. Remembering numbers (and other stuff)...

2SKILL. Variables Lesson 6. Remembering numbers (and other stuff)... Remembering numbers (and other stuff)... Let s talk about one of the most important things in any programming language. It s called a variable. Don t let the name scare you. What it does is really simple.

More information

CITS3001. Algorithms, Agents and Artificial Intelligence. Semester 2, 2016

CITS3001. Algorithms, Agents and Artificial Intelligence. Semester 2, 2016 CITS3001 Algorithms, Agents and Artificial Intelligence Semester 2, 2016 Tim French School of Computer Science & Software Eng. The University of Western Australia 2. Review of algorithmic concepts CLRS,

More information

GRAPH THEORY: AN INTRODUCTION

GRAPH THEORY: AN INTRODUCTION GRAPH THEORY: AN INTRODUCTION BEGINNERS 3/4/2018 1. GRAPHS AND THEIR PROPERTIES A graph G consists of two sets: a set of vertices V, and a set of edges E. A vertex is simply a labeled point. An edge is

More information

Reliable programming

Reliable programming Reliable programming How to write programs that work Think about reliability during design and implementation Test systematically When things break, fix them correctly Make sure everything stays fixed

More information

Discrete Math in CS Problem Set 3 CS 280 Fall 2005 Due September 23, 2005

Discrete Math in CS Problem Set 3 CS 280 Fall 2005 Due September 23, 2005 Discrete Math in CS Problem Set 3 CS 280 Fall 2005 Due September 23, 2005 Reading: Rosen, Sections 2.4-2.6. As in previous problem sets, some of the questions present claims, and ask you to decide whether

More information

Denotational semantics

Denotational semantics 1 Denotational semantics 2 What we're doing today We're looking at how to reason about the effect of a program by mapping it into mathematical objects Specifically, answering the question which function

More information

Section 1.1 Definitions and Properties

Section 1.1 Definitions and Properties Section 1.1 Definitions and Properties Objectives In this section, you will learn to: To successfully complete this section, you need to understand: Abbreviate repeated addition using Exponents and Square

More information

Excerpt from "Art of Problem Solving Volume 1: the Basics" 2014 AoPS Inc.

Excerpt from Art of Problem Solving Volume 1: the Basics 2014 AoPS Inc. Chapter 5 Using the Integers In spite of their being a rather restricted class of numbers, the integers have a lot of interesting properties and uses. Math which involves the properties of integers is

More information

the Computability Hierarchy

the Computability Hierarchy 2013 0 the Computability Hierarchy Eric Hehner Department of Computer Science, University of Toronto hehner@cs.utoronto.ca Abstract A computability hierarchy cannot be constructed by halting oracles. Introduction

More information

Topic 1: What is HoTT and why?

Topic 1: What is HoTT and why? Topic 1: What is HoTT and why? May 5, 2014 Introduction Homotopy type theory (HoTT) is a newly emerging field of mathematics which is currently being developed as a foundation of mathematics which is in

More information

CS40-S13: Functional Completeness

CS40-S13: Functional Completeness CS40-S13: Functional Completeness Victor Amelkin victor@cs.ucsb.edu April 12, 2013 In class, we have briefly discussed what functional completeness means and how to prove that a certain system (a set)

More information

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/18/14

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/18/14 600.363 Introduction to Algorithms / 600.463 Algorithms I Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/18/14 23.1 Introduction We spent last week proving that for certain problems,

More information

Simple Graph. General Graph

Simple Graph. General Graph Graph Theory A graph is a collection of points (also called vertices) and lines (also called edges), with each edge ending at a vertex In general, it is allowed for more than one edge to have the same

More information

Concepts of programming languages

Concepts of programming languages Concepts of programming languages Lecture 5 Wouter Swierstra 1 Announcements Submit your project proposal to me by email on Friday; The presentation schedule in now online Exercise session after the lecture.

More information

Chapter Summary. Mathematical Induction Recursive Definitions Structural Induction Recursive Algorithms

Chapter Summary. Mathematical Induction Recursive Definitions Structural Induction Recursive Algorithms Chapter Summary Mathematical Induction Recursive Definitions Structural Induction Recursive Algorithms Section 5.1 Sec.on Summary Mathematical Induction Examples of Proof by Mathematical Induction Mistaken

More information

(Refer Slide Time: 01:01)

(Refer Slide Time: 01:01) Principles of Programming Languages Dr. S. Arun Kumar Department of Computer Science & Engineering Indian Institute of Technology, Delhi Lecture - 32 Monomorphism Welcome to lecture 32. So today I will

More information

CONNECTED SPACES AND HOW TO USE THEM

CONNECTED SPACES AND HOW TO USE THEM CONNECTED SPACES AND HOW TO USE THEM 1. How to prove X is connected Checking that a space X is NOT connected is typically easy: you just have to find two disjoint, non-empty subsets A and B in X, such

More information

Propositional Logic Formal Syntax and Semantics. Computability and Logic

Propositional Logic Formal Syntax and Semantics. Computability and Logic Propositional Logic Formal Syntax and Semantics Computability and Logic Syntax and Semantics Syntax: The study of how expressions are structured (think: grammar) Semantics: The study of the relationship

More information

(Refer Slide Time: 00:01:30)

(Refer Slide Time: 00:01:30) Digital Circuits and Systems Prof. S. Srinivasan Department of Electrical Engineering Indian Institute of Technology, Madras Lecture - 32 Design using Programmable Logic Devices (Refer Slide Time: 00:01:30)

More information

(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1

(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1 CS 70 Discrete Mathematics for CS Fall 2000 Wagner MT1 Sol Solutions to Midterm 1 1. (16 pts.) Theorems and proofs (a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are

More information

Figure 4.1: The evolution of a rooted tree.

Figure 4.1: The evolution of a rooted tree. 106 CHAPTER 4. INDUCTION, RECURSION AND RECURRENCES 4.6 Rooted Trees 4.6.1 The idea of a rooted tree We talked about how a tree diagram helps us visualize merge sort or other divide and conquer algorithms.

More information

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS 1 THE FORMALIZATION OF MATHEMATICS by Harvey M. Friedman Ohio State University Department of Mathematics friedman@math.ohio-state.edu www.math.ohio-state.edu/~friedman/ May 21, 1997 Can mathematics be

More information

CSC 501 Semantics of Programming Languages

CSC 501 Semantics of Programming Languages CSC 501 Semantics of Programming Languages Subtitle: An Introduction to Formal Methods. Instructor: Dr. Lutz Hamel Email: hamel@cs.uri.edu Office: Tyler, Rm 251 Books There are no required books in this

More information

Introduction to Programming

Introduction to Programming CHAPTER 1 Introduction to Programming Begin at the beginning, and go on till you come to the end: then stop. This method of telling a story is as good today as it was when the King of Hearts prescribed

More information

Propositional Logic. Part I

Propositional Logic. Part I Part I Propositional Logic 1 Classical Logic and the Material Conditional 1.1 Introduction 1.1.1 The first purpose of this chapter is to review classical propositional logic, including semantic tableaux.

More information

6.001 Notes: Section 1.1

6.001 Notes: Section 1.1 6.001 Notes: Section 1.1 Slide 1.1.1 This first thing we need to do is discuss the focus of 6.001. What is this course all about? This seems quite obvious -- this is a course about computer science. But

More information

Order from Chaos. Nebraska Wesleyan University Mathematics Circle

Order from Chaos. Nebraska Wesleyan University Mathematics Circle Order from Chaos Nebraska Wesleyan University Mathematics Circle Austin Mohr Department of Mathematics Nebraska Wesleyan University February 2, 20 The (, )-Puzzle Start by drawing six dots at the corners

More information

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1 Introduction to Automata Theory BİL405 - Automata Theory and Formal Languages 1 Automata, Computability and Complexity Automata, Computability and Complexity are linked by the question: What are the fundamental

More information

Guidelines for Writing Mathematical Proofs

Guidelines for Writing Mathematical Proofs Appendix A Guidelines for Writing Mathematical Proofs One of the most important forms of mathematical writing is writing mathematical proofs. The writing of mathematical proofs is an acquired skill and

More information

A computer implemented philosophy of mathematics

A computer implemented philosophy of mathematics A computer implemented philosophy of mathematics M. Randall Holmes May 14, 2018 This paper presents a philosophical view of the basic foundations of mathematics, which is implemented in actual computer

More information