12
Recursion & Proof by Induction 1 10-607 Computational Foundations for Machine Learning Matt Gormley Lecture 7 Nov. 12, 2018 Machine Learning Department School of Computer Science Carnegie Mellon University

Recursion & Proof by Inductionmgormley/courses/606-607-f...Recursion & Proof by Induction 1 10-607 Computational Foundations for Machine Learning Matt Gormley Lecture 7 Nov. 12, 2018

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Recursion & Proof by Inductionmgormley/courses/606-607-f...Recursion & Proof by Induction 1 10-607 Computational Foundations for Machine Learning Matt Gormley Lecture 7 Nov. 12, 2018

Recursion & Proof by Induction

1

10-607 Computational Foundations for Machine Learning

Matt GormleyLecture 7

Nov. 12, 2018

Machine Learning DepartmentSchool of Computer ScienceCarnegie Mellon University

Page 2: Recursion & Proof by Inductionmgormley/courses/606-607-f...Recursion & Proof by Induction 1 10-607 Computational Foundations for Machine Learning Matt Gormley Lecture 7 Nov. 12, 2018

Reminders

• Homework B: Complexity & Recursion– Out: Thu, Nov. 8– Due: Tue, Nov. 20 at 11:59pm

• Quiz 1: Logic & Proofs; Computation– Mon, Nov. 19, in-class– Covers Lectures 1 – 6

2

Page 3: Recursion & Proof by Inductionmgormley/courses/606-607-f...Recursion & Proof by Induction 1 10-607 Computational Foundations for Machine Learning Matt Gormley Lecture 7 Nov. 12, 2018

Q&A

3

Page 4: Recursion & Proof by Inductionmgormley/courses/606-607-f...Recursion & Proof by Induction 1 10-607 Computational Foundations for Machine Learning Matt Gormley Lecture 7 Nov. 12, 2018

RECURSION

4

Page 5: Recursion & Proof by Inductionmgormley/courses/606-607-f...Recursion & Proof by Induction 1 10-607 Computational Foundations for Machine Learning Matt Gormley Lecture 7 Nov. 12, 2018

Example: Greedy Search

5

StartState

EndStates

Goal:• Search space consists

of nodes and weighted edges

• Goal is to find the lowest (total) weight path from root to a leaf

Greedy Search:• At each node, selects

the edge with lowest (immediate) weight

• Heuristic method of search (i.e. does notnecessarily find the best path)

2431 7

335

4122

3564

7898

Page 6: Recursion & Proof by Inductionmgormley/courses/606-607-f...Recursion & Proof by Induction 1 10-607 Computational Foundations for Machine Learning Matt Gormley Lecture 7 Nov. 12, 2018

Example: Greedy Search

6

StartState

EndStates

Goal:• Search space consists

of nodes and weighted edges

• Goal is to find the lowest (total) weight path from root to a leaf

Greedy Search:• At each node, selects

the edge with lowest (immediate) weight

• Heuristic method of search (i.e. does notnecessarily find the best path)

2431 7

335

4122

3564

7898

9919

Page 7: Recursion & Proof by Inductionmgormley/courses/606-607-f...Recursion & Proof by Induction 1 10-607 Computational Foundations for Machine Learning Matt Gormley Lecture 7 Nov. 12, 2018

Example: Greedy Search

7

StartState

EndStates

Goal:• Search space consists

of nodes and weighted edges

• Goal is to find the lowest (total) weight path from root to a leaf

Greedy Search:• At each node, selects

the edge with lowest (immediate) weight

• Heuristic method of search (i.e. does notnecessarily find the best path)

2431 7

335

4122

3564

7898

9919

7135

2122

5315

Page 8: Recursion & Proof by Inductionmgormley/courses/606-607-f...Recursion & Proof by Induction 1 10-607 Computational Foundations for Machine Learning Matt Gormley Lecture 7 Nov. 12, 2018

Example: Decision Trees

8

Page 9: Recursion & Proof by Inductionmgormley/courses/606-607-f...Recursion & Proof by Induction 1 10-607 Computational Foundations for Machine Learning Matt Gormley Lecture 7 Nov. 12, 2018

Proof by Induction

Chalkboard:– Weak Induction• basis case• inductive hypothesis• inductive step

– Example: sum of powers of two– Why does proof by induction work?• propositional logic interpretation

9

Page 10: Recursion & Proof by Inductionmgormley/courses/606-607-f...Recursion & Proof by Induction 1 10-607 Computational Foundations for Machine Learning Matt Gormley Lecture 7 Nov. 12, 2018

Proof by Induction

In-Class ExerciseProve the following statement by induction.

10

Answer Here:

Page 11: Recursion & Proof by Inductionmgormley/courses/606-607-f...Recursion & Proof by Induction 1 10-607 Computational Foundations for Machine Learning Matt Gormley Lecture 7 Nov. 12, 2018

Recursion

Chalkboard:– Example: Factorial (iterative implementation)– Example: Factorial (recursive implementation)– Strong Induction• multiple basis cases• complete assumption

– Proof of recursive factorial correctness

11

Page 12: Recursion & Proof by Inductionmgormley/courses/606-607-f...Recursion & Proof by Induction 1 10-607 Computational Foundations for Machine Learning Matt Gormley Lecture 7 Nov. 12, 2018

Recursion

Chalkboard:– Definition: Sorted Array– Example: Insertion Sort (iterative

implementation)– Example: Insertion Sort (recursive

implementation)– Big Idea: Divide and Conquer– Example: Merge Sort

12