Processing math: 52%
Lecture Notes: The Pigeonhole Principle
Preliminaries
- Name tags
- Sign in
- Introductions:
- Name
- Fun fact about yourself
- Tour of:
- Canvas
- Syllabus
- Course website
- Gradescope
Course Content
Motivation
Discrete Structures
- A rhetorical question: why is this course called “discrete structures?” The course could have been called “discrete math,” but we call it discrete structures to distinguish it from the similar course offered by the Math department. But why discrete?
- Ask: Can anyone explain the difference between a discrete variable and a continuous variable? When programming?
- Integers vs floating point.
- This course will be mainly concerned with math that involved discrete quantities.
Proofs
- Some of the math we do will involve mathematical proofs.
- Ask: What is a proof?
- Textbook: “Proving something requires formal reasoning, starting with things known to be true and connecting them by incontestable logical inferences.”
- Instead of “known to be true” I would say “accepted to be true.” For example, changing starting assumptions can sometimes be useful. See Euclidean geometry vs non-Euclidian geometry.
Propositions
- We will prove whether propositions are true or false.
- Write: Definition: A proposition is a statement that is either true or false.
- Some propositions can be proved or disproved trivially, while others require sequences of reasoning.
- Are these propositions true or false?
- 1 + 1 = 2?
- 2 + 3 = 4?
- Ask: Can someone give me another example of a proposition?
Generalization
- Usually, we want to prove things in a general way. Let’s see some examples of generalization.
- Write: Proposition: There can be no triangle with sides of length 1, 2, and 6.
- Ask: Can someone explain why this is impossible?
- Open: Triangle Demo
- Show: 1, 2, 2
- Show: 1, 2, 2.9
- Show: 1, 2, 2.99
- Show: 1, 2, 3
- A formal proof would use geometric axioms.
- Write: Proposition: There can be no triangle with sides of length a, b, and c if a, b, c are any numbers such that a + b ≤ c.
- Textbook: “A proposition becomes more useful if it is more general; it can be applied with confidence in a greater variety of circumstances. [Also], a general proposition makes it easier to grasp what is really going on, because it leaves out irrelevant, distracting detail.”
- Ask: Does the proposition hold in the reverse? This is, if a + b > c, is a triangle formed by a, b, c?
- Show: 1, 2, 2
- Show: 1, 2.9, 2
- Show: 1, 2.99, 2
- Show: 1, 3, 2
- So our proposition doesn’t fully explain what’s necessary to form a triangle.
- Note that visual proofs are not considered as rigorous as written, logical proofs.
Sets
- Let’s see another example of generalization, which will connect to this lecture’s big idea, the pigeonhole principle.
- As we saw earlier, many of you have birthdays on the same day of the week.
- The pigeonhole principle explains why this is certain to happen, given that this class has X students, and there are only 7 days of the week.
- To explain the pigeonhole principle, we need to introduce the concept of a mathematical set.
- Write: Definition: “A set is a collection of elements. The elements that belong to the set are called its members. The members of a set must be all different from each other (i.e., distinct).”
- Next, let’s write out the members of the class and the days of the week as sets.
- For our purposes, it suffices to just write eight students (use attendance sheet):
- S = {Aaron, Betty, …}
- D = {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday}
- Notation: Sunday∈D
- Next, let’s introduce some terminology about numbers
- Integers: …, -2, -1, 0, 1, 2, … Denoted as Z.
- Real numbers: integers and numbers between them (e.g., 12,−√2,π). Denoted as R.
- Positive, negative, and nonnegative numbers
- Integers and real numbers are examples of infinite sets
- Sets S and D are finite. This means they have size, or cardinality, which is a nonnegative integer.
- Notation: ∣D∣=7
Functions
- Ask: Who has heard the term “function” when programming?
- In math, “function” has a different but related meaning.
- Write: Definition: “A function from one set to another is a rule that associates each member of the first set with exactly one member of the second set.”
- Math functions are close to the programming concept of “pure functions.”
- Notation: f:X→Y
- This means that f is a function from set X to set Y.
- f maps elements from X to Y.
- Notation: f(x)
- x is an argument to function f. f(x) is the value of f on argument x.
- Thus, x∈X and f(x)∈Y
- Example: b:S→D denotes the function that associates each student with the day of the week of their birthday in 2025. For example, if Aaron’s birthday is on a Thursday, then b(Aaron) = Thursday.
- Finally, we have laid the groundwork for the pigeonhole principle!
- Write: Pigeonhole Principle:
For any finite sets X and Y, if f:X→Y and ∣X∣>∣Y∣, then there are elements x1,x2∈X such that x1≠x2 and f(x1)=f(x2)
- This is enough to explain what is going on with eight students and seven days of the week.
- Or with ten pigeons and nine pigeonholes.
- We can generalize the principle further to explain what happens when there are many more elements in X than in Y (e.g., twenty pigeons and nine pigeonholes).
- Write: Extended Pigeonhole Principle:
For any finite sets X and Y and any positive integer k such that ∣X∣>k⋅∣Y∣, if f:X→Y, then there are at least k+1 distinct members x1,…,xk+1∈X such that f(x1)=…=f(xk+1)
- Sequence notation depicts xi where 1≤i≤k+1
- The regular Pigeonhole Principle is the k = 1 case of the Extended Pigeonhole Principle.
- Draw: Examples. k = 1 for eight students and seven days of the week. k = 2 for twenty pigeons and nine pigeonholes.
- How do we determine the value of k?
- Short answer: Divide the size of the sets and round up.
- Long answer: we need some additional mathematical notation.
- Notation: ⌊x⌋ is the floor of x. That is, the greatest integer less than or equal to x. Round down.
- Notation: ⌈x⌉ is the ceiling of x. That is, the smallest integer greater than or equal to x. Round up.
- Give examples.
- Write: Extended Pigeonhole Principle, Alternate Version:
Let X and Y be any finite sets and let f:X→Y.
Then there is some y∈Y such that f(x)=y for at least
⌈∣X∣∣Y∣⌉
values of x.
- Give examples.
- This is equivalent to the original Extended Pigeonhole Principle, with k=⌈∣X∣∣Y∣⌉−1
Application to Data Dictionaries
- Next, I’ll give you a preview of some material from Data Structures, where the Pigeonhole Principle applies in the implementation of data dictionaries.
- A data dictionary uses a key to look up the corresponding value.
- Write:
print(student_names[student_id])
- Ask: What does this code do?
- Internally, keys need to be organized in some way. The number of keys in a dictionary grows as more data is added to the dictionary.
- To have space for an arbitrary number of keys, keys are organized into buckets.
- Draw: An array of length five, representing the five buckets.
- A hash function maps each key to its bucket number. This is used to store and retrieve each key/value pair.
- A hash table’s performance degrades if a bucket contains many duplicate values.
- The Pigeonhole Principle tells you minimum number of keys that will end up in the same bucket.
- Give examples.
Introduction to Number Theory (Needed For Lab)
- Next, I’ll cover a brief introduction to number theory.
- Cryptography is built on number theory.
- Cryptography is essential to ecommerce (HTTPS), encrypted messaging, etc.
- But today we’ll just be covering the basics.
- Notation: p∣q is read as “integer p divides integer q.” p is said to be a factor or divisor of q. This means that qp is an integer.
- Notation: p∤ is read as “integer p does not divide integer q.” This means that \frac{q}{p} is not an integer.
- Give examples.
- A prime number is an integer greater than 1 that is divisible only by itself and 1.
- If the number is divisible by numbers other than itself and 1, it is a composite number.
- 1 is neither prime nor composite.
- Give examples of prime numbers, composite numbers, and factors.
- Write: The Fundamental Theorem of Arithmetic (FTA):
There is one and only one way to express a positive integer as a product of distinct prime numbers in increasing order and with positive integer exponents.
- The prime decomposition of a number n is that unique product: n = p_1^{e_1} \cdot \ldots \cdot p_k^{e_k} where p_i are primes in increasing order and e_i are positive integers.
- Example: 6 = 2^1 \cdot 3^1
- Example: 30 = 2^1 \cdot 3^1 \cdot 5^1
- Example: 180 = 2^2 \cdot 3^2 \cdot 5^1
- The prime decomposition of the product of two integers m and n combines the prime decompositions of m and of n.
- We will prove the FTA later in the course.
- The textbook uses the FTA to prove a simple theorem.
- Write: Theorem: If m, n, and p are integers greater than 1, p is prime, and p \mid m \cdot n , then either p \mid m or p \mid n .
- In plain language, this theorem states that every prime factor of m \cdot n is a prime factor of one or the other.
- Intuitively, this makes sense: the prime must come from somewhere.
- Due to time, we won’t prove this theorem, but if you are interested please refer to the textbook.
Number Theory Proofs
- Review the The Fundamental Theorem of Arithmetic
- Let’s prove a theorem:
- Write: Theorem: There are arbitrarily large prime numbers.
- “Arbitrarily large” means that for every n > 0, there is a prime number
greater than n.
- Write: Proof: Pick some value of k for which we know there are at least k primes, and let p_1, \ldots , p_k be the first k primes in increasing order.
- Since p_1 = 2, p_2 = 3, p_3 = 5, we could certainly take k = 3.
- We’ll show how to find a prime number greater than p_k.
- Since this process could be repeated indefinitely, there must be infinitely many primes.
- Consider the number N that is one more than the product of the first k primes: N = (p_1 \cdot p_2 \cdot \ldots \cdot p_k) + 1
- Dividing N by any of p_1, \ldots, p_k would leave a remainder of 1. So N has no prime divisors less than or equal to p_k.
- Therefore, either N is not prime but has a prime factor greater than p_k, or else N is prime itself.
- Show an example: k = 3. N = 2 \cdot 3 \cdot 5 + 1 = 31 . 31 is prime.
- Let’s introduce a new term.
- A common divisor of two numbers is a number that divides both of them.
- Example: 21 and 36 have the common divisors 1 and 3.
- Example: 16 and 21 have no common divisor greater than 1.
- Finally, let’s solve a theory problem using the Pigeonhole Principle.
- Write: Choose m distinct numbers between 2 and 40 inclusive, where m ≥ 13. Then at least two of the numbers have some common divisor greater than 1.
- Note: Inclusive means 2 and 40 are included.
- Our proof will use the pigeonhole principle. First, let’s think about our sets.
- There are 12 prime numbers less than or equal to 40.
- Write: P = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}
- Write: X is a set of at least 13 numbers in the range from 2 to 40 inclusive.
- Think of the members of X as pigeons and the members of P as pigeonholes.
- To place pigeons in pigeonholes, use the function:
- Write: f : X \rightarrow P , where f(x) is the smallest prime that divides x.
- Examples: f(16) = 2, f(17) = 17, f(21) = 3.
- By the Pigeonhole Principle, since 13 > 12, the values of f must be equal for two distinct members of X, meaning that at least two members of X have a common prime divisor.