Skip to main content

Introduction to sets

Back to mathematics

In maths we often need to talk about a whole group of things at once. For example: all the numbers from 2 to 5, all the answers to an equation, or all the students in a class who play football. A set is the tool for this. With it, we can say exactly which things are in the group and which are not.

We start with a box, because a set behaves very much like one. Then we put all the numbers on a line and use sets to describe a stretch of it. At the end we combine two sets: join them, keep what they share, or take one away from the other.

01

What is a set?

A set is a collection of elements. “Collection” just means a group of things. An “element” means one thing in that group. For example, an apple can be an element, so we can collect it in a set.

We write this set as {apple}\{\text{apple}\}. The two curly brackets { }\{\ \} mean “a set”. What we write between them are its elements, separated by commas. So {apple,ball}\{\text{apple}, \text{ball}\} is a set with two elements.

A box helps us picture this. In the model below, the two ends of the box are shaped like {\{ and }\}: the walls of the box are the brackets. You can put anything inside: an apple, a ball, a toy dog. In maths we usually put in numbers, such as 22 and 55.

Click an object, or its button, to put it in the box. Click it again to take it out. Under the box, the set is written out as you go.

Loading the box…

{}=∅\{\} = \varnothing
Put things in the box

A pressed button means the object is in the box. Drag the picture to look from another side.

We usually name a set with a capital letter, such as A={apple,ball}A = \{\text{apple}, \text{ball}\}. To say “the apple is in AA”, we write apple∈A\text{apple} \in A. The symbol ∈\in is read “is an element of”. To say the dog is not in AA, we cross the symbol out: dog∉A\text{dog} \notin A.

02

Three rules of the box

Rule 1: A set records which elements are present. It does not record where they are placed or which one was put in first. For example, listing the apple before the ball and listing the ball before the apple both describe exactly those two elements. That is why the order in a set's list does not change the set. A physical box also has positions, but we deliberately leave those positions out of our set record.

Loading the box…

{apple,ball,dog}\{\text{apple}, \text{ball}, \text{dog}\}
Put things in the box

A pressed button means the object is in the box. Drag the picture to look from another side.

Put a few objects in the box above, then press “Shake the box”. The objects move, and the set under the box is read again from left to right. The list is in a new order, but nothing went in or came out. So it is the same set: {apple,ball}={ball,apple}\{\text{apple}, \text{ball}\} = \{\text{ball}, \text{apple}\}.

Rule 2: each element must be definite. Second rule. We have not yet said what an element must be. An apple is fine: it is a specific thing you know. But suppose you want to put in “something I saw on the street yesterday”. Well, you may have seen lots of things on the street yesterday. Which one goes in?

As it stands, that description does not tell us which element to include. We need a description that fixes the membership: changing the person reading it must not change which things count. This is what well-defined means here. Finding the answer may still take work; the requirement is a definite rule, not that every answer must be immediately known. In the cards below, decide whether the wording gives a definite rule.

“Something I saw on the street yesterday”
“Big numbers”
“The whole numbers from 1 to 5”
“Numbers bigger than 100”

Rule 3: the same element counts only once. Now distinguish an object from what it represents. The two wooden blocks are two different objects, but here both stand for the same number 22. We are recording numbers, so putting in the second block does not add a new number: 22 was already present. Thus {2,2}={2}\{2,2\}=\{2\}. If our elements were the individual wooden blocks instead, we would name them separately, and there would be two elements. Decide what the elements mean before counting them.

A set can also have nothing in it. That is reasonable, because a box can be empty too. This set is called the empty set. We write it as {}\{\} or, more often, ∅\varnothing. Press “Empty the box” to see it.

03

All the numbers on one line

Anything can be an element, so numbers like 2.22.2, π\pi and 0.000000240.00000024 are all fine. Now suppose we want the set of all the numbers from 22 to 55. We cannot list them. Between 22 and 55 there are 2.22.2, 2.212.21, 2.2112.211, and so on, without end.

Integers, fractions such as 1/31/3, and numbers such as π\pi all have a place on a straight line; that line is the number line drawn below. The numbers that have a place on it are called real numbers in this lesson. π\pi is about 3.141593.14159: it is the distance around a circle divided by the distance across its centre. The set of all real numbers is written R\mathbb R.

We put all the real numbers on a line, called the number line. First choose a point for 00 and a length for 11. Then every number has its own point: positive numbers to the right of 00, negative numbers to the left.

Move the slider below; the point on the line moves with it. Its displayed coordinate is rounded, so an approximation sign appears in front. Zoom in to inspect nearby positions. The screen and slider show only finitely many positions, but the line is not a string of separate dots: between any two different numbers there is always another number. Take 2 and 5: their midpoint 3.5 lies between them, and between 3.5 and 5 there is 4.25; this can go on forever. The screen shows only part of that line.

Move along the line
Marker3.14163.1416

The marker starts at π. Each zoom shows ten times more detail around it.

04

A stretch of the line: intervals

All the real numbers from 22 to 55, including 22 and 55, can be written as an interval: [2,5][2, 5]. It means every real number between 22 and 55, together with 22 and 55 themselves. On the number line it is the whole stretch from 22 to 55, with a filled dot at each end.

