Solutions


Try solving the exercise yourself first before checking the solution!

Set Theory: Exercises

Sets

  1. True, \mathcal{A} = \mathcal{B} since order does not matter for sets and both contain the same elements.
  2. False, \mathcal{A} \neq \mathcal{B} since \mathcal{A} contains duplicate values it is not a set.
  3. \lvert \mathcal{C} \rvert = 5
  4. False, \text{forecasting} \notin \mathcal{T}_{\text{DATS} \ 6103}. This machine learning task is covered in DATS 6313: Time Series Analysis and Modeling.
  5. False, \text{flower} \notin \{ \text{airplane}, \text{automobile}, \text{bird}, \text{cat}, \text{deer}, \text{dog}, \text{frog}, \text{horse}, \text{ship}, \text{truck} \}

Set-builder Notation

  1. \{\ldots,-11,-6,-1,4,9,\ldots\}
  2. \{ -\sqrt{3}, \sqrt{3}\}
  3. \{ -3, -2\}
  4. \{ -4,-3,-2,-1,0,1,2,3,4\}
  5. \{ \ldots,-2,1,0,1,2\ldots\} = \mathbb{Z}
  6. \{ x^n: n \in \mathbb{N}\}
  7. \{ 3x : n \in \mathbb{Z}\}
  8. \{ n^2 : n \in \mathbb{Z}\}
  9. \{ x \in \mathbb{N} : 3 \leq x \leq 8 \}
  10. \{ 2^{n} : n \in \mathbb{Z} \}

Subsets

  1. \{\emptyset, \{\emptyset\}\}
  2. \{\emptyset, \{1\}, \{2\}, \{3\}, \{1,2\}, \{2,3\}, \{1,3\}, \{1,2,3\}\}
  3. \{\emptyset, \{\text{Python}\}, \{\text{R}\}, \{\text{SQL}\}, \{\text{Python},\text{R}\}, \{\text{R},\text{SQL}\}, \{\text{Python},\text{SQL}\}, \{\text{Python},\text{R},\text{SQL}\}\}
  4. \{\emptyset, \{1\}, \{\{2,3\}\}, \{1, \{2,3\}\} \}
  5. \{\emptyset, \{\mathbb{N}\}, \{\mathbb{Z}\}, \{\mathbb{N}, \mathbb{Z}\} \}

Set Operations

  1. \mathcal{A} \cup \mathcal{B} = \{ 1, 2, 3, 4 \}
  2. \mathcal{A} \cap \mathcal{C} = \{ 1 \}
  3. \mathcal{B} - \mathcal{C} = \{ 2, 3 \}
  4. \mathcal{A} \cup (\mathcal{B} \cap \mathcal{C}) = \{ 1, 2, 3, 4 \}
  5. (\mathcal{A} - \mathcal{B}) \cap \mathcal{C} = \{ 1 \}

Cartesian Product

  1. Given the dataset \mathcal{D}:

\mathcal{D} = \{ (x_i, y_i) \}_{i=1}^{n}

We can rewrite the dataset in set-builder notation:

\mathcal{D} = \{ (x_i, y_i) : x_i \in \mathcal{X},\; y_i \in \mathcal{Y},\; i = 1,\ldots,n \}

To demonstrate that it is a subset of the set of all possible combinations of feature and target ordered pairs:

\begin{align*} \mathcal{D} \subseteq \{ (x, y) : x \in \mathcal{X},\; y \in \mathcal{Y} \} &= \mathcal{X} \times \mathcal{Y}. \end{align*}

  1. \mathcal{A} \times \mathcal{A} = \{(d,d), (d,a), (a,d), (a,a)\}
  2. \mathcal{A} \times \emptyset = \emptyset
  3. \mathcal{A} \times \mathcal{B} = \{(d,t), (d,a), (a,t), (a,a)\}
  4. \mathcal{B} \times \mathcal{C} = \{(t,s), (t,c), (t,i), (a,s), (a,c), (a,i)\}
  5. \mathcal{A} \times \mathcal{B} \times \mathcal{C} = \{ (d,t,s), (d,t,c), (d,t,i), (d,a,s), (d,a,c), (d,a,i), (a,t,s), (a,t,c), (a,t,i), (a,a,s), (a,a,c), (a,a,i)\}

Functions

  1. No, functions must assign exactly one output to each input. Notice that the real number 4 occurs as the first coordinate of more than one element of f, for example (4,-2) and (4,2).
  2. Yes, the function contains ordered pairs with exactly one output for each input.
  3. Domain: \mathbb{Z}, Codomain: \mathbb{N}, Range: \mathbb{N}
  4. Domain: \mathbb{N}, Codomain: \mathbb{R}, Range: \{x^2: x \in \mathbb{N}\} = \{1,4,9,16,\ldots\}
  5. No, the two functions are not equal as sets \mathbb{N} \neq \{1,4,9,16,\ldots\}
  6. f could be injective or surjective (bijective).
  7. h could be injective but not surjective.
  8. g could be surjective but not injective.
  9. f, g and h could be neither injective nor subjective.
  10. g \circ f=\{(1,1),(2,1),(3,3)\}
  11. f \circ g =\{(1,1),(2,2),(3,2)\}
  12. f^{-1}(x,y)=\left( \sqrt[3]{y},\; \frac{x}{\,y^{2/3}+1\,} \right)