CS 5 Nightly Wrapup College Canceled

Size: px
Start display at page:

Download "CS 5 Nightly Wrapup College Canceled"

Transcription

1 CS 5 Nightly Wrapup College Canceled Claremont (The Student Life): The administrators of Harvey Mudd College announced today that the entire institution had been canceled. Classes will terminate immediately. We realized that there is a much better economic model, explained President G. Reedy. We will continue to accept students, and the tuition will remain the same. After four years of paying tuition, the students will be awarded a degree, just as in previous years. The only difference will be that we won t hold classes. That will give the students more time for the pursuits they love, like video gaming, dancing, partying, and setting things on fire, without harming their chances of getting a lucrative job after they get their degree. When asked what the faculty would be doing, President Reedy smiled. That s the best part! he exclaimed. We ll finally be rid of the pesky critters. No penguins could be reached for comment.

2 cmp hc cmp(5) == 17 hc(cs5) == True Two uncomputable functions these would be useful - if only they were possible PLAN! Friday: final project due (by 8pm) come to labs for f.p. help! 2: final exam

3 All known and imagined computers can compute only what Turing Machines can... Quantum computation Molecular computation Parallel computers Integrated circuits Electromechanical computation Water-based computation Tinkertoy computation Turing Machines! though some are faster than others

4 TM's can do everything though not fast but Useful, FMs + but TMs limited can ~ get unruly pretty fast! can't count Finite State Machines 0 s0 1 s1 0 1 Universal definition of what can be computed Turing Machines Extra #1!

5 TM's can do everything but only everything that can be computed! There are surprisingly many mathematical functions that no program, computer, or Turing Machine can compute! TM Now that's a frustrating program to debug! You can certainly write programs for them, but those programs provably have at least one bug! And, fixing the bug necessarily creates more!

6 (Many) more functions than programs! the Reals from 0 to 1 Positive integers Uncountably infinite > Countably infinite This is how many int-bool functions there are. This is how many programs there are.

7 Cantor and "friends" "Charlatan" "Renegade" "Corrupter of Youth" "Laughable and wrong" "Utter nonsense" No one shall expel us from the paradise that Cantor has created. And this was before 1900! Leopold Kronecker Lugwig Wittgenstein David Hilbert

8 Let's get real the reals (from 0 to 1) { 0.0 <= r <= 1.0 } Are these sets equal-sized? the integers (positive) { 1, 2, 3, 4, 5, } Why is this NOT a valid matching? Essence? Finite patterns!

9 Cantor Diagonalization From any list, there are always real #s missing! the Reals from 0 to 1 Positive integers real #s are always missing r = 0 4 if r i [i]!= 4 else 2 r = matching regardless of the 1 r = r = r = r =

10 more functions than programs uncountably many functions Well-defined mathematical functions (uncountable) Wow ~ I can't even describe the stuff out here! What's swimming around out here? Programs (countable) countably many programs

11 more functions than programs uncountably many functions Well-defined mathematical functions (uncountable) Wow ~ I can't even describe the stuff out here! What's swimming around out here? Programs (countable) countably many programs Humandescribable things

12 more functions than programs uncountably many functions Well-defined mathematical functions (uncountable) Wow ~ I can't even describe the stuff out here! What's swimming around out here? Programs (countable) countably many programs cmp hc Humandescribable things Next

13 But what's a specific function that can't be computed!? an example!? it's computable! anything expressed w/math it's programmable! any describable pattern the complexity of an integer

14 What is the complexity of an integer? 100 zeros total each of these integers has the same # of digits same number of total digits as above **105 Which "feels like" the more complex - or more compressible - number... Why?

15 What is the complexity of an integer? 100 zeros total each of these integers has the same # of digits Intuition: The complexity or compressibility of x is the length of the shortest description of x. same number of total digits as above Which "feels like" the more complex - or more compressible - number... Why?

16 Inputs a "googol" a "googolplex" total zeros googol total zeros 27 Outputs This green function seems alien!!!

17 Inputs a "googol" a "googolplex" total zeros googol total zeros Output s The complexity, cmp, of an integer x is the length of x's shortest description

18 The complexity of x, cmp(x), is the length of the shortest zero-input function that outputs x. "description" The complexity, cmp, of an integer x is the length of x's shortest description

19 The complexity of x, cmp(x), is the length of the shortest zero-input function that outputs x. "description" Kolmogorov Complexity cmp( 42 ) = 18 So, 42 has a complexity of 18. Why 18?

20 Thanks, Neel!

21

22 The complexity of x, cmp(x), is the length of the shortest zero-input function that outputs x. "description" Kolmogorov Complexity cmp( 42 ) = 18 def f(): return because, Python has 16 characters of overhead and 2 more are needed

