Sets and logic

Sets collect objects together. Logic makes precise what “and”, “or”, “not” and “if … then” mean. Together they are the grammar of mathematics. They also power database searches and computer circuits.

Key facts

  • A ∪ B (union): in A or B or both. A ∩ B (intersection): in both. A′ (complement): not in A. ∅ is the empty set.
  • n(A ∪ B) = n(A) + n(B) − n(A ∩ B). For three sets: add the singles, subtract the pairs, add back the triple.
  • A set with n elements has 2ⁿ subsets, and n(A × B) = n(A) × n(B).
  • ¬ means not, ∧ means and, ∨ means or, and ⇔ means if and only if. ⇒ means implies: it is false only when a true statement implies a false one.
  • De Morgan’s laws: ¬(P ∧ Q) ≡ ¬P ∨ ¬Q and ¬(P ∨ Q) ≡ ¬P ∧ ¬Q.
  • P ⇒ Q is equivalent to its contrapositive ¬Q ⇒ ¬P, but not to its converse Q ⇒ P.

Worked examples

Example 1

In a class of 30, 18 play football, 12 play tennis and 5 play both. How many play neither?

  1. Number playing at least one: 18 + 12 − 5 = 25
  2. Neither: 30 − 25 = 5

Answer: 5

Example 2

Show that P ⇒ Q has the same truth table as ¬P ∨ Q.

  1. Rows (P, Q): (T, T), (T, F), (F, T), (F, F).
  2. P ⇒ Q gives T, F, T, T.
  3. ¬P ∨ Q gives T, F, T, T. The columns match, so the statements are equivalent.

Answer: Both are false only when P is true and Q is false

Example 3

How many integers from 1 to 100 are divisible by 3 or 5?

  1. Multiples of 3: 33. Multiples of 5: 20.
  2. Numbers divisible by both are multiples of 15: there are 6.
  3. Total: 33 + 20 − 6 = 47

Answer: 47

Example 4

A = {1, 2, 3, 4} and B = {3, 4, 5}. Find A ∩ B and A ∪ B.

  1. The intersection holds the elements in both sets. A ∩ B = {3, 4}
  2. The union holds the elements in either set. A ∪ B = {1, 2, 3, 4, 5}

Answer: A ∩ B = {3, 4}, A ∪ B = {1, 2, 3, 4, 5}

Example 5

How many subsets does the set {a, b, c} have?

  1. Each element is either in a subset or not.
  2. Multiply the choices. 2 × 2 × 2 = 8

Answer: 8