Squaring a number, reflecting a point and seating each guest at a table are all processes that turn one thing into another, and a proof about any of them needs to know exactly what such a process is and when it can be undone.
The previous lesson made collections precise as sets, with subsets, the Cartesian product of ordered pairs, and the habit of proving two sets equal by showing each contains the other. A set on its own does nothing, though. This lesson builds processes out of sets, assuming only that lesson, the quantifiers, and the direct and contrapositive proofs before it. As throughout the course, starts at .
What a function is
Let and be sets. A function is a rule that assigns to each element of exactly one element of , written and called the value of at . The set is the domain and is the codomain. A rule given by a formula is often written with a barred arrow, as in , read " goes to ".
"Rule" is informal, and the previous lesson supplies the formal version in one sentence: a function from to is the sets and together with a subset of such that for every there is exactly one with , and names that . Nothing here asks for a formula, so a seating plan is as much a function as is.
"Exactly one" makes two demands: every element of the domain receives a value, and none receives two. The rule "send to a real number whose square is " fails both as a function from to : at there is no such number, and at there are two. The square root repairs both by shrinking the domain to and choosing the non-negative root, a convention rather than a discovery.
Two functions are equal when they have the same domain, the same codomain, and the same value at every element of the domain. So and on are one function written two ways.
Why the codomain is part of the function
Take the rule with two codomains: and , with . They have the same set of pairs, yet they answer one question differently: is every element of the codomain a value? For it is, since each equals . For it is not, since no real number squares to .
That question decides, later in this lesson, whether a function can be undone: an inverse of would have to send somewhere, and there is nowhere to send it. That is why the codomain is recorded as part of the function, why and count as different, and why " is surjective" is neither true nor false until the codomain is named.
The values a function actually takes form its range, , a subset of the codomain. For and alike it is . The codomain is where values may land; the range is where they do.
Image and preimage
For and , the image of is , the values taken on . For , the preimage of is , the inputs that land in . The notation is a trap: is a set, and it exists for every function, whether or not has an inverse.
With on , the image of is : squares of numbers in lie between and , and each in is the square of . The preimage of is , since negative inputs count too, and the preimage of is .
A round trip need not return where it started: the preimage of is , whose image is , strictly smaller than . One inclusion always holds, though.
Example. Let and . Prove that .
Let . By the definition of image, for some . By the definition of preimage, means . So , and since was arbitrary, the inclusion holds.
The reverse fails for because is not a value at all. In general is exactly the part of that reaches, so equality holds for every precisely when every element of is a value.
Now you. Let and . Prove that , and find a set for which the inclusion is strict when .
Answer
Let . Then is the value of at an element of , so by the definition of image. By the definition of preimage, an element of whose value lies in belongs to , so . Hence . For strictness take : then and , which contains . The round trip collects every input that shares a value with something in .
Injective, surjective and bijective
A function is injective, or one-to-one, when distinct inputs give distinct outputs. The useful form is the contrapositive: for all , if then . The proof template is "Let with ", then algebra, then "so ". To disprove it, one pair suffices: .
It is surjective, or onto, when every element of the codomain is a value: for every there exists with . The template follows the quantifiers: "Let . Put ", then check that and . The formula for comes from scratch work solving , which is not part of the proof; the check that lies in the domain is, and it is the step most often forgotten. To disprove it, name one and prove that has no solution in .
It is bijective, a bijection, when it is both, so that each is the value of exactly one . The two properties are independent. The map , , is injective, since gives , but not surjective, since forces . With the even natural numbers as codomain, the same rule is a bijection. The function is surjective and not injective.
Example. Prove that , , is a bijection.
Injective: let with . Then , so , and dividing by gives . Surjective: let and put . This is a real number, and . So is injective and surjective, hence a bijection.
On the integers the same rule, from to , is injective by the same argument but not surjective: needs , not an integer. The membership check is exactly where the two cases part.
Now you. Let be given by . Show that never takes the value , so that it is a function into , and prove that it is a bijection.
Answer
Values: would give , which is false. Injective: let with . Clearing denominators, , so . Surjective: let and put , defined since . It is not , since would give . And . So is a bijection. Both excluded points were forced: because the formula fails there, because it is never reached.
Composition
Given and , the composite is , read " after ": runs first. Order matters: with and on , while . Composition is associative, since and both send to , so brackets can be dropped.
Example. Prove that if and are injective, then is injective.
Let with . The elements and of have the same value under , and is injective, so . Since is injective, . So is injective.
The proof peels the functions off from the outside in. A partial converse holds: if is injective then so is , since gives and so . But need not be: with , , the composite is injective while is not.
Now you. Prove that if and are surjective, then is surjective.
Answer
Let . Since is surjective, there is with . Since is surjective, there is with . Then , so is surjective. Again the proof works from the outside in, finding before .
Together the two results say that a composite of bijections is a bijection.
Inverses
The identity on is , . A function is an inverse of when and .
Theorem. A function has an inverse if and only if it is a bijection.
Suppose first that is an inverse. For injectivity, let ; applying gives . For surjectivity, let and put ; then . Conversely, suppose is a bijection. For each , surjectivity gives some with and injectivity says there is only one, so letting be that assigns exactly one element of to each , and is a function. By construction . For , is the unique element sent to , and is such an element, so . Hence is an inverse.
Each half of the definition did one job: forced injectivity and surjectivity. Neither alone is enough. For , the map sending an even to and an odd to satisfies , yet . An inverse is also unique: if and are both inverses, then by associativity. So it earns the name . For it is , the formula the surjectivity proof already found.
Counting functions between finite sets
Let and , and list as . A function is a free choice of , then , and so on, each from : an ordered list of elements of . By the product rule of the previous lesson, extended to factors by induction, there are functions from to .
For an injection each choice must avoid the earlier ones: options for , for , down to for . So there are injections, a falling factorial. When some factor is and there are none, which is the pigeonhole principle. When , an injection takes distinct values in a set of elements, so it hits all of , and there are bijections.
A computer listing every function on small sets agrees. From a 3-element set to a 4-element set there are functions, of which are injective. From a 4-element set to itself there are , and exactly are injective, the same that are surjective. The falling factorial also settles the birthday problem: of the ways to give 23 people birthdays, the injective fraction is , so a shared birthday is more likely than not.
For finite sets of equal size, then, injective and surjective coincide. The map on , injective and not surjective, shows that this fails for infinite sets, a first sign that counting the infinite needs a different idea.
When one output is not enough
A function relates each input to exactly one output, and that restriction is what made composition and inverses work. Many relations mathematics cares about break it. "Divides" on the positive integers links to , , and every other multiple. The equation links to both and and links to nothing, so the circle is not the graph of a function from to . "Leaves the same remainder on division by " links to , and .
Each is still a set of ordered pairs, a subset of a product, with the "exactly one" condition dropped. The next lesson takes such relations up, beginning with the ones that declare two things to be the same for present purposes.