23 5 17 Inputs Output (x) s cmp(x) def f(): return Python has 16 characters of overhead, so cmp(100) is 19

24 5 17 Inputs Output (x) s cmp(x) def f(): return Python has 16 characters of overhead, so cmp(1000) is 20

25 5 17 Inputs Output (x) s cmp(x) def f(): return Python has 16 characters of overhead, so cmp(10000) is 21

26 5 17 Inputs Output (x) s cmp(x) ? def f(): return Python has 16 characters of overhead, but we can do better here!

27 Inputs (x) Output s cmp(x) 10**5 def f(): return Python has 16 characters of overhead, and cmp(100000) is also 21

28 cmp(42) = = 18 cmp(9001) = 16 + = 20 cmp( )= 6 zeros a million 16 + Worksheet! What does cmp(x)return for each of these integers, x? cmp( )= a million and cmp( ) = 1 googol zeros a googolplex 16 + cmp( )= 9 zeros a billion 16 + cmp( ) = 1 billion digits of pi, as an integer 16 + just estimate this one cmp( )= 100 zeros a googol 16 + cmp( ) = 1 thousand patternless digits 16 + Extra: What's the largest x with cmp(x) == 20? Extra Extra: Are there any integers x with cmp(x) > 1,000,000? Extra Extra Extra! How big is the SMALLEST such integer?

29 cmp(42) = = 18 cmp(9001) = = 20 cmp( )= cmp( )= 10**6+42 cmp( )= 9 zeros a million and 42 a billion cmp( )= 100 zeros a googol Extra: What's the largest x with cmp(x) == 20? 9**9 6 zeros a million vs. 10** **9 10** = 21 whoa! 16 + = 21 = 23 = 23 What does cmp(x)return for each of these integers, x? cmp( ) = 1 googol zeros a googolplex 10**10**100 cmp( ) = 1 billion digits of pi, as an integer cmp( ) = 1 thousand patternless digits just estimate this one 16 + Extra Extra: Are there any integers x with cmp(x) > 1,000,000? yes! Extra Extra Extra! How big is the SMALLEST such integer? 100 for i in range(10**10**100): throwdart() [through all 1,000 digits] = 27

30 cmp(42) = = 18 cmp(9001) = = 20 cmp( )= cmp( )= 10** zeros a million vs. cmp( )= 9 zeros 10**6 a million and a billion 10**9 cmp( )= 100 zeros a googol 10** = 21 whoa! 16 + Try this on the back page first... = 21 = 23 = 23 What does cmp(x)return for each of these integers, x? cmp( ) = 1 googol zeros a googolplex 10**10**100 cmp( ) = 1 billion digits of pi, as an integer cmp( ) = 1 thousand patternless digits Quiz! just estimate this one for i in range(10**10**100): throwdart() [through all 1,000 digits] = 27 Extra: What's the largest x with cmp(x) == 20? 9**9 Extra Extra: Are there any integers x with cmp(x) > 1,000,000? Yes, a LOT! Extra Extra Extra! How big is the SMALLEST such integer? Sorry...

31 Although cmp(x) is a well-defined mathematical function, with an int output for each int input x, cmp(x) the complexity of x the compressability of x is not a programmable function. all of its programs have bugs! This is a function that we will prove can't be programmed How!?

32 Although cmp(x) is a well-defined mathematical function, with an int output for each int input x, cmp(x) is not a programmable function. the complexity of x the compressability of x all of its programs have bugs! You'll show every possible program for cmp has a bug! you This is a function that we will prove can't be programmed How!?

33 Although cmp(x) is a well-defined mathematical function, with an int output for each int input x, cmp(x) is not a computable function. the complexity of x the compressability of x all of its programs have bugs! You'll show every possible program for cmp has a bug! you This is a function that we will prove can't be programmed How!?

34 cmp version #1 We know cmp(5)==17, so we propose this: def cmp( x ) return x+12 Looks good to me! bug(s)?

35 cmp version #1 We know cmp(5)==17, so we propose this: def cmp( x ) return x+12 Aargh! No 42! cmp(42) should be 18. Find a bug: But our cmp(42) outputs 60. it's not colon-y! no docstring! This cmp has a bug! (actually, LOTS of bugs!)

36 cmp version #2 We know cmp(x) is 16+, so, let's try this: def cmp( x ): return 16 + len(str(x)) It works for 5, 42, and 47! bug(s)?

37 cmp version #2 We know cmp(x) is 16+, so, let's try this: def cmp( x ): return 16 + len(str(x)) It works for 5, 42, and 47! Find a bug: cmp(100000) is actually 21. But, this cmp(100000) isn't digits because 10**5 it's 22 So, this cmp also has a bug! (lots, in fact )

