CSC236H Lecture 2. Ilir Dema. September 19, 2018

Similar documents
CSC236 Week 3. Larry Zhang

CS 220: Discrete Structures and their Applications. Mathematical Induction in zybooks

Reading 5 : Induction

Discrete Mathematics. Spring 2017

Mathematical Induction. Rosen Chapter 4.1,4.2 (6 th edition) Rosen Ch. 5.1, 5.2 (7 th edition)

Mathematical Induction. Part Two

Notes on induction proofs and recursive definitions

Hence, the sequence of triangular numbers is given by., the. n th square number, is the sum of the first. S n

Mathematical Induction. How does discrete math help us. How does discrete math help (CS160)? How does discrete math help (CS161)?

CS1800: Mathematical Induction. Professor Kevin Gold

Proof Techniques (Review of Math 271)

Example. How to Guess What to Prove

Strong Induction (Second Principle) Example: There are two piles of cards, players take turn: each turn: one player removes any number of cards from

Binomial Coefficient Identities/Complements

CS 360, Winter Morphology of Proof: An introduction to rigorous proof techniques

Data structures Exercise 1 solution. Question 1. Let s start by writing all the functions in big O notation:

Induction and Recursion

CSI Mathematical Induction. Many statements assert that a property of the form P(n) is true for all integers n.

CS 173: Induction. Madhusudan Parthasarathy University of Illinois at Urbana-Champaign. February 7, 2016

Chapter 2 Section 2.1: Proofs Proof Techniques. CS 130 Discrete Structures

Solution Set 2. Problem 1. [a] + [b] = [a + b] = [b + a] = [b] + [a] ([a] + [b]) + [c] = [a + b] + [c] = [a + b + c] = [a] + [b + c] = [a] + ([b + c])

Chapter 2. Mathematical Reasoning. 2.1 Mathematical Models

CMSC250 Homework 9 Due: Wednesday, December 3, Question: Total Points: Score:

Outline. We will cover (over the next few weeks) Induction Strong Induction Constructive Induction Structural Induction

Mathematical Induction. Part Two

Sum of Squares. Defining Functions. Closed-Form Expression for SQ(n)

Lecture 4: Probability, Proof Techniques, Method of Induction Lecturer: Lale Özkahya

Induction and recursion. Chapter 5

Lecture 7: Dynamic Programming I: Optimal BSTs

CPSC 121: Models of Computation. Module 9: Proof Techniques (part 2) Mathematical Induction

Chapter Summary. Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms

Mathematical Induction. Defining Functions. Overview. Notation for recursive functions. Base case Sn(0) = 0 S(n) = S(n 1) + n for n > 0

At the start of the term, we saw the following formula for computing the sum of the first n integers:

Lecture 6 September 21, 2016

Strong Mathematical Induction

THE ISLAMIC UNIVERSITY OF GAZA ENGINEERING FACULTY DEPARTMENT OF COMPUTER ENGINEERING DISCRETE MATHMATICS DISCUSSION ECOM Eng. Huda M.

Advanced Analysis of Algorithms - Midterm (Solutions)

Quiz 1 Solutions. Problem 2. Asymptotics & Recurrences [20 points] (3 parts)

Lecture 10 September 27, 2016

k-protected VERTICES IN BINARY SEARCH TREES

CS173 Lecture B, September 10, 2015

ICS141: Discrete Mathematics for Computer Science I

Lecture 6 : Induction DRAFT

Induction. Induction. Induction. Induction. Induction. Induction 2/22/2018

CSE 311: Foundations of Computing. Lecture 14: Induction

CSE 311: Foundations of Computing I Autumn 2014 Practice Final: Section X. Closed book, closed notes, no cell phones, no calculators.

Models of Computation,

Discrete Math, Spring Solutions to Problems V

Mathematical Induction Assignments

Carmen s Core Concepts (Math 135)

CVO103: Programming Languages. Lecture 2 Inductive Definitions (2)

