Course summary

Download Report

Transcript Course summary

Course Summary
CS 202
Aaron Bloomfield
1
Outline
A review of the proof methods gone over
in class
Interspersed with the most
demotivators from CS 101
popular
Course summary
2
Demotivator winners!

Methodology
– 1st place vote counted for 3 points
– 2nd place vote counted for 2 points
– 3rd place vote counted for 1 point

Have not tallied the Toolkit ones yet
– I won’t get those for a few weeks

Will then buy two demotivators and hang
them in my office…
3
Proof methods learned so far
Logical equivalences


via truth tables
via logical equivalences
Set equivalences




via membership tables
via set identities
via mutual subset proof
via set builder notation and
logical equivalences
Ten proof methods in section 1.5:








Rules of inference


for propositions
for quantified statements
Constructive
Non-constructive


Pigeonhole principle
Combinatorial proofs
Direct proofs
Indirect proofs
Vacuous proofs
Trivial proofs
Proof by contradiction
Proof by cases
Proofs of equivalence
Existence proofs
Uniqueness proofs
Counterexamples
Induction



Weak mathematical induction
Strong mathematical induction
Structural induction
4
Using Logical Equivalences
( p  r )  (q  r )  ( p  q)  r
Original statement
(p Definition
r )  (qofimplication
r )  ( p pq)
 qr  p  q
(p DeMorgan’s
r )  (q  Law
r )  (p( pqq))  
r p  q
Associativity
p  r  q ofrOr (pprq) (rq  r )  p  r  q  r
Re-arranging
p  q  r  r  p  q  r
Idempotent
Law
p  q 
r 
p
r
r rq  r
5
In
th
12
place (11 votes)
6
Set equivalences (§1.7)
Prove that A∩B=B-(B-A)
A  B  B-(B  A )
Definition of difference
 B  (B  A )
Definition of difference
 B  (B  A )
DeMorgan’s law
 B  (B  A)
Complementation law
 (B  B )  (B  A)
Distributive law
   (B  A)
Complement law
 (B  A)
Identity law
 A B
Commutative law
7
Proof by set builder notation
and logical equivalences 2
B  ( B  A)
Original statement
 {x | x  B  x  ( B  A)}
Definition of difference
 {x | x  B  ( x  ( B  A))}
Negating “element of”
 {x | x  B  ( x  B  x  A)}
Definition of difference
 {x | x  B  ( x  B  x  A)}
DeMorgan’s Law
 {x | x  B  x  B  x  B  x  A}
Distributive Law
 {x | x  B  ( x  B)  x  B  x  A}
 {x | F  x  B  x  A}
 {x | x  B  x  A}
Negating “element of”
 A B
Definition of intersection
Negation Law
Identity Law
8
In
th
11
place (1/3) (12 votes)
9
Rules of inference (§1.5)
Example 6 of Rosen, section 1.5
We have the hypotheses:
p
q


r

s
t

“It is not sunny this afternoon and it
is colder than yesterday”
“We will go swimming only if it is
sunny”
“If we do not go swimming, then we
will take a canoe trip”
“If we take a canoe trip, then we will
be home by sunset”
Does this imply that “we will be
home by sunset”?
¬p  q
r→p
¬r → s
s→t
t
10
Rules of inference (§1.5)
1.
2.
3.
4.
5.
6.
7.
8.
¬p  q
¬p
r→p
¬r
¬r → s
s
s→t
t
pq
p
1st hypothesis
Simplification using step 1
2nd hypothesis
Modus tollens using steps 2 & 3
3rd hypothesis
Modus ponens using steps 4 & 5
4th hypothesis
Modus ponens using steps 6 & 7
p
q
pq
pq
q
 p
11
In
th
11
place (2/3) (12 votes)
12
Rules of inference (§1.5)
Rosen, section 1.5, question 10a
Given the hypotheses:


