Announcements. Problem Set 3 due Friday, October 21. Alternate Midterm Times. Drop by office hours! Ask questions at

Similar documents
The Pigeonhole Principle & Functions

Graph Theory Part Two

Functions. How is this definition written in symbolic logic notation?

A graph is a mathematical structure for representing relationships.

Functions 2/1/2017. Exercises. Exercises. Exercises. and the following mathematical appetizer is about. Functions. Functions

It is important that you show your work. There are 134 points available on this test.

Functions, High-School Edition

Functions. Jason Filippou UMCP. Jason Filippou UMCP) Functions / 19

Functions. Def. Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A.

2. Functions, sets, countability and uncountability. Let A, B be sets (often, in this module, subsets of R).

Functions, High-School Edition

MATHEMATICS 191, FALL 2004 MATHEMATICAL PROBABILITY Outline #1 (Countability and Uncountability)

Comparing sizes of sets

COMPUTABILITY THEORY AND RECURSIVELY ENUMERABLE SETS

Let A(x) be x is an element of A, and B(x) be x is an element of B.

Extra Practice Problems 2

Counting. Andreas Klappenecker

M3P1/M4P1 (2005) Dr M Ruzhansky Metric and Topological Spaces Summary of the course: definitions, examples, statements.

THREE LECTURES ON BASIC TOPOLOGY. 1. Basic notions.

13 th Annual Johns Hopkins Math Tournament Saturday, February 19, 2011 Automata Theory EUR solutions

MATH 22 MORE ABOUT FUNCTIONS. Lecture M: 10/14/2003. Form follows function. Louis Henri Sullivan

CONNECTED SPACES AND HOW TO USE THEM

MA651 Topology. Lecture 4. Topological spaces 2

CSE 20 DISCRETE MATH. Fall

Graph Theory Part Two

Cardinality Lectures

Ma/CS 6b Class 26: Art Galleries and Politicians

Lecture 1. 1 Notation

Section 1.1. Inductive Reasoning. Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Treaps. 1 Binary Search Trees (BSTs) CSE341T/CSE549T 11/05/2014. Lecture 19

Notes for Recitation 8

EDAA40 At home exercises 1

Figure 1: From Left to Right, General Venn Diagrams for One, Two, and Three Sets

Outline for Today. The Pigeonhole Principle. Graph Theory Party Tricks. The Hadwiger-Nelson Problem. Results that are too big to fail.

Continuous functions and homeomorphisms

3. Determine whether f is a function from the set of all bit strings to the set of integers if

QED Q: Why is it called the triangle inequality? A: Analogue with euclidean distance in the plane: picture Defn: Minimum Distance of a code C:

CSE 20 DISCRETE MATH. Winter

Section 1.1. Inductive Reasoning. Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Ramsey s Theorem on Graphs

Functions, High-School Edition

Grade 6 Math Circles November 6 & Relations, Functions, and Morphisms

5 Graphs

Math Circles: Pigeons and Rams(ey)

Functions and Sequences Rosen, Secs. 2.3, 2.4

Discrete mathematics , Fall Instructor: prof. János Pach

1.5 Part - 2 Inverse Relations and Inverse Functions

The Language of Sets and Functions

γ(ɛ) (a, b) (a, d) (d, a) (a, b) (c, d) (d, d) (e, e) (e, a) (e, e) (a) Draw a picture of G.

Notes on metric spaces and topology. Math 309: Topics in geometry. Dale Rolfsen. University of British Columbia

Problem One: A Quick Algebra Review

Chapter 4. Relations & Graphs. 4.1 Relations. Exercises For each of the relations specified below:

CHAPTER 7. Copyright Cengage Learning. All rights reserved.

MITOCW watch?v=4dj1oguwtem

Lecture 20 : Trees DRAFT

Ma/CS 6b Class 10: Ramsey Theory

Functions. Prof. Susan Older. 20 October (CIS 375) Functions 20 Oct / 14

2.3: FUNCTIONS. abs( x)