38 cmp ~ any version Aargh! Let's try this cmp(x): def cmp( x ): do stuff and then return answer I guess you'd call this part of the code a GRAY AREA

39 cmp ~ any version Aargh! Let's try this cmp(x): def cmp( x ): do stuff and then return answer I guess you'd call this part of the code a GRAY AREA The challenge: we have to find a bug in any possible version of cmp(x)!

40 def cmp( x ): do stuff and then return answer This version of cmp is 900,000 chars long and claims to return the complexity of x We need to prove that this cmp(x) function contains a bug. We're going to write a function to find and show that bug!

41 def BFF(): def cmp( x ): do stuff and then return answer x = 0 while cmp(x) < : x += 1 return x This version of cmp is 900,000 chars long and claims to return the complexity of x bug = BFF() BFF?

42 def BFF(): def cmp( x ): do stuff and then return answer x = 0 while cmp(x) < : x += 1 return x This version of cmp is 900,000 chars long and claims to return the complexity of x bug = BFF() BFF? Bug-Finding Function!

43 def BFF(): def cmp( x ): do stuff and then return answer x = 0 while cmp(x) < : x += 1 return x bug = BFF() This version of cmp is 900,000 chars long and claims to return the complexity of x Note that BFF is a zero-input function that is 900,058 characters long and it returns an integer, bug! yet...

44 def BFF(): def cmp( x ): do stuff and then return answer x = 0 while cmp(x) < : x += 1 return x bug = BFF() This version of cmp is 900,000 chars long and claims to return the complexity of x Note: this loop checks cmp(x), not x itself. (1) When does this while loop stop? [A] when cmp(x)< 1,000,000 or [B] when cmp(x)>= 1,000,000 or [C] it never stops (2) The while ensures the x BFF returns is [T] an int x with complexity < 1,000,000 [U] an int x with complexity >= 1,000,000 [V] nothing x is never returned at all (1) (2) Proof (3) Why does this mean cmp has a bug? [F] because x!= bug [G] BFF shows bug's complexity is 900,058 or less! [H] there were no three-eyed aliens involved -) (3)

45 def BFF(): def cmp( x ): do stuff and then return answer This version of cmp is 900,000 chars long and claims to return the complexity of x x = 0 while cmp(x) < : x += 1 return x bug = BFF() zero-input f'n of size less than a million Even this implementation of cmp(x) contains a bug! but, we allowed it to do anything at all! number with complexity ver a million! cmp failed! so, every implementation of cmp(x) contains a bug!

46 Although cmp(x) is a well-defined mathematical function, with an int output for each int input x, cmp(x) is not a computable function. cmp(x) can't be debugged! proven!

47 Compression connection? The best-compressed version of any data D is the shortest program that generates D.

48 Compression connection? The best-compressed version of any data D is the shortest program that generates D. An impressive compression result!

49 Compression connection? The best-compressed version of any data D is the shortest program that generates D. best-compressed version? Uncomputable!

50 XkcD Kolmogorov Complexity?

51 insight? Some infinite patterns/functions have finite descriptions. - they're all programmable/ computable More infinite patterns/functions do not have finite descriptions. - they're not programmable/computable

52 insight? not all infinities are created equal! Some infinite patterns/functions have finite descriptions. - they're all programmable/ computable More infinite patterns/functions do not have finite descriptions. - they're not programmable/computable

53 Two useful functions that provably can't be computed cmp( x ) Kolmogorov Complexity ~ the complexity of an integer x (compressibility) hc( f ) Halt Checking ~ does f() halt or loop forever?

54 Haltchecking is uncomputable. hc( f ) Halt Checking ~ returns whether f() halts or not hc always has a bug!

55 Haltchecking is uncomputable. any Python function def hc( f ): It is impossible to write a (bug-free) function hc(f) that determines if a function f halts when run: hc(f) returns True if f() halts and hc(f) returns False if f() loops infinitely

56 Suppose hc(f) worked for all f Create this BFF: def BFF(): if hc(bff) == True: while 1+1==2: print 'Ha!' else: return # halt! Is hc(bff) == True? Is hc(bff) == False? hc always has a bug Proven!

57 And this is important because

58 And this is important because loops are undetectable some are detectable, but some are not and there's no way to know!

59 And this is important because loops are undetectable some are detectable, but some are not and there's no way to know! bugs are inevitable infinite loops are just one type of bug In general, they're all undetectable ~ all behavioral, not syntactic, bugs Rice's Theorem: CS81

60 And this is important because loops are undetectable some are detectable, but some are not and there's no way to know! bugs are inevitable infinite loops are just one type of bug In general, they're all undetectable ~ all behavioral, not syntactic, bugs Rice's Theorem: CS81 programming is not automatable at least, not bug-free programming

61 xkcd's take is all too True, in fact. Good luck with final projects They will halt all too soon! Tutoring hours and labs through Friday...!

