Mat. DiscretaSets and Functions

Set Operations

Union, intersection, difference and complement, pictured with Venn diagrams, with De Morgan's laws for sets.

Sin empezar Ir a la práctica

Esta lección aún no está traducida. Por ahora se muestra en inglés; la versión en español está en camino.

In probability you combined events with "or," "and" and "not." Events are sets of outcomes, so those were set operations all along. Here they get their general names and notation, building on sets and subsets.

Idea clave

For sets inside a universe $U$: the union $A \cup B$ is everything in $A$ or $B$ (or both); the intersection $A \cap B$ is everything in both; the difference $A \setminus B$ is what is in $A$ but not $B$; the complement $A^{c} = U \setminus A$ is everything in $U$ not in $A$. De Morgan's laws hold for sets: $(A \cup B)^{c} = A^{c} \cap B^{c}$ and $(A \cap B)^{c} = A^{c} \cup B^{c}$.

Por qué funciona

Each operation is a logical connective applied to membership. $x \in A \cup B$ means $x \in A \vee x \in B$; $x \in A \cap B$ means $x \in A \wedge x \in B$; $x \in A^{c}$ means $\neg(x \in A)$. So every logical equivalence becomes a set identity. De Morgan's laws for sets are the same laws you proved with truth tables, with "or" and "and" replaced by $\cup$ and $\cap$. (Probability books often write $A'$ for the complement; it means the same as $A^{c}$.)
Tap regions, or pick an event. Compare $(A \cap B)'$ with $A' \cap B'$: they are different regions. (This visual writes the complement as $A'$.)

Worked examples

Ejemplo resuelto: Computing with a universe

Let $U = \{1, 2, \ldots, 10\}$, $A = \{2, 4, 6, 8, 10\}$ (the even numbers) and $B = \{3, 6, 9\}$ (the multiples of $3$). Find $A \cup B$, $A \cap B$, $A \setminus B$, $A^{c}$ and $(A \cup B)^{c}$.
  1. $A \cup B = \{2, 3, 4, 6, 8, 9, 10\}$ (each element once).
  2. $A \cap B = \{6\}$, and $A \setminus B = \{2, 4, 8, 10\}$.
  3. $A^{c} = \{1, 3, 5, 7, 9\}$, the odd numbers.
  4. $(A \cup B)^{c} = \{1, 5, 7\}$: in neither set. Check De Morgan: $$A^{c} \cap B^{c} = \{1, 3, 5, 7, 9\} \cap \{1, 2, 4, 5, 7, 8, 10\} = \{1, 5, 7\}.$$

Respuesta: $\{2, 3, 4, 6, 8, 9, 10\}$, $\{6\}$, $\{2, 4, 8, 10\}$, $\{1, 3, 5, 7, 9\}$, $\{1, 5, 7\}$

Ejemplo resuelto: Sizes with De Morgan

In a universe of $40$ people, $|A| = 18$, $|B| = 15$ and $|A \cap B| = 6$. How many people are in $A^{c} \cup B^{c}$?
  1. De Morgan: $A^{c} \cup B^{c} = (A \cap B)^{c}$.
  2. So the count is everyone except the $6$ people in both: $40 - 6 = 34$.

Respuesta: $34$

Error común

Complementing each piece without switching the operation. $(A \cap B)^{c}$ is not $A^{c} \cap B^{c}$. To be outside "both $A$ and $B$," you only need to miss one of them, so $(A \cap B)^{c} = A^{c} \cup B^{c}$. Check with one element: in the example above, $3$ is in $(A \cap B)^{c}$ (it is not in both), but $3$ is not in $A^{c} \cap B^{c}$ (it is in $B$).

Práctica

Apruebas con 3 respuestas correctas, las 2 últimas seguidas. Cada respuesta correcta da 1 XP.

Cargando la práctica…

Se apoya en

Lleva a

Fuentes y lecturas

  • Oscar Levin, Discrete Mathematics: An Open Introduction (3rd ed.), section "Sets" (operations on sets, Venn diagrams)
  • MIT OpenCourseWare 6.042J Mathematics for Computer Science (Lehman, Leighton and Meyer), chapter "Mathematical Data Types" (set operations)