Skip to main content

Introduction to Discrete Mathematics

Chapter 1 Sets and Counting Principles

A set is a collection of objects called elements. Typically, braces are used to denote sets as in \(\{b,c,d,f\}\text{,}\) which is the same set as \(\{b,d,c,f\}\text{,}\) and the same as \(\{c,f,c,f,d,b\}\text{.}\) If \(A\) is a set and \(x\) is an element of \(A\text{,}\) we write \({x\in A}\text{.}\) Otherwise, we write \({x\notin A}\text{.}\) For example, \(b\in \{b,d,c,f\}\) while \(e\notin \{b,d,c,f\}\text{.}\) The set containing no elements is called the empty set, and is denoted by the symbol \({\emptyset}\text{,}\) but can also be written as \({\{\}}\text{.}\) Any set that contains at least one element is referred to as a nonempty set. If we think of a set as a box potentially containing some stuff, then the empty set is a box with nothing in it.
The empty set and the set \(\{b,c,d,f\}\) are examples of finite sets. Any set that is not finite is an infinite set. For example, the natural numbers defined by \({\mathbb{N}\:= \{1,2,3,\ldots\}}\) and integers defined by \({\mathbb{Z}\:= \{0, \pm 1, \pm2, \pm 3, \ldots\}}\) are both examples of infinite sets. Some books will include zero in the set of natural numbers, but we do not. Since the set of natural numbers consists of the positive integers, the natural numbers are sometimes denoted by \({\mathbb{Z}^+}\text{.}\) The real numbers, denoted by \({\mathbb{R}}\text{,}\) is another example of an infinite set. If you look closely at our definitions for the natural numbers and integers you will notice that we wrote \({\:=}\) instead of \(=\text{.}\) We use \(\:=\) to mean that the symbol or expression on the left is defined to be equal to the expression on the right.
The language associated to sets is specific. We will often define sets using the following notation, called set-builder notation:
\begin{equation*} {S=\{x \in A\mid P(x)\}}\text{,} \end{equation*}
where \(P(x)\) is some predicate statement involving \(x\text{.}\) The first part β€œ\(x \in A\)” denotes what type of \(x\) is being considered. The predicate to the right of the vertical bar determines the condition(s) that each \(x\) must satisfy in order to be a member of the set. This notation is read as β€œThe set of all \(x\) in \(A\) such that \(P(x)\text{.}\)”

Example 1.1.

The set \(\{x\in \mathbb{N}\mid x \mbox{ is even and } x\geq 8\}\) describes the collection of even natural numbers that are greater than or equal to 8.

Example 1.2.

We can define the rational numbers using set-builder notation via
\begin{equation*} {\mathbb{Q}\:= \{a/b \mid a, b \in \mathbb{Z} \text{ and } b \neq 0\}}\text{.} \end{equation*}

Problem 1.3.

Write the set of perfect squares \(\{1,4,9,16,\ldots\}\) using set-builder notation.

Problem 1.4.

Translate the following set defined with set-builder notation in English and list a few of its elements:
\begin{equation*} P=\{x\in\mathbb{N} \mid x=2^n\mbox{ for some } n\in\mathbb{N}\}\text{.} \end{equation*}
The cardinality of a set \(A\text{,}\) denoted by \({|A|}\text{,}\) is the number of elements in \(A\text{.}\) For example, if \(A = \{b,c,d,f\}\text{,}\) then \(|A| = 4\text{.}\) We will mostly concern ourselves with the cardinality of finite sets in this book. Cardinality gets wildly more complicated if we consider infinite sets.
If \(A\) and \(B\) are sets, then we say that \(A\) is a subset of \(B\text{,}\) written \({A\subseteq B}\text{,}\) provided that every element of \(A\) is an element of \(B\text{.}\)

Example 1.5.

We have \(\{c,f,g\} \subseteq \{b,c,d,f,g\}\text{.}\)

Problem 1.6.

Let \(A\) be a set. Determine whether each of the following statements is true or false. If a statement is true, explain why. If a statement is false, provide a specific counterexample.
  1. \(A\subseteq A\text{.}\)
  2. \(\emptyset \subseteq A\text{.}\)

Problem 1.7.

