Set notation

From CS2800 wiki


  • The symbol "[math]\in [/math]" ("\in" in LaTeX) means "is in" or just "in". For example, [math]1 \in \{1,2,3\} [/math], but [math]4 \notin \{1,2,3\} [/math].
  • Curly braces usually indicate a set. I have already used [math]\{1,2,3\} [/math] to denote the set containing 1, 2, and 3.
  • There is a "set comprehension" syntax that is useful for building other sets. For example, if [math]A = \{1,2,3\} [/math], we can write [math]\{x \in A \mid x \gt 2\} [/math]. This should be read as "the set of all elements [math]x [/math] in the set [math]A [/math] such that [math]x \gt 2 [/math]." This is another way of writing [math]\{3\} [/math]. You can use any description (as long as it is clear an unambiguous) in the predicate (the part after the vertical bar). For example [math]\{x \in A \mid x \gt 2 \text{ or } x = 1\} [/math].
  • Informally, one can describe a set, for example: [math]\{all~colors\} [/math] is an informal way to write [math]\{red, green, blue, tope, mauve, \dots\} [/math]. Be careful with this notation, for two reasons:
    1. It can be hard to unambiguously determine whether something is in the set or not. Is "tangerine" in [math]\{all~colors\} [/math]?
    2. it is unclear whether [math]\{all~colors\} [/math] is the set containing all colors, or the set containing the set of all colors.
  • A much better approach is to describe the set in English: Let [math]C [/math] be the set of all colors. In general, the test of whether you've given a good definition is not the notation you use, but whether the definition is clear and unambiguous. Sometimes notation helps with this, but other times it makes your writing less clear.
  • The symbol [math]\emptyset [/math] (LaTeX \emptyset) stands for the empty set (which contains no elements).