week 15 - wednesday. what did we talk about last time? review first third of course

44
CS322 Week 15 - Wednesday

Upload: anissa-hubbard

Post on 31-Dec-2015

247 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

CS322Week 15 - Wednesday

Page 2: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Last time

What did we talk about last time? Review first third of course

Page 3: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Questions?

Page 4: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Logical warmup

Consider the following shape to the right:

Now, consider the next shape, made up of pieces of exactly the same size:

We have created space out of nowhere!

How is this possible?

Page 5: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Indirect Proofs

Page 6: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Proof by contradiction

In a proof by contradiction, you begin by assuming the negation of the conclusion

Then, you show that doing so leads to a logical impossibility

Thus, the assumption must be false and the conclusion true

Page 7: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Contradiction formatting

A proof by contradiction is different from a direct proof because you are trying to get to a point where things don't make sense

You should always mark such proofs clearly Start your proof with the words Proof by

contradiction Write Negation of conclusion as the

justification for the negated conclusion Clearly mark the line when you have both p and

~p as a contradiction Finally, state the conclusion with its justification

as the contradiction found before

Page 8: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Practice

Use a proof by contradiction to prove the following: For all integers n, if n2 is odd then n is

odd For all prime numbers a, b, and c, a2 +

b2 ≠ c2

Page 9: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Sequences and Induction

Page 10: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Sequences

Mathematical sequences can be represented in expanded form or with explicit formulas

Examples: 2, 5, 10, 17, 26, … ai = i2 + 1, i ≥ 1

Summation notation is used to describe a summation of some part of a series

Product notation is used to describe a product of some part of a series

nmmm

n

mkk aaaaa

...21

nmmm

n

mkk aaaaa

...21

Page 11: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Proof by mathematical induction

To prove a statement of the following form: n Z, where n a, property P(n) is true

Use the following steps:1. Basis Step: Show that the property is true

for P(a)2. Induction Step: ▪ Suppose that the property is true for some n = k,

where k Z, k a▪ Now, show that, with that assumption, the

property is also true for k + 1

Page 12: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Practice

Write the following in closed form:

Use mathematical induction to prove: For all integers n ≥ 1, 2 + 4 + 6+· · ·+2n

= n2 + n

Page 13: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Recursion

Using recursive definitions to generate sequences

Writing a recursive definition based on a sequence

Using mathematical induction to show that a recursive definition and an explicit definition are equivalent

Page 14: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Solving recursion by iteration

Expand the recursion repeatedly without combining like terms

Find a pattern in the expansions When appropriate, employ formulas

to simplify the pattern Geometric series: 1 + r + r2+ … + rn =

(rn+1 – 1)/(r – 1) Arithmetic series: 1 + 2 + 3 + … + n =

n(n+ 1)/2

Page 15: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Practice

Use the method of iteration to find an explicit formula for the following recursively defined sequence: dk = 2dk−1 + 3, for all integers k ≥ 2

d1 = 2 Use a proof by induction to show that

your explicit formula is correct

Page 16: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Solving second order linear homogeneous recurrence relations with constant coefficients

To solve sequence ak = Aak-1 + Bak-2

Find its characteristic equation t2 – At – B = 0

If the equation has two distinct roots r and s Substitute a0 and a1 into an = Crn + Dsn

to find C and D If the equation has a single root r

Substitute a0 and a1 into an = Crn + Dnrn to find C and D

Page 17: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Practice

Find an explicit formula for the following: rk = 2rk-1 − rk-2, for all integers k ≥ 2

r0 = 1

r1 = 4

Page 18: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Set Theory

Page 19: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Set theory basics

Defining finite and infinite sets Definitions of:

Subset Proper subset Set equality

Set operations: Union Intersection Difference Complement

The empty set Partitions Cartesian product

Page 20: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Set theory proofs

Proving a subset relation Element method: Assume an element is

in one set and show that it must be in the other set

Algebraic laws of set theory: Using the algebraic laws of set theory (given on the next slide), we can show that two sets are equal

Disproving a universal statement requires a counterexample with specific sets

Page 21: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Laws of set theory

Name Law Dual

Commutative A B = B A A B = B A

Associative (A B) C = A (B C) (A B) C = A (B C)

Distributive A (B C) = (A B) (A C) A (B C) = (A B) (A C)

Identity A = A A U = A

Complement A Ac = U A Ac =

Double Complement (Ac)c = A

Idempotent A A = A A A = A

Universal Bound A U = U A =

De Morgan’s (A B)c = Ac Bc (A B)c = Ac Bc

Absorption A (A B) = A A (A B) = A

Complements of U and

Uc = c = U

Set Difference A – B = A Bc

Page 22: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Russell's paradox

It is possible to give a description for a set which describes a set that does not actually exist

For a well-defined set, we should be able to say whether or not a given element is or is not a member

If we can find an element that must be in a specific set and must not be in a specific set, that set is not well defined

Page 23: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Functions

