# Sets and functionsSet Builder Notation

It's often useful to define a set in terms of the properties its elements are supposed to have.

**Definition**

If is a set and is a property which each element of either satisfies or does not satisfy, then

denotes the set of all elements in which have the property . This is called *set builder notation*. The colon is read as "such that".

**Example**

Suppose the set denotes the set of all real numbers between 0 and 1. Then can be expressed as

Counting the number of elements in a set is also an important operation:

**Definition** (Cardinality)

Given a set , the cardinality of , denoted , denotes the number of elements in .

**Exercise**

Let . Then =

*Solution.* There are three values with the property that . Therefore, .

Not every set has an integer number of elements. Some sets have more elements than any set of the form . These sets are said to be

**Definition** (Countably infinite)

A set is *countably infinite* if its elements can be arranged in a sequence.

**Example**

The set is

The set of rational numbers between 0 and 1 is countably infinite, since they all appear in the sequence

The set of all real numbers between 0 and 1 is *Cantor's diagonal argument*, which you can read more about here if you're interested.

**Exercise**

Show that the set of all ordered pairs of positive integers is countably infinite.

*Solution.* We visualize the pairs as a grid of points in the first quadrant. We arrange the points in a sequence by beginning in the lower left corner at and snake through the grid: we go right to , then diagonally northwest to , then up to , then diagonally southeast to and through to , and so on.