Point-Set Topology 1. TOPOLOGICAL SPACES AND CONTINUOUS FUNCTIONS

Proof Techniques Alphabets, Strings, and Languages. Foundations of Computer Science Theory

Matching Algorithms. Proof. If a bipartite graph has a perfect matching, then it is easy to see that the right hand side is a necessary condition.

Notes slides from before lecture. CSE 21, Winter 2017, Section A00. Lecture 9 Notes. Class URL:

Combinatorial Gems. Po-Shen Loh. June 2009

Ma/CS 6b Class 12: Ramsey Theory

Functions (4A) Young Won Lim 5/8/17

Lecture 17: Continuous Functions

Binomial Coefficient Identities and Encoding/Decoding

Notebook Assignments

1 Counting triangles and cliques

Graph Theory Questions from Past Papers

Midterm 2 Solutions. CS70 Discrete Mathematics and Probability Theory, Spring 2009

2010 SMT Power Round

CS61A Lecture 38. Robert Huang UC Berkeley April 17, 2013

HW 1 CMSC 452. Morally DUE Feb 7 NOTE- THIS HW IS THREE PAGES LONG!!! SOLUTIONS THROUGOUT THIS HW YOU CAN ASSUME:

Week 8: The fundamentals of graph theory; Planar Graphs 25 and 27 October, 2017

Instructor: Paul Zeitz, University of San Francisco

Lecture 19. Lecturer: Aleksander Mądry Scribes: Chidambaram Annamalai and Carsten Moldenhauer

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Notes slides from before lecture. CSE 21, Winter 2017, Section A00. Lecture 10 Notes. Class URL:

Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

Range Minimum Queries Part Two

p x i 1 i n x, y, z = 2 x 3 y 5 z

Infinity and Uncountability. Countable Countably infinite. Enumeration

Functions (4A) Young Won Lim 3/16/18

Lecture 7: the quotient topology

.Math 0450 Honors intro to analysis Spring, 2009 Notes #4 corrected (as of Monday evening, 1/12) some changes on page 6, as in .

CPS 102: Discrete Mathematics. Quiz 3 Date: Wednesday November 30, Instructor: Bruce Maggs NAME: Prob # Score. Total 60

Matchings, Ramsey Theory, And Other Graph Fun

Lecture 4: Petersen Graph 2/2; also, Friendship is Magic!

Math 443/543 Graph Theory Notes

MAT 145: PROBLEM SET 6

T. Background material: Topology

Zhibin Huang 07. Juni Zufällige Graphen

1.6 objective: Quiz on Friday

Math 443/543 Graph Theory Notes

CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5

Lecture 6: Faces, Facets

MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015

Theorem 2.9: nearest addition algorithm

Ambiguous Grammars and Compactification

Transcription:

Functions

Announcements Problem Set 3 due Friday, October 21 Drop by office hours! Ask questions at cs103@cs.stanford.edu. Alternate Midterm Times Wednesday, October 26, 7:00PM 10:00PM Thursday, October 27, 9:00AM 12:00 noon Please email us with a preference ASAP so that we can get appropriately-sized rooms.

A function is a means of associating each object in one set with an object in some other set.

Black and White

Black and White

Formally A function is a set f A B such that every value in A is associated with some value in B. More formally: If (a, b) f and (a, c) f, then b = c. For any a A, there is some b B such that (a, b) f. Even more formally: a A. b B. ((a, b) f c B. ((a, c) f c = b)) If (a, b) f, we write f(a) = b.

Terminology If f is a function from A to B, we sometimes say that f is a mapping from A to B. We call A the domain of f. We call B the codomain of f. We denote that f is a function from A to B by writing f : A B

Is this a function?

Is this a function?

Is this a function?

Is this a function? Each object in the domain has to be associated with exactly one object in the codomain!

Is this a function? Black and White

Is this a function? Black and White Every element of the domain must be associated with exactly one element of the codomain!

Is this a function? Black and White Every element of the domain must be associated with exactly one element of the codomain!

Is this a function?