CSC236 Week 2. Larry Zhang

Theory of Computation

Module 9: Mathematical Induction

CS60007 Algorithm Design and Analysis 2018 Assignment 1

Discrete Mathematics for CS Fall 2003 Wagner Lecture 3. Strong induction

x P(x) x P(x) CSE 311: Foundations of Computing announcements last time: quantifiers, review: logical Inference Fall 2013 Lecture 7: Proofs

Reading and Writing. Mathematical Proofs. Slides by Arthur van Goetham

Induction 1 = 1(1+1) = 2(2+1) = 3(3+1) 2

Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort

MATH CSE20 Homework 5 Due Monday November 4

means is a subset of. So we say A B for sets A and B if x A we have x B holds. BY CONTRAST, a S means that a is a member of S.

With Question/Answer Animations

CSCE 222 Discrete Structures for Computing. Review for Exam 2. Dr. Hyunyoung Lee !!!

CS1800: Strong Induction. Professor Kevin Gold

CS325: Analysis of Algorithms, Fall Midterm

TECHNISCHE UNIVERSITEIT EINDHOVEN Faculteit Wiskunde en Informatica. Final exam Logic & Set Theory (2IT61) (correction model)

21 Induction. Tom Lewis. Fall Term Tom Lewis () 21 Induction Fall Term / 14

n n P} is a bounded subset Proof. Let A be a nonempty subset of Z, bounded above. Define the set

Math 3361-Modern Algebra Lecture 08 9/26/ Cardinality

ECS 20: Discrete Mathematics for Computer Science UC Davis Phillip Rogaway June 12, Final Exam

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d

MODEL ANSWERS TO THE THIRD HOMEWORK. 1. We prove this result by mathematical induction. Let P (n) be the statement that

MATH 55 - HOMEWORK 6 SOLUTIONS. 1. Section = 1 = (n + 1) 3 = 2. + (n + 1) 3. + (n + 1) 3 = n2 (n + 1) 2.

E.g. The set RE of regular expressions is given by the following rules:

Induction and recursion. Topics. Induction and Recursion Vojislav Kecman CMSC 302

Putnam Greedy Algorithms Cody Johnson. Greedy Algorithms. May 30, 2016 Cody Johnson.

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programming II Date: 10/12/17

1 True/False. Math 10B with Professor Stankova Worksheet, Discussion #9; Thursday, 2/15/2018 GSI name: Roy Zhao

CmSc 250 Intro to Algorithms. Mathematical Review. 1. Basic Algebra. (a + b) 2 = a 2 + 2ab + b 2 (a - b) 2 = a 2-2ab + b 2 a 2 - b 2 = (a + b)(a - b)

MAT 300 RECITATIONS WEEK 7 SOLUTIONS. Exercise #1. Use induction to prove that for every natural number n 4, n! > 2 n. 4! = 24 > 16 = 2 4 = 2 n

Discrete Math in Computer Science Solutions to Practice Problems for Midterm 2

SIGNAL COMPRESSION Lecture 7. Variable to Fix Encoding

CSE373: Data Structures and Algorithms Lecture 2: Proof by Induction. Linda Shapiro Spring 2016

Finite Automata Theory and Formal Languages TMV027/DIT321 LP Recap: Logic, Sets, Relations, Functions

Computer Science Foundation Exam

Discrete Mathematics. Spring 2017

EECS 1028 M: Discrete Mathematics for Engineers

Problem One: Order Relations i. What three properties does a binary relation have to have to be a partial order?

Section 4.2: Mathematical Induction 1

Fall 2017 November 10, Written Homework 5

Winter Camp 2009 Number Theory Tips and Tricks

In-Class Soln 1. CS 361, Lecture 4. Today s Outline. In-Class Soln 2

Element x is R-minimal in X if y X. R(y, x).

PRACTICE PROBLEMS: SET 1

Mathematical Fundamentals

