You are on page 1of 60

m e

e co
li b
206
w l
(it
p a d
ot e

r ing
B dy)
a n
Discrete Structures II
han

Casimir A. Kulikowski
Department of Computer Science
Rutgers University | NJ, USA

Lecture 2 | 205 Recap | Tuesday 09/07 2021


What we will cover today
• Recap
• How to do well in the course?
• Main points about Combinatorics from Lecture Week- 1
• Combinatorics Introductory Overview (Recap 205)
• Sets (Today’s Lecture)
• Venn Diagram
• Functions
• Proofs (Start today – finish Friday)
• Induction (Friday)
Remember
What we cover in lectures

What you have to


cover by yourselves
Recap

How to do well in the course?


• Stay up to date with the material
– Studying the day before a quiz/midterm is a bad idea

– After each lecture the slides will be posted on canvas

– Before the end of the day spend ~20 mins going over slides
and make notes of things you did not understand

– Bring questions to next class and office hours

– When you “attend” a lecture, have a notepad in front of you


(not a PC!!!) and solve (by hand) the problems (till the very
end)
Recap

How to do well in the course?


• Lecture format
– Each lecture will consist of introducing a concept and
doing examples related to that concept

– HWs, quizzes, recitations, study groups will give you more


practice on examples related to these concepts – once the
PTLs and graders are hired!

– The more you practice, the better you will get…


Recap

How to do well in the course?


“I don't have any magical ability. I look at a problem, and it looks something
like one I've done before; I think maybe the idea that worked before will work
here. When I was a kid, I had a romanticized notion of mathematics, that
hard problems were solved in 'Eureka' moments of inspiration. [But] with
me, it's always, 'Let's try this. That gets me part of the way, or that doesn't
work. Now let's try this. Oh, there's a little shortcut here…. It's not about being
smart or even fast. It's like climbing a cliff: If you're very strong and quick
Terence Tao and have a lot of rope, it helps, but you need to devise a good route to get up
there. Doing calculations quickly and knowing a lot of facts are like a rock
World’s greatest living
mathematician. climber with strength, quickness and good tools. You still need a plan — that's
2006 Fields Medalist, the hard part — and you have to see the bigger picture.”
Claymath prize
Combinatorics

• The study of arrangements of objects

• Studied as long ago as the 17th century, when combinatorial


questions arose in the study of gambling games

• Used to solve many different types of problems


• Examples:
Enumeration, the counting of objects with certain
properties
1. Counting determines the complexity of algorithms
2. Counting determines whether there are enough
resources to solve a problem
3. …
Used to solve many different types of problems
Enumeration, the counting of objects with certain properties
Example:

Combinatorics 1.
2.
Counting determines the complexity of algorithms
Counting determines whether there are enough resources to solve a problem.

• Study of discrete structures


• Counting structures of a given kind/size

What questions
can you ask?
Used to solve many different types of problems
Enumeration, the counting of objects with certain properties
Example:

Combinatorics 1.
2.
Counting determines the complexity of algorithms
Counting determines whether there are enough resources to solve a problem.

• Study of discrete structures


• Counting structures of a given kind/size

Complexity:
What is the runtime?

Resources:
What is the memory
usage?
Combinatorics – Enumerating Example
Combinatorics

Recently, it has played a key role in

mathematical biology,

e.g., in sequencing DNA, RNA, other

macromolecules…..
Rosen, 385

Combinatorics
• We will study the basic rules of counting
• They can solve a tremendous variety of problems, such as:
• Enumerate the different telephone numbers possible in the United States,
• Enumerate the allowable passwords on a computer system,
• Enumerate the different orders in which the runners in a race can finish
• They can help us answer questions that seem hard: What is the chance that
among the 240 students in this class, we find 2 with the same birthday?

• An important combinatorial tool is the pidgeonhole principle: When


objects are placed in boxes and there are more objects than boxes,
then there is a box containing at least 2 objects.
• E.g., we can use this principle to show that among a set of 15 or more
students, at least 3 were born on the same day of the week
Pidgeon Hole Principle
• If you have N pidgeon holes and M objects that must be placed in
the holes – and more objects than holes (M>N) then at least one
hole must contain more than one object.
• One of those obvious things - so easy to accept that nobody much
thinks about the truth or otherwise of it.
• If you work at a company that has 100 employees - and the parking
lot only has 99 spaces - then there is a risk that someone will have
nowhere to park if everyone drives in their own cars and everyone
comes to work that day…….Why? Because you can’t get two cars
into one parking place………….
Pidgeon Hole Principle
• Simple Example: if you have a drawer full of socks - some black, some
white and if it’s too dark to see properly - how many socks do you have
to grab in order to guarantee that you get a matching pair?
If you imagine having two pidgeon holes - one where you put black socks
that you pulled from the drawer and another where you put white socks -
then you have two pidgeon holes - and you only need to pull one more sock
than there are pidgeon holes in order to ensure that one pidgeon hole has
two or more socks in it…and you’ll have a matched pair. So grabbing three
socks will work.
• A harder example: if you have red, blue, green, yellow, purple, black and
white socks (7 different colors) all mixed up in the drawer - then you have
to grab one more sock than there are colors in order to be sure to get a
pair……..so grabbing 8 socks would guarantee it.
Combinatorics