Consider the set \(A=\{a,b,c\}\text{.}\) How many subsets does \(A\) have?
Note that two sets \(A\) and \(B\) are equal, denoted \({A=B}\text{,}\) if the sets contain the same elements. It’s clear that \(A=B\) if and only if \(A \subseteq B\) and \(B \subseteq A\text{.}\) If \(A\subseteq B\text{,}\) then \(A\) is called a proper subset provided that \(A\neq B\text{.}\) In this case, we may write \({A\subset B}\) or \({A\subsetneq B}\text{.}\) Some authors use \(\subset\) to mean \(\subseteq\text{,}\) so some confusion could arise if you are not reading carefully.
Sometimes it is useful to fix a set to focus our attention on. The term universe of discourse (or domain of discourse) generally refers to the collection of objects being discussed in a specific context.
Let \(A\) and \(B\) be sets in some universe of discourse \(U\text{.}\) We define the following.
  1. The union of \(A\) and \(B\) is \({A \cup B \:= \{x\in U \mid x\in A \mbox{ or } x\in B \}}\text{.}\)
  2. The intersection of \(A\) and \(B\) is \({A \cap B \:=\{x\in U \mid x\in A \mbox{ and } x\in B \}}\text{.}\)
  3. If \(A\) and \(B\) have the property that \(A \cap B = \emptyset\text{,}\) then we say that \(A\) and \(B\) are disjoint.
  4. The set difference (relative to \(U\)) of the sets \(A\) and \(B\) is \({A \setminus B \:=\{x\in U \mid x\in A \mbox{ and } x\notin B \}}\text{.}\)
  5. The complement (relative to \(U\)) of \(A\) is the set \({A^c\:= U \setminus A =\{x \in U \mid x \notin A\}}\text{.}\)

Problem 1.9.

Suppose that the universe of discourse is \(U=\{1,2,3,4,5,6,7,8,9,10\}\text{.}\) Let \(A=\{1, 2, 3, 4, 5\}\text{,}\) \(B=\{1, 3, 5\}\text{,}\) and \(C=\{2, 4, 6, 8\}\text{.}\) Find each of the following and then determine the cardinality of the set.
  1. \(\displaystyle A \cap C\)
  2. \(\displaystyle B \cap C\)
  3. \(\displaystyle A \cup B\)
  4. \(\displaystyle A\setminus B\)
  5. \(\displaystyle B \setminus A\)
  6. \(\displaystyle C \setminus B\)
  7. \(\displaystyle B^c\)
  8. \(\displaystyle A^c\)
  9. \(\displaystyle (A\cup B)^c\)
  10. \(\displaystyle A^c\cap B^c\)
Is any pair of the original sets \(A\text{,}\) \(B\text{,}\) and \(C\) disjoint?
The next theorem should be clear.
The following principle is a natural notion.

Problem 1.12.

A domino is a rectangular tile, usually with a line dividing its face into two square ends, and each end is marked with a number of dots (also called pips) or is blank. FigureΒ 1.1 shows a few examples of dominoes. The first and second domino in the figure are actually the same domino since orientation of the domino is irrelevant! When tackling the problems below, consider handling disjoint cases. If you visualize the various cases, you may end up with a nice staircase-looking arrangement.
  1. How many dominoes are there in a set that includes double blank through double nine?
  2. How many dominoes are there in a set that includes double blank through double twelve?
  3. How many dominoes are there in a set that includes double blank through double \(n\text{?}\)
First domino has 4 pips and 2 pips, second has 2 pips and 4 pips, third has 5 pips and 5 pips, fourth has 3 pips and 0 pips.
The image contains four examples of dominoes. From left to right, first domino has 4 pips and 2 pips, second domino has 2 pips and 4 pips, third domino has 5 pips and 5 pips, fourth domino has 3 pips and 0 pips.
Figure 1.1. Examples of dominoes.

Problem 1.13.

How many students are enrolled in MAT 136 or MAT 226 (or both) if there are 409 in MAT 136 and 156 in MAT 226? Do you need to know that 40 students are in both courses?
The previous problems gives us an indication of how to generalize the Sum Principle (TheoremΒ 1.11) to the case when the sets are not disjoint.

Problem 1.15.

I’m in the mood for a cup of coffee! Let’s say that the nearest place to get a cup of coffee is four blocks East and three blocks North. Assuming I only walk East or North, how many different routes can I take to get there if:
  1. The last block I walk is heading North?
  2. The last block I walk is heading East?
  3. I don’t care whether the last block I walk is North or East?
In ProblemΒ 1.15, we could describe paths to the coffee shop using expressions like \(NNENEEE\text{,}\) where we interpret the expression from left to right as instruction for which direction to walk at each step. Such expressions have a name. A string of objects of length \(k\) is a linearly ordered arrangements of \(k\) objects. The objects in a string may be repeated unless specified otherwise. For example, \(NNENEEE\) is a string of length 7 consisting of \(N\)’s and \(E\)’s. If a string consists of letters, then it may be called a word (we do not require a word to be in the dictionary!). A bit string is a string consisting of 0’s and 1’s. Each occurrence of a 0 or 1 in a bit string is called a bit. The strings \(010\) and \(100\) are two different bit strings of length 3.