“Linda, a student in this class, owns a
red convertible.”
“Everybody who owns a red convertible
has gotten at least one speeding ticket”
C(Linda)
R(Linda)
x (R(x)→T(x))
Can you conclude: “Somebody in x (C(x)T(x))
this class has gotten a speeding
ticket”?
13
Rules of inference (§1.5)
1.
2.
3.
4.
5.
6.
7.
x (R(x)→T(x))
R(Linda) → T(Linda)
R(Linda)
T(Linda)
C(Linda)
C(Linda)  T(Linda)
x (C(x)T(x))
3rd hypothesis
Universal instantiation using step 1
2nd hypothesis
Modes ponens using steps 2 & 3
1st hypothesis
Conjunction using steps 4 & 5
Existential generalization using
step 6
Thus, we have shown that “Somebody in
this class has gotten a speeding ticket”
14
In
th
11
place (3/3) (12 votes)
15
Proof methods (§1.5)
Ten proof methods:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
Direct proofs
Indirect proofs
Vacuous proofs
Trivial proofs
Proof by contradiction
Proof by cases
Proofs of equivalence
Existence proofs
Uniqueness proofs
Counterexamples
16
In
th
10
place (1/5) (13 votes)
17
Direct proof example
Rosen, section 1.5, question 20


Show that the square of an even number is an
even number
Rephrased: if n is even, then n2 is even
Assume n is even



Thus, n = 2k, for some k (definition of even
numbers)
n2 = (2k)2 = 4k2 = 2(2k2)
As n2 is 2 times an integer, n2 is thus even
18
Indirect proof example
If n2 is an odd integer then n is an odd integer
Prove the contrapositive: If n is an even integer,
then n2 is an even integer
Proof: n=2k for some integer k (definition of even
numbers)
n2 = (2k)2 = 4k2 = 2(2k2)
Since n2 is 2 times an integer, it is even
19
In
th
10
place (2/5) (13 votes)
20
Proof by contradiction
Given a statement p, assume it is false

Assume ¬p
Prove that ¬p cannot occur

A contradiction exists
Given a statement of the form p→q

To assume it’s false, you only have to consider the
case where p is true and q is false
21
Proof by contradiction
Theorem (by Euclid): There are infinitely many
prime numbers.
Proof. Assume there are a finite number of primes
List them as follows: p1, p2 …, pn.
Consider the number q = p1p2 … pn + 1

This number is not divisible by any of the listed primes
If we divided pi into q, there would result a remainder of 1

We must conclude that q is a prime number, not among
the primes listed above
This contradicts our assumption that all primes are in the list
p1, p2 …, pn.
22
Proof by contradiction example 2
Rosen, section 1.5, question 21 (b)

Prove that if n is an integer and n3+5 is odd, then n is even

Rephrased: If n3+5 is odd, then n is even
Thus, p is “n3+5” is odd, q is “n is even”
Assume p and q

Assume that n3+5 is odd, and n is odd
Since n is odd:

n=2k+1 for some integer k (definition of odd numbers)

n3+5 = (2k+1)3+5 = 8k3+12k2+6k+6 = 2(4k3+6k2+3k+3)

As n3+5 = 2(4k3+6k2+3k+3) is 2 times an integer, n must be even

Thus, we have concluded q
Contradiction!


We assumed q was false, and showed that this assumption implies that q must
be true
As q cannot be both true and false, we have reached our contradiction
23
In
th
10
place (3/5) (13 votes)
24
Vacuous proof example
When the antecedent is false
Consider the statement:


All criminology majors in CS 202 are female
Rephrased: If you are a criminology major and you
are in CS 202, then you are female
Could also use quantifiers!
Since there are no criminology majors in this
class, the antecedent is false, and the
implication is true
25
Trivial proof example
When the consequence is true
Consider the statement:

If you are tall and are in CS 202 then you are
a student
Since all people in CS 202 are students,
the implication is true regardless
26
Proof by cases example
Prove that

a a

b b
Note that b ≠ 0
Cases:

Case 1: a ≥ 0 and b > 0
Then |a| = a, |b| = b, and

Case 2: a ≥ 0 and b < 0
Then |a| = a, |b| = -b, and

Case 3: a < 0 and b > 0
Then |a| = -a, |b| = b, and

Case 4: a < 0 and b < 0
Then |a| = -a, |b| = -b, and
a a a
 
b b b
a
a
a
a
 

b
b b b
a
a a a
 

b
b
b
b
a a a a
 

b b b b
27
In
th
10
place (4/5) (13 votes)
28
Proofs of equivalence example
Rosen, section 1.5, question 40


Show that m2=n2 if and only if m=n or m=-n
Rephrased: (m2=n2) ↔ [(m=n)(m=-n)]
Need to prove two parts:

