Lecture 3

Set operations

Let AA and BB be sets. We define their union ABA\cup B to contain exactly the things that are in one set or the other (or both): AB={xxA or xB}.A\cup B = \left\{x \mid \text{$x\in A$ or $x\in B$} \right\}.

That notation is called a set comprehension: the thing on the left of the vertical bar are the things we want to put in the set, and the things on the right of the vertical bar are the conditions under which we put them in. We’ll use them a lot.

Similarly, we define the intersection ABA\cap B to contain exactly the things that are in both sets: AB={xxA and xB}.A\cap B = \left\{x \mid \text{$x\in A$ and $x\in B$} \right\}.

Lastly, we define the difference A\BA\backslash B to be the things which are in AA but not in BB: A\B={xxA and xB}.A\backslash B = \left\{x \mid \text{$x\in A$ and $x\notin B$} \right\}.


Two sets AA and BB are equal if they have the same members.

A straightforward way of proving this is often to show that ABA\subset B and BAB\subset A. That is, in words, two sets AA and BB are equal if every element of AA is an element of BB and every element of BB is an element of AA.

Here’s an example of this proof strategy:


1 Let AA, BB and CC be three sets. We have A(BC)=(AB)(AC).A\cap(B\cup C) = (A\cap B)\cup(A\cap C).


We’ll show that each side is contained in the other: first we’ll prove that A(BC)(AB)(AC),A\cap(B\cup C) \subset (A\cap B)\cup(A\cap C), and then that (AB)(AC)A(BC).(A\cap B)\cup(A\cap C) \subset A\cap(B\cup C).

For the first one, suppose that xA(BC)x\in A\cap(B\cup C); we must prove that x(AB)(AC)x\in (A\cap B)\cup (A\cup C).

Since xA(BC)x\in A\cap(B\cup C), we have both xAx\in A and xBCx\in B\cup C, which in turn means that xBx\in B or xCx\in C. In either case, the desired result holds:

So we’ve proved that containment.

Now let’s prove the other containment: that (AB)(AC)A(BC)(A\cap B)\cup(A\cap C)\subset A\cap(B\cup C). We suppose that x(AB)(AC)x\in(A\cap B)\cup(A\cap C) and must prove that xA(BC)x\in A\cap(B\cup C).

Since x(AB)(AC)x\in (A\cap B)\cup(A\cap C), we have either xABx\in A\cap B or xACx\in A\cap C. In either case, we get what we want.

That was the first example of a formal proof in this course. You’ll have to write many proofs like this yourself, in assessed homework and in the exam. Though we’ll discuss it in depth later, it may be worth observing the style from the beginning. One big mistake that many beginner mathematicians make is not using words to explain the flow of the argument.

A warning

What we are practising here is called naı̈ve set theory. What’s so naı̈ve about it?

The Welsh mathematician Bertrand Russell realised in 1901 that there are serious problems with being allowed to form sets carelessly:


Suppose there is a set SS of all sets which are not elements of themselves: S={AAA}.S = \left\{A\mid A\notin A\right\}. This creates a contradiction.


Is SS a member of itself? If SSS\in S, then by the definition of SS, we have SSS\notin S. On the other hand, if SSS\notin S, then again by the definition of SS we have SSS\in S.

As a result of this paradox, modern set theorists impose strict rules on what sets can be formed, with the aim of banning this particular beast and everything like it.

However, you probably won’t need to worry about this, unless you take a course in set theory later in your mathematical careers.


A function is to be thought of as a machine that takes an element of one set and gives you an element of another. Here’s a formal definition:
Definition: Given sets AA and BB, a function (sometimes called a map) f:ABf:A\rightarrow B gives for each element aAa\in A a unique element f(a)Bf(a)\in B.

Examples include:

The set AA is called the domain of ff, and BB is called the codomain of ff. We call f(a)f(a) the value of ff at aa, or the image of aa under ff.

Consider the “age in years” function from the set of people watching this lecture to the natural numbers.

The domain of this function is the set of values you’re permitted to apply it to. This is the set of people watching the lecture, because I said so.

The codomain of this function is the set of values it is permitted to take. This is the set N\mathbb{N} of natural numbers, because I said so.

Some people like to talk about the image of this function, being the set of values it actually takes in practice. This might (perhaps) be the set {18,19,20,37}.\left\{18,19,20,{37}\right\}.

The range is not a phrase that’s used consistently:

  1. In this course, we’ll be numbering results by lecture, so that Theorem 15.3 will be the third result in the 15th lecture.↩︎