62 CS5 Black Worksheet Name: Date:

The CS 5 Post ALIEN INVASION!!!

The CS 5 Post ALIEN INVASION!!! The CS 5 Post ALIEN INVASION!!! Claremont (AP): A party at a private college here was disrupted when uninvited aliens burst through the gates. Every year, we celebrate Long Tall Penguins, explained an

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

CS103 Spring 2018 Mathematical Vocabulary

CS103 Spring 2018 Mathematical Vocabulary CS103 Spring 2018 Mathematical Vocabulary You keep using that word. I do not think it means what you think it means. - Inigo Montoya, from The Princess Bride Consider the humble while loop in most programming

More information

CS103 Handout 50 Fall 2018 November 30, 2018 Problem Set 9

CS103 Handout 50 Fall 2018 November 30, 2018 Problem Set 9 CS103 Handout 50 Fall 2018 November 30, 2018 Problem Set 9 What problems are beyond our capacity to solve? Why are they so hard? And why is anything that we've discussed this quarter at all practically

More information

Turing Machines Part Two

Turing Machines Part Two Turing Machines Part Two Recap from Last Time The Turing Machine A Turing machine consists of three parts: A finite-state control that issues commands, an infinite tape for input and scratch space, and

More information

Lambda Calculus and Computation

Lambda Calculus and Computation 6.037 Structure and Interpretation of Computer Programs Chelsea Voss csvoss@mit.edu Massachusetts Institute of Technology With material from Mike Phillips and Nelson Elhage February 1, 2018 Limits to Computation

More information

Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D.

Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D. Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D. Ullman And Introduction to Languages and The by J. C. Martin Basic Mathematical

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

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

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

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

Exam 2. cs3102: Theory of Computation. Class 20: Busy Beavers

Exam 2. cs3102: Theory of Computation. Class 20: Busy Beavers cs3102: Theory of Computation Office hours: I am not able to hold my Thursday morning office hours this week. I will have office hours Thursday 11am-1pm instead. Class 20: usy eavers Spring 2010 University

More information

Skill 1: Multiplying Polynomials

Skill 1: Multiplying Polynomials CS103 Spring 2018 Mathematical Prerequisites Although CS103 is primarily a math class, this course does not require any higher math as a prerequisite. The most advanced level of mathematics you'll need

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

Nagual and Tonal Maths: Numbers, Sets, and Processes. Lukas A. Saul Oxford, England May, 2015

Nagual and Tonal Maths: Numbers, Sets, and Processes. Lukas A. Saul Oxford, England May, 2015 Nagual and Tonal Maths: Numbers, Sets, and Processes Lukas A. Saul Oxford, England May, 2015 Abstract: Some definitions and elementary theorems are given here describing tonal and nagual numbers, sets,

More information

MITOCW watch?v=sdw8_0rdzuw

MITOCW watch?v=sdw8_0rdzuw MITOCW watch?v=sdw8_0rdzuw PROFESSOR: Directed acyclic graphs are a special class of graphs that really have and warrant a theory of their own. Of course, "directed acyclic graphs" is lot of syllables,

More information

Computational Complexity and Implications for Security DRAFT Notes on Infeasible Computation for MA/CS 109 Leo Reyzin with the help of Nick Benes

Computational Complexity and Implications for Security DRAFT Notes on Infeasible Computation for MA/CS 109 Leo Reyzin with the help of Nick Benes Computational Complexity and Implications for Security DRAFT Notes on Infeasible Computation for MA/CS 109 Leo Reyzin with the help of Nick Benes The Study of Computational Complexity Let s summarize what

More information

How convincing is our Halting Problem proof? Lecture 36: Modeling Computing. Solutions. DrScheme. What is a model? Modeling Computation

How convincing is our Halting Problem proof? Lecture 36: Modeling Computing. Solutions. DrScheme. What is a model? Modeling Computation Lecture 6: Modeling Computing How convincing is our Halting Problem proof? define contradict-halts x if halts? contradict-halts loop-forever t contradicts-halts cannot exist. Everything we used to make

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

Warmup : Name that tune!

Warmup : Name that tune! Warmup : Name that tune! Write, using a loop, Java code to print the lyrics to the song 99 Bottles of Beer on the Wall 99 bottles of beer on the wall. 99 bottles of beer. Take one down, pass it around,

More information

Introduction to CS. Welcome to CS 5! 1 handout. We don't have words strong enough to describe this class. Everyone will get out of this course a lot!

Introduction to CS. Welcome to CS 5! 1 handout. We don't have words strong enough to describe this class. Everyone will get out of this course a lot! Welcome to CS 5! Introduction to CS Wally Wart, a protrusive advocate of concrete computing We don't have words strong enough to describe this class. -US News and Course Report Everyone will get out of