Definitions Domain Co-domain Range Inverse image

Arrow diagrams Poorly defined functions Function equality

Page 24: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Inverses

One-to-one (injective) functionsOnto (surjective) functions If a function F: X Y is both one-to-

one and onto (bijective), then there is an inverse function F-1: Y X such that: F-1(y) = x F(x) = y, for all x X and y

Y

Page 25: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Cardinality

Pigeonhole principle: If n pigeons fly into m pigeonholes, where n >

m, then there is at least one pigeonhole with two or more pigeons in it

Cardinality is the number of things in a set It is reflexive, symmetric, and transitive

Two sets have the same cardinality if a bijective function maps every element in one to an element in the other

Any set with the same cardinality as positive integers is called countably infinite

Page 26: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Practice

Consider the set of integer complex numbers, defined as numbers a + bi, where a, b Z and i is

Prove that the set of integer complex numbers is countable

Page 27: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Relations

Page 28: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Relations

Relations are generalizations of functions In a relation (unlike functions), an element

from one set can be related to any number (from zero up to infinity) of other elements

We can define any binary relation between sets A and B as a subset of A x B

If x is related to y by relation R, we write x R y

All relations have inverses (just reverse the order of the ordered pairs)

Page 29: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Properties of relations

For relation R on set A R is reflexive iff for all x A, (x, x) R R is symmetric iff for all x, y A, if (x, y) R then (y, x) R R is transitive iff for all x, y, z A, if (x, y) R and (y, z)

R then (x, z) R R is antisymmetric iff for all a and b in A, if a R b and b R

a, then a = b The transitive closure of R called Rt satisfies the

following properties: Rt is transitive R Rt

If S is any other transitive relation that contains R, then Rt S

Page 30: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Equivalence relations and partial orders

Let A be partitioned by relation RR is reflexive, symmetric, and

transitive iff it induces a partition on A

We call a relation with these three properties an equivalence relation Example: congruence mod 3

If R is reflexive, antisymmetric, and transitive, it is called a partial order Example: less than or equal

Page 31: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Practice

Prove that the subset relationship is a partial order

Consider the relation x R y, where R is defined over the set of all people x R y ↔ x lives in the same house as y Is R an equivalence relation? Prove it.

Page 32: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Counting and Probability

Page 33: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Probability definitions

A sample space is the set of all possible outcomes

An event is a subset of the sample space Formula for equally likely probabilities:

Let S be a finite sample space in which all outcomes are equally likely and E is an event in S

Let N(X) be the number of elements in set X▪ Many people use the notation |X| instead

The probability of E is P(E) = N(E)/N(S)

Page 34: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Multiplication rule

If an operation has k steps such that Step 1 can be performed in n1 ways

Step 2 can be performed in n2 ways

… Step k can be performed in nk ways

Then, the entire operation can be performed in n1n2 … nk ways

This rule only applies when each step always takes the same number of ways

If each step does not take the same number of ways, you may need to draw a possibility tree

Page 35: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Addition and inclusion/exclusion rules

If a finite set A equals the union of k distinct mutually disjoint subsets A1, A2, … Ak, then:N(A) = N(A1) + N(A2) + … + N(Ak)

If A, B, C are any finite sets, then:N(A B) = N(A) + N(B) – N(A B)

And:N(A B C) = N(A) + N(B) + N(C) – N(A B) – N(A C) – N(B C) + N(A B C)

Page 36: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Counting guide

This is a quick reminder of all the different ways you can count k things drawn from a total of n things:

Recall that P(n,k) = n!/(n – k)! And = n!/((n – k)!k!)

Order MattersOrder Doesn't

Matter

Repetition Allowed nk

Repetition Not Allowed P(n,k)

k

nk 1

k

n

k

n

Page 37: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Binomial theorem

The binomial theorem states:

You can easily compute these coefficients using Pascal's triangle for small values of n

kknn

k

n bak

nba

0

)(

Page 38: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Probability axioms

Let A and B be events in the sample space S 0 ≤ P(A) ≤ 1 P() = 0 and P(S) = 1 If A B = , then P(A B) = P(A) + P(B) It is clear then that P(Ac) = 1 – P(A) More generally, P(A B) = P(A) + P(B) –

P(A B)

Page 39: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Expected value

Expected value is one of the most important concepts in probability, especially if you want to gamble

The expected value is simply the sum of all events, weighted by their probabilities

If you have n outcomes with real number values a1, a2, a3, … an, each of which has probability p1, p2, p3, … pn, then the expected value is:

n

kkkpa

1

Page 40: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Conditional probability

Given that some event A has happened, the probability that some event B will happen is called conditional probability

This probability is:

)()(

)|(AP

BAPABP

Page 41: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Quiz

Page 42: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Upcoming

Page 43: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Next time…

Review third third of the course

Page 44: Week 15 - Wednesday.  What did we talk about last time?  Review first third of course

Reminders

Review chapters 10 – 12 and notes on grammars and automata