Example 1.16.

How many two-letter words are there using only the letters \(b\text{,}\) \(c\text{,}\) \(d\text{,}\) \(f\text{?}\)

Solution.

We can easily list these, but using the arrangement in TableΒ 1.2 illustrates a more powerful technique. The table makes it clear that there are 16 two-letter words using the letters \(b\text{,}\) \(c\text{,}\) \(d\text{,}\) and \(f\text{.}\) Another way to see this is to note that there are 4 choices for the first (left-hand) letter and for each of these there are 4 choices for the right-hand letter, so there are \(4 \cdot 4 = 16\) words total.
Table 1.2. All possible two-letter words using the letters \(b\text{,}\) \(c\text{,}\) \(d\text{,}\) \(f\)
\(b\) \(c\) \(d\) \(f\)
\(b\) \(bb\) \(bc\) \(bd\) \(bf\)
\(c\) \(cb\) \(cc\) \(cd\) \(cf\)
\(d\) \(db\) \(dc\) \(dd\) \(df\)
\(f\) \(fb\) \(fc\) \(fd\) \(f\!f\)

Example 1.17.

How many β€œnumbered words” are there consisting of two letters from \(b\text{,}\) \(c\text{,}\) \(d\text{,}\) and \(f\) followed by one of the digits \(1\text{,}\) \(2\text{,}\) \(3\text{,}\) \(4\text{,}\) and \(5\text{?}\)

Solution.

A geometric display as in TableΒ 1.2 would seem to require three dimensions, but we can take what we already know and just add a digit to the right. See TableΒ 1.3. There are 16 rows (each with a word from ExampleΒ 1.16) and five columns, so there are \(16\cdot 5 = 80\) two-letter words using \(b\text{,}\) \(c\text{,}\) \(d\text{,}\) and \(f\text{,}\) followed by a digit from 1, 2, 3, 4, and 5.
Table 1.3. All possible β€œnumbered words” consisting of two letters from \(b\text{,}\) \(c\text{,}\) \(d\text{,}\) \(f\) followed by one of the digits \(1\text{,}\) \(2\text{,}\) \(3\text{,}\) \(4\text{,}\) and \(5\text{.}\)
\(1\) \(2\) \(3\) \(4\) \(5\)
\(bb\) \(bb1\) \(bb2\) \(bb3\) \(bb4\) \(bb5\)
\(bc\) \(bc1\) \(bc2\) \(bc3\) \(bc4\) \(bc5\)
\(\vdots\) \(\vdots\) \(\vdots\) \(\vdots\) \(\vdots\) \(\vdots\)
\(f\!f\) \(f\!f1\) \(f\!f2\) \(f\!f3\) \(f\!f4\) \(f\!f5\)
If \(A\) and \(B\) are sets, the Cartesian product of \(A\) and \(B\text{,}\) denoted \(A\times B\) (read as β€œ\(A\) times \(B\)” or β€œ\(A\) cross \(B\)”), is the set of all ordered pairs where the first component is from \(A\) and the second component is from \(B\text{.}\) In set-builder notation, we have
\begin{equation*} {A\times B\:= \{(a,b)\mid a\in A, b\in B\}}\text{.} \end{equation*}
Similarly, the Cartesian product of sets \(A_1, \ldots, A_n\) sets is the collection of \(n\)-tuples given by
\begin{equation*} {A_1\times \cdots \times A_n\:= \{(a_1,\ldots,a_n)\mid a_j\in A_j \mbox{ for all } 1\leq j\leq n\}}\\text{,} \end{equation*}
where \(A_i\) is referred to as the \(i\)th factor of the Cartesian product. As a special case, the set
\begin{equation*} \underbrace{A\times \cdots \times A}_{n\text{ factors } } \end{equation*}
is often abbreviated as \({A^n}\text{.}\)
Cartesian products are named after French philosopher and mathematician RenΓ© Descartes (1596–1650).

Example 1.18.

If \(A=\{a,b,c\}\) and \(B=\{\alpha,\beta\}\text{,}\) then
\begin{equation*} A\times B=\{(a,\alpha), (a,\beta),(b,\alpha),(b,\beta), (c,\alpha),(c,\beta)\}\text{.} \end{equation*}

Example 1.19.

The standard two-dimensional plane \(\mathbb{R}^2\) and standard three space \(\mathbb{R}^{3}\) are familiar examples of Cartesian products. In particular, we have
\begin{equation*} \mathbb{R}^2=\mathbb{R}\times \mathbb{R}=\{(x,y)\mid x,y\in \mathbb{R}\} \end{equation*}
and
\begin{equation*} \mathbb{R}^3=\mathbb{R}\times \mathbb{R}\times \mathbb{R}=\{(x,y,z)\mid x,y,z\in \mathbb{R}\}\text{.} \end{equation*}