More information

Time Complexity of an Algorithm

Time Complexity of an Algorithm CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 335] Time Complexity of an Algorithm Time complexity of an algorithm: the function T (n) that describes the (worst-case) running time

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

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

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

MITOCW watch?v=penh4mv5gag

MITOCW watch?v=penh4mv5gag MITOCW watch?v=penh4mv5gag PROFESSOR: Graph coloring is the abstract version of a problem that arises from a bunch of conflict scheduling situations. So let's look at an example first and then define the

More information

Computer Sciences Department

Computer Sciences Department 1 Reference Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER 3 D E C I D A B I L I T Y 4 Objectives 5 Objectives investigate the power of algorithms to solve problems.

More information

Comparing sizes of sets

Comparing sizes of sets Comparing sizes of sets Sets A and B are the same size if there is a bijection from A to B. (That was a definition!) For finite sets A, B, it is not difficult to verify that there is a bijection from A

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

Problems, Languages, Machines, Computability, Complexity

Problems, Languages, Machines, Computability, Complexity CS311 Computational Structures Problems, Languages, Machines, Computability, Complexity Lecture 1 Andrew P. Black Andrew Tolmach 1 The Geography Game Could you write a computer program to play the geography

More information

MITOCW watch?v=zm5mw5nkzjg

MITOCW watch?v=zm5mw5nkzjg MITOCW watch?v=zm5mw5nkzjg The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

More information

CONTENTS: While loops Class (static) variables and constants Top Down Programming For loops Nested Loops

CONTENTS: While loops Class (static) variables and constants Top Down Programming For loops Nested Loops COMP-202 Unit 4: Programming with Iterations Doing the same thing again and again and again and again and again and again and again and again and again... CONTENTS: While loops Class (static) variables

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 3.2, 3.3 Define variants of TMs Enumerators Multi-tape TMs Nondeterministic TMs

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

MITOCW watch?v=9h6muyzjms0

MITOCW watch?v=9h6muyzjms0 MITOCW watch?v=9h6muyzjms0 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

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

Graph Theory Part Two

Graph Theory Part Two Graph Theory Part Two Recap from Last Time A graph is a mathematical structure for representing relationships. Nodes A graph consists of a set of nodes (or vertices) connected by edges (or arcs) A graph

More information

Beyond programming. CS 199 Computer Science for Beginners Spring 2009 Lois Delcambre Week 5/12/2009 1

Beyond programming. CS 199 Computer Science for Beginners Spring 2009 Lois Delcambre Week 5/12/2009 1 Beyond programming CS 199 Computer Science for Beginners Spring 2009 Lois Delcambre Week 5/12/2009 1 Introduction We ve covered: Python data types Python expressions Python statements We ve written approximately

More information

COMP-202 Unit 4: Programming with Iterations

COMP-202 Unit 4: Programming with Iterations COMP-202 Unit 4: Programming with Iterations Doing the same thing again and again and again and again and again and again and again and again and again... CONTENTS: While loops Class (static) variables

More information

Name: CS 341 Practice Final Exam. 1 a 20 b 20 c 20 d 20 e 20 f 20 g Total 207

Name: CS 341 Practice Final Exam. 1 a 20 b 20 c 20 d 20 e 20 f 20 g Total 207 Name: 1 a 20 b 20 c 20 d 20 e 20 f 20 g 20 2 10 3 30 4 12 5 15 Total 207 CS 341 Practice Final Exam 1. Please write neatly. You will lose points if we cannot figure out what you are saying. 2. Whenever

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 Getting used to Python

1 Getting used to Python 1 Getting used to Python We assume you know how to program in some language, but are new to Python. We'll use Java as an informal running comparative example. Here are what we think are the most important

More information

CPSC 320 Midterm #1. February 4, 2015

CPSC 320 Midterm #1. February 4, 2015 CPSC 320 Midterm #1 February 4, 2015 1 2 Reminders (but do not miss the problem also on this page!): ˆ f(n) O(g(n)) (big-o, that is) exactly when there is a positive real constant c and positive integer

More information

Section 2.4 Sequences and Summations

