Lesson 4
Functions
Taught
More Sets
Once the axioms of set theory are in place, we can review some elementary albeit very useful constructions that these axioms enable.
Ordered Pairs
We often need to pair two elements while retaining their positions, and an ordinary two-element set cannot do this, since ; something more is needed if one element is to be marked as coming before the other. We could simply declare that the notation is ordered, but what does ordered mean in terms of sets?
Before choosing a set to represent , we state the property any such choice must have: whenever and are ordered pairs,
In particular, the two coordinates must be recoverable from the pair.
Definition 4.1 (Ordered pair).
Let and be objects. The ordered pair is the set
where is its first coordinate and its second coordinate.
The sets used to encode the pair, and , are supplied by the pairing axiom of the last chapter, and the set on the right exists by that same axiom applied once more, to those two. The construction is due to Kuratowski. Does it satisfy ?
Proposition 4.2 (Equality of ordered pairs).
For objects , , and , if and only if and .
Discussion.
Our statement is a biconditional. The reverse implication, and implies , is a direct substitution into the definition of the ordered pair. For the forward implication we assume and must recover the coordinates from the set; the argument splits into the cases and , because in the first case the pair collapses to the singleton while in the second its two elements are distinct and can be chased through the equality one at a time. The logical proof avoids the split: it expands each ordered pair, rewrites set equality as the two inclusions by mutual inclusion, and lets the distributive and absorption laws of the first chapter reduce the resulting disjunctions to the conjunction .
Proof (element style).
Let , , and be arbitrary objects. For the reverse implication, suppose and . Then and ; hence .
For the forward implication, suppose . By the definition of set equality, every element of either ordered pair belongs to the other; we divide the argument into two cases, and .
If , then . Both and belong to , so each must equal ; hence and . Since as well, we obtain and .
If , then ; consequently has two distinct elements. Since , either or . The latter equality would give , so would have only one element; this contradicts , since has two. Therefore , and hence .
Similarly, since , either or . The former equality would give , contradicting ; therefore . It follows that or ; but , so and hence . Thus and .
Remark.
This logical proof is dumb and covoluted lol but why not.
Proof (logical style).
Let , , and be arbitrary objects. By the definition of set equality,
Corollary 4.3 (Swapping coordinates).
For objects and , if and only if .
Proof.
If , then Proposition 4.2 gives by comparing first coordinates. Conversely, if , then .
Kuratowski’s is not the only set that will serve. A shorter candidate suggests itself, and the next problem asks what it costs.
Some authors define the ordered pair by the shorter set
- Prove that this also satisfies , so that if and only if and . You may use the axiom of regularity from the last chapter, and in particular the conclusion of its second problem.
- Show that regularity is genuinely needed, by identifying the step of your argument that fails without it, and say why the same step does not arise for Definition 4.1 .
Nesting ordered pairs builds longer ordered tuples.
Definition 4.4 (Ordered triples and longer).
Let , , and be objects. The ordered triple and ordered quadruple are
and further tuples are assembled the same way.
Remark.
We have now overloaded the parenthesis symbols once again: they are used not only to group operators and arguments, but also to enclose ordered pairs. This is usually not a problem in practice, as one can still determine from context which usage is intended.
Cartesian Products
With ordered pairs in hand we can collect all of them at once. The collection has to come from somewhere, and the power set supplies it.
Proposition 4.5 (Where ordered pairs live).
Let and be sets, let and . Then .
Discussion.
An ordered pair is a set of two sets, so it sits two power sets up from whatever holds its coordinates, and the set holding both coordinates is . The work is to climb that ladder one rung at a time: show each of and is a subset of , which puts both in , and then that having both as elements makes a subset of , which is what membership in the next power set asks for.
Proof.
Since we have , and since we have . Every element of is , and every element of is or , so both and , that is, both belong to .
The elements of are exactly those two sets, so , which is .
Definition 4.6 (Cartesian product).
Let and be sets. The Cartesian product is the set of all ordered pairs with first coordinate in and second in ,
so that for every object , exactly when for some and some .
The product needs no axiom of its own. The proposition above puts every candidate pair inside , a set we are already holding, and comprehension carves the product out of it.
Let and . Then . Order matters here in a way it did not for unordered pairs: while , and the two products are different sets.
Let and be sets. Show that if and only if or .
Membership in a product is a conjunction, which adds another line to the dictionary:
Order matters, and in general . With and we have , which is not the earlier set: the element lies in but not in , since .
For any set , both and are empty. A pair in would need its second coordinate from , which has nothing to give; through the dictionary, .
Products of three or more sets work the same way, collecting the triples with , and , and so on upwards. There is a wrinkle in that, and it is worth seeing before we lean on the notation.
Remark (Order of operations).
The definition takes two sets at a time, so for three sets there are two readings, and they are not the same set. Applying it twice, the elements of are the pairs , which unfold to
while the elements of are the pairs , which unfold to
Both should intuitively be the set of all triples , and they do describe the same object once we identify them. Using a term we introduce below, the identification amounts to checking that
is a bijection from the first set onto the second, so the product is associative up to that correspondence. Once bijections are in hand this is a short piece of work, and the problems below ask you to do it; from then on we drop the brackets and write .
We said that in general. Find every case in which they are equal.
Indexed Families
A bag of sets is awkward to work with, since we keep having to point at its members. Giving each set a label fixes that: every member becomes addressable, and the labels do the organising from then on.
Definition 4.10 (Indexed family).
Let be a set. An indexed family consists of one object for each , and is written . The set is the index set and is an index. Different indices may label the same object.
Let , and be sets, take , and declare , , and . The family has four entries, and the coincidence erases neither of them: the labels and know themselves apart even when the objects they carry do not. The braces in the notation are a convention, since what we are holding is an assignment of an object to each index, and that assignment remembers what the plain set of members, , has already forgotten.
Definition 4.12 (Indexed unions and intersections).
Let be an indexed family of sets with non-empty. Its union and intersection are
so that exactly when for some , and exactly when for every .
Neither needs an axiom beyond those we have. Replacement turns the index set into the set of members, since each has exactly one partner , and the union axiom pools what those members hold. The intersection is then carved out of that union by comprehension, exactly as the intersection of a system of sets was in the last chapter, and for the same reason: an object lying in every member lies in some member, so nothing is lost by looking only inside the union.
By the bounded quantifier convention of the last chapter, the two membership tests unabbreviate to for the union and for the intersection.
For the new symbols hand back the old ones, and . With quantifiers doing the work, the negation rules settle what it takes not to belong:
An is kept out of the intersection by a single refusing set, but kept out of the union only when every set refuses it.
Let and let be the set of whole numbers with . Determine and .
Let be a non-empty set, let be a statement not involving , and let be a predicate on . Prove the two exchange laws
Where does the non-emptiness of enter? Show that if one of the two equivalences survives and the other fails.
Proposition 4.13 (Set difference over indexed families).
Let be a set and let be an indexed family of sets with non-empty. Then
- ;
- .
Discussion.
Both are equalities of sets, so we compare membership on the two sides, and each comparison admits two readings. Elementwise, an element of sits in and misses some , so it sits in and hence in the union of the differences; conversely, belonging to one difference already keeps the element out of the intersection. The second identity is the same pair of thoughts with “some” replaced by “every”. The logical route says this through the dictionary: the definition turns membership in the intersection into a universal quantifier and membership in the union into an existential one, the negation rules swap for and back, and the exchange laws of the problem above push the fixed condition through the quantifier.
Proof (element style).
For the first, suppose . Then , but does not belong to every , so for some . Hence , and therefore . Conversely, suppose belongs to that union. Then for some we have , so and . It follows that , whence .
For the second, suppose . Then and for every , so for every , that is, . Conversely, membership in that intersection gives for every , so and no holds , which puts in .
Proof (logical style).
For any ,
and likewise
Corollary 4.14 (De Morgan's laws for indexed families).
Let be an indexed family of subsets of an ambient set , with non-empty. With every complement taken in ,
Proof.
Take in the two parts of the proposition. Each difference is the complement , and the identities follow.
Let be a set and an indexed family of sets with non-empty. Prove that if and only if for every , and that if and only if for every .
Let be an indexed family of sets with and non-empty. Decide which inclusion between
holds for every such family, and whether equality is forced. (Harder.)
Functions
In order to do analysis it is not particularly useful to have only the notion of a set; we also need the notion of a function from one set to another. Informally, a function is an operation which assigns to each element, or input, in a single element, or output, in . Formulas, rules and graphs are convenient ways to describe the pairing of inputs with outputs, but the set of pairs itself is the function.
Let and be sets. A function from to is a subset such that for every there is exactly one with . We write , call the domain of , written , and the codomain, and write for the unique paired with , so that for any and ,
The condition on is sometimes called the vertical line test: exactly one pair of stands above each point of the domain. It is two demands at once, existence and uniqueness, and either can fail on its own.
We also write for the pairing. The object is the image of , and is a preimage of , one of possibly several. Functions are also called maps, mappings or transformations, depending on the context.
Remark.
A function is often handed to us as a property rather than a set of pairs. Let pertain to and , and suppose that for every there is exactly one making true. Then
is a set by comprehension, and the hypothesis on is exactly the vertical line test, so is a function from to with precisely when holds. No further axiom is needed to turn a property into a function; the ones we already have build the set of pairs for us.
Assuming you know what the real numbers are, take both domain and codomain to be them. The declaration assigns nothing at , so existence fails there and is not a function on that domain. The condition offers two candidates whenever , namely and , so uniqueness fails and is not a function either.
Remark (Informal examples).
Several examples below assume you know the real numbers and the whole numbers, which we have not built yet. In those we write for the real numbers and for the whole numbers, and we borrow the rules of school algebra openly. Nothing in the theory rests on them; they are there because familiar objects make the definitions easier to read.
A rule that meets both requirements, assigning a unique value in the codomain to every element of the domain, is said to be well defined. One common way to present a function is to specify its domain, its codomain, and how the output is generated from each input; this is an explicit definition.
Remark.
Functions obey substitution: if then , since was defined as the unique paired with , and and name the same object. Equal inputs give equal outputs. Unequal inputs need not give unequal outputs, as a constant map shows.
Three functions occur often enough to deserve names.
Definition 4.17 (Inclusion, identity and constant maps).
Let . The inclusion map is defined by . When this is the identity map on , written . For sets and and a fixed , the constant map with value is given by for every .
There is a function from to any set , namely the empty set of pairs. Neither requirement can find an element of on which to fail, so both hold vacuously. It is a dull function, but a function all the same, and we shall see below that it is the only one from to .
When the domain and codomain are sets of real numbers we can plot the pairs of in the Cartesian plane to draw its graph; for this yields the familiar parabola. An arbitrary domain might admit no geometric picture, but the underlying set of pairs remains. Read this way the three named maps become shapes: the identity on is the diagonal, since it pairs each with itself, and a constant map is a horizontal line.
Proposition 4.19 (Equality of functions).
Functions and are equal if and only if they have the same domain and for every in it.
Discussion.
We prove the two implications of the biconditional. Suppose first that . Equality of the sets of ordered pairs gives equality of their first coordinates, hence equality of the domains; for an arbitrary element of the common domain the pair belongs to , and the uniqueness clause of Definition 4.15 gives . Conversely, assume the domains agree and the two functions have the same value at every point of the common domain. By mutual inclusion it is enough to prove the two inclusions. An arbitrary has in the domain and , so the hypotheses put in ; the reverse inclusion follows symmetrically.
Proof (element style).
Suppose first that . The domain of a function consists of the first coordinates of its elements, so and have the same domain. For any in it the pair belongs to , and since we have , which gives by the uniqueness of images in .
Conversely, assume the domains agree and for every in the common domain. If , then lies in that domain and ; since we have , so . Hence . A symmetric argument gives , so .
Proof (logical style).
If , then for every ,
and for in this common domain , so uniqueness gives . Conversely, for every ordered pair ,
Remark.
The codomain does not enter the criterion, because under Definition 4.15 a function is simply its set of ordered pairs. Consequently the set defines the identity map , but for any with it equally defines the inclusion map . The set of pairs is identical; the declared codomain matters when we ask whether every element of the target is reached.
There is only one function from to a given set . Any two have the same domain, namely , and agree at every point of it, since there are none, so the proposition makes them equal.
Definition 4.21 (Restriction and extension).
Let be a function and let . The restriction of to is the function given by . The function is called an extension of to .
Consider
By the proposition, : the domains agree, and the rules of school algebra give for every real number. The function is a different object entirely. Its domain is , so it cannot equal or , even though its values agree with theirs at every whole number. It is their common restriction, . Equality of functions depends on domains, not on formulas.
Remark.
Definition 4.15 builds a function as a set of pairs, and the domain and codomain are read off the notation rather than carried by the set. A tidier alternative is to package all three, taking a function to be the ordered triple of a domain, a codomain and a set obeying the vertical line test. Nothing in what follows depends on the choice, and the problems below ask you to check that the two accounts agree.
Let and . Which of the following are functions from to ? Justify each answer.
- ;
- ;
- .
Give sets and for which is a function from to . What is , and what are the preimages of ? Is your choice of and the only one?
Let and be non-empty sets. Prove that is a function from to if and only if has exactly one element.
Let be a function and define its graph to be the subset of .
- Show that two functions are equal if and only if they have the same graph.
- Conversely, let be such that for each the set has exactly one element. Show that there is exactly one function whose graph is .
- Suppose we define a function instead to be an ordered triple with obeying the vertical line test, taking the domain to be , the codomain , and the unique with . Show that this definition agrees with Definition 4.15 , in the sense that every choice of domain, codomain and property obeying the vertical line test produces a function in this sense with all the properties the earlier definition requires.
Images and Preimages
Definition 4.23 (Image of a set).
Let be a function and let . The image of under is . The image of the whole domain is the range of , written .
The range is a subset of the codomain, and it may be a proper one. In terms of the ordered pairs of Definition 4.15 ,
Definition 4.24 (Preimage of a set).
Let be a function and let . The preimage of under is . In particular is the set of all preimages of .
The notation does not assume that has an inverse function; the definition applies to every function. The set may be empty, may hold one element, or may hold several.
Let and , and define by , , , . Then , and . The element belongs to the codomain but not to the range, and its point preimage is empty. In general is non-empty exactly when , and how many elements it holds records how many inputs are sent to . Here , and .
Take with , and let be the set of real numbers with . Then is the set of real numbers with : on the one hand gives , which proves one inclusion, and on the other, any such has in with , which proves the reverse. The same calculation read backwards gives .
Proposition 4.27 (Set laws for preimages).
Let be a function and let . Then
- ;
- ;
- .
Discussion.
We prove each equality by comparing membership at an arbitrary . By the definition of the preimage, membership says that and that its image has the required property. So says precisely that ; membership in means membership in at least one of and ; and membership in means membership in both. Translating those three conditions back through the same definition yields the complement, the union and the intersection we want.
Proof (element style).
If , then and , so . Conversely, if , then ; since this puts , whence .
If , then belongs to or to , so belongs to . Conversely, membership in that union puts in one of the two preimages, so and .
Finally gives both and , so ; and membership in both preimages gives , which is the reverse inclusion.
Proof (logical style).
For every ,
The middle steps distribute the conjunct across the disjunction and the conjunction, which is Distributivity and, for the third line, Idempotence. The membership conditions agree in each pair, so the corresponding sets are equal.
Preimages preserve complements, unions and intersections. Images preserve unions, but need not preserve intersections, as the problems below ask you to show.
Read as the assignments and , a function induces two maps between power sets, one from to and one from to , written and again. The two behave differently, and the proposition is the reason: the preimage map preserves all three operations, while the image map preserves only unions.
Remark.
This asymmetry is why continuity is later stated in terms of preimages rather than images: a function is continuous exactly when the preimage of every open set is open.
For the finite function above, determine , , and .
Let be a function and let . Prove that . Must always hold?
Surjections, Injections, Bijections
A function is surjective, or onto , if ; equivalently, if for every there is some with .
Every function is surjective onto its range.
The successor map given by is not surjective, since has no preimage among the whole numbers. The same ordered pairs define a surjection onto . So surjectivity depends on the declared codomain, not on the pairs alone.
A function is injective, or one-to-one, if for all , .
The contrapositive of that implication says distinct inputs have distinct images. To show a function is not injective it is enough to give two distinct inputs with the same image; to show it is not surjective it is enough to give an element of the codomain with no preimage.
Proposition 4.31 (Point preimages).
Let be a function.
- is injective if and only if holds at most one element for every ;
- is surjective if and only if is non-empty for every .
Discussion.
For the first part we compare the definition of injectivity with the assertion that two members of coincide. In one direction two such members have equal images; in the other, equal images make the two inputs members of one point preimage. For the second part, the definition of the preimage says is non-empty exactly when some satisfies , which is what surjectivity asks.
Proof.
Suppose is injective. If , then , so . Conversely, suppose every point preimage holds at most one element. Whenever , both and belong to , and hence they are equal. This proves the first part.
The second is the surjectivity condition rewritten: is non-empty exactly when some satisfies .
For a real number , the translation given by is injective and surjective. If , then , and adding to both sides gives . For surjectivity, take any and put ; then , so every element of the codomain has a preimage.
The squaring map with is neither injective nor surjective: , and lies outside its range because every square is non-negative.
The product map with is surjective, since for every whole number . It is not injective, since while by Proposition 4.2 .
For the finite function of the previous section, decide whether it is injective and whether it is surjective, justifying each answer from the definitions.
Let be non-empty and let have exactly two elements. How many functions from to are not surjective?
Bijections
A function is bijective, or a bijection, if it is both injective and surjective. A bijection from to is also called a one-to-one correspondence between them.
Surjectivity asks for at least one preimage of each point of the codomain and injectivity permits at most one, so a bijection has exactly one.
Proposition 4.36 (Unique preimages).
A function is bijective if and only if for every there is a unique with .
Discussion.
We use the two parts of Proposition 4.31 . If is bijective, surjectivity gives a preimage of each and injectivity shows no second preimage is possible. Conversely, existence of a preimage for every gives surjectivity, and its uniqueness gives injectivity. The same criterion is what will let us reverse the ordered pairs of a bijection later.
Proof.
Suppose first that is bijective. Surjectivity supplies, for each , an with . If and both have this property, then , so injectivity gives .
Conversely, suppose every has exactly one preimage. Existence makes surjective. If , both and are preimages of the same element of , so uniqueness gives and is injective as well.
For finite sets, an injection from to needs at least as many elements in as in , and a surjection needs at least as many in as in ; a bijection therefore forces the two to have the same number of elements. Comparing sets by functions rather than by counting is what will extend this to infinite sets, where counting is no longer available.
With and as above, take . Each member of appears once as a first coordinate and each member of once as a second, so is a bijection. The function of the previous section is neither injective nor surjective: is hit twice and is not hit at all.
Proposition 4.38 (An injection onto its range).
If is injective, then the function from to with the same ordered pairs is bijective.
Discussion.
The new function has the same ordered pairs as , so injectivity carries over unchanged, the definition mentioning only inputs and their images. For surjectivity, take in the new codomain ; the definition of the image provides an with , which is the preimage required.
Proof.
Changing the codomain from to does not alter the ordered pairs, and injectivity is a condition on those alone, so the new function is injective. Every is for some by the definition of the image, so it is also surjective.
Every translation is a bijection, by the example above, and so is the identity map , since each is its own unique preimage. The squaring map and the product map are not, each having already failed one of the two conditions.
Let be bijective and let . Prove that the restriction is bijective.
Let be injective and let . Prove that .
Let , and be sets. Prove that
is a bijection from onto , so that the two readings of a triple product agree up to that correspondence. Show also that the two sets are not in general equal, by exhibiting an element of one which is not an element of the other.
Composition
Definition 4.39 (Composition).
Let and be functions. Their composition is the function given by .
The notation is read from right to left: acts first and second. The codomain of must be the domain of , so that every value of can serve as an input of .
For the squaring map and the translation above, while . At these take the values and , so by Proposition 4.19 . Composition is not commutative.
Theorem 4.41 (Associativity of composition).
Let , and be functions. Then .
Discussion.
By Proposition 4.19 we must check that the two functions have the same domain and agree at every input. Both are functions from to , so only the values are in question, and at an arbitrary the definition of composition evaluates either side by applying , then , then .
Proof.
Both sides have domain . For every , so Proposition 4.19 gives the equality.
Associativity lets us write without brackets. The identity maps satisfy the identity laws one expects.
Proposition 4.42 (Identity laws).
If , then and .
Discussion.
Again Proposition 4.19 reduces each identity to a comparison of domains and values. Both sides of each have domain , and at an arbitrary the definitions of composition and of the identity map reduce both composites to .
Proof.
For every we have and . Each pair of functions has the same domain, so Proposition 4.19 applies.
Theorem 4.43 (Composition and bijections).
Let and be functions.
- If and are injective, then is injective;
- If and are surjective, then is surjective;
- If and are bijective, then is bijective.
Discussion.
For the first part the definition of injectivity asks us to start from an equality of composite values; expanding the composition, injectivity of gives equality of the -values, and injectivity of then gives equality of the inputs. For the second, take an arbitrary , choose with , then choose with , and evaluate the composite at . The third is the first two together with the definition of a bijection.
Proof.
Suppose , that is, . Injectivity of gives , and injectivity of then gives , which is the first part.
For the second, take . Since is surjective, some has ; since is surjective, some has . Then . The third part follows from the other two.
Let and . Prove that if is injective then is injective, and that if is surjective then is surjective.
Construct finite sets , , and functions , for which is bijective although is not surjective and is not injective.
Inverse Functions
Definition 4.44 (Inverse function).
Let and be functions. The function is an inverse of if and . A function which has an inverse is called invertible.
The first equation returns each element of after applying and then ; the second does the same for . The problems below examine what each equation achieves on its own.
Theorem 4.45 (Invertibility and bijections).
A function is invertible if and only if it is bijective, and when an inverse exists it is unique.
Discussion.
Suppose first that is an inverse of . To get injectivity, apply to an equality and use ; to get surjectivity, use as a preimage of an arbitrary and use . Conversely, Proposition 4.36 gives exactly one reversed pair for each , so the set of reversed pairs passes the vertical line test and is a function from to ; the two inverse identities are then those pairs read in the two directions. For uniqueness, two inverses are compared by sandwiching between them, where associativity and the identity laws collapse the composite in two ways.
Proof.
Let have an inverse . If , then , so is injective. Given , put ; the second identity gives , so is surjective.
Conversely, suppose is bijective and set . For each , Proposition 4.36 gives a unique with , so is a function from to . Reading the pairs in each direction gives for and for , that is, and .
For uniqueness, let and both be inverses of . Associativity and the identity laws give
The unique inverse of a bijection is written . The construction in the proof gives
Remark.
The symbol also denotes the preimage of a set. The two uses are distinct: is an element of produced by the inverse function, and exists only for a bijection, while is a subset of and is defined for every function. For a bijection they are related by , the preimage of a point being the singleton of its inverse image.
Reversing the pairs of the bijection gives . Also for any set .
The translations invert one another: , since for every real number .
Proposition 4.48 (The inverse is a bijection).
If is bijective, then is bijective and .
Discussion.
The two equations defining an inverse are symmetric in and , so they say equally that is an inverse of . That makes invertible, and the theorem above turns invertibility into bijectivity; its uniqueness clause then names as the inverse of .
Proof.
The identities and also say that is an inverse of . So is invertible and hence bijective by Theorem 4.45 , and uniqueness of its inverse gives .
Theorem 4.49 (Inverse of a composition).
If and are bijections, then .
Discussion.
Put . Rather than compute we show directly that meets the definition of an inverse of : evaluate at an arbitrary and at an arbitrary , where associativity and the inverse identities cancel the adjacent pairs. Since is bijective, uniqueness of inverses then identifies as the one.
Proof.
Put . For and ,
So is an inverse of , which is bijective by Theorem 4.43 , and uniqueness in Theorem 4.45 gives the formula.
Corollary 4.50 (Cancellation by a bijection).
Let be bijective and let . Then implies . Likewise, if is bijective and , then implies .
Proof.
For the first, compose on the left with and use associativity:
For the second, compose on the right with :
Let and be real numbers with . Prove that given by is bijective, and determine .
Let be bijective and let . Determine the inverse of .
Let and . Prove that forces to be injective and to be surjective, while forces to be surjective and to be injective.
Left and Right Inverses
Definition 4.51 (Left and right inverses).
Let and be functions. The function is a left inverse of if , and a right inverse of if . When it is both, it is an inverse in the earlier sense.
The names record the side on which sits in the composite. The last problem above gave the two implications that come for free: a left inverse makes injective, and a right inverse makes surjective. What the two halves achieve together is the next theorem.
Theorem 4.52 (Bijections via one-sided inverses).
Let be a function. Then is bijective if and only if it has both a left inverse and a right inverse; when both exist they coincide, and their common value is .
Discussion.
One direction is free: a bijection has , which is a left and a right inverse by definition. For the other, the left inverse gives injectivity and the right inverse gives surjectivity, so is bijective and exists. To identify the one-sided inverses with each other we evaluate the triple composite in its two groupings: associativity and the identity laws collapse the middle pair either way, leaving . The same calculation with in place of either names their common value.
Proof.
Suppose has a left inverse and a right inverse . If , then , so is injective. For , the element satisfies , so is surjective. Hence is bijective and exists by Theorem 4.45 . Associativity and the identity laws give
so the two agree; and since is itself both a left and a right inverse of , the same computation identifies their common value with .
Conversely, if is bijective then is a left and a right inverse by definition.
Theorem 4.53 (Injections and left inverses).
Let be non-empty. A function is injective if and only if it has a left inverse.
Discussion.
If a left inverse exists, injectivity is the implication already noted. For the converse, an injective is a bijection onto its range by Proposition 4.38 , so it has an inverse there. On the range a left inverse is forced to be that one, since determines at every point of ; on the rest of we are free, and non-emptiness of lets us send all of to one fixed element. That freedom is why left inverses are rarely unique. The hypothesis on cannot be dropped: the function from to is injective, but a function from to exists only when is empty.
Proof.
Suppose first that . If , then , so is injective.
Conversely, assume is injective. By Proposition 4.38 the function from to with the same pairs is bijective; let be its inverse, which exists by Theorem 4.45 . Fix , which we may do since is non-empty, and define by for and for . For every the point lies in and , so and .
Surjections sit at the other end, and their story is not symmetric. A right inverse forces surjectivity, as we have seen; the converse, that every surjection has a right inverse, is a claim of a different kind. A right inverse must choose, for every at once, one element of , and when is infinite nothing among our axioms says such a simultaneous choice can be made. That missing licence is the axiom of choice.
Let be non-empty and injective. Show that any two left inverses of agree on . For the inclusion map from to , exhibit two left inverses and say where they differ.
General Cartesian Products
With functions in hand we can take the product of an arbitrary collection of sets, not just two. First, the informal indexed family of the earlier section can now be said properly.
Remark.
An indexed family of subsets of a set is formally a function , with . It is the function itself, not its range: the range is the plain set of members, which is what the earlier example saw forgetting the labels, while remembers which member sits at which index. Since is a subset of , it is a set by the axioms of the last chapter, and that is why we ask that all the be subsets of one set .
Definition 4.54 (General Cartesian product).
Let be a set and let be an indexed family of sets, all of them subsets of a given set. The Cartesian product of the family is
The notation is easier to read once we recall that a function from to is by Definition 4.15 a subset of . So every candidate lies in the power set displayed above, a set we are already holding, and comprehension carves the product out of it. An element of the product picks one member from each , all at once.
The definition subsumes the earlier one. A function defined on the two-element set is determined by the pair of values , so the functions with and correspond to the pairs with and . This identifies with the general product for , and , and we will not distinguish between the two readings from here on.
Definition 4.56 (Cartesian power).
Let and be sets. The Cartesian power is the product of the constant family,
The product of two non-empty sets is non-empty, witnessed by any pair with and , and the same argument covers three sets, four, and any collection we can write out in full. A perplexing issue arises once is infinite, where the argument fails for the reason we met in the last chapter: we have no way to string an unspecified number of such choices together. Closing that gap takes another axiom.
The Axiom of Choice
Let be a non-empty set and let be an indexed family of sets with for every . Then there exists a function with and for every . Equivalently, a non-empty family of non-empty sets has non-empty product.
Such an is a choice function for the family. The quantifier order is the whole content: the hypothesis grants each set an element of its own, while the conclusion assembles one selection from every set into a single function.
Remark.
The axiom is independent of the others, in the sense that neither it nor its negation follows from them. In sets carrying some structure a distinguished element can often be picked out constructively, and no axiom is needed; the axiom supplies one in full generality, where no rule for choosing is available. Mathematicians find it rather less comfortable than the rest, so it is good practice, which we will follow, to say plainly whenever it is used.
Theorem 4.58 (Every surjection has a right inverse).
Let be surjective. Then has a right inverse .
Discussion.
Surjectivity says, through Proposition 4.31 , that every point preimage is non-empty. That is exactly the hypothesis of the axiom of choice applied to the family of point preimages indexed by , and what the axiom returns is a function picking one element out of each. The union of the point preimages is , and says precisely that , which is the right-inverse identity. The axiom is doing real work: each preimage alone has an element, and the theorem needs one choice per preimage assembled into a single map.
Proof.
If is empty then so is , since every element of would have an image in , and the empty function is a right inverse; so assume is non-empty. For every the set is non-empty by Proposition 4.31 . Applying the axiom of choice to the family gives a function from to with for every . Each point preimage is a subset of , so that union is and . Finally is equivalent to , so and is a right inverse of .
Corollary 4.59 (Surjections and right inverses).
A function is surjective if and only if it has a right inverse.
Proof.
One direction is the theorem. For the other, a right inverse gives for every , so is a preimage of and is surjective.
Let and let be a family of non-empty sets. Show that is non-empty without appealing to the axiom of choice. Where would the argument break down for an index set that cannot be written out in full?
Exercises
Answers are checked in your browser, as often as you like. Nothing is sent anywhere and
nothing is kept but your own work. A formula may be written with the symbols themselves or
with ~ & | -> <-> ^, and \and, \or, \to expand as you type.
Let and .
The only pair belonging to both and is:
is:
Write and for the statements and , and and for and . Give the condition on the pair for membership in each set below.
The two sets are different. Place one pair that separates them.
Which two products does the second set leave out?
Now the condition of the first part again, written as a disjunction of conjunctions.
Let , and , with , and take as the ambient set.
is:
is:
Let be a positive whole number, let , and let be a family with whenever .
and are:
A family is disjoint if , and pairwise disjoint if whenever .
The family , , is:
For families of three sets:
Counting.
and each have three elements. The number of functions from to is:
has three elements and has two. The number of injections from to is:
And the number of surjections from to is:
With those same and , the number of injections from to is:
Cartesian powers.
The number of elements of is:
For every non-empty set , the power is:
For every set , the power is:
Take the real numbers on trust and let be given by .
is:
is:
is:
A function satisfies for every exactly when it is:
And holds for every exactly when is:
Injective, surjective, both or neither.
given by is:
given by is:
The inclusion map of a set with is:
A constant map , where and both have at least two elements, is:
The function from to a non-empty is:
Keeping the real numbers, let , and be the maps given by , and , where is when and otherwise.
The function is:
The composites and are:
The function is:
Inverses, one-sided and two-sided.
Let and be bijections. The composite is defined:
A function with a left inverse but no right inverse is:
The statement that cannot be proved without the axiom of choice is:
Exercises in Lean
The proofs below are checked in your browser. Nothing is sent anywhere, and nothing is
stored but your own work. Type \to for →,
\and for ∧, \< and
\> for ⟨ ⟩.
The last sheet gave the checker a universe of objects and the algebra of sets. This one adds the constructions of this chapter: the ordered pair, the product, the indexed family and the map.
A pair is typed as it is written, (a, b), and longer tuples nest to the left exactly as Definition 4.4 says, so (a, b, c) is ((a, b), c). The product is ×, typed \x, and it binds like ∩. A map is written f : Obj → Obj and applied by juxtaposition, f x; the domain and codomain of Definition 4.15 are carried by the statement being proved rather than by the arrow.
Ordered pairs
The pair itself is opaque: the checker knows nothing about , only what Proposition 4.2 established about it. That proposition is Set.pair_eq, a biconditional, so .mp reads coordinates off an equality of pairs and .mpr builds one.
Example.
The forward direction turns the equality into a conjunction; the first half of it is the first coordinate.
Corollary 4.3 , in one direction.
Coordinates read off one pair and put back into another.
A triple is a pair of a pair, so its middle coordinate takes two steps to reach.
Products
Membership in a product is the dictionary line of the chapter: (x, y) ∈ A × B is x ∈ A ∧ y ∈ B, in the way that x ∈ A ∩ B was a conjunction on the last sheet, so ⟨_, _⟩ builds one and .left and .right take one apart.
Example.
Two memberships, one pair.
An arbitrary object is not written as a pair, and for it the criterion says the rest of Definition 4.6 : p ∈ A × B is
∃ a, ∃ b, p = (a, b) ∧ a ∈ A ∧ b ∈ Bso a membership hypothesis about an unknown hands over two coordinates, an equation and two memberships. obtain takes all five at once, and the equation is what rw then uses to turn into a pair everywhere it is needed.
Example.
Once has been rewritten, the goal is about a pair and the criterion applies to it.
The coordinates change places and so do the factors.
Nothing can serve as a second coordinate.
The product respects inclusion in each factor.
Products distribute over intersections.
And over unions.
An intersection of products is a product of intersections.
The inclusion that never fails.
The equality the last exercise fell short of, with the two mixed products restored.
Indexed families
A family is a map from indices to sets, written B : Obj → Obj, and its union and intersection are ⋃ i ∈ I, B i and ⋂ i ∈ I, B i, typed \bigcup and \bigcap. Their criteria are the two the chapter gave: membership in the union is ∃ i, i ∈ I ∧ x ∈ B i, and membership in the intersection is ∀ i, i ∈ I → x ∈ B i. So an intersection is used by applying it to an index and a proof that the index belongs to , and a union is built with use.
Example.
The intersection applied at one index.
Example.
use supplies the index; what remains is that the index is one of ours and that lies in its set.
An object kept out of an intersection is refused by some one set, but the index doing the refusing is not handed to us: all we hold is that no index can be a witness. Getting the index out is the classical step, and by_contra twice is what does it.
Example.
The first by_contra denies the index we want; the second turns that denial into membership at every index, which is what the hypothesis refuses.
A set lies inside the intersection exactly when it lies inside every member.
And the union lies inside a set exactly when every member does.
The first part of Proposition 4.13 .
The second part. The hypothesis hj is the non-emptiness of , and one of the two inclusions cannot be had without it.
The inclusion between the two mixed families, in the direction that holds.
Maps
For a map f : Obj → Obj, the image and preimage of a set are f '' S and f ⁻¹' U, typed as two apostrophes and as \preimage. Their criteria are those of Definition 4.23 and Definition 4.24 : y ∈ f '' S is ∃ x, x ∈ S ∧ f x = y, and x ∈ f ⁻¹' U is f x ∈ U. Composition is g ∘ f, typed \o, and (g ∘ f) x is g (f x). Finally Injective f and Surjective f are the two conditions of Definition 4.30 and Definition 4.28 , ∀ x y, f x = f y → x = y and ∀ y, ∃ x, f x = y, so both are opened with intro.
Example.
The witness is the point itself, and the equation it has to satisfy is an identity.
The preimage passes membership straight through to , and that is the whole of why it preserves the operations: both sides of each law are the same statement about .
Example.
Part three of Proposition 4.27 , which the criterion settles outright.
Images preserve unions.
Every point of is sent into the image of .
And the image of a preimage is no bigger than the set it came from.
The first part of Theorem 4.43 .
Its second part.
Only the first map need be injective for the composite to be.
And only the second need be surjective.
A left inverse, written out pointwise, makes injective.
A right inverse makes it surjective.
Images preserve intersections when, and only when, nothing is glued together on the way.
The inclusion two exercises above becomes an equality for an injective map.
What the checker understands
Tactics
| intro h | assume the hypothesis of an implication, naming it h |
| exact e | give the proof outright |
| apply f | reduce the goal to the hypotheses of f |
| assumption | close the goal with a hypothesis already present |
| trivial | close the goal True |
| exfalso | replace the goal with False |
| by_contra h | assume the negation of the goal |
| constructor | split ∧ into both halves, or ↔ into both directions |
| left / right | choose which half of a ∨ to prove |
| rcases h with a | b | argue by cases on a disjunction |
| obtain ⟨a, b⟩ := h | take a conjunction or an existential apart |
| cases h | as above, keeping the name |
| refine e | give the proof with holes left in it |
| have h : p := … | record an intermediate result |
| show p | restate the goal in an equal form |
| use w | give a witness for ∃ |
| specialize h a | instantiate a ∀ hypothesis |
| rw [h] | rewrite with an equation, ← to go backwards |
| rfl | both sides compute to the same thing |
| decide / norm_num | settle a closed computation |
| tauto | close a goal that is true by pure logic |
Results you may cite
| Classical.em | ∀ (a : Prop), a ∨ ¬a — the law of excluded middle |
| Classical.byContradiction | ∀ {a : Prop}, (¬a → False) → a — proof by contradiction; the tactic by_contra does this for you |
| Classical.byCases | ∀ {a b : Prop}, (a → b) → (¬a → b) → b — split on whether a holds |
| not_not | ∀ {a : Prop}, ¬¬a ↔ a — double negation |
| not_and_or | ∀ {a b : Prop}, ¬(a ∧ b) ↔ ¬a ∨ ¬b — De Morgan |
| not_or | ∀ {a b : Prop}, ¬(a ∨ b) ↔ ¬a ∧ ¬b — De Morgan |
| not_imp | ∀ {a b : Prop}, ¬(a → b) ↔ a ∧ ¬b |
| and_comm | ∀ {a b : Prop}, a ∧ b ↔ b ∧ a |
| or_comm | ∀ {a b : Prop}, a ∨ b ↔ b ∨ a |
| Set.ext | ∀ {A B : Obj}, (∀ x : Obj, x ∈ A ↔ x ∈ B) → A = B — extensionality: sets with the same elements are equal |
| Set.ext_iff | ∀ {A B : Obj}, A = B ↔ (∀ x : Obj, x ∈ A ↔ x ∈ B) — extensionality and substitution, in one biconditional |
| Set.subset_antisymm | ∀ {A B : Obj}, A ⊆ B → B ⊆ A → A = B — mutual inclusion is equality |
| Set.empty_subset | ∀ {A : Obj}, ∅ ⊆ A — the empty set is a subset of every set |
| Set.pair_eq | ∀ {a b c d : Obj}, ((a, b) = (c, d)) ↔ (a = c ∧ b = d) — two ordered pairs are equal exactly when their coordinates are |
From the logical core
| And.intro | ∀ {a b : Prop}, a → b → a ∧ b |
| And.left | ∀ {a b : Prop}, a ∧ b → a |
| And.right | ∀ {a b : Prop}, a ∧ b → b |
| And.symm | ∀ {a b : Prop}, a ∧ b → b ∧ a |
| Or.inl | ∀ {a b : Prop}, a → a ∨ b |
| Or.inr | ∀ {a b : Prop}, b → a ∨ b |
| Or.elim | ∀ {a b c : Prop}, a ∨ b → (a → c) → (b → c) → c |
| Or.symm | ∀ {a b : Prop}, a ∨ b → b ∨ a |
| Iff.intro | ∀ {a b : Prop}, (a → b) → (b → a) → (a ↔ b) |
| Iff.mp | ∀ {a b : Prop}, (a ↔ b) → a → b |
| Iff.mpr | ∀ {a b : Prop}, (a ↔ b) → b → a |
| Iff.symm | ∀ {a b : Prop}, (a ↔ b) → (b ↔ a) |
| Iff.rfl | ∀ {a : Prop}, a ↔ a |
| Iff.trans | ∀ {a b c : Prop}, (a ↔ b) → (b ↔ c) → (a ↔ c) |
| True.intro | True |
| False.elim | ∀ {a : Prop}, False → a |
| absurd | ∀ {a b : Prop}, a → ¬a → b |
| id | ∀ {a : Prop}, a → a |
| mt | ∀ {a b : Prop}, (a → b) → ¬b → ¬a |
| Eq.refl | ∀ {α : Type} (a : α), a = a |
| Eq.symm | ∀ {α : Type} {a b : α}, a = b → b = a |
| Eq.trans | ∀ {α : Type} {a b c : α}, a = b → b = c → a = c |
| congrArg | ∀ {α : Type} {β : Type} {a b : α} (f : α → β), a = b → f a = f b |
| Exists.intro | ∀ {α : Type} {p : α → Prop} (w : α), p w → ∃ x : α, p x |
| Exists.elim | ∀ {α : Type} {p : α → Prop} {b : Prop}, (∃ x : α, p x) → (∀ y : α, p y → b) → b |