[(m=n)(m=-n)] → (m2=n2)
Proof by cases!
Case 1: (m=n) → (m2=n2)

(m)2 = m2, and (n)2 = n2, so this case is proven
Case 2: (m=-n) → (m2=n2)


(m)2 = m2, and (-n)2 = n2, so this case is proven
(m2=n2) → [(m=n)(m=-n)]
Subtract n2 from both sides to get m2-n2=0
Factor to get (m+n)(m-n) = 0
Since that equals zero, one of the factors must be zero
Thus, either m+n=0 (which means m=n)
Or m-n=0 (which means m=-n)
29
In
th
10
place (5/5) (13 votes)
30
Constructive existence proof
example
Show that a square exists that is the sum
of two other squares

Proof: 32 + 42 = 52
Show that a cube exists that is the sum of
three other cubes

Proof: 33 + 43 + 53 = 63
31
Non-constructive existence proof
example
Rosen, section 1.5, question 50
Prove that either 2*10500+15 or 2*10500+16 is not a
perfect square


A perfect square is a square of an integer
Rephrased: Show that a non-perfect square exists in the set
{2*10500+15, 2*10500+16}
Proof: The only two perfect squares that differ by 1 are 0
and 1



Thus, any other numbers that differ by 1 cannot both be perfect
squares
Thus, a non-perfect square must exist in any set that contains
two numbers that differ by 1
Note that we didn’t specify which one it was!
32
In
th
9
place (14 votes)
33
Uniqueness proof example
If the real number equation 5x+3=a has a
solution then it is unique
Existence


We can manipulate 5x+3=a to equal (a-3)/5
Is this constructive or nonconstructive?
Uniqueness


If there are two such numbers, then they would fulfill
the following: a = 5x+3 = 5y+3
We can manipulate this to yield that x = y
Thus, the one solution is unique!
34
In
th
8
place (15 votes)
35
Counterexamples
Given a universally quantified statement, find a single
example which it is not true
Note that this is DISPROVING a UNIVERSAL statement
by a counterexample
x ¬R(x), where R(x) means “x has red hair”

Find one person (in the domain) who has red hair
Every positive integer is the square of another integer

The square root of 5 is 2.236, which is not an integer
36
In
th
7
place (16 votes)
37
Weak mathematical induction (§ 3.3)
Rosen, question 7: Show
Base case: n = 1
n(n  1)( 2n  1)
i 

6
i 1
n
2
1(1  1)( 2  1)
i 

6
i 1
6
2
1 
6
11
1
2
Inductive hypothesis: assume
k (k  1)( 2k  1)
i 

6
i 1
k
2
38
Weak mathematical induction (§ 3.3)
Inductive step: show
k 1
2
i
 
i 1
(k  1)(( k  1)  1)( 2(k  1)  1)
6
(k  1)(( k  1)  1)( 2(k  1)  1)
i 

6
i 1
k 1
2
k
(k  1) 2   i 2 
i 1
(k  1) 2 
(k  1)( k  2)( 2k  3)
6
k (k  1)( 2k  1) (k  1)( k  2)( 2k  3)

6
6
6(k  1) 2  k (k  1)( 2k  1)  (k  1)(k  2)(2k  3)
2k 3  9k 2  13k  6  2k 3  9k 2  13k  6
k
2
i
 
i 1
k (k  1)( 2k  1)
6 39
In
th
6
place (18 votes)
40
Strong mathematical induction (§ 3.3)
Show that any number > 1 can be written
as the product of primes
Base case: P(2)

2 is the product of 2 (remember that 1 is not
prime!)
Inductive hypothesis: P(1), P(2), P(3), …,
P(k) are all true
Inductive step: Show that P(k+1) is true
41
Strong mathematical induction (§ 3.3)
Inductive step: Show that P(k+1) is true
There are two cases:

k+1 is prime
It can then be written as the product of k+1

k+1 is composite
It can be written as the product of two composites,
a and b, where 2 ≤ a ≤ b < k+1
By the inductive hypothesis, both P(a) and P(b) is
true
42
In
th
5
place (1/2) (21 votes)
43
Structural induction (§ 3.4)
Show that n(T) ≥ 2h(T) + 1
Inductive hypothesis:

