Set Theory & Venn Diagram Calculator
Calculate union, intersection, complement, and Venn diagram regions for 2 or 3 sets using inclusion-exclusion.
As an Amazon Associate and CJ Affiliate publisher we earn from qualifying purchases. Prices and availability may vary.
Set Theory Guide
What's the key thing to understand about Set Operations?
Union (∪): elements in A or B (or both). |A ∪ B| = |A| + |B| − |A ∩ B|. Intersection (∩): elements in both A and B. Complement (A'): elements NOT in A. |A'| = |U| − |A| where U is universal set. Difference (A − B): in A but not in B. |A − B| = |A| − |A ∩ B|. Example: in a class of 30, 18 study Maths (M), 15 study Physics (P), 10 study both. |M ∪ P| = 18 + 15 − 10 = 23 study at least one subject. Neither subject: 30 − 23 = 7.
What do I need to know about Inclusion-Exclusion (3 sets)?
For 3 sets: |A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|. Each pairwise intersection is subtracted (because it was double-counted). The triple intersection is added back (because it was subtracted three times and counted three times — net zero, but should appear once). Example: 100 students, 50 study A, 40 study B, 30 study C, 15 in A∩B, 10 in A∩C, 8 in B∩C, 3 in all three. |A∪B∪C| = 50+40+30 − 15−10−8 + 3 = 90 study at least one. 10 study none. Drawing a 3-set Venn diagram and filling in each region from the innermost overlap outward is the clearest way to verify this calculation and avoid double-counting errors.
What should I know about Probability and Venn Diagrams?
P(A ∪ B) = P(A) + P(B) − P(A ∩ B). For mutually exclusive events (A and B cannot both occur): P(A ∩ B) = 0, so P(A ∪ B) = P(A) + P(B). For independent events: P(A ∩ B) = P(A) × P(B). Example: roll a die. P(even or > 4) = P(even) + P(>4) − P(both) = 3/6 + 2/6 − 1/6 = 4/6 = 2/3. Conditional probability: P(A|B) = P(A ∩ B) / P(B). Read as 'probability of A given B'. Example: P(student plays football | studies maths) = students playing both ÷ students studying maths. Used in medical testing — Bayes'
What's the key thing to understand about Set Theory in Computer Science?
Set theory underlies many computer science concepts. Database queries: SQL JOIN operations are set operations. INNER JOIN = intersection. UNION = set union (removing duplicates). LEFT JOIN = A minus (A ∩ B) plus the matched pairs. Search engines: keyword search uses Boolean set operations. 'A AND B' = intersection. 'A OR B' = union. 'A NOT B' = set difference. Programming: Python and JavaScript have built-in set types with operations including union, intersection, difference, symmetric difference, and complement — these map directly onto database queries and boolean logic in programming.
What's the key thing to understand about De Morgan's Laws for Sets?
De Morgan's Laws for sets mirror the logic versions: (A ∪ B)' = A' ∩ B' and (A ∩ B)' = A' ∪ B', where the prime denotes the complement relative to a universal set U. In words, "not in A or B" is the same as "not in A, and not in B," and "not in both A and B" is the same as "not in A, or not in B." You can verify this with a Venn diagram: shading everything outside A∪B gives the same region as shading outside A and outside B simultaneously. These identities are useful for simplifying set expressions before computing, and they underpin query optimization in databases, where a NOT-OR filter condition can be rewritten as an AND of two NOT conditions (or vice versa) to match how an index is structured.
What's the key thing to understand about Subsets, Power Sets, and Cardinality?
A set A is a subset of B (written A ⊆ B) if every element of A is also in B; it's a proper subset (A ⊂ B) if additionally A ≠ B. The power set of a set with n elements, P(A), is the collection of all possible subsets of A, including the empty set and A itself, and it always contains exactly 2ⁿ subsets — a set of 3 elements has 2³ = 8 subsets. This 2ⁿ relationship comes directly from each element independently being either "in" or "out" of a given subset. Cardinality, written |A|, is simply the count of elements in a set; for finite sets it's a whole number, but the idea extends to comparing the "sizes" of infinite sets too, which is how mathematicians distinguish countable infinities (like the integers) from uncountable ones (like the real numbers).
What should I know about Ordered Pairs and the Cartesian Product?
Most set operations covered so far — union, intersection, complement — produce a new set made up of elements drawn from the original sets, but the Cartesian product builds something structurally different: a set of ordered pairs. The Cartesian product of sets A and B, written A × B, is defined as the set of all ordered pairs (a, b) where a is any element of A and b is any element of B: A × B = {(a,b) : a ∈ A, b ∈ B}. If A = {1, 2} and B = {x, y}, then A × B = {(1,x), (1,y), (2,x), (2,y)}, containing exactly |A| × |B| = 4 pairs — the cardinality of a Cartesian product is always the product of the two sets' cardinalities. Crucially, order matters: (1,x) is a different element from (x,1), and in general A × B is not the same set as B × A unless A and B happen to be identical. The Cartesian product is the formal foundation for defining relations and functions in mathematics: a relation between A and B is simply defined as any subset of A × B, and a function is a special kind of relation where every element of A is paired with exactly one element of B, linking basic set theory directly to the definitions used throughout algebra and calculus.
Worked Example: Analyzing a Student Survey with Set Theory
A school surveys 100 students: 60 study Math, 45 study Physics, and 20 study both. Using the inclusion-exclusion idea, several useful quantities can be found. Number studying at least one subject: |Math ∪ Physics| = |Math| + |Physics| − |Math ∩ Physics| = 60 + 45 − 20 = 85. Number studying only Math (not Physics): 60 − 20 = 40. Number studying only Physics (not Math): 45 − 20 = 25. As a check, only-Math + only-Physics + both = 40 + 25 + 20 = 85, matching the "at least one" total above. Number studying neither subject: 100 − 85 = 15. This same four-region breakdown (only A, only B, both, neither) is exactly what a two-circle Venn diagram displays, and it's the pattern behind almost every "survey of students/customers/voters" word problem that mentions set overlap.
Reference Table: Common Set Theory Symbols
A quick-reference glossary of the notation used throughout set theory problems:
| Symbol | Name | Meaning |
|---|---|---|
| ∪ | Union | elements in A or in B (or both) |
| ∩ | Intersection | elements in both A and B |
| A' (or Aᶜ) | Complement | elements not in A |
| ∅ | Empty set | the set containing no elements |
| ⊆ | Subset | every element of A is also in B |
| × | Cartesian product | the set of all ordered pairs (a, b) |
Mixing up ∪ (union, "or") and ∩ (intersection, "and") is the single most common error students make, and one easy memory aid is that ∪ looks like a cup that can hold everything from both sets ("or"), while ∩ looks like an upside-down cap that only fits where the two sets overlap ("and").
Worked Example: A Three-Set Survey Problem
A survey of 50 people about drink preferences finds: 20 like coffee, 25 like tea, 15 like juice, 10 like both coffee and tea, 8 like both tea and juice, 5 like both coffee and juice, and 3 like all three drinks. Using inclusion-exclusion for three sets: |C ∪ T ∪ J| = |C| + |T| + |J| − |C∩T| − |T∩J| − |C∩J| + |C∩T∩J| = 20 + 25 + 15 − 10 − 8 − 5 + 3 = 40. So 40 of the 50 people surveyed like at least one of the three drinks, meaning 50 − 40 = 10 people like none of them. The final "+3" term is easy to forget — without it, the triple-overlap region would be subtracted out three times (once in each pairwise term) and added back only implicitly, which is exactly the error inclusion-exclusion is designed to correct for.