UPI Study › Courses › Discrete Mathematics › Free lessons › Lesson 2.8 Free with a free account
Surjective and Bijective Functions
Discrete Mathematics · Chapter 2: Set Theory and FunctionsSection 2.8 · lesson 16 of 879 min · free with a free account
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Discrete Mathematics.
Lesson complete
Earn the 4 college credits for Discrete Mathematics
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: Introduction to Sequences →← Injective Functions: One-to-One Mappings and Their PropertiesNext lesson: Introduction to Sequences →
In this lesson
Every slot used, nothing left over - and a function you can run backwards.
- Define a surjective (onto) function
- Define a bijection as injective and surjective together
- Prove that an inverse exists exactly for bijections
- Connect bijections to equal cardinality - and avoid the converse trap
Transcript
Everything said in the video, section by section (1,287 words). Read along, or search it.
Set Theory and Functions
Surjective and Bijective Functions
This last section of chapter two adds a new property of functions, and then combines it with injectivity. We'll define surjective, or onto, functions, and bijections, which are injective and surjective together. We'll prove exactly when a function can be run backwards. And we'll connect bijections to the sizes of sets, while avoiding a tempting trap.
The Opening Problem
A Migration That Can't Lose a Record
A software team is migrating a legacy system's user records into a new database, with a fresh ID scheme. Every one of the old system's one hundred thousand record IDs must map to exactly one new ID. That's just what it means for the remapping to be a function. But leadership has a sharper requirement. The new system has exactly one hundred thousand ID slots, and every single one must end up assigned to a migrated record. An empty slot would mean a record silently vanished during migration. That's exactly the kind of bug a migration can't afford. And once that property and injectivity hold together, the migration gains something for free. Engineers can run it backwards on demand, taking any new ID and recovering which old record produced it. Exactly what an audit or a rollback needs.
Definition 2.8.1
Surjective, or Onto
For a function f from A to B, every output is automatically in the codomain B. That's built into what a function is. What isn't automatic is whether every element of B actually gets used as an output. A function is surjective, or onto, if every element of B has at least one preimage in A. For every b in B, there's at least one a with f of a equal to b. Equivalently, f is surjective exactly when its range equals the whole codomain, rather than merely being a subset of it.
Table 2.8.1
A First Attempt: 4 Records, 5 Slots
Here's a first attempt at the migration, with four old IDs and five new slots, one over-provisioned. One oh one maps to slot two, one oh two to slot five, one oh three to slot one, and one oh four to slot four. Check every slot. Slots one, two, four, and five each have a preimage. But slot three has none. So f is not surjective. A slot was left empty. Notice what this does and doesn't say. The outputs, two, five, one, and four, are all different. So f is perfectly injective. Injectivity says no slot gets hit twice. It says nothing about whether every slot gets hit. A function can have one property without the other. Here, one extra, unused slot is exactly what keeps an otherwise well-behaved function from being surjective.
Table 2.8.2
Corrected: 4 Records, 4 Slots
Now remove the extra slot, so there are exactly four slots for the four old records. Define g. One oh one maps to three, one oh two to one, one oh three to four, and one oh four to two. Check every slot. Slot one comes from one oh two. Slot two from one oh four. Slot three from one oh one. And slot four from one oh three. Every slot has a preimage, in fact exactly one. So g is surjective.
Definition 2.8.2
Bijective: Both at Once
A function is bijective, or a bijection, if it's both injective and surjective. A bijection is also called a one-to-one correspondence. It pairs every element of A with a unique element of B, and every element of B with a unique element of A. Nothing on either side is left unpaired. The corrected migration g is bijective. Its table already confirms it's surjective. And its outputs, three, one, four, and two, are all different, so it's injective too.
Figure 2.8.1
Injective Only, Versus Bijective
This figure draws both functions as arrow diagrams, side by side. On the left, f is injective but not surjective. Slot three receives no arrow. On the right, g is bijective. Every old record has exactly one outgoing arrow, and every slot has exactly one incoming arrow. It's a perfect pairing, with nothing left over on either side.
Table 2.8.3
The 3 Properties Compared
This table compares the three properties. An injective function can still leave some element of B with no preimage. It requires A to be no larger than B. A surjective function can still reach some element of B more than once. It requires A to be at least as large as B. A bijection fails in neither way, and it requires A and B to be exactly the same size. We'll prove the cardinality part carefully at the end of this section.
Definition 2.8.3 and Theorem 2.8.1
When Can a Function Be Reversed?
A one-to-one correspondence invites a question. Can the pairing be read in the opposite direction, as a function from B back to A? An inverse function, f inverse, from B to A, satisfies two identities. f inverse of f of a is a, for every a. And f of f inverse of b is b, for every b. Here's the theorem. A function has an inverse if and only if it's bijective. Suppose f is bijective, and take any b. Since f is surjective, some a maps to b. Since f is injective, that a is unique. So define f inverse of b to be that a. Both identities then hold. Conversely, suppose an inverse exists. If f of a one equals f of a two, apply f inverse to both sides, and you get a one equals a two. So f is injective. And for any b, let a be f inverse of b. Then f of a is b, so b has a preimage. So f is surjective too, and therefore bijective.
Reading Off the Inverse
The Audit Lookup
Reading off g inverse is immediate. Just reverse each pair. g inverse of one is one oh two. g inverse of two is one oh four. g inverse of three is one oh one. And g inverse of four is one oh three. That's precisely the audit lookup the migration team needed. Contrast the first attempt, f. Trying to define f inverse of three, there's nothing to point to, since no record maps to slot three. So f inverse would be undefined there, and it fails to be a function on all of B. That's the theorem failing in practice, because f isn't surjective. A repeated output would break the inverse in the other way. It would stop being well-defined.
Theorem 2.8.2
Bijections Force Equal Size
Recall that the cardinality of a finite set is the count of its distinct elements. A bijection between two finite sets forces those counts to agree. Theorem. If A and B are finite and there's a bijection from A to B, then A and B have the same cardinality. The proof. List A's n elements, a one through a n. Applying f gives a list of n values, all in B. Because f is injective, those n values have no repeats. Because f is surjective, every element of B appears somewhere in the list. A list of n distinct values that includes every element of B is exactly B. So B has n elements, the same as A. That's why the engineers built the new system with exactly one hundred thousand slots. It made a bijection possible in the first place.
The Converse Trap
Equal Size Isn't Enough
But the converse deserves a careful warning. Equal cardinality is a necessary condition for a bijection to exist between two sets. It is not sufficient to make any particular function one. Here's something to think about. With four records and four slots, a junior engineer says whatever migration we write is automatically a bijection. Test that against h, which sends one oh one and one oh two both to slot one, one oh three to two, and one oh four to three. Is h bijective? And what's the difference between equal sizes guaranteeing a bijection could exist, and guaranteeing this particular function is one? To summarize. Surjective means the range is the whole codomain. Bijective means injective and surjective. An inverse exists exactly for bijections, and a bijection forces equal sizes.
About Discrete Mathematics at UPI Study
Discrete Mathematics (Math 230) is a self-paced online course of 87 video lessons in 13 chapters, from logic and proof to counting, probability, graph theory and trees. It carries a NCCRS credit recommendation for 4 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus Every course with PRO →
Why take it here
Why students take Discrete Mathematics with UPI Study
Where the credit goes
Universities that work with NCCRS
Discrete Mathematics carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About Surjective and Bijective Functions
What does it mean for a function to be surjective (onto)?
What is a bijection, and how is it different from an injective function?
Why does a function have an inverse only if it is a bijection?
If two finite sets have the same size, is every function between them a bijection?
About the Discrete Mathematics course
How many college credits is Discrete Mathematics?
How much does Discrete Mathematics cost and what is included?
Which universities accept UPI Study credits?
How long does Discrete Mathematics take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 4 credits in Discrete Mathematics.
87 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
4 credits · NCCRSEnroll →