Sometimes we want to leave an end out. A round bracket means “not including”. So (2,5](2, 5] includes 55 but not 22, [2,5)[2, 5) includes 22 but not 55, and (2,5)(2, 5) includes neither. On the line, an end that is left out gets a hollow dot.

Click an end dot to switch it between filled and hollow, and use the sliders to move the ends. Then move the test number and see whether it belongs to the interval.

0123456784.994.99∈[2,5)4.99 \in [2, 5)
Build an interval
Left end22
Right end55
Test number4.994.99

Look closely at the end. 5∈[2,5]5 \in [2, 5], but 5∉[2,5)5 \notin [2, 5). Yet 4.94.9, 4.994.99 and 4.9994.999 are all in [2,5)[2, 5). This interval gets as close to 55 as we like, but 55 itself is left out.

05

Joining sets and finding what they share

Now we want to combine sets. We use two small sets: A={1,2,3,4}A = \{1, 2, 3, 4\} and B={3,4,5,6}B = \{3, 4, 5, 6\}. A picture called a Venn diagram helps. Each set is drawn as a circle, with its elements written inside.

The numbers 33 and 44 are in both sets. So the two circles overlap, and 33 and 44 sit in the overlapping part.

Putting both sets together gives their union, written A∪BA \cup B and read “AA union BB”. It contains every element that is in AA, or in BB, or in both. Here A∪B={1,2,3,4,5,6}A \cup B = \{1, 2, 3, 4, 5, 6\}. We write 33 and 44 only once, because a set has no repeats.

The overlapping part is the intersection, written A∩BA \cap B and read “AA intersect BB”. It contains only the elements that are in both AA and BB. Here A∩B={3,4}A \cap B = \{3, 4\}. If two sets share nothing, their intersection is the empty set ∅\varnothing.

Choose an operation below. The part of the picture it keeps is shaded, and the result is written underneath.

A∪B={1,2,3,4,5,6}A \cup B = \{1, 2, 3, 4, 5, 6\}
Choose an operation

Bold numbers are in the result. A={1,2,3,4}A = \{1, 2, 3, 4\}, B={3,4,5,6}B = \{3, 4, 5, 6\}.

06

Taking away, and what is left outside

Sometimes we want AA without the elements of BB. This is the difference, written A∖BA \setminus B and read “AA minus BB”. It keeps the elements of AA that are not in BB. Here A∖B={1,2}A \setminus B = \{1, 2\}. But B∖A={5,6}B \setminus A = \{5, 6\}, so here the order does matter.

For the last operation, we must say what “everything” means. The set of all the things we are talking about is called the universal set, UU. In the picture it is the rectangle: U={1,2,3,4,5,6,7,8}U = \{1, 2, 3, 4, 5, 6, 7, 8\}. The numbers 77 and 88 are in UU but in neither circle.

The complement of AA is everything in UU that is not in AA. We write it AcA^{c}; some books write A′A'. Here Ac={5,6,7,8}A^{c} = \{5, 6, 7, 8\}. It is the same as U∖AU \setminus A: the universal set with AA taken away.

A∖B={1,2}A \setminus B = \{1, 2\}
Choose an operation

Bold numbers are in the result. A={1,2,3,4}A = \{1, 2, 3, 4\}, B={3,4,5,6}B = \{3, 4, 5, 6\}.

07

Set operations on the number line

Intervals are sets too, so we can join them, find their overlap and take one away from another. Let A=[2,5]A = [2, 5] and B=[4,7]B = [4, 7].

The two pieces overlap between 44 and 55, so together they cover everything from 22 to 77 without a gap: A∪B=[2,7]A \cup B = [2, 7]. The part they share runs from 44 to 55. Both 44 and 55 are in both intervals, so A∩B=[4,5]A \cap B = [4, 5].

A∖BA \setminus B removes from AA every number that is in BB. That removes everything from 44 to 55, including 44 itself, because 4∈B4 \in B. What is left starts at 22 and stops just before 44: A∖B=[2,4)A \setminus B = [2, 4). This is where round brackets are needed.

Take all real numbers R\mathbb{R} as the universal set. The complement of AA is every number less than 22 and every number greater than 55. These stretches never end. We show “goes on without end” with the symbol ∞\infty, read “infinity”. It is not a number, so it always gets a round bracket: the complement is (−∞,2)∪(5,+∞)(-\infty, 2) \cup (5, +\infty).

Slide BB along the line and choose an operation. Watch the ends of the answer switch between square and round brackets.

A∖B=[2,4)A \setminus B = [2, 4)
Combine two intervals
A=[2,5]A = [2, 5], B=[4,7]B = [4, 7]
Slide B44

Choose one number and follow the vertical guide through AA, BB and the green result. A filled marker means that row includes the number; a hollow marker means it does not.

Number to check44
4∈A,4∈B4\in A,\qquad 4\in BStart with A. Keep its number only if that number is absent from B.4∉A∖B4\notin A \setminus B
08

Try it yourself

Is {1,2,3}\{1, 2, 3\} the same set as {3,1,2,2}\{3, 1, 2, 2\}?

Which of these describes a set?

Is 55 an element of [2,5)[2, 5)?

With A={1,2,3,4}A = \{1, 2, 3, 4\} and B={3,4,5,6}B = \{3, 4, 5, 6\}, what is A∩BA \cap B?

What is [2,5]∖[4,7][2, 5] \setminus [4, 7]?