Describe what a set is and how a set’s contents and members are denoted (\(\{\ldots\}\),\(\in\) )
Know the notation for natural numbers (\(\mathbb{N}\)), integers (\(\mathbb{Z}\)), rational numbers (\(\mathbb{Q}\)), real numbers, and the empty set (\({\varnothing}\) or \(\emptyset\), or occasionally \(\{\}\)).
Define sets using set-builder notation.
Calculate the cardinality of a set.
We will have covered the material you need by the end of tomorrow’s lecture.
You’ll write your answers in LaTeX. See this guide to get started. This is also linked from the Assignments section of the syllabus.
See L02.rkt.
The key idea is to pass information down the recursive rabbit hole using arguments.
As an example, we can compute the average in two passes like:
(/ (sum lst) (length lst))
But we can compute it in one using a helper function such as:
(define avg-helper
(lambda (lst sum-so-far length-so-far)
; ...
because when the list is empty, we have the running sum and length already so we can simply divide them and return.
A set is an unordered collection of unique items. The items in a set are its elements.
This membership relationship is denoted \(a \in S\), read “\(a\) is an element of \(S\).”, or “\(a\) is in \(S\).” If \(a\) is not in \(S\), we write \(a \not\in S\).
You can write a set by listing its elements in curly braces (this is the “roster method”):
For example: If \(S = \{1, 2, 3, 4\}\), then \(1 \in S\) and \(2 \in S\), but \(0 \not\in S\).
Sets are unordered: changing the order you list the elements does not change the set:
\(S = \{2, 3, 4, 1\} = \{1, 2, 3, 4\}\), and so on.
Elements of a set must be unique: listing an element more than once does not change the set:
\(S = \{1, 2, 3, 4\} = \{1, 1, 2, 3, 4, 4\}\), and so on.
If the meaning is obvious, you can use ellipses (\(\ldots\)) to describe a set without listing all of its members:
\(A = \{\text{a}, \text{b}, \text{c}, \ldots, \text{z}\}\) describes the English alphabet.
\(\mathbb{N}\) is the set of natural numbers \(\{1, 2, 3, \ldots\}\)
\(\mathbb{Z}\) is the set of integers \(\{\ldots, -2, -1, 0, 1, 2, \ldots\}\)
\(\mathbb{Q}\) is the set of rational numbers, i.e., numbers that can be written as a fraction \(a/b\) where \(a, b \in \mathbb{Z}\) and \(b \ne 0\).
\(\mathbb{R}\) is the set of real numbers; \(\mathbb{C}\) is the set of complex numbers.
\(\varnothing\) is the empty set, i.e., the set containing no elements. It can also be written \(\{\}\), or \(\emptyset\).
Do Exercises Part A
We saw the roster method last time. You can also specify the members of a set using “set-builder” notation: \[ \{\text{expression} : \text{membership test}\} \] For example, the set (written using the roster method) \(\{1, 3, 5, 7, 9\}\) could also be written in any of the following ways:
The colon is read “such that”, or “where”. Sometimes you’ll see a vertical bar (\(|\)) used instead of a colon (\(:\)).
Do Exercises Part B
Definition: If there are exactly \(n\) distinct elements in \(S\), and \(n\) is a nonnegative integer, then \(S\) is finite. Otherwise, \(S\) is infinite.
Definition: The cardinality of a finite set \(A\), denoted \(|A\)|, is the number of (distinct) elements in \(A\).
Examples:
Fact that can give rise to confusion: elements of a set can be sets themselves.
For example, let $ S = {{1, 2}, {2, 3}, }$. Some interesting facts:
Do Exercises Part C