Let T1 and T2 be full binary trees
Assume that n(T1) ≥ 2h(T1) + 1 for some tree T1
Assume that n(T2) ≥ 2h(T2) + 1 for some tree T2
Recursive step:

Let T = T1 ∙ T2
Here the ∙ operator means creating a new tree with a root note r and
subtrees T1 and T2
New element is T

By the definition of height and size, we know:
n(T) = 1 + n(T1) + n(T2)
h(T) = 1 + max ( h(T1), h(T2) )

Therefore:
n(T) = 1 + n(T1) + n(T2)
≥ 1 + 2h(T1) + 1 + 2h(T2) + 1
≥ 1 + 2*max ( h(T1), h(T2) )
the sum of two non-neg #’s is at least
as large as the larger of the two
= 1 + 2*h(T)

Thus, n(T) ≥ 2h(T) + 1
44
In
th
5
place (2/2) (21 votes)
45
Induction methods compared
Used for
Assumption
Weak
mathematical
Strong
Mathematical
Structural
Usually
formulae
Usually formulae not
provable via
mathematical induction
Only things defined
via recursion
Assume P(1), P(2), …,
P(k)
Assume statement is
true for some "old"
elements
Assume P(k)
Statement is true for
some "new" elements
created with "old"
elements
What to
prove
True for
P(k+1)
True for P(k+1)
Step 1
called
Base case
Base case
Basis step
Step 3
called
Inductive step
Inductive step
Recursive step
46
In
th
4
place (25 votes)
47
Pigeonhole principle (§4.2)
Consider 5 distinct points (xi, yi) with integer values, where i = 1,
2, 3, 4, 5
Show that the midpoint of at least one pair of these five points
also has integer coordinates
Thus, we are looking for the midpoint of a segment from (a,b) to
(c,d)

The midpoint is ( (a+c)/2, (b+d)/2 )
Note that the midpoint will be integers if a and c have the same
parity: are either both even or both odd

Same for b and d
There are four parity possibilities

(even, even), (even, odd), (odd, even), (odd, odd)
Since we have 5 points, by the pigeonhole principle, there must
be two points that have the same parity possibility

Thus, the midpoint of those two points will have integer coordinates
48
In
rd
3
place (1/2) (27 votes)
49
Combinatorial proof (§4.3)
Let n be a non-negative integer. Then
n
n



2

 
k 0  k 
n
Combinatorial proof

A set with n elements has 2n subsets
By definition of power set

Each subset has either 0 or 1 or 2 or … or n elements
n
n
There are  0  subsets with 0 elements,  1  subsets with 1
element, … and  nn  subsets with n elements
 
Thus, the total number of subsets is

Thus,
n
n



2

 
k 0  k 
n
n
 

k 0  k 
n
50
In
rd
3
place (2/2) (27 votes)
51
Official course goals
1.
2.
3.
4.
5.
Logic: Introduce a formal system (propositional and predicate
logic) which mathematical reasoning is based on. (sections 1.11.4)
Proofs: Develop an understanding of how to read and construct
valid mathematical arguments (proofs) and understand
mathematical statements (theorems), including inductive proofs.
Also, introduce and work with various problem solving strategies
and techniques. (sections 1.5, 3.1, 3.3, 3.4)
Counting: Introduce the basics of integer theory, combinatorics,
and counting principles, including a brief introduction to discrete
probability. (sections 2.4, 4.1-4.4, 5.1)
Structures: Introduce and work with important discrete data
structures such as sets, relations, sequences, and discrete
functions. (sections 1.6-1.8, 2.7, 3.2, 7.1, 7.3-7.6)
Applications: Gain an understanding of some application areas of
the material covered in the course. (sections 2.6, 3.6, 10.3)
The written final will be based on these goals!
52
In
nd
2
place (30 votes)
53
Unofficial course goals
Ensure that all students have a “base” level of discrete
mathematical proficiency


In particular, ensure that they know a number of covered topics,
such as sets, logic, etc.
Used in CS 216, in particular
To prepare for more advanced computer theory classes
(CS 302, CS 432)
To give the students more experience in math

The best way to get better at anything is through practice
To help create a computer scientist, not a computer
programmer
54
And the winner is…
with 45 votes…
55
Have a summer!
Final is 9 a.m. this Saturday!
56