Section 2.4 Sequences and Summations Section 2.4 Sequences and Summations Definition: A sequence is a function from a subset of the natural numbers (usually of the form {0, 1, 2,... } to a set S. Note: the sets and {0, 1, 2, 3,..., k} {1,

More information

Greedy Algorithms. Alexandra Stefan

Greedy Algorithms. Alexandra Stefan Greedy Algorithms Alexandra Stefan 1 Greedy Method for Optimization Problems Greedy: take the action that is best now (out of the current options) it may cause you to miss the optimal solution You build

More information

Notes on Turing s Theorem and Computability

Notes on Turing s Theorem and Computability 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

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

MATHEMATICS 191, FALL 2004 MATHEMATICAL PROBABILITY Outline #1 (Countability and Uncountability)

MATHEMATICS 191, FALL 2004 MATHEMATICAL PROBABILITY Outline #1 (Countability and Uncountability) MATHEMATICS 191, FALL 2004 MATHEMATICAL PROBABILITY Outline #1 (Countability and Uncountability) Last modified: September 16, 2004 Reference: Apostol, Calculus, Vol. 2, section 13.19 (attached). The aim

More information

Examples of P vs NP: More Problems

Examples of P vs NP: More Problems Examples of P vs NP: More Problems COMP1600 / COMP6260 Dirk Pattinson Australian National University Semester 2, 2017 Catch Up / Drop in Lab When Fridays, 15.00-17.00 Where N335, CSIT Building (bldg 108)

More information

MITOCW watch?v=ytpjdnlu9ug

MITOCW watch?v=ytpjdnlu9ug MITOCW watch?v=ytpjdnlu9ug The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality, educational resources for free.

More information

CSE 373: Data Structures and Algorithms

CSE 373: Data Structures and Algorithms CSE 373: Data Structures and Algorithms Lecture 2: Wrap up Queues, Asymptotic Analysis, Proof by Induction Instructor: Lilian de Greef Quarter: Summer 2017 Today: Announcements Wrap up Queues Begin Asymptotic

More information

CS 11 Haskell track: lecture 1

CS 11 Haskell track: lecture 1 CS 11 Haskell track: lecture 1 This week: Introduction/motivation/pep talk Basics of Haskell Prerequisite Knowledge of basic functional programming e.g. Scheme, Ocaml, Erlang CS 1, CS 4 "permission of

More information

CPSC 320 Sample Solution, Playing with Graphs!

CPSC 320 Sample Solution, Playing with Graphs! CPSC 320 Sample Solution, Playing with Graphs! September 23, 2017 Today we practice reasoning about graphs by playing with two new terms. These terms/concepts are useful in themselves but not tremendously

More information

Cantor s Diagonal Argument for Different Levels of Infinity

Cantor s Diagonal Argument for Different Levels of Infinity JANUARY 2015 1 Cantor s Diagonal Argument for Different Levels of Infinity Michael J. Neely University of Southern California http://www-bcf.usc.edu/ mjneely Abstract These notes develop the classic Cantor

More information

Computability Mechanizing Reasoning

Computability Mechanizing Reasoning 12 Computability However unapproachable these problems may seem to us and however helpless we stand before them, we have, nevertheless, the firm conviction that their solution must follow by a finite number

More information

Project 1. due date Sunday July 8, 2018, 12:00 noon

Project 1. due date Sunday July 8, 2018, 12:00 noon Queens College, CUNY, Department of Computer Science Object-oriented programming in C++ CSCI 211 / 611 Summer 2018 Instructor: Dr. Sateesh Mane c Sateesh R. Mane 2018 Project 1 due date Sunday July 8,

More information

CMPT 120 Control Structures in Python. Summer 2012 Instructor: Hassan Khosravi

CMPT 120 Control Structures in Python. Summer 2012 Instructor: Hassan Khosravi CMPT 120 Control Structures in Python Summer 2012 Instructor: Hassan Khosravi The If statement The most common way to make decisions in Python is by using the if statement. The if statement allows you

More information

MITOCW ocw f99-lec12_300k

MITOCW ocw f99-lec12_300k MITOCW ocw-18.06-f99-lec12_300k This is lecture twelve. OK. We've reached twelve lectures. And this one is more than the others about applications of linear algebra. And I'll confess. When I'm giving you

More information

Computer Science E-50a: Introduction to Computer Science Using Java, I Handout #7 part 2

Computer Science E-50a: Introduction to Computer Science Using Java, I Handout #7 part 2 Computer Science E-50a: Introduction to Computer Science Using Java, I Handout #7 part 2 part 2 These problems are due prior to the start of lecture on Monday night, March 31. Part A The Reading You may

More information

Intro. Comparisons. > x > y if and only if x is bigger than y. < x < y if and only if x is smaller than y.

Intro. Comparisons. > x > y if and only if x is bigger than y. < x < y if and only if x is smaller than y. Intro Recall that and are the two booleans in Python. It turns out they're pretty important. For instance, what if we want to do something, but only if a particular condition is? What if we want to repeat

More information

Section 1.7 Sequences, Summations Cardinality of Infinite Sets

Section 1.7 Sequences, Summations Cardinality of Infinite Sets Section 1.7 Sequences, Summations Cardinality of Infinite Sets Definition: A sequence is a function from a subset of the natural numbers (usually of the form {0, 1, 2,... } to a set S. Note: the sets and

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

Troubleshooting Maple Worksheets: Common Problems

Troubleshooting Maple Worksheets: Common Problems Troubleshooting Maple Worksheets: Common Problems So you've seen plenty of worksheets that work just fine, but that doesn't always help you much when your worksheet isn't doing what you want it to. This

More information

Express Yourself. The Great Divide

Express Yourself. The Great Divide CS 170 Java Programming 1 Numbers Working with Integers and Real Numbers Open Microsoft Word and create a new document Save the file as LastFirst_ic07.doc Replace LastFirst with your actual name Put your

More information

Introduction to Sets and Logic (MATH 1190)

Introduction to Sets and Logic (MATH 1190) Introduction to Sets and Logic () Instructor: Email: shenlili@yorku.ca Department of Mathematics and Statistics York University Dec 4, 2014 Outline 1 2 3 4 Definition A relation R from a set A to a set

More information

def F a c t o r i a l ( n ) : i f n == 1 : return 1 else : return n F a c t o r i a l ( n 1) def main ( ) : print ( F a c t o r i a l ( 4 ) )

def F a c t o r i a l ( n ) : i f n == 1 : return 1 else : return n F a c t o r i a l ( n 1) def main ( ) : print ( F a c t o r i a l ( 4 ) ) 116 4.5 Recursion One of the most powerful programming techniques involves a function calling itself; this is called recursion. It is not immediately obvious that this is useful; take that on faith for

More information

Administrivia. CMSC 216 Introduction to Computer Systems Lecture 24 Data Representation and Libraries. Representing characters DATA REPRESENTATION

Administrivia. CMSC 216 Introduction to Computer Systems Lecture 24 Data Representation and Libraries. Representing characters DATA REPRESENTATION Administrivia CMSC 216 Introduction to Computer Systems Lecture 24 Data Representation and Libraries Jan Plane & Alan Sussman {jplane, als}@cs.umd.edu Project 6 due next Friday, 12/10 public tests posted

More information

Does this program exist? Limits of computability. Does this program exist? A helper function. For example, if the string program is

Does this program exist? Limits of computability. Does this program exist? A helper function. For example, if the string program is Does this program exist? For example, if the string program is Limits of computability public void abc(string s) { if( s == "abc" ) { print "Hello world!"; } else { print "Whatever"; }} then test called

More information

Languages and Automata

Languages and Automata Languages and Automata What are the Big Ideas? Tuesday, August 30, 2011 Reading: Sipser 0.1 CS235 Languages and Automata Department of Computer Science Wellesley College Why Take CS235? 1. It s required

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

A Random Walk through CS70

A Random Walk through CS70 A Random Walk through CS70 CS70 Summer 2016 - Lecture 8B David Dinh 09 August 2016 UC Berkeley 1 Today (and tomorrow, and Wednesday) Review: what have we done in class? Future classes: where do you go

More information

6. Advanced Topics in Computability

6. Advanced Topics in Computability 227 6. Advanced Topics in Computability The Church-Turing thesis gives a universally acceptable definition of algorithm Another fundamental concept in computer science is information No equally comprehensive

More information

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch Purpose: We will take a look at programming this week using a language called Scratch. Scratch is a programming language that was developed

More information

Midterm CSE 21 Spring 2012

Midterm CSE 21 Spring 2012 Signature Name Student ID Midterm CSE 21 Spring 2012 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 _ (20 points) _ (15 points) _ (13 points) _ (23 points) _ (10 points) _ (8 points) Total _ (89 points) (84

More information

Finding and Fixing Bugs

Finding and Fixing Bugs C Finding and Fixing Bugs C.1 Introduction As you will quickly find the BUG is the pain of all programmers existence. This section looks at the most common types of BUGS and some of the strategies for

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

MITOCW watch?v=yarwp7tntl4

MITOCW watch?v=yarwp7tntl4 MITOCW watch?v=yarwp7tntl4 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality, educational resources for free.

More information

CS1 Lecture 2 Jan. 16, 2019

CS1 Lecture 2 Jan. 16, 2019 CS1 Lecture 2 Jan. 16, 2019 Contacting me/tas by email You may send questions/comments to me/tas by email. For discussion section issues, sent to TA and me For homework or other issues send to me (your

More information

TA hours and labs start today. First lab is out and due next Wednesday, 1/31. Getting started lab is also out

TA hours and labs start today. First lab is out and due next Wednesday, 1/31. Getting started lab is also out Announcements TA hours and labs start today. First lab is out and due next Wednesday, 1/31. Getting started lab is also out Get you setup for project/lab work. We ll check it with the first lab. Stars

More information

EECS 203 Spring 2016 Lecture 8 Page 1 of 6

EECS 203 Spring 2016 Lecture 8 Page 1 of 6 EECS 203 Spring 2016 Lecture 8 Page 1 of 6 Algorithms (3.1-3.3) Algorithms are a huge topic. In CSE we have 2 theory classes purely dedicated to algorithms (EECS 477 and EECS 586) and a number of classes

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

COS 109 Final Exam, Fall 2016

COS 109 Final Exam, Fall 2016 COS 109 Final Exam, Fall 2016 January 22, 2017 3 hours 180 points total Please PRINT your name here Honor Pledge: I pledge my honor that I have not violated the Honor Code during this examination. Please

More information

Computability, Cantor s diagonalization, Russell s Paradox, Gödel s s Incompleteness, Turing Halting Problem.

Computability, Cantor s diagonalization, Russell s Paradox, Gödel s s Incompleteness, Turing Halting Problem. Computability, Cantor s diagonalization, Russell s Paradox, Gödel s s Incompleteness, Turing Halting Problem. Advanced Algorithms By Me Dr. Mustafa Sakalli March, 06, 2012. Incompleteness. Lecture notes

More information

CS 151. Recursion (Review!) Wednesday, September 19, 12

CS 151. Recursion (Review!) Wednesday, September 19, 12 CS 151 Recursion (Review!) 1 Announcements no class on Friday, and no office hours either (Alexa out of town) unfortunately, Alexa will also just be incommunicado, even via email, from Wednesday night

More information

Extra Practice Problems 2

Extra Practice Problems 2 CS103 Handout 31 Fall 2018 October 29, 2018 Extra Practice Problems 2 Here's a set of a bunch of practice problems you can work through to solidify your understanding of the topics from Problem Sets Three,

More information

MITOCW ocw f99-lec07_300k

MITOCW ocw f99-lec07_300k MITOCW ocw-18.06-f99-lec07_300k OK, here's linear algebra lecture seven. I've been talking about vector spaces and specially the null space of a matrix and the column space of a matrix. What's in those

More information

The following content is provided under a Creative Commons license. Your support

The following content is provided under a Creative Commons license. Your support MITOCW Lecture 9 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To make a donation

More information

Software System Design and Implementation

Software System Design and Implementation Software System Design and Implementation Admin & Motivation & Some History Gabriele Keller Admin: Liam O Connor-Davies The University of New South Wales School of Computer Science and Engineering Sydney,

More information

Finite Automata Part Three

Finite Automata Part Three Finite Automata Part Three Recap from Last Time A language L is called a regular language if there exists a DFA D such that L( D) = L. NFAs An NFA is a Nondeterministic Finite Automaton Can have missing

More information

CS103 Handout 42 Spring 2017 May 31, 2017 Practice Final Exam 1

CS103 Handout 42 Spring 2017 May 31, 2017 Practice Final Exam 1 CS103 Handout 42 Spring 2017 May 31, 2017 Practice Final Exam 1 We strongly recommend that you work through this exam under realistic conditions rather than just flipping through the problems and seeing

More information

Outline for Today. How can we speed up operations that work on integer data? A simple data structure for ordered dictionaries.

Outline for Today. How can we speed up operations that work on integer data? A simple data structure for ordered dictionaries. van Emde Boas Trees Outline for Today Data Structures on Integers How can we speed up operations that work on integer data? Tiered Bitvectors A simple data structure for ordered dictionaries. van Emde

More information

English for Computer Science

English for Computer Science English for Computer Science Mohammad Farshi Department of Computer Science, Yazd University 1388-1389 (CS Dept. Yazd U.) Yazd Univ. English4CS 1388-1389 1 / 15 Azmoone 1389(CS) Azmoone 1389(CS) (CS Dept.

More information

The following content is provided under a Creative Commons license. Your support

The following content is provided under a Creative Commons license. Your support MITOCW Lecture 2 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To make a donation

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

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

A graph is a mathematical structure for representing relationships.

A graph is a mathematical structure for representing relationships. Graphs Part Two A graph is a mathematical structure for representing relationships. Nodes A graph consists of a set of nodes (or vertices) connected by edges (or arcs) A graph is a mathematical structure

More information

MITOCW watch?v=0jljzrnhwoi

MITOCW watch?v=0jljzrnhwoi MITOCW watch?v=0jljzrnhwoi The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

More information

The following content is provided under a Creative Commons license. Your support

The following content is provided under a Creative Commons license. Your support MITOCW Recitation 1 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To make

More information

A lot of people make repeated mistakes of not calling their functions and getting errors. Make sure you're calling your functions.

A lot of people make repeated mistakes of not calling their functions and getting errors. Make sure you're calling your functions. Handout 2 Functions, Lists, For Loops and Tuples [ ] Functions -- parameters/arguments, "calling" functions, return values, etc. Please make sure you understand this example: def square(x): return x *

More information