Functions and relations turn product sets into structured mathematical objects: functions impose unique outputs, while relations record general connections.
Functions are special relations
Definition
A function
A function from to is a subset of such that every is paired with exactly one .
The same information can be read in several equivalent ways:
- is the domain, the set of allowed inputs.
- is the target, the set of possible outputs.
- The graph of is , the set of pairs with input and output .
- The image of a set is the set of outputs reached by that set.
- The preimage of a set is the set of inputs that land there.
Common mistake
A function must not send one input to two outputs
A relation may connect one input to many outputs. A function cannot. Every input must have exactly one output.
How to test a proposed graph
For a subset to be the graph of a function , every must occur in exactly one pair . There are two separate failure modes. A missing input has no corresponding output, so it violates existence. An input paired with two different outputs violates uniqueness. The entire stated domain must be covered exactly once.
For example, viewed as a subset of misses input , since would require . It is therefore not a graph of a function from . By contrast, is a graph from to : for each integer , the unique choice is . The set is also not a graph from to ; it misses negative inputs and has both and as pairs for input .
Common mistake
The domain may depend on context
The formula is not a single function unless you specify a domain. It can be a function on , on , or on another domain where division by zero is excluded.
The set of all functions
Once functions have been defined as sets of ordered pairs, we can also make a set whose elements are functions. If and are sets, the notation
means the set of all functions from to .
This notation is not accidental. When is finite with elements and is finite with elements, a function is made by choosing one of outputs for each of the inputs. Hence there are such functions. For example, if and , then has functions. This is the same counting principle behind .
Worked example
Read as a function set
Let and . Then contains exactly four functions:
Each row is one whole function, not one value of a single function.
Reading a function carefully
Worked example
The square function has repeated outputs
Take the rule .
Then and , so different inputs may share the same output. That is allowed.
What is not allowed is a single input having two different outputs.
For example, the relation “” on is not a function if you read it as a rule from to , because allows both and .
The graph of a function is a very special subset of a product: every vertical line through an allowed input hits the graph exactly once.
Image, preimage, and composition
For a function , the course uses the word image in three related ways:
- is the image of the single input .
- If , then is the image of the set.
- is the full image of , meaning the actual outputs that appear.
The preimage of a set is
This exists even when does not have an inverse function.
Composition is defined by
The order matters: means “first , then ”.
Worked example: computing compositions
For , , and , direct substitution gives
The rightmost function is applied first.
Image and preimage identities
Let , , and . The image of a union satisfies
For the inclusion from left to right, take . Then for some . If , then ; if , then . Thus . Conversely, if , it has a preimage in or in , and that preimage also lies in ; hence .
For intersections only inclusion is guaranteed:
Indeed, a value obtained from an input in is obtained from an input in each of and . Equality can fail when two different inputs collide. Take , , , , and . Then , while .
Preimages preserve both unions and intersections, with full membership proofs:
For the union, means , so or ; this is exactly . Reading the same equivalence backwards proves the reverse inclusion. For the intersection, means and , which is exactly ; again both directions are the same membership equivalence.
The corresponding difference and complement laws must state their ambient sets:
For example, belongs to the first left side exactly when and , which is the condition on the right. In the complement law, is the complement inside the target , while is the complement inside the domain .
Worked example
Compare image and preimage for
Let be given by , and let
Then
Also,
Every listed point maps into . Conversely, if , then , , or . Factoring each equation gives respectively , , or . Hence there are no other real preimages.
If we instead take , then
Injective, surjective, bijective
Definition
Three useful words
- Injective means different inputs never collide.
- Surjective means every target value is hit.
- Bijective means both injective and surjective.
Equivalent formulations are often useful:
- is injective if implies .
- is surjective if .
- is bijective if every element of the target is hit exactly once.
Worked examples: injectivity and surjectivity
First consider the finite map , , with values , , , and , the value is attained by two inputs, so the map is not injective. All three elements of occur, so it is surjective.
Next consider is . Its five values are
They are distinct, so this map is injective. It is not surjective onto , since, for example, is not among the values.
Finally, , , is not injective: with . It is not surjective either, because is always even, so no odd integer can be an output.
Read the arrows to distinguish the definitions
An arrow diagram tests unique outputs, collisions, and whether the target is covered.
Use one arrow diagram to keep domain, target, image, preimage, injectivity, surjectivity, and composition distinct.
Domain and target
A function f:X->Y is a relation where every input in X has exactly one output in the target Y.
Graph as ordered pairs
The graph stores the same arrows as ordered pairs inside X x Y, with one pair for each input.
Image and preimage
Image is read forward to reached outputs; preimage is read backward from an output set to the inputs that land there.
Injective
Injective means no collision: if two inputs have the same output, they must have been the same input.
Surjective
Surjective means the actual image equals the whole target, so no target element is missed.
Composition
For g o f, first apply f and then feed the resulting output into g.
The same arrow diagram separates the main definitions. A function gives each input exactly one output, injectivity forbids collisions, surjectivity covers the target, and composition feeds one output into the next map.
Theorem
Inverse functions exist exactly for bijections
For a function , an inverse function exists if and only if is bijective.
Proof: why a bijection has an inverse
If is injective and surjective, then for every there is a unique with .
That uniqueness lets us define a new function by declaring to be the unique satisfying .
By construction, and , so is the inverse of .
Proof: uniqueness and existence of inverses
Suppose are both inverses of . Using associativity of composition and both inverse equations,
Thus an inverse, when it exists, is unique. Composition is associative: if , , and , then for every ,
The later inverse-implications proof establishes necessity: an inverse makes bijective. The construction above gives the inverse of a bijection.
Worked example
Construct injective and non-injective examples
The function on is injective and surjective, so it is bijective.
The function on is not injective because and have the same image.
The function on is injective but not surjective onto , because it never reaches nonpositive numbers.
Common mistake
Do not confuse preimage with inverse function
always makes sense as a preimage. The inverse function only exists when is bijective.
Left and right inverses
- A left inverse satisfies .
- A right inverse satisfies .
These conditions are not the same in general.
Worked example
One map with a left inverse but no right inverse
Let and . Define
This map is injective but not surjective, because is never hit. So it can have a left inverse, but it cannot have a right inverse.
For instance, define by
Then .
The missing value rules out , so no right inverse exists.
Worked example
One map with a right inverse but no left inverse
Define by
This map is surjective but not injective, so it can have a right inverse but no left inverse.
A right inverse is given by with
Then .
The collision rules out a left inverse.
Theorem
Finite self-maps: a left inverse already forces an inverse
Let be finite and let . If there exists with , then is bijective and is also a right inverse of .
Proof: a finite self-map with a left inverse
The equation says that is injective: if , then applying gives .
For a finite set, an injective map from to itself is automatically surjective. Thus is bijective. Since its inverse is unique and already undoes on the left, must be the inverse function. Therefore as well.
Proof: inverse implications and their converses
For and , if , then implies . Thus a left inverse implies injectivity. If , each equals , so a right inverse implies surjectivity.
Conversely, suppose is injective and . Fix one . Define as the unique preimage when and as otherwise. This is a left inverse and uses no axiom of choice: one fixed fallback value suffices. For , the injection into a nonempty has no left inverse, since no map exists. When both sets are empty, the empty map is its own inverse.
For a surjection, constructing a right inverse means choosing one element from each fibre . Explicit choices or finite choices require no general choice axiom. The assertion that every arbitrary surjection has a right inverse invokes the axiom of choice. This differs from the unique preimages of a bijection, which require no such selection principle.
Worked example
An infinite inclusion with a total left inverse
Let be , with . Define by for and for . Then for every . There is no right inverse because a negative integer, such as −1, has no preimage under .
Relations
Definition
A relation
A relation on a pair of sets and is any subset of .
If , we simply call it a relation on .
We write to mean .
This is the broader notion. A function is just a relation with the extra rule that every input has exactly one output.
For a relation :
- the domain of is the set of that relate to at least one ;
- the image or range of is the set of that are hit by at least one .
Worked example
A relation need not be a function
Let be the set of countries and the set of cities.
The relation “ is a capital city of ” is a relation on . Whether it is a function depends on the historical period and the country.
The relation on is also a relation. It is not a function when read from to , because one input may have multiple outputs.
Relations let us talk about connections without forcing uniqueness. That is exactly what we need for order relations and equivalence relations later on.
Relations on one set
Relations are especially important.
Theorem
Four properties used constantly
A relation on may have these properties:
- Reflexive: for every
- Symmetric: implies
- Antisymmetric: if and , then
- Transitive: if and , then
Two special kinds of relations appear everywhere in later chapters:
- a partial order is reflexive, antisymmetric, and transitive;
- an equivalence relation is reflexive, symmetric, and transitive.
The difference between symmetric and antisymmetric is easy to blur:
- symmetric says the arrows go both ways whenever one goes one way;
- antisymmetric says two-way arrows force equality.
Worked example
The divisibility relation is a partial order
On the positive integers , write when divides .
This relation is reflexive because every number divides itself. It is antisymmetric because if and , then for positive integers. It is transitive because divisibility passes through chains.
So divisibility is a partial order.
The qualification “positive” matters. On all of , both and , although , so antisymmetry would fail there.
Posets are not just a vocabulary item. They let us organize objects by how one contains, refines, or divides another.
Relation tests and counterexamples
Let and define by . This relation is not reflexive: a nonempty set such as does not have empty intersection with itself. It is symmetric because intersection is symmetric. It is not transitive: with , , and , we have and , but not . It is not antisymmetric: and , although the two sets are different.
Now test the following relations on the integers:
- odd is not reflexive, since ; it is symmetric, but not transitive, since and while is not related to .
- even is an equivalence relation. Reflexivity and symmetry are immediate, and if and are even, then is even. Its two classes are the even integers and the odd integers.
- is not reflexive (except at ) and is not transitive: and , but is not related to itself.
- The condition is reflexive and symmetric because it is equivalent to saying that and have the same sign, or that at least one is zero. It is not transitive: and , but is not related to . Therefore it is not an equivalence relation, and it has no equivalence classes to list.
These examples show why each relation property must be tested separately; a single failed property is enough to rule out equivalence.
Worked example
The subset relation as a small poset
Let and consider , the set of all subsets of . Order by inclusion.
The bottom element is , the top element is , and the two middle elements are and . The only immediate covering relations are
A Hasse diagram draws only these immediate covers; all longer comparisons are then understood by transitivity.
Worked example
A simple equivalence relation
Congruence modulo is an equivalence relation on : integers are related when they have the same remainder. Modulo , the three classes contain the integers congruent to , , and , and these classes partition .
Proof: congruence modulo
Fix with . Define when . This is an equivalence relation on .
It is reflexive because and every positive divides . It is symmetric because if , then . It is transitive: if and , then divides their sum . Thus all three required properties hold.
The class of is
so the classes are exactly the residue classes modulo .
Equivalence classes and quotient sets
An equivalence relation declares which differences we will ignore. Before constructing a new object from its equivalence class, we must prove that every representative gives the same class. The partition theorem below makes that step precise; the integer and rational constructions will reuse it.
Definition
Equivalence class
Let be an equivalence relation on . For , the equivalence class of is
Definition
Quotient set
If is an equivalence relation on , then the set of equivalence classes is written .
Theorem
Equivalence classes partition the set
If is an equivalence relation on , then the equivalence classes cover , and any two classes are either equal or disjoint.
Proof: overlapping equivalence classes are equal
Reflexivity gives , hence for every . Thus the classes cover .
Suppose . Then and . If , we have ; symmetry gives , and transitivity gives and then . Hence , proving .
Conversely, if , then ; symmetry gives , so transitivity yields and then . Thus , proving . Two inclusions give equality. Therefore unequal classes cannot intersect, and the distinct classes form a partition of .
Cardinality and operation language
Cardinality means size, but in set theory the correct comparison is not always ordinary counting. Two sets and have the same cardinality when there is a bijection between them:
Worked example
A first bijection between and
This corresponds to a function such as
Every integer appears exactly once in this list, so this is a bijective enumeration.
Worked example
An injection from into
One useful countability test is whether an ordered pair of natural numbers can be encoded by a single natural number. A clean answer is
This defines a function , because is a natural number for every pair .
To see that is injective, suppose
Then
Unique prime factorization says that a positive integer has only one factorization into powers of primes. Therefore the exponent of must agree on both sides, and the exponent of must agree on both sides:
So two different ordered pairs cannot be sent to the same natural number.
Definition
Operations as functions
An -ary operation on a set is a function
For example, addition is a binary operation because it takes a pair of inputs and returns one output in the same set.
A -ary operation may look strange at first. It is a function with no input slot and one value in , so it can be read as choosing a distinguished element of .
Common mistakes
Common mistake
Do not treat preimage as inverse function
is always a subset of the domain. It does not require to be bijective.
Common mistake
Symmetric is not the same as antisymmetric
is antisymmetric but not symmetric. Equality is both symmetric and antisymmetric, while divisibility on is antisymmetric but not symmetric.
Common mistake
A relation can fail to be a function in several ways
It may send one input to many outputs, or it may leave some inputs with no output at all.
Quick checks
Checkpoint
Is on the real numbers a relation? Is it a function?
First ask whether it is a subset of . Then ask whether every input has exactly one output.
Solution · Answer
It is a relation, because it is a subset of . It is not a function, because one input is related to many possible values of .
Checkpoint
Is defined when is not bijective?
Separate preimage notation from inverse-function notation.
Solution · Answer
Yes. The preimage always exists.
Checkpoint
If has three elements and has two elements, how many functions are in ?
Choose one output in for each input in .
Solution · Answer
There are functions.
Checkpoint
If has a left inverse and is finite, what property of comes first in the proof that is invertible?
Use the equation .
Solution · Answer
First prove that is injective. Since is finite, injective then implies surjective, so is bijective.
Checkpoint
Why does define an injection from to ?
Use the exponents of the primes and .
Solution · Answer
If , unique prime factorization forces and . Therefore equal outputs imply equal ordered pairs, so is injective.
Checkpoint
If a relation is reflexive, symmetric, and transitive, what is it called?
Recall the special name for a relation that partitions the set into classes.
Solution · Answer
It is an equivalence relation.