Download Intro to Induction

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
Transcript
snick
∨
snack
Outline
• Prereqs, Learning Goals, and Quiz Notes
• Problems and Discussion
CPSC 121: Models of Computation
2010 Winter Term 2
– Single-Elimination Tournaments
– Binary Trees
• A First Pattern for Induction
• Induction on Numbers
• Next Lecture Notes
Introduction to Induction
Steve Wolfman
2
1
Learning Goals: Pre-Class
Learning Goals: In-Class
By the start of class, you should be able to:
By the end of this unit, you should be able
to:
– Convert sequences to and from explicit formulas
that describe the sequence.
– Convert sums to and from summation/“sigma”
notation.
– Convert products to and from product/“pi”
notation.
– Manipulate formulas in summation/product
notation by adjusting their bounds, merging or
splitting summations/products, and factoring out
values.
– Establish properties of self-referential
structures using inductive proofs that naturally
build on those self-references.
4
Where We Are in
The Big Stories
Theory
Hardware
How do we model
computational systems?
How do we build devices to
compute?
Now: Developing a new
proof technique that’s
perfect for algorithms
involving (111 people)
loops or (110 people)
recursion... which is
almost all interesting
algorithms!
5
Outline
• Prereqs, Learning Goals, and Quiz Notes
• Problems and Discussion
Now: Taking a break in
lecture. In lab, continuing
to build toward the
complete, working
computer!
6
– Single-Elimination Tournaments
– Binary Trees
• A First Pattern for Induction
• Induction on Numbers
• Next Lecture Notes
7
Single-Elimination Tournaments
In each round teams play in pairs. Losing
teams are eliminated. The tournament
ends when only one team remains.
Single-Elimination
Tournament Problem
What’s the maximum number of teams in a
1-round single-elimination tournament?
a. 0 teams
b. 1 team
c. 2 teams
d. 3 teams
e. None of these
8
Single-Elimination
Tournament Problem
9
Single-Elimination
Tournament Problem
What’s the maximum number of teams in a
2-round single-elimination tournament?
a. 0 teams
b. 1 team
c. 2 teams
d. 3 teams
e. None of these
What’s the maximum number of teams in an
n-round single-elimination tournament?
a. n teams
b. 2n teams
c. n2 teams
d. 2n teams
e. None of these
10
Tournament
Step-by-Step
11
Tournament Logic
So, if p teams can play in an n-round
tournament, then 2p teams can play in an
n+1-round tournament.
If we want to prove this statement, which of the
following techniques might we use?
a. Antecedent assumption
b. Witness proof
c. WLOG
d. Proof by cases
e. None of these
Problem 2: Prove your result for...
n=1
n=2
n=3
n=4
...
n = 0?
12
13
Tournaments Built
from Tournaments
Tournaments Built
from Tournaments
The key insight is the same way hockey
(and many other sports) get from an “east
half” and “west half” tournament to a whole
tournament:
A tournament is either one game (1-round
tournament), or it’s two slightly shorter
tournaments combined by having the
champions play against each other.
One extra round:
east winner vs. west winner
One extra round:
east winner vs. west winner
14
15
Tournament
Step-by-Step
Tournament Proof
Theorem: 2n teams can play in an n-round tournament.
Proof:
Only two (21) teams can play in a 1-round tournament.
We work up to any other size by showing:
if 2k teams can play in a k-round tournament, then
2k+1 teams can play in an k+1-round tournament.
Assume the antecedent: 2k teams can play in a k-round
tournament.
A k+1-round tournament is two k-round tournaments (“eastern
and western conferences” or the like) where the winners play
each other for the overall championship.
Each of the k-round tournaments has 2k teams in it.
So, the k+1-round tournament has:
2k + 2k = 2*2k = 2k+1 teams.
QED
Problem 2: Prove your result for...
n=1
n=2
n=3
n=4
...
2 teams
2*2 = 22 = 4 teams
2*4 = 23 = 8 teams
2*8 = 24 = 16 teams
17
16
Outline
“Binary Trees”
A “binary tree” is a root
“node” and a collection
of “child nodes”
beneath the root.
Each node is an object
that has up to two
children—a left child
and a right child—each
of which are
themselves binary
trees.
• Prereqs, Learning Goals, and Quiz Notes
• Problems and Discussion
– Single-Elimination Tournaments
– Binary Trees
• A First Pattern for Induction
• Induction on Numbers
• Next Lecture Notes
18
10
5
2
20
9
7
15
17
19
(They let us do some cool CS things... see CS110, 210, 211, 221.)
10
Binary Trees’ Height
10
5
20
2
15
9
7
A binary tree’s “height” is the
maximum number of steps it
takes to get from the root down
to a node with no children.
5
This one’s height is:
a. 0
2
b. 1
c. 2
7
d. 3
e. 4
Binary Trees’ Height
5
20
2
15
9
17
7
17
Problem 1: What’s the maximum number of
nodes in a binary tree of height n?
10
20
9
15
17
20
21
10
Binary Trees’ Height
10
5
20
2
9
15
7
17
Binary Trees,
Take Two
5
20
2
15
9
7
17
Problem 1: Give an algorithm to determine
the height of a binary tree.
Problem 2: Prove that your algorithm is
correct.
Problem 2: Prove your result.
22
Outline
23
An Induction Proof Pattern
Type of Problem: Prove some property of a
structure that is naturally defined in terms of
itself.
Part 1: Insight. Induction doesn’t help you with
this part. It is not a technique to figure out
patterns, only to prove them.
Part 2: Proof. Establish that the property holds
for simple structures. Establish that it holds
at each step of construction of a more
complex structure.
• Prereqs, Learning Goals, and Quiz Notes
• Problems and Discussion
– Single-Elimination Tournaments
– Binary Trees
• A First Pattern for Induction
• Induction on Numbers
• Next Lecture Notes
24
25
Natural Numbers and Induction
Can we prove things about the natural
numbers using induction? Are they “selfreferential”?
Let’s try one...
Partly Worked Problem:
Sum of 0..n
Partly Worked Problem: What is the sum
of the natural numbers 0..n?
Induction doesn’t help with insight...
But spoilers do: n(n+1)/2.
Problem: What is the sum of the natural
numbers 0..n?
Now, how do we prove it?
26
Partly Worked Problem:
Sum of 0..n
27
Outline
Partly Worked Problem: Prove that the
sum of the natural numbers 0..n is
n(n+1)/2.
• Prereqs, Learning Goals, and Quiz Notes
• Problems and Discussion
Is this self-referential? If we knew the sum
of the numbers 0..(n-1), would it tell us
anything about the sum of the numbers
0..n?
• A First Pattern for Induction
• Induction on Numbers
• Next Lecture Notes
– Single-Elimination Tournaments
– Binary Trees
28
29
Next Lecture Learning Goals:
Pre-Class
Learning Goals: In-Class
By the start of class, you should be able to:
By the end of this unit, you should be able
to:
– Establish properties of self-referential
structures using inductive proofs that naturally
build on those self-references.
Note: this learning goal is not yet looking for formal
inductive proofs. Instead, we’re just exploring how we
work with things that are defined in terms of themselves.
30
– Given a theorem to prove stated in terms of its
induction variable (i.e., usually, in terms of n),
write out the skeleton of an inductive proof
including: the base case(s) that need to be
proven, the induction hypothesis, and the
inductive step that needs to be proven.
So, take what we did in this lecture and use the
textbook readings to formalize your understanding.
31
We will have much more practice on inductive proofs.
Next Lecture Prerequisites
See the Mathematical Induction Textbook
Sections at the bottom of the “Textbook
and References” page.
32