Mathematical Reasoning Rules of Inference & Mathematical Induction. 1. Assign propositional variables to the component propositional argument.

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

CSCE 222 Discrete Structures for Computing. Proof by Induction. Dr. Hyunyoung Lee. !!!!!! Based on slides by Andreas Klappenecker

Divide and Conquer. CSE21 Winter 2017, Day 9 (B00), Day 6 (A00) January 30,

Transcription:

CSC236H Lecture 2 Ilir Dema September 19, 2018

Simple Induction Useful to prove statements depending on natural numbers Define a predicate P(n) Prove the base case P(b) Prove that for all n b, P(n) P(n + 1).

Is it enough? Prove by induction that one needs precisely n 1 cuts to cut a chocolate bar in n pieces.

ConcepTest Prove by induction that one needs precisely n 1 cuts to cut a chocolate bar in n pieces. In a proof by simple induction: A. The base case cannot be proved B. The inductive hypothesis (I.H.) can t be stated C. It is difficult to use the I.H. to prove the inductive case D. The proof is not possible

Prime or Product of Primes We want to prove that every natural number greater than 1 can be written as a product of primes. Some examples: 2 = 2 (2 itself is prime) 4 = 2 2 28 = 2 2 7 100 = 5 5 2 2 101 = 101 (101 itself is prime) 57 =? (Grothendieck prime)

Prime or Product of Primes We want to prove that every natural number greater than 1 can be written as a product of primes. Try simple induction: Some examples: 2 = 2 (base case) Let s try to get some intuition for the inductive step... Say we check 8 = 2 2. How does that help prove 9 = 3 3?

Prime or Product of Primes

Aye, captain. Complete Induction Principle of complete (strong) induction: (1) If P(b) is True, (2) And P(b) P(b + 1)... P(n) P(n + 1) is True for all n b, Then P(n) is True for all integers n b.

Intuition for Complete Induction Suppose that we prove P(0) We can therefore use P(0) to prove P(1) Then we can use both P(0) and P(1) to prove P(2) Then we can use all three of P(0), P(1), and P(2) to prove P(3)...

ConcepTest Read Presentation 1 on the handout. Which of the following is true? A. The proof is invalid; the inductive hypothesis cannot be assumed B. The proof is invalid; the base case for 18 is incorrect C. The proof is invalid; we must argue that 17 cents cannot be formed from 4-cent and 7-cent stamps D. The proof is valid E. The claim is false; a counterexample can be found

Look, ma, I won 6 poins!

ConcepTest You begin with a stack of n cups. On each move, you break a stack of cups into two stacks of cups. If you break a stack of a + b cups into a stack of a cups and a stack of b cups, you get ab points. The game ends when there is one cup per stack. What is the maximum number of points that you can get starting with 5 cups? A. 5 B. 10 C. 15 D. 120

Unstacking cups... P(n): no matter how we unstack n cups, we get a score of n(n 1)/2 points We can prove this using complete induction. (1) For n = 1, we can t do any unstacking, so we get 0 points. 1(1 1)/2 = 0, so the formula is correct for the base case.

ConcepTest P(n): no matter how we unstack n cups, we get a score of n(n 1)/2 points In the inductive step, we have n + 1 cups. Let 1 k n. How many total points do we get for unstacking n + 1 cups into a stack of k and a stack of n + 1 k? A. k(n + 1 k) B. k(n + 1 k) + k(k 1)/2 C. k(n + 1 k) + k(k 1)/2 + (n + 1 k)(n k)/2 D. k(n + 1 k) + k(k 1)/2 (n + 1 k)(n k)/2

Application: Continued Fractions

What is a continued fraction? Formally, a continued fraction is: An integer n A fraction n + 1 F where n is an integer and F is a continued fraction

All rational numbers can be represented as continued fractions