Problem 1.21.

Let \(A=\{1, 2, 3\}\text{,}\) \(B=\{1,2\}\text{,}\) and \(C=\{1,3\}\text{.}\) Find \(A \times B\times C\text{.}\)

Problem 1.22.

If \(A\) is a set, then what is \(A\times \emptyset\) equal to?

Problem 1.23.

If \(A\) and \(B\) are both finite sets, find a nice formula for \(|A\times B|\text{.}\)

Problem 1.24.

Are collections of words or strings that we encountered earlier in the chapter just Cartesian products in disguise? Explain.

Problem 1.25.

Is a set of dominoes a Cartesian product in disguise? Explain.
We have been dancing around a fundamental counting principle. Let’s state it officially. There are three progressively more general versions, the first of which we already encountered in ProblemΒ 1.23. The second version officially follows from the first version by induction, which is a topic we will encounter later. The third version follows from the second by making a careful use of notation to identify the set \(\mathcal{O}\) with a Cartesian product.
The key difference between versions (b) and (c) of the Product Principle is that versionΒ (c) does not assume that the set of choices for step \(i\) is independent of the previous choices.

Problem 1.27.

A fashion-challenged freshman has three pair of pants, five shirts (all t-shirts, but different patterns) and a pair of sandals. How many different ensembles are available for this freshman?

Problem 1.28.

Suppose you flip a coin fives times in a row, recording the sequence of heads and tails that you see. How many different sequences of flips are possible?

Problem 1.29.

Suppose we roll a six-sided die and then flip a coin. How many distinct outcomes are possible?

Problem 1.30.

How many bit strings of length \(n\) are there? How many of these start and end with the bit 1?

Problem 1.31.

How many subsets does a set with \(n\) elements have? Make sure you are taking the case \(n=0\) into account. You should be able to carefully justify your answer by cleverly utilizing the Product Principle.

Problem 1.32.

How many four-letter words are there using lower-case English letter consonants (including \(y\)) that include exactly one occurrence of \(b\text{?}\)

Problem 1.33.

A pass code consists of a string of two or three case-sensitive English letters followed by three digits (i.e., \(0,1,2,3,4,5,6,7,8,9\)). How many different possible pass codes are there?
So far we have encountered the following fundamental methods for determining the cardinality of a set:
  • Systematic brute-force (with good bookkeeping);
  • Sum Principle: If there are multiple disjoint cases, we can add up the sizes of the various cases. If you can phrase a problem with β€œor”, you should consider adding cases.
  • Product Principle: If all the elements/outcomes can be constructed using a step-by-step process, you should multiply the number of ways each step in process can occur. Be on the look out for the keywords β€œand” or β€œthen”.
The next result is simply a special case of TheoremΒ 1.11. Sometimes it might be easier to count the opposite of what you are looking to count and then to subtract from the size of the universe of discourse. This idea is sometimes referred to as the Subtraction Principle. Keep this in mind as a method of attack for future problems.

Problem 1.35.

How many words of length 4 are there consisting of lower-case English letters that utilize at least two x’s? Find the answer in two different ways.

Problem 1.37.

Six friends sit on one side of long rectangular table.
  1. How many seating arrangements are there?
  2. How many seating arrangements are there if Sally and Maria always sit next to each other?
The next principle, called the Division Principle, provides a method for ignoring β€œunimportant” differences when counting things. Loosely speaking, the general idea is count a larger set of distinct objects and then use the Division Principle to β€œmerge” the ones that are not significantly different from each other. As a motivating example, suppose my kids have 30 toys scattered around the room. After asking my kids to pick up all the toys and put each toy in a bin according to what type of toy it is (e.g., Transformer), there ends up being 6 toys in each bin. In this case, it is easy to see that there must be 5 distinct bins.

Problem 1.39.

Six friends sit around a circle to play a game. Rotations of the group do not constitute different seating orders.
  1. How many circular seating arrangements are there?
  2. How many circular seating arrangements are there if Sally and Maria always sit next to each other?

Problem 1.40.

How many ways can the letters of the word SLOPPY be arranged?

Problem 1.41.

It’s Halloween and five students arrive at my office begging for candy. I happen to have five pieces of candy. Depending on my mood, I may give away none of the candy, all of the candy, or any amount in between. Assuming I don’t give any student more than one piece of candy, how many different ways can I distribute the candy? Does it matter if the pieces of candy are identical or not? If so, count both situations.