How many different passwords we can


create?
Lehman, 69-72

Sets
• What is a Set?
• A collection of objects which are called elements
• Elements are objects that share the same property

• Examples
• Someone’s followers on Twitter
• The set of webpages for a given Google query
• Collection of YouTube videos
Lehman, 69-72

Sets
• What is a Set?
• A collection of objects which are called elements
• Elements are objects that share the same property

• Examples
• Someone’s followers on Twitter
• The set of webpages for a given Google query
• Collection of YouTube videos
Sets

Sets – Common Sets

curly braces
Sets - Set Operations

Sets - Set Comparisons

Power Set

New Stuff

Set Builder Notation



Work on it

Exercise 1: Put everything together


Venn Diagram

• Represent sets as circles


and elements as points
within it.

• Elegant way to capture


relationships among sets.
Work on it

Exercise 2: Venn Diagram


• There are 131 students in CS 206.
• 100 like chocolate ice cream. 50 like vanilla ice cream.
• 20 like both chocolate and vanilla ice cream.
• Draw a Venn diagram to represent this.
• How many students do not like either flavor of ice cream.
Lehman, 73-75

Functions

Functions - Example
Types of Functions
Exercise 3: Types of Functions

Exercise 3: Types of Functions)
• 𝑓: ℝ ↦ ℝ, 𝑓( 𝑥 )= 3𝑥 + 7
• 𝑓: ℝ ↦ ℝ 𝑓(𝑥) = 𝑥2
Work on it

Exercise 3: Types of Functions


• 𝑓: ℝ ↦ ℝ, 𝑓 𝑥 = 3𝑥 + 7
• 𝑓: ℝ ↦ ℝ, 𝑓 𝑥 = 𝑥2
Lehman, 3-15

Proofs

• A mathematical proof…
• …of a proposition is a chain of logical deductions from axioms
and previously proved statements. A prime is an integer greater than one that is not divisible by any other
integer greater than 1, e.g., 2, 3, 5, 7, 11, . . .
• Proposition
• A statement that is either true or false
• e.g., Every even integer greater than 2 is the sum of two primes
(Goldbach’s Conjecture – remains unsolved since 1742…)
• Predicates
• A proposition whose truth depends on the value of variables
• e.g., P 𝑛 ∷= "𝑛 𝑖𝑠 𝑎 𝑝𝑒𝑟𝑓𝑒𝑐𝑡 𝑠𝑞𝑢𝑎𝑟𝑒" – P 4 is true but P 5 is false
Axioms
• A standard procedure for establishing truth in mathematics was
invented by Euclid, a Greek mathematician working in Alexandria,
circa 300 BC.
• He began with 5 assumptions about geometry, which seemed
undeniable based on direct experience. (For example, “There is a
straight line segment between every pair of points.)
• Propositions like these that are simply accepted as true are
called axioms
• Starting from these axioms, Euclid established the truth of many
additional propositions by providing “proofs.”
Euclid’s Axioms of Plane Geometry
• Assumptions about geometry, which seemed undeniable based on direct
experience:
1) There is a straight line segment between every pair of points
2) A finite line can be extended indefinitely
3) A circle can be crawn, given a center and a radius
4) All right angles are equal (and measure ninety degrees)
5) For any given point not on a given line, there is exactly one line
through the point that does not meet the given line (Parallel
Postulate………it does not follow from the previous four axioms, but
this was not proven until the 19th Century!)
Axioms
• Euclid’s axiom-and-proof approach, now called the axiomatic
method, remains the foundation for mathematics today.

• In fact, just a handful of axioms, called the axioms Zermelo-


Frankel with Choice (ZFC), together with a few logical
deduction rules, appear to be sufficient to derive
essentially all of mathematics
Zermelo-Frankel Axiomatic Set theory
• Zermelo–Fraenkel set theory is intended to formalize a single
primitive notion, that of a hereditary well-founded set, so that all
entities in the universe of discourse are such sets.
• The axioms of Zermelo–Fraenkel set theory refer only to pure sets
and prevent its models from containing urelements (elements of
sets that are not themselves sets).
• Proper classes (collections of mathematical objects defined by a
property shared by their members where the collections are too big
to be sets) can only be treated indirectly.
• ZF does not allow for the existence of a universal set (a set
containing all sets) nor for unrestricted comprehension, thereby
avoiding Russell's paradox.
• Russell redefined the language of logic -> first order logic
Russell’s Paradox:
• Define R to be the set {x| x is a set and x is not an element of
itself}.
• That is, R is not a member of itself, but if it is a member of
itself, then it is not a member of itself, since it is the set of all
sets, that are not members of themselves…..
Logical Deductions (or Inference Rules)
Used to prove new propositions using previously proved ones

!,!⇒$

$
• If 𝑃 is true and 𝑃 implies 𝑄, then 𝑄 is true. If we can prove this …