Proof P(d): A rational with denominator d > 0 can be written as continued fraction. (Any rational r = n/d can be written with d > 0 so the above suffices) Base case: d = 1. Then r = n/1 = n is a continued fraction. Inductive step: Assume for some d N with d > 1, for all 1 d < d, P(d ) is true. Let r = n/d a rational with denominator d. Then n = qd + r. Case 1: r = 0. Then r = qd/d = q, so the representation of r is the continued fraction q. Case 2: 0 < r < d. Then r = n d = q + r d = q + 1 d r. Apply inductive hypothesis and conclude.

Summary: Simple/Complete Induction Now we have seen both simple/weak and complete/strong induction. If using one number back is sufficient to prove the claim for the next number, then use simple induction If jumping further back is necessary, use complete induction In terms of what they can prove: the two techniques are equivalent! And in terms of proof structure: they are very similar!

Summary: Simple/Complete Induction... For both simple and complete induction: Prove the base case(s) of P Use induction hypothesis to prove P(n + 1) Use principle of induction to conclude that P holds for the base case and all larger numbers The difference between simple and complete induction is in the induction hypothesis Simple induction: assume P(n) Complete induction: assume P(b), P(b + 1),..., P(n)

Where do natural numbers come from? Consider the following recursively-defined set S, the smallest set such that: S. If p S then {p} p S. What is the relation of S and N?

ConcepTest Consider the following recursively-defined set S, the smallest set such that: ɛ (the empty string ) and 1 are in S. If w is a string in S, then so is w00. If w is a string in S, then so is w01. Which of the following is true? A. Every string in S has no consecutive 1s B. Every binary string with no consecutive 1s is in S C. Both of the above are true D. None of the above is true

Structural Induction A recursively-defined set has One or more base case elements One or more rules for generating new, larger elements of the set from existing elements in the set Structural induction is a technique for proving that every element in such a set has a given property For the converse (every element that has a given property is in the set), use simple or complete induction!

Structural Induction... Principle of structural induction: Suppose that X is a recursively-defined set and P is some predicate. (1) If P is true for each base element of X, (2) and, under the assumption that P(e) is true for element e of X, we find that each recursive rule produces an element that satisfies P, Then P is true for all elements of X We must use (ii) separately on each recursive rule!

Structural Induction Proof Consider the following recursively-defined set S, the smallest set such that: ɛ (the empty string ) and 1 are in S. If w is a string in S, then so is w00. If w is a string in S, then so is w01. Prove, for all s S, that s does not contain two consecutive 1s.

Exercise 1 Exercise 1 on handout.

Structural induction

ConcepTest Here is a recursive definition for some set T of non-empty binary trees. A single node is in T If t 1 and t 2 are in T, then the bigger tree with root r connected to the roots of t 1 and t 2 is in T If t 1 is in T, then the bigger tree with root r connected to the root of t 1 to the left or right is in T Nothing else is in T Which of the following is true? A. Every element of T has m nodes with two children and m + 1 leaves B. Every binary tree that has m nodes with two children and m + 1 leaves is in T C. Both of the above are true D. None of the above is true

Heap Example Suppose we store numbers in the nodes of a full binary tree. The numbers obey the heap property if, for every node X in the tree, the value in X is at least as big as the value in each of Xs children.

Heap Example Prove that If a full binary tree has the heap property, then the value in the root of the tree is at least as large as the value in any node of the tree. Base Case: If a tree contains only one node, obviously the largest value in the tree lives in the root! Inductive Case: Suppose that the claim is true for trees X and Y. We need to show that the claim is also true for the tree T that consists of a root node plus subtrees X and Y.

Heap Example (continued) Let r be the root of the whole tree T. Suppose p and q are the children of r, i.e. the root nodes of X and Y. Since T has the heap property, v(r) v(p) and v(r) v(q). Suppose that x is any node of T. We need to show that v(r) v(x). There are three cases: Case 1: x = r. This is obvious. Case 2: x is any node in the subtree X. By the inductive hypothesis v(p) v(x). But we know that v(r) v(p). So v(p) v(x). Case 3: x is any node in the subtree Y. Similar to case 2.