Is this a function? Wish Funshine Love-a-Lot Tenderheart Friend

Is this a function? Wish Funshine Love-a-Lot Tenderheart Friend

Is this a function? Wish Funshine Love-a-Lot It's fine that nothing is associated with Friend; functions do not need to use the entire codomain. Tenderheart Friend

Classical Rock Jazz Country R&B

Classical Rock Jazz Country R&B

Classical Rock Jazz Country R&B

Classical Rock Jazz Country R&B

Classical Rock Jazz Country R&B

Classical Rock Jazz Country R&B The image of a function f : A B is the set f [A] = { y x A. f(x) = y }

Classical Rock Jazz Country R&B

Classical Rock Jazz Country R&B

Classical Rock Jazz Country R&B

Classical Rock Jazz Country R&B The image of a set X A is the set f [X] = { y x X. f(x) = y }

Classical Rock Jazz Country R&B

Classical Rock Jazz Country R&B

Classical Rock Jazz Country R&B

Classical Rock Jazz Country R&B The preimage of a set Y B is the set f -1 [Y] = { x y Y. f(x) = y }

Classical Rock Jazz Country R&B

Classical Rock Jazz Country R&B The preimage of a set may be empty.

Images and Preimages Let f : A B. The image of a set X A is the set f [X] = { y x X. f(x) = y } The preimage of a set Y B is the set f -1 [Y] = { x y Y. f(x) = y } The term range is sometimes used to refer to the image of A, though sometimes range refers to the entire codomain.

Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune Pluto

Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune Pluto

Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune

Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune

Injective Functions A function f : A B is called injective (or oneto-one) if each element of the codomain has at most one element of the domain associated with it. A function with this property is called an injection. More formally: x A. x' A. (f(x) = f(x') x = x')) An intuition: injective functions assign names from B to objects in A.

Front Door Balcony Window Bedroom Window

Front Door Balcony Window Bedroom Window

Surjective Functions A function f : A B is called surjective (or onto) if each element of the codomain has at least one element of the domain associated with it. A function with this property is called a surjection. More formally: y B. x A. f(x) = y An intuition: surjective functions cover every element of B with at least one element of A.

Recap An injective function associates at most one element of the domain with each element of the codomain. A surjective function associates at least one element of the domain with each element of the codomain. What about functions that associate exactly one element of the domain with each element of the codomain?

LOL AWWWWWW YEAAAAHHH Problem?

LOL AWWWWWW YEAAAAHHH Problem?

Bijections A function that associates each element of the codomain with a unique element of the domain is called bijective. Such a function is a bijection. Formally, a bijection is a function that is both injective and surjective. A bijection is a one-to-one correspondence between two sets.

Functions and Sets

Cardinality Recall (from lecture one!) that the cardinality of a set is the number of elements it contains. Denoted S. {1, 2, 3} = 3 {100, 200, 300} = 3 N = ℵ 0

Functions and Cardinality Formally: S = T There is a bijection f : S T

Functions and Cardinality Formally: S = T There is a bijection f : S T 0 1 2 3 4 5 6 7 8... 0 2 4 6 8 10 12 14 16... f(n) = 2n S = { x x N and x is even } S = N = ℵ 0