antecedents
!⇒$,$⇒%
• consequent
!⇒%
• If 𝑃 implies 𝑄 and 𝑄 implies 𝑅, then 𝑃 implies 𝑅.
…then this is true

¬!⇒¬$

$⇒!
• If ¬𝑃 implies ¬𝑄, then 𝑄 implies 𝑃
Proving an Implication
• To prove: 𝑃 ⇒ 𝑄

• Assume that 𝑃 is true.

• Show that 𝑄 logically follows


Proving an Implication via Direct Proof
• To prove: 𝑃 ⇒ 𝑄

• Assume that 𝑃 is true.

• Show that 𝑄 logically follows


Work on it

Direct Proof
The sum of two even numbers is even.
• To prove: 𝑃 ⇒ 𝑄
Proof x = 2m, y = 2n
• Assume that 𝑃 is true.
x+y = 2m+2n
• Show that 𝑄 logically follows = 2(m+n)

The product of two odd numbers is odd.

Proof x = 2m+1, y = 2n+1


xy = (2m+1)(2n+1)
= 4mn + 2m + 2n + 1
= 2(2mn+m+n) + 1
Example of Proving an Implication
• Theorem: 1 ≤ 𝑥 ≤ 2 ⇒ 𝑥 ' − 3𝑥 + 2 ≤ 0
Work on it

Example of Proving an Implication


Theorem: 1 ≤ 𝑥 ≤ 2 ⇒ 𝑥 ' − 3𝑥 + 2 ≤ 0

Intuition:When x grows, 3x grows faster than x2 in that range.


Proof by Contrapositive
• To prove: 𝑃 ⇒ 𝑄

• Prove that ¬𝑄 ⇒ ¬𝑃.

• Assume ¬Q is true and show that ¬𝑃 follows logically.


proving “if P, then Q” is equivalent to proving “if not Q, then not P”

Proof by Contrapositive
• To prove: 𝑃 ⇒ 𝑄

• Prove that ¬𝑄 ⇒ ¬𝑃.

• Assume ¬Q is true and show that ¬𝑃 follows logically.

i.e., we will assume the opposite of our desired conclusion and show
that this fancy opposite conclusion could never be true in the first place.
Example of Proof by Contrapositive
• Theorem: If 𝑟 is irrational, then 𝑟 is irrational.
Rational Number
R is rational ó there are integers a and b such that
numerator

and b ≠ 0.

denominator
Remember:
1. A number is rational if it is equal to a ratio of integers
2. The sum of two rational numbers is always a rational number
3. The difference of two rational numbers is always a rational number
4. The product of two rational numbers is always a rational number
5. The quotient of two rational numbers is always a rational number
proving “if P, then Q” is equivalent to proving “if not Q, then not P”

Example of Proof by Contrapositive


• Theorem: If 𝑟 is irrational, then 𝑟 is irrational.

Proof: We shall prove the contrapositive –


“if √r is rational, then r is rational.”

Since √r is rational, √r = a/b for some integers a,b.

So r = a2/b2. Since a,b are integers, a2,b2 are integers.

Therefore, r is rational. Q.E.D.

(Q.E.D.) "which was to be demonstrated", or “quite easily done”. J


quod erat demonstrandum

Intuition: Square roots and absolute values are our worst enemies in proofs
Example of Proof by Case Analysis
• Theorem: For all 𝑥 ∈ ℝ, −5 ≤ 𝑥 + 2 − 𝑥 − 3 ≤ 5
Example of Proof by Case Analysis
• Theorem: For all 𝑥 ∈ ℝ, −5 ≤ 𝑥 + 2 − 𝑥 − 3 ≤ 5
Example of Proof by Case Analysis
• Theorem: For all 𝑥 ∈ ℝ, −5 ≤ 𝑥 + 2 − 𝑥 − 3 ≤ 5
Proof by Contradiction
• To prove 𝑃
• Assume 𝑃 is false.
• Logically deduce something that is known to be false.
Example of Proof by Contradiction
• Theorem: There are infinitely many primes.
Lehman, 115-129

Induction
• Let 𝑃(𝑚) be a predicate of non-negative integers

• You want to prove that 𝑃(𝑚) is true for all non-negative


integers.

• Step 1: Prove that 𝑃(0) is true

• Step 2: Prove that 𝑃 𝑛 ⇒ P(n + 1) for all non-negative


integers.
Example of Induction
• Theorem: For all 𝑛 ∈ ℕ,
! !"#
• 1 + 2 + ⋯+ 𝑛 = $
Faulty Induction
• All horses are the same color.
Strong Induction
• Let 𝑃 be a predicate of non-negative integers
• You want to prove that 𝑃(𝑚) is true for all non-negative
integers.
• Step 1: Prove that 𝑃(0) is true
• Step 2: Prove that P 0 , P 1 , … , 𝑃 𝑛 ⇒ P(n + 1) for all non-
negative integers.
Strong Induction
• Theorem: Every integer greater than 1 is a product of primes.
The roots of education
are bitter,
but the fruit
is sweet

Aristotle, 384 – 322 BC

You might also like