15-251. Great Theoretical Ideas in Computer Science



Similar documents
WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT?

15-251: Great Theoretical Ideas in Computer Science Anupam Gupta Notes on Combinatorial Games (draft!!) January 29, 2012

5544 = = = Now we have to find a divisor of 693. We can try 3, and 693 = 3 231,and we keep dividing by 3 to get: 1

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

CALCULUS COURSES AT THE COMPUTER SCIENCE FACULTY, THE UNIVERSITY OF INDONESIA

How to Study Mathematics Written by Paul Dawkins

Mathematical Induction

This material is intended for use by undergraduate students who are contemplating taking a course with me.

MTH124: Honors Algebra I

Answer: (a) Since we cannot repeat men on the committee, and the order we select them in does not matter, ( )

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Mathematical Induction. Mary Barnes Sue Gordon

6.042/18.062J Mathematics for Computer Science. Expected Value I

How to Pass Physics 212

What does student success mean to you?

Critical analysis. Be more critical! More analysis needed! That s what my tutors say about my essays. I m not really sure what they mean.

A Concrete Introduction. to the Abstract Concepts. of Integers and Algebra using Algebra Tiles

Sample Induction Proofs

Handout #1: Mathematical Reasoning

Access Code: RVAE4-EGKVN Financial Aid Code: 6A9DB-DEE3B-74F

Cryptography and Network Security Department of Computer Science and Engineering Indian Institute of Technology Kharagpur

Mathematical Induction

Student Guide and Syllabus for MAT100 Introductory Algebra

Solutions for Practice problems on proofs

An Innocent Investigation

Discrete Math in Computer Science Homework 7 Solutions (Max Points: 80)

Regular Languages and Finite Automata

SECTION 10-2 Mathematical Induction

136 CHAPTER 4. INDUCTION, GRAPHS AND TREES

Unit 12: Introduction to Factoring. Learning Objectives 12.2

B490 Mining the Big Data. 0 Introduction

Math 55: Discrete Mathematics

Math Workshop October 2010 Fractions and Repeating Decimals

A simple algorithm with no simple verication

Polynomials and Factoring. Unit Lesson Plan

Basic Proof Techniques

CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs

>> My name is Danielle Anguiano and I am a tutor of the Writing Center which is just outside these doors within the Student Learning Center.

CS 40 Computing for the Web

Would You Like To Earn $1000 s With The Click Of A Button?

3. Mathematical Induction

Automata and Formal Languages

THREE BIG NURSING SCHOOL MISTAKES YOU MIGHT BE MAKING

NP-Completeness and Cook s Theorem

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

Chapter 11 Number Theory

How to write proofs: a quick guide

6.080/6.089 GITCS Feb 12, Lecture 3

Answer Key for California State Standards: Algebra I

Review of Intermediate Algebra Content

EFFICIENTLY PREPARING A CASE FOR TRIAL ABA Distance CLE Teleconference January 12, A. I have previously presented a teleconference on

mod 10 = mod 10 = 49 mod 10 = 9.

The Right Stuff: How to Find Good Information

CS 103X: Discrete Structures Homework Assignment 3 Solutions

02-201: Programming for Scientists

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

CELC Benchmark Essays Set 3 Prompt:

GREEN CHICKEN EXAM - NOVEMBER 2012

Mathematical Induction. Lecture 10-11

SQUARE-SQUARE ROOT AND CUBE-CUBE ROOT

Static Program Transformations for Efficient Software Model Checking

CS 3719 (Theory of Computation and Algorithms) Lecture 4

If A is divided by B the result is 2/3. If B is divided by C the result is 4/7. What is the result if A is divided by C?

VISUAL ALGEBRA FOR COLLEGE STUDENTS. Laurie J. Burton Western Oregon University

Revised Version of Chapter 23. We learned long ago how to solve linear congruences. ax c (mod m)

Welcome to Introduction to programming in Python

Summation Algebra. x i

ASSIGNMENT POLICY SETTINGS & BEST PRACTICES

Probability Using Dice

Theorem (informal statement): There are no extendible methods in David Chalmers s sense unless P = NP.

SEO Education 101. By Matt Bush. Visit for the latest internet marketing tips and tactics

MATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1.

CS 1340 Sec. A Time: 8:00AM, Location: Nevins Instructor: Dr. R. Paul Mihail, 2119 Nevins Hall, rpmihail@valdosta.

1. The RSA algorithm In this chapter, we ll learn how the RSA algorithm works.

Math 4310 Handout - Quotient Vector Spaces

Teaching Public Speaking Online

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

COURSE DESCRIPTION. Required Course Materials COURSE REQUIREMENTS

Recursive Algorithms. Recursion. Motivating Example Factorial Recall the factorial function. { 1 if n = 1 n! = n (n 1)! if n > 1

Sin #1 - Not Establishing a Clear and Realistic Goal

Study Strategies Used By Successful Students

CS 1133, LAB 2: FUNCTIONS AND TESTING

Encoding Text with a Small Alphabet

The program also provides supplemental modules on topics in geometry and probability and statistics.

This chapter is all about cardinality of sets. At first this looks like a

1 Construction of CCA-secure encryption

9.2 Summation Notation

How to Make Sure Your Talk Doesn t Suck. David Tong

Colored Hats and Logic Puzzles

Collaborative Learning in a Design Course

Marketing for Martial Arts Schools:

A Few Basics of Probability

Stanford Math Circle: Sunday, May 9, 2010 Square-Triangular Numbers, Pell s Equation, and Continued Fractions

TEST-TAKING STRATEGIES FOR READING

Proseminar on Semantic Theory Fall 2013 Ling 720. Problem Set on the Formal Preliminaries : Answers and Notes

Factoring & Primality

Spring 2015 Syllabus for ENG : Writing Experience I

Transcription:

15-251 Great Theoretical Ideas in Computer Science

15-251 Course Evaluations: sadistic Student Comments 251 is like: we re gonna kick your ass and you re gonna enjoy it. And we did! Awesome, despite soul-crushing homework Von Ahn mocked Intelligent Design in one of the first lectures, which deeply offended me von Ahn > Chuck Norris

Some 15-251 Great Theoretical Ideas in Computer Science for www.cs.cmu.edu/~15251

Course Staff Instructors Luis von Ahn Anupam Gupta TAs Anton Bachin Drew Besse Michelle Burroughs Andrew Krieger Alan Pierce Daniel Schafer Nicholas Tan David Yang

Grading Homework 35% Final 25% Participation 5% 3 In-Recitation Tests 30% In-Class Quizzes 5%

Dr. von Ahn, I know my grade is a 42/100, and according to the class Web site that is an F. Is there an alternative grading scheme by which I can get a C? Dear X, As a matter of fact, there are infinitely many alternative grading schemes by which you would get a C with a 42/100. Unfortunately for you, I will not use any of them.

Weekly Homework Homework will go out every week and be due the next week Ten points per day late penalty No homework will be accepted more than three days late Homework MUST be typeset

Collaboration + Cheating You may NOT share written work You may NOT use Google, or solutions to previous years homework You MUST sign the class honor code

Textbook There is NO textbook for this class We have class notes in wiki format You too can edit the wiki!!!

((( ))) Feel free to ask questions

Bits of Wisdom on Solving Problems, Writing Proofs, and Enjoying the Pain: How to Succeed in This Class Lecture 1 (January 13, 2009)

What did our brains evolve to do? What were our brains intelligently designed to do? What kind of meat did the Flying Spaghetti Monster put in our heads?

Our brains did NOT evolve to do math! Over the last 30,000 years, our brains have essentially stayed the same!

The human mind was designed by evolution to deal with foraging in small bands on the African Savannah... faulting our minds for succumbing to games of chance is like complaining that our wrists are poorly designed for getting out of handcuffs Steven Pinker How the Mind Works

Our brains can perform simple, concrete tasks very well And that s how math should be approached! Substitute concrete values for the variables: x=0, x=100, Draw simple pictures Try out small examples of the problem: What happens for n=1? n=2?

I don t have any magical ability I look at the problem, and it looks like one I ve already done. When nothing s working out, then I think of a small trick that makes it a little better. I play with the problem, and after a while, I figure out what s going on. Terry Tao (Fields Medalist, considered to be the best problem solver in the world)

Novice Expert

Simple and to the point The better the problem solver, the less brain activity is evident. The real masters show almost no brain activity!

Use a lot of paper, or a board!!!

Quick Test... Count the green squares (you will have three seconds)

How many were there?

Hats with Consecutive Numbers A - B = 1 Alice Bob Alice starts:

Hats with Consecutive Numbers I don t know what my number is (round 1) Alice A - B = 1 and A, B > 0 Bob Alice starts:

Hats with Consecutive Numbers I don t know what my number is (round 2) Alice A - B = 1 and A, B > 0 Bob Alice starts:

Hats with Consecutive Numbers I don t know what my number is (round 3) Alice A - B = 1 and A, B > 0 Bob Alice starts:

Hats with Consecutive Numbers I don t know what my number is (round 4) Alice A - B = 1 and A, B > 0 Bob Alice starts:

Hats with Consecutive Numbers I know what my number is!!!!!!!! (round 251) Alice A - B = 1 and A, B > 0 Bob Alice starts:

Hats with Consecutive Numbers I know what my number is!!!!!!!! (round 252) Alice A - B = 1 and A, B > 0 Bob Alice starts:

Question: What are Alice and Bob s numbers?

Imagine Alice Knew Right Away I know what my number is!!!!!!!! (round 1) Alice A - B = 1 and A, B > 0 Then A = 2 and B = 1 Bob

1,2 N,Y 2,1 Y 2,3 N,Y 3,2 N,N,Y 3,4 N,N,N,Y 4,3 N,N,Y 4,5 N,N,N,Y

Inductive Claim Claim: After 2k NOs, Alice knows that her number is at least 2k+1. After 2k+1 NOs, Bob knows that his number is at least 2k+2. Hence, after 250 NOs, Alice knows her number is at least 251. If she says YES, her number is at most 252. If Bob s number is 250, her number must be 251. If his number is 251, her number must be 252.

Exemplification: Try out a problem or solution on small examples. Look for the patterns.

A volunteer, please

Relax I am just going to ask you a Microsoft interview question

Four guys want to cross a bridge that can only hold two people at one time. It is pitch dark and they only have one flashlight, so people must cross either alone or in pairs (bringing the flashlight). Their walking speeds allow them to cross in 1, 2, 5, and 10 minutes, respectively. Is it possible for them to all cross in 17 minutes?

Get The Problem Right! Given any context you should double check that you read/heard it correctly! You should be able to repeat the problem back to the source and have them agree that you understand the issue

Four guys want to cross a bridge that can only hold two people at one time. It is pitch dark and they only have one flashlight, so people must cross either alone or in pairs (bringing the flashlight). Their walking speeds allow them to cross in 1, 2, 5, and 10 minutes, respectively. Is it possible for them to all cross in 17 minutes?

Intuitive, But False 10 + 1 + 5 + 1+ 2 = 19, so the four guys just can t cross in 17 minutes Even if the fastest guy is the one to shuttle the others back and forth you use at least 10 + 1 + 5 + 1 + 2 > 17 minutes

Vocabulary Self-Proofing As you talk to yourself, make sure to tag assertions with phrases that denote degrees of conviction

Keep track of what you actually know remember what you merely suspect 10 + 1 + 5 + 1 + 2 = 19, so it would be weird if the four guys could cross in 17 minutes even if we use the fastest guy to shuttle the others, they take too long.

If it is possible, there must be more than one guy doing the return trips: it must be that someone gets deposited on one side and comes back for the return trip later!

Suppose we leave 1 for a return trip later We start with 1 and X and then X returns Total time: 2X Thus, we start with 1,2 go over and 2 comes back.

1 2 5 10

1 2 5 10

1 2 5 10 5 10 2 1

1 2 5 10 5 10 2 1

1 2 5 10 5 10 2 5 10 2 1 1

1 2 5 10 5 10 2 5 10 2 1 1

1 2 5 10 5 10 2 5 10 2 2 1 1 1 5 10

1 2 5 10 5 10 2 5 10 2 2 1 1 1 5 10

1 2 5 10 5 10 2 5 10 2 1 2 2 1 1 1 5 10 5 10

1 2 5 10 5 10 2 5 10 2 1 2 2 1 1 1 5 10 5 10

1 2 5 10 5 10 2 5 10 2 1 2 2 1 1 1 5 10 5 10 1 2 5 10

5 and 10 Load Balancing : Handle our hardest work loads in parallel! Work backwards by assuming 5 and 10 walk together

In this course you will have to write a lot of proofs!

Think of Yourself as a (Logical) Lawyer Your arguments should have no holes, because the opposing lawyer will expose them

Statement 1 Statement 2 Statement n Prover There is no sound reason to go from Statament 1 to Statement 2 Verifier

The verifier is very thorough, (he can catch all your mistakes), but he will not supply missing details of a proof A valid complaint on his part is: I don t understand The verifier is similar to a computer running a program that you wrote! Verifier

Writing Proofs Is A Lot Like Writing Programs You have to write the correct sequence of statements to satisfy the verifier Errors than can occur with a program and with a proof! Syntax error Undefined term Infinite Loop Output is not quite what was needed

Good code is well-commented and written in a way that is easy for other humans (and yourself) to understand Similarly, good proofs should be easy to understand. Although the formal proof does not require certain explanatory sentences (e.g., the idea of this proof is basically X ), good proofs usually do

Writing Proofs is Even Harder than Writing Programs The proof verifier will not accept a proof unless every step is justified! It s as if a compiler required your programs to have every line commented (using a special syntax) as to why you wrote that line

Prover Verifier A successful mathematician plays both roles in their head when writing a proof

Gratuitous Induction Proof S n = sum of first n integers = n(n+1)/2 Want to prove: S n is true for all n > 0 Base case: S 1 = 1 = 1(1+1)/2 I.H. Suppose S k is true for some k > 0 Induction step: 1 + 2 +. + k + (k+1) = k(k+1)/2 + (k+1) (by I.H.) = (k + 1)(k+2)/2 Thus S k+1

Gratuitous Induction Proof S n = sum of first n integers = n(n+1)/2 Want to prove: S n is true for all n > 0 Base case: S 1 = 1 = 1(1+1)/2 I.H. Suppose S k is true for some k > 0 Induction step: 1 + 2 +. + n + (n+1) = n(n+1)/2 + (n+1) (by I.H.) = (n + 1)(n+2)/2 Thus S k+1 wrong variable

10 Proof by Throwing in the Kitchen Sink The author writes down every theorem or result known to mankind and then adds a few more just for good measure When questioned later, the author correctly observes that the proof contains all the key facts needed to actually prove the result Very popular strategy on 251 exams Believed to result in partial credit with sufficient whining

10 Proof by Throwing in the Kitchen Sink The author writes down every theorem or result known to mankind and then adds Like a few writing more just a for program good measure with functions that do most When questioned later, the author correctly everything you d ever want to do observes that the proof contains all the key facts (e.g. needed sorting to actually integers, prove calculating the result derivatives), which in the end Very popular strategy on 251 exams simply prints hello world Believed to result in extra credit with sufficient whining

9 Proof by Example The author gives only the case n = 2 and suggests that it contains most of the ideas of the general proof. Like writing a program that only works for a few inputs

8 Proof by Cumbersome Notation Best done with access to at least four alphabets and special symbols. Helps to speak several foreign languages. Like writing a program that s really hard to read because the variable names are screwy

7 Proof by Lengthiness An issue or two of a journal devoted to your proof is useful. Works well in combination with Proof strategy #10 (throwing in the kitchen sink) and Proof strategy #8 (cumbersome notation). Like writing 10,000 lines of code to simply print hello world

6 Proof by Switcharoo Concluding that p is true when both p q and q are true Makes as much sense as: If (PRINT X is prime ) { PRIME(X); }

Switcharoo Example S n = sum of first n integers = n(n+1)/2 Want to prove: S n is true for all n > 0 Base case: S 1 = 1 = 1(1+1)/2 I.H. Suppose S k is true for some k > 0 Induction step: by S k+1 1 + 2 +. + k + (k+1) = (k + 1)(k+2)/2 Hence blah blah, S k is true

5 Proof by It is Clear That It is clear that that the worst case is this: Like a program that calls a function that you never wrote

4 Proof by Assuming The Result Assume X is true Therefore, X is true! Like a program with this code: RECURSIVE(X) { : : return RECURSIVE(X); }

Assuming the Result Example S n = sum of first n integers = n(n+1)/2 Want to prove: S n is true for all n > 0 Base case: S 1 = 1 = 1(1+1)/2 I.H. Suppose S k is true for all k > 0 Induction step: 1 + 2 +. + k + (k+1) = k(k+1)/2 + (k+1) (by I.H.) = (k + 1)(k+2)/2 Thus S k+1

3 Not Covering All Cases Usual mistake in inductive proofs: A proof is given for N = 1 (base case), and another proof is given that, for any N > 2, if it is true for N, then it is true for N+1 Like a program with this function: RECURSIVE(X) { if (X > 2) { return 2*RECURSIVE(X-1); } if (X = 1) { return 1; } }

Not Covering All Cases Example S n = sum of first n integers = n(n+1)/2 Want to prove: S n is true for all n > 0 Base case: S 0 = 0 = 0(0+1)/2 I.H. Suppose S k is true for some k > 0 Induction step: 1 + 2 +. + k + (k+1) = k(k+1)/2 + (k+1) (by I.H.) = (k + 1)(k+2)/2 Thus S k+1

2 Incorrectly Using By Definition By definition, { a n b n n > 0 } is not a regular language Like a program that assumes a procedure does something other than what it actually does

1 Proof by OMGWTFBBQ 1/20

Solving Problems Always try small examples! Use enough paper Here s What You Need to Know Writing Proofs Writing proofs is sort of like writing programs, except every step in a proof has to be justified Be careful; search for your own errors