Operations on Sets — Exercises

énoncés

By Pr. El Hadiq Zouhair

Contents

  1. Basic union, intersection, difference easy
  2. N-ary operations easy
  3. Complement with a universe easy
  4. Operator precedence medium
  5. Venn regions (3 sets) medium
  6. Inclusion–Exclusion medium
  7. De Morgan by brute force medium
  8. Distributivity check medium
  9. Membership table medium
  10. Simplify with SymPy hard
  11. Symmetric difference identities hard
  12. Word problem — Venn 3 sets hard

1Basic union, intersection, difference easy

Let $A = \{2, 4, 6, 8\}$ and $B = \{1, 2, 3, 4, 5\}$. Compute: $A \cup B$, $A \cap B$, $A \setminus B$, $B \setminus A$.

Your answer…

2N-ary operations easy

Given the family of sets L = [{1,2,3}, {2,3,4}, {3,4,5}, {3,5,7}], compute:

Your answer…

3Complement with a universe easy

With universe $U = \{1, 2, \dots, 10\}$ and $A = \{1, 3, 5, 7, 9\}$ (odd numbers), compute $A'$. Then verify $A \cup A' = U$ and $A \cap A' = \varnothing$.

Your answer…

4Operator precedence medium

Complement > Intersection > Union. With $U = \{1..10\}$, $A = \{1,2,3\}$, $B = \{2,3,4\}$, $C = \{3,4,5\}$, evaluate by hand, then in Python:

  1. $A \cup B \cap C$  (meaning $A \cup (B \cap C)$)
  2. $(A \cup B) \cap C$
  3. $A' \cap B \cup C$  (meaning $(A' \cap B) \cup C$)
Your answer…

5The 8 regions of a 3-set Venn medium

With $A = \{1..7\}$, $B = \{3..9\}$, $C = \{5..11\}$, write a function that returns the contents of each of the 8 regions of the Venn diagram of $A, B, C$. Which regions are empty?

Your answer…

6Inclusion–Exclusion (2 sets) medium

Pick any $A, B \subseteq \{1, \dots, 20\}$ randomly and verify $|A \cup B| = |A| + |B| - |A \cap B|$ holds on 1000 random pairs.

Your answer…

7De Morgan by brute force medium

For $U = \{1, 2, 3, 4\}$, check $(A \cup B)' = A' \cap B'$ for every pair of subsets of $U$ (there are $2^4 \times 2^4 = 256$ pairs).

Your answer…

8Distributivity check medium

Prove (by exhaustive check on $U = \{1, 2, 3\}$) that $A \cap (B \cup C) = (A \cap B) \cup (A \cap C)$ for all $A, B, C \subseteq U$.

Your answer…

9Membership table medium

Print the full membership (truth) table for $(A \cup B)'$ and $A' \cap B'$ and show they are equal.

Your answer…

10Simplify with SymPy hard

Using SymPy's simplify (boolean), show that $A \cup (A \cap B) \equiv A$ (absorption).

Then show $(A \cap B) \cup (A \cap B') \equiv A$ (a useful "splitting" identity).

Your answer…

11Symmetric difference identities hard

Show, by brute force on $U = \{1, 2, 3, 4\}$, that:

  1. $A \,\triangle\, B = (A \cup B) \setminus (A \cap B)$
  2. $A \,\triangle\, A = \varnothing$
  3. $A \,\triangle\, B \,\triangle\, C$ is associative
Your answer…

12Word problem — 3-set Venn hard

A survey of 200 people about three streaming services (N, P, D) reports:

How many use:

  1. at least one service?
  2. exactly one service?
  3. exactly two services?
  4. none?
Your answer…

Going further

Open the main lesson for the matching theory.