Functions and Cardinality Formally: S = T There is a bijection f : S T N 0 1 2 3 4 5 6 7 8... Z 0 1-1 2-2 3-3 4-4... f (n)={ n/2 (n+1)/2 Z = N = ℵ 0 if nis even otherwise

Comparing Cardinalities S = T is defined using bijections. We define S T as follows: S T There is a surjection f : T S Intuitively, we can cover set S using elements of T. Equivalently: S T There is an injection f : S T Intuitively, there are enough elements of T to assign one to each of the elements of S without running out.

Compositions

Function Composition Let f : A B and g : B C The function g f : A C is defined as (g f)(x) = g(f(x)) Note that f is applied first, but f is on the right side! Function composition is associative: h (g f) = (h g) f

Function Composition Suppose f : A A and g : A A. Then both g f and f g are defined. Does g f = f g? In general, no: Let f(x) = 2x Let g(x) = x + 1 (g f)(x) = g(f(x)) = g(2x) = 2x + 1 (f g)(x) = f(g(x)) = f(x + 1) = 2x + 2

The Identity Function Given a set A, the identity function on A is the special function id A : A A defined as id A (x) = x This function is not particularly exciting, but it does have its uses.

LOL AWWWWWW YEAAAAHHH Problem?

LOL AWWWWWW YEAAAAHHH Problem?

LOL AWWWWWW YEAAAAHHH Is this a function? Problem?

Inverses, Informally Informally, the inverse of a function f : A B is the function f -1 : B A such that if f(a) = b, then f -1 (b) = a. Not all functions have inverses: If the function isn't injective, then for some a 0 a 1, f(a 0 ) = b = f(a 1 ). What is f -1 (b)? If the function isn't surjective, some element of b B has nothing mapping to it. What is f -1 (b)? If a function is not bijective, it is not invertible.

LOL AWWWWWW YEAAAAHHH Problem?

LOL AWWWWWW YEAAAAHHH Problem?

LOL AWWWWWW YEAAAAHHH Problem?

LOL AWWWWWW YEAAAAHHH Problem?

Inverses, Formally The inverse of a function f : A B is a function f -1 : B A such that That is, f -1 (f(x)) = x f -1 f = id Inverse functions are unique. Theorem: A function has an inverse iff it is bijective. Interesting exercise: why is this? A

The Pigeonhole Principle

The Pigeonhole Principle Suppose that you have n pigeonholes. Suppose that you have m > n pigeons. If you put the pigeons into the pigeonholes, some pigeonhole will have more than one pigeon in it.

The Pigeonhole Principle Suppose that you have n pigeonholes. Suppose that you have m > n pigeons. If you put the pigeons into the pigeonholes, some pigeonhole will have more than one pigeon in it.

The Pigeonhole Principle Suppose that you have n pigeonholes. Suppose that you have m > n pigeons. If you put the pigeons into the pigeonholes, some pigeonhole will have more than one pigeon in it.

The Pigeonhole Principle Suppose that you have n pigeonholes. Suppose that you have m > n pigeons. If you put the pigeons into the pigeonholes, some pigeonhole will have more than one pigeon in it.

Proof of the Pigeonhole Principle Theorem: If m > n objects are put into n bins, there must be some bin with at least two objects in it. Proof: By contradiction; assume all n bins have at most one element in them. But then there are are at most n elements distributed across them, contradicting the fact that m > n + 1. We have reached a contradiction, so our assumption was wrong and some bin has at least two objects in it.

Proof of the Pigeonhole Principle Theorem: If m > n objects are put into n bins, there must be some bin with at least two objects in it. Proof: By contradiction; assume all n bins have at most one element in them. But then there are are at most n elements distributed across them, contradicting the fact that m > n + 1. We have reached a contradiction, so our assumption was wrong and some bin has at least two objects in it.

Proof of the Pigeonhole Principle Theorem: If m > n objects are put into n bins, there must be some bin with at least two objects in it. Proof: By contradiction; assume all n bins have at most one element in them. But then there are are at most n elements distributed across them, contradicting the fact that m > n + 1. We have reached a contradiction, so our assumption was wrong and some bin has at least two objects in it.

Proof of the Pigeonhole Principle Theorem: If m > n objects are put into n bins, there must be some bin with at least two objects in it. Proof: By contradiction; assume all n bins have at most one element in them. But then there are are at most n elements distributed across them, contradicting the fact that m > n. We have reached a contradiction, so our assumption was wrong and some bin has at least two objects in it.

Proof of the Pigeonhole Principle Theorem: If m > n objects are put into n bins, there must be some bin with at least two objects in it. Proof: By contradiction; assume all n bins have at most one element in them. But then there are are at most n elements distributed across them, contradicting the fact that m > n. We have reached a contradiction, so our assumption was wrong and some bin has at least two objects in it.

Proof of the Pigeonhole Principle Theorem: If m > n objects are put into n bins, there must be some bin with at least two objects in it. Proof: By contradiction; assume all n bins have at most one element in them. But then there are are at most n elements distributed across them, contradicting the fact that m > n. We have reached a contradiction, so our assumption was wrong and some bin has at least two objects in it.

Some Simple Applications Any group of 367 people must have a pair of people that share a birthday. 366 possible birthdays (pigeonholes) 367 people (pigeons) Two people in San Francisco have the exact same number of hairs on their head. Maximum number of hairs ever found on a human head is no greater than 500,000. There are over 800,000 people in San Francisco.

Nonconstructive Proofs The pigeonhole principle often is used in nonconstructive proofs. A proof is constructive if it shows how to find some particular object. Examples: Proving any tournament graph has a tournament winner. Showing that a 2 n 2 n board with a square missing can be tiled with right triominoes. A proof is nonconstructive if it guarantees that some object must exist, but does not say how to find it. What two SF residents have the same number of hairs on their heads?

Proofs with Pigeonholes Proofs using the pigeonhole principle often work as follows: Construct some set of n bins into which at least n + 1 elements must be distributed. (This is the creative step of the proof) Claim, by the pigeonhole principle, that some bin must contain at least two distinct objects. Argue that these two objects must have something in common, which can be used to assert that some object must exist.

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Proof: Consider any equilateral triangle whose side lengths are d. Put this triangle anywhere in the plane. By the pigeonhole principle, because there are three vertices, two of the vertices must have the same color. These vertices are at distance d from each other, as required.

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Thought: There are two colors here, so if we Proof: Consider any equilateral triangle whose side lengths start picking points, we'll be dropping them are d. Put this triangle anywhere in the plane. By the into one of two buckets (red or blue). pigeonhole principle, because there are three vertices, two of the vertices must have the same color. These vertices are at How many points do we need to pick to distance d from each other, as required. guarantee that we get two of the same color?

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Proof: Consider any equilateral triangle whose side lengths are d. Put this triangle anywhere in the plane. By the pigeonhole principle, because there are three vertices, two of the vertices must have the same color. These vertices are at distance d from each other, as required.

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Proof: Consider any equilateral triangle whose side lengths are d. Put this triangle anywhere d in the d plane. By the pigeonhole principle, because there are three vertices, two of the vertices must have the same color. These vertices are at distance d from each other, as required.

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Proof: Consider any equilateral triangle whose side lengths are d. Put this triangle anywhere d in the d plane. By the pigeonhole principle, because there are three vertices, two of the vertices must have the same color. These vertices are at distance d from each other, as required.

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Proof: Consider any equilateral triangle whose side lengths are d. Put this triangle anywhere d in the d plane. By the pigeonhole principle, because there are three vertices, two of the vertices must have the same color. These vertices are at distance d from each other, as required.

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Proof: Consider any equilateral triangle whose side lengths are d. Put this triangle anywhere d in the d plane. By the pigeonhole principle, because there are three vertices, two of the vertices must have the same color. These vertices are at distance d from each other, as required.

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Proof: Consider any equilateral triangle whose side lengths are d. Put this triangle anywhere d in the d plane. By the pigeonhole principle, because there are three vertices, two of the vertices must have the same color. These vertices are at distance d from each other, as required.

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Proof: Consider any equilateral triangle whose side lengths are d. Put this triangle anywhere d in the d plane. By the pigeonhole principle, because there are three vertices, two of the vertices must have the same color. These vertices are at distance d from each other, What if as we required. could force these two points to be distance d from one another?

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Proof: Consider any equilateral triangle whose side lengths are d. Put this triangle anywhere in the plane. By the pigeonhole principle, because there are three vertices, two of d d the vertices must have the same color. These vertices are at distance d from each other, as required. d

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Proof: Consider any equilateral triangle whose side lengths are Any d. pair Put of this points triangle is at anywhere in the plane. By the pigeonhole distance d principle, from one because there are three vertices, two of the another. vertices Since must two have must d d the same color. These vertices are at distance be the same d from color, each there other, as required. d is a pair of points of the same color at distance d!

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Proof: Consider any equilateral triangle whose side lengths are d. Put this triangle anywhere in the plane. By the pigeonhole principle, because there are three vertices, two of the vertices must have the same color. These vertices are at distance d from each other, as required.

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Proof: Consider any equilateral triangle whose side lengths are d. Put this triangle anywhere in the plane. By the pigeonhole principle, because there are three vertices, two of the vertices must have the same color. These vertices are at distance d from each other, as required.

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Proof: Consider any equilateral triangle whose side lengths are d. Put this triangle anywhere in the plane. By the pigeonhole principle, because there are three vertices, two of the vertices must have the same color. These vertices are at distance d from each other, as required.

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Proof: Consider any equilateral triangle whose side lengths are d. Put this triangle anywhere in the plane. By the pigeonhole principle, because there are three vertices, two of the vertices must have the same color. These vertices are at distance d from each other, as required.

A More Complex Application Theorem: Suppose that every point in the real plane is colored either red or blue. Then for any distance d > 0, there are two points exactly distance d from one another that are the same color. Proof: Consider any equilateral triangle whose side lengths are d. Put this triangle anywhere in the plane. By the pigeonhole principle, because there are three vertices, two of the vertices must have the same color. These vertices are at distance d from each other, as required.

The Limits of Data Compression

The Pigeonhole Principle and Functions Consider a function f : A B for finite sets A and B. If A > B, then by the pigeonhole principle some element of B has at least two elements of A that map to it. Thus f cannot be injective.

Bitstrings A bitstring is a finite sequence of 0s and 1s. Examples: 11011100 010101010101 0000 ε (the empty string) There are 2 n bitstrings of length exactly n. There are 2 0 + 2 1 + + 2 n = 2 n + 1 1 bitstrings of length at most n. We proved this by induction earlier in the quarter.

Data Compression Inside a computer, all data are represented as sequences of 0s and 1s (bitstrings) To transfer data (across a network, on DVDs, on a flash drive, etc.), it is advantageous to try to reduce the number of 0s and 1s before transferring it. Most real-world data can be compressed by exploiting redundancies. Text repeats common patterns ( the, and, etc.) Bitmap images use similar colors throughout the image. Idea: Replace each bitstring with a shorter bitstring that contains all the original information. This is called lossless data compression.

101010101010101010101010101010

101010101010101010101010101010 1111110 Compress

101010101010101010101010101010 1111110 Compress Transmit 1111110

101010101010101010101010101010 1111110 Compress Transmit 1111110 Decompress 101010101010101010101010101010

Lossless Data Compression In order to losslessly compress data, we need two functions: A compression function C, and A decompression function D. These functions must be inverses of one another: D = C -1. Otherwise, we can't uniquely encode or decode some bitstring. Since C is invertible, C must be a bijection.

A Perfect Compression Function Ideally, the compressed version of a bitstring would always be shorter than the original bitstring. Question: Can we find a lossless compression algorithm that always compresses a string into a shorter string? Let's assume we only care about strings of length at least 10.

A Counting Argument Let n be the set of strings of length n, and <n be the set of strings of length less than n. How many bitstrings of length n are there? Answer: 2 n How many bitstrings of length less than n are there? Answer: 2 0 + 2 1 + + 2 n 1 = 2 n 1 Using our earlier result, by the pigeonhole principle, there cannot be an injective function from n to <n. Since every bijection is an injection, there is no bijection between n and <n. There is no perfect compression function!

Why this Result is Interesting Our result says that no matter how hard we try, it is impossible to compress every string into a shorter string. No matter how clever you are, you cannot write a lossless compression algorithm that always makes strings shorter. In practice, only highly redundant data can be compressed. The fields of information theory and Kolmogorov complexity explore the limits of compression; if you're interested, go explore!

Next Time Structural Induction Trees A Sorting Lower Bound