Sets and Functions — 1st Year Baccalaureate, Mathematical Sciences
Interactive English course on sets and functions: notation, operations, proofs, images and preimages, injectivity, surjectivity, bijectivity and composition.
mohamed Lagzouli
Créateur de ce parcours interactif.
Home
Mathematics • 1st Year Baccalaureate, Mathematical Sciences
Sets and Functions
Welcome to this interactive course on sets and functions.
In the first part, you will learn to describe, compare and work with sets.
In the second part, you will discover how a function assigns to each element of one set an element of another set, then the notions of injectivity, surjectivity, bijectivity and composition.
The goal is not only to know the definitions: you will observe, try, reason, solve problems and check your understanding step by step.
Course objectives
By the end of this lesson, you should be able to:
- use \( \in \), \( \notin \) and \( \subset \) correctly;
- write a set in roster form or in set-builder form;
- compare two sets;
- determine the power set of a set;
- compute an intersection and a union;
- use the complement and the difference;
- understand the Cartesian product;
- prove an inclusion or an equality of sets;
- recognise a function;
- identify the domain and the codomain;
- determine images and preimages;
- determine a direct image or an inverse image;
- understand restriction and extension;
- study injectivity and surjectivity;
- recognise a bijection;
- determine the inverse function of a bijection;
- compose two functions.
Prerequisites
Before starting, it helps to know the usual number sets:
You will also use the logical connectives:
- “and”;
- “or”;
- “not”;
- implication.
Quick diagnostic
This diagnostic is not graded. It simply tells you which ideas deserve a reminder.
Question 1
True or false?
Show the answer
Question 2
Consider:
Which statement is correct?
- \(2\in E\)
- \(2\subset E\)
Show the answer
Question 3
True or false?
Show the answer
Question 4
Let:
What is the image of \(3\)?
Show the answer
Question 5
If:
then \(2\) is:
- the image of \(5\)
- a preimage of \(5\)
Show the answer
Question 6
We know that:
Can we already suspect that \(f\) is not injective?
Show the answer
Reading your diagnostic
A very good start. You can move straight on.
A good start. Some ideas will be consolidated during the course.
A few basics need strengthening. Take your time with the reminders and the examples.
Free preview
Discover a few key ideas before starting the full course.
Activity 1 — Membership or inclusion?
Consider:
\(3\in E\)
True\(\{3\}\subset E\)
True\(3\subset E\)
False\(\{3\}\in E\)
False\(\varnothing\subset E\)
True\(x\in E\) is about an element.
\(A\subset E\) is about a set.
Activity 2 — Union and intersection
Consider:
The elements common to both sets are:
The elements belonging to at least one of the two sets are:
Activity 3 — A first example of a function
Consider:
Question 1
What is the image of \(2\)?
Show the answer
Question 2
What is a preimage of \(6\)?
Show the answer
Question 3
Does \(8\) have a preimage in \(\{1,2,3\}\) under this function?
Show the answer
You have just met three key ideas of this chapter. The full course will help you understand these concepts, apply them and prove related properties.
Continue the lessonCore lesson
This chapter has two main parts: sets, then functions.
Part A — Sets
A1 — Set, element and notation
A set is a collection of objects called its elements.
Example:
We write:
and:
The empty set
The set with no element at all is written:
Careful:
\(\varnothing\) has no element, whereas \(\{\varnothing\}\) has one element.
Singleton
is a singleton.
Pair
is a pair.
A2 — Roster form and set-builder form
Roster form
The elements are listed explicitly.
Set-builder form
The elements are described by a property.
One and the same collection can therefore be described in several ways.
A3 — Inclusion
We say that \(A\) is included in \(B\) if every element of \(A\) belongs to \(B\).
means:
Example:
Then:
Properties
A4 — Equality of two sets
Two sets are equal when they have exactly the same elements.
A fundamental method is to establish two inclusions:
then:
We then conclude:
A5 — The power set
The set of all subsets of \(E\) is written:
Example:
Then:
A6 — Intersection
The intersection of \(A\) and \(B\) contains the elements that belong to both sets at the same time.
Example:
A7 — Union
The union of \(A\) and \(B\) contains the elements belonging to \(A\) or to \(B\).
With:
we obtain:
A8 — Complement
Let \(A\subset E\). The complement of \(A\) in \(E\) contains the elements of \(E\) that do not belong to \(A\).
A9 — Difference
The difference \(A\setminus B\) contains the elements belonging to \(A\) but not to \(B\).
A10 — Symmetric difference
This idea may be studied as an extension.
We can also write:
A11 — Properties of intersection and union
Commutativity
Associativity
Distributivity
A12 — De Morgan's laws
A13 — Cartesian product
The Cartesian product of \(A\) and \(B\) is the set of ordered pairs \((x,y)\) such that \(x\in A\) and \(y\in B\).
Example:
A14 — Reasoning with sets
To prove a property about sets, we often translate membership into logical statements.
For example:
means:
which is equivalent to:
Therefore:
Part B — Functions
B1 — The idea of a function
Let \(E\) and \(F\) be two non-empty sets.
A function from \(E\) to \(F\) assigns to each element of \(E\) exactly one element of \(F\).
In this course, “function” always means this: every element of the starting set has one and only one image. Some textbooks call it a map; the two words mean the same thing here.
- \(E\): the domain (starting set);
- \(F\): the codomain (arrival set);
- \(f(x)\): the image of \(x\).
B2 — Image and preimage
If:
then \(y\) is the image of \(x\), and \(x\) is a preimage of \(y\).
An element of the codomain may have:
- no preimage;
- one preimage;
- several preimages.
B3 — Equality of two functions
Two functions are equal when they have:
- the same domain;
- the same codomain;
- the same image for every element of the domain.
B4 — Direct image of a subset
Let:
and:
The direct image of \(A\) is:
Example:
Then:
B5 — Inverse image of a subset
For \(B\subset F\), we define:
Example:
Then:
Careful: here \(f^{-1}(B)\) denotes the inverse image of a subset.
This does not necessarily mean that \(f\) has an inverse function.
B6 — Restriction
A function can be limited to a subset of its domain.
For example:
We may consider the restriction of \(f\) to:
Reading the interval notation: a bracket turned inwards includes the endpoint, a bracket turned outwards excludes it. So \([0,+\infty[\) contains \(0\) and every number greater than \(0\). This is the notation used in the Moroccan curriculum; some English textbooks write the same set differently.
B7 — Extension
An extension consists in extending a function to a larger set while keeping its values on the set where it was already defined.
A restriction is determined uniquely, whereas a function can generally admit several extensions.
B8 — Injectivity
A function \(f:E\to F\) is injective if every element of \(F\) has at most one preimage.
Example:
If:
then:
so:
The function is therefore injective.
B9 — Surjectivity
A function \(f:E\to F\) is surjective if every element of \(F\) has at least one preimage.
B10 — Bijectivity
A function is bijective when every element of the codomain has exactly one preimage.
B11 — Inverse function
If:
is bijective, it has an inverse function:
because:
B12 — Composition of functions
Let:
and:
The composite of \(f\) followed by \(g\) is:
with:
In general:
Composition of functions is therefore generally not commutative.
B13 — Inverse and composition
If \(f:E\to F\) is bijective, then:
and:
Worked examples
Watch the method before trying on your own. Use the hints only if you need them.
Example 1 — From set-builder form to roster form
Write in roster form:
Hint 1
Look for all the integers between \(-2\) and \(3\).
Solution
Key point: set-builder form gives a condition; roster form lists the elements.
Example 2 — Proving an equality of sets
To prove:
a very important method is to prove in turn:
then:
We can then conclude:
Key point: this method is called double inclusion.
Example 3 — Intersection and union of intervals
Let:
Determine \(A\cap B\) and \(A\cup B\).
Hint
For the intersection, keep the real numbers belonging to both intervals at the same time.
Solution
Example 4 — Using one of De Morgan's laws
Complete:
Solution
Example 5 — Image and preimage
Let:
Determine the image of \(3\).
Solution
So \(7\) is the image of \(3\), and \(3\) is a preimage of \(7\).
Example 6 — Inverse image
Let:
Determine:
Hint 1
Solve:
Solution
Therefore:
Example 7 — Testing injectivity
Let:
We observe:
but:
So two distinct elements have the same image.
What happens if we restrict \(f\) to \([0,+\infty[\)?
Example 8 — Composition
Let:
Then:
whereas:
Therefore:
Interactive exercises
Work your way from elementary checks to exercises that call for genuine reasoning. Look for each answer yourself before revealing it.
Level 1 — Consolidation
Quick check — Operations on sets
Four checks to do in your head. If one of them resists, go back to Part A of the Core lesson before continuing.
Let:
a) Determine \(A\cap B\).
Show the answer
Every element of \(A\) belongs to \(B\), so \(A\subset B\).
b) Determine \(A\cup B\).
Show the answer
Same reason: \(A\subset B\).
c) Determine \(\mathcal{P}(E)\).
Show the answer
Four subsets, as expected from \(2^2\).
d) Determine the complement of \(]-\infty,0]\) in \(\mathbb{R}\).
Show the answer
The endpoint \(0\) belonged to the set, so it does not belong to the complement.
Exercise 1 — Images and preimages of an affine function
Consider the function:
a) Compute \(f(2)\), \(f(0)\) and \(f(-1)\).
Show the answer
b) Determine the preimage of \(8\) under \(f\), then that of \(0\).
Show the hint
A preimage of \(8\) is a real number \(x\) satisfying \(f(x)=8\). Write the equation and solve it.
Show the answer
The preimage of \(8\) is \(2\).
Remark: \(f(2)=8\) and the preimage of \(8\) is \(2\). Image and preimage are two opposite readings of the same equality.
c) Show that every real number \(y\) has a unique preimage under \(f\).
Show the hint
Start from \(f(x)=y\) and express \(x\) in terms of \(y\). How many solutions do you get?
Show the answer
Let \(y\in\mathbb{R}\).
This equation has one solution and only one. Every real number therefore has exactly one preimage under \(f\).
Level 2 — Mastery
Exercise 2 — Direct image, inverse image and bijection
What you have established. In Exercise 1 you showed that for \(f:\mathbb{R}\to\mathbb{R}\), \(f(x)=3x+2\), every real number \(y\) has a unique preimage, namely \(x=\dfrac{y-2}{3}\). We now build on that result.
a) Determine the direct image \(f([0;2])\).
Show the hint
\(f\) is affine with coefficient \(3>0\), hence increasing: the image of a segment is read off its endpoints.
Show the answer
\(f\) is increasing on \(\mathbb{R}\), so:
b) Determine the inverse image \(f^{-1}(]-1;5])\).
Show the hint
Translate \(x\in f^{-1}(]-1;5])\) into the double inequality \(-1<f(x)\leqslant 5\), then isolate \(x\).
Show the answer
The open and closed endpoints carry over in the same order, because \(f\) is increasing. With a decreasing function they would be swapped.
c) Using the result of Exercise 1 c), show that \(f\) is bijective and write \(f^{-1}\) explicitly.
Show the hint
Uniqueness of the preimage gives injectivity; its existence gives surjectivity.
Show the answer
Exercise 1 c) establishes that every \(y\in\mathbb{R}\) has a preimage — so \(f\) is surjective — and only one — so \(f\) is injective. Consequently \(f\) is bijective, and:
Check: \(f^{-1}(8)=\dfrac{6}{3}=2\), and \(f(2)=8\).
Exercise 3 — Direct and inverse images of \(x\mapsto x^2\)
Consider the function:
a) Solve the inequality \(1\leqslant x^2\leqslant 4\) in \(\mathbb{R}\).
Show the hint
\(1\leqslant x^2\leqslant 4\) is equivalent to \(1\leqslant |x|\leqslant 2\).
Show the answer
b) Deduce \(f^{-1}([1;4])\).
Show the answer
By definition, \(f^{-1}([1;4])=\{x\in\mathbb{R}\mid 1\leqslant f(x)\leqslant 4\}\), so:
The inverse image of an interval need not be an interval: here it is a union of two segments.
c) Determine \(f^{-1}([-4;-1])\).
Show the hint
What is the sign of \(x^2\) for an arbitrary real number \(x\)?
Show the answer
For every real number \(x\), \(x^2\geqslant 0\). No real number has its image in \([-4;-1]\):
The inverse image of a non-empty set can be empty. Here the notation \(f^{-1}\) denotes the inverse image of a subset, not an inverse function: \(f\) is not bijective.
d) Determine the direct image \(f([-2;1])\).
Show the hint
\(f\) is not monotonic on \([-2;1]\). Where is the minimum reached?
Show the answer
On \([-2;1]\), \(f\) decreases on \([-2;0]\) then increases on \([0;1]\). The minimum is \(f(0)=0\); at the endpoints, \(f(-2)=4\) and \(f(1)=1\), so the maximum is \(4\).
Answering \([1;4]\) is the classic mistake: reading the image from the endpoints alone is only valid for a monotonic function.
Exercise 4 — Injectivity, surjectivity, restriction
a) Let \(f:\mathbb{R}\to\mathbb{R}\), \(f(x)=2x+1\). Is \(f\) injective? Justify.
Show the hint
Start from \(f(x)=f(x')\) and conclude about \(x\) and \(x'\).
Show the answer
Let \(x,x'\in\mathbb{R}\):
\(f\) is injective.
b) Is \(f\) surjective? Deduce that it is bijective.
Show the answer
Let \(y\in\mathbb{R}\). The equation \(2x+1=y\) has the solution \(x=\dfrac{y-1}{2}\), which is a real number. Every element of the codomain \(\mathbb{R}\) has a preimage: \(f\) is surjective.
Injective and surjective, \(f\) is bijective, with inverse:
c) Let \(g:\mathbb{R}\to\mathbb{R}\), \(g(x)=x^2\). Is \(g\) injective? surjective?
Show the hint
For injectivity, look for two distinct real numbers with the same image. For surjectivity, look for a real number with no preimage.
Show the answer
Not injective: \(g(-1)=g(1)=1\) although \(-1\neq 1\).
Not surjective: \(-1\) has no preimage, since \(x^2\geqslant 0\) for every real number \(x\).
d) Consider the two functions:
Study the injectivity and the surjectivity of \(g_1\), then of \(g_2\). Conclude for each one.
Show the hint
\(g_1\) and \(g_2\) have the same domain \([0;+\infty[\) and the same formula; only their codomain differs. Examine separately what this changes for injectivity, then for surjectivity.
Show the answer
Injectivity — it involves only the domain, which is the same for \(g_1\) and \(g_2\). Let \(x,x'\in[0;+\infty[\):
\(g_1\) and \(g_2\) are therefore both injective.
Surjectivity — it involves the codomain, which is what distinguishes them.
- \(g_1:[0;+\infty[\to\mathbb{R}\) — the real number \(-1\) belongs to the codomain \(\mathbb{R}\) and has no preimage in \([0;+\infty[\). \(g_1\) is not surjective, hence not bijective.
- \(g_2:[0;+\infty[\to[0;+\infty[\) — for every \(y\geqslant 0\), the real number \(x=\sqrt{y}\) belongs to \([0;+\infty[\) and satisfies \(g_2(x)=y\). \(g_2\) is surjective, hence bijective, with inverse:
Key method. \(g_1\) and \(g_2\) have the same formula and the same domain: they differ only in their codomain, and yet one is bijective and the other is not.
Injectivity is read off the domain: restricting the domain can make it appear, as here when passing from \(\mathbb{R}\) to \([0;+\infty[\).
Surjectivity, on the other hand, is always judged against the codomain that has been chosen. If some elements of the codomain have no preimage, restricting the domain cannot make the function surjective. One may then choose the image of the function as the codomain.
Hence the writing rule: a conclusion about bijectivity must always name both sets. Writing “\(x\mapsto x^2\) is bijective on \([0;+\infty[\)” is incomplete; writing “\(g_2:[0;+\infty[\to[0;+\infty[\) is bijective” is exact.
Level 3 — Reasoning
Exercise 5 — De Morgan's law by double inclusion
Let \(A\) and \(B\) be two subsets of a set \(E\). We want to establish:
a) Let \(x\in\overline{A\cap B}\). Translate this membership using “not”, “and”, “or”.
Show the hint
\(x\in\overline{A\cap B}\) means \(x\notin A\cap B\), that is, the negation of “\(x\in A\) and \(x\in B\)”.
Show the answer
Let \(x\in E\).
The negation of a conjunction is the disjunction of the negations:
b) Deduce the inclusion \(\overline{A\cap B}\subset\overline{A}\cup\overline{B}\).
Show the answer
“\(x\notin A\) or \(x\notin B\)” means \(x\in\overline{A}\) or \(x\in\overline{B}\), that is, \(x\in\overline{A}\cup\overline{B}\). Hence:
c) Prove the reverse inclusion.
Show the hint
Run the reasoning of a) backwards: every step is an equivalence.
Show the answer
Let \(x\in\overline{A}\cup\overline{B}\). Then \(x\notin A\) or \(x\notin B\); so it is false that \(x\) belongs both to \(A\) and to \(B\). Hence \(x\notin A\cap B\), that is, \(x\in\overline{A\cap B}\). Therefore:
d) Conclude.
Show the answer
The two inclusions give the equality:
Every step in a) is an equivalence: we could have concluded in one go. Double inclusion is required because it remains valid when the implications cannot be reversed — that is the method to master.
Exercise 6 — Composition and characterisation
Let two functions:
a) Show that if \(f\) and \(g\) are injective, then \(g\circ f\) is injective.
Show the hint
Start from \((g\circ f)(x)=(g\circ f)(x')\) and use the injectivity of \(g\) first.
Show the answer
Let \(x,x'\in E\) be such that \((g\circ f)(x)=(g\circ f)(x')\), that is, \(g(f(x))=g(f(x'))\).
Since \(g\) is injective: \(f(x)=f(x')\).
Since \(f\) is injective: \(x=x'\).
So \(g\circ f\) is injective.
b) Show that if \(f\) and \(g\) are surjective, then \(g\circ f\) is surjective.
Show the hint
Start from an element \(z\in G\) and work back: first through \(g\), then through \(f\).
Show the answer
Let \(z\in G\).
Since \(g\) is surjective, there exists \(y\in F\) such that \(g(y)=z\).
Since \(f\) is surjective, there exists \(x\in E\) such that \(f(x)=y\).
So \(g\circ f\) is surjective.
c) Deduce the case where \(f\) and \(g\) are bijective.
Show the answer
If \(f\) and \(g\) are bijective, they are injective and surjective. By a) and b), \(g\circ f\) is injective and surjective, hence bijective.
The order in which the hypotheses are used differs: one “goes down” through \(g\) then \(f\) for injectivity, and “works back” through \(g\) then \(f\) for surjectivity.
Exercise 7 — Inverse function (extension)
Let \(f:E\to F\) be a bijective function, with inverse \(f^{-1}:F\to E\).
a) Show that \(f^{-1}\circ f=Id_E\).
Show the hint
For \(x\in E\), set \(y=f(x)\) and go back to the definition of \(f^{-1}(y)\).
Show the answer
Let \(x\in E\); set \(y=f(x)\).
By definition, \(f^{-1}(y)\) is the unique preimage of \(y\) under \(f\). Now \(x\) is a preimage of \(y\). By uniqueness, \(f^{-1}(y)=x\), so:
This holding for every \(x\in E\): \(f^{-1}\circ f=Id_E\).
b) Show that \(f\circ f^{-1}=Id_F\).
Show the hint
For \(y\in F\), set \(x=f^{-1}(y)\) and apply \(f\).
Show the answer
Let \(y\in F\); set \(x=f^{-1}(y)\). By definition of the inverse, \(x\) is the preimage of \(y\), so \(f(x)=y\), that is:
This holding for every \(y\in F\): \(f\circ f^{-1}=Id_F\).
The two composites are not the same function: one is the identity of \(E\), the other that of \(F\). The distinction is obvious as soon as \(E\neq F\).
Final quiz
Now check your mastery of sets and functions.
Question 1
Let:
Which statement is correct?
- \(2\subset E\)
- \(2\in E\)
Show the solution
Answer: B.
Question 2
True or false?
Show the solution
Answer: True.
Question 3
Let:
Determine:
Show the solution
\[ A\cap B=\{2,3\} \]
Question 4
For the same sets, determine:
Show the solution
\[ A\cup B=\{1,2,3,4\} \]
Question 5
Let:
How many elements does \(\mathcal{P}(E)\) have?
Show the solution
Answer: \(4\).
Question 6
Complete:
Show the solution
\[ \overline{A\cup B} = \overline A\cap\overline B \]
Question 7
If:
then \(7\) is:
- the image of \(3\)
- a preimage of \(3\)
Show the solution
Answer: A.
Question 8
If two different elements have the same image, can the function be injective?
Show the solution
Answer: No.
Question 9
A surjective function satisfies:
- every element of the codomain has at least one preimage;
- every element of the domain has two images;
- no image can be repeated.
Show the solution
Answer: A.
Question 10
A bijective function is:
- only injective;
- only surjective;
- injective and surjective.
Show the solution
Answer: C.
Question 11
Let:
Compute:
We have:
then:
Show the solution
Answer: \(9\).
Question 12 — Reasoning
Let:
Why is \(f\) not injective?
Show the solution
Because two distinct elements can have the same image. For example:
with:
Your mastery report
The final result should not be reduced to a single overall mark. The course can distinguish the following skills:
- Notation and inclusion
- Operations on sets
- Set-theoretic proofs
- Images and preimages
- Direct image and inverse image
- Injectivity
- Surjectivity
- Bijectivity
- Composition