All Tools

Set Theory Visualizer

Enter elements for each set and instantly see the result highlighted on an interactive Venn diagram. Explore union, intersection, complement, difference, symmetric difference, power set, and Cartesian product for 2 or 3 sets.

Set Inputs

Venn Diagram

UAB1, 23, 45, 6(2)(2)(2)
Set ASet BHighlighted region

Result

A ∪ B
{ 1, 2, 3, 4, 5, 6 }
Cardinality: 6

Set Properties

|A|4
|B|4
|U|10
|A \u2229 B|2

A \u2286 Bno
B \u2286 Ano
A = Bno
A \u2229 B = \u2205not disjoint

Reference Guide

Set Operations

A set is a well-defined collection of distinct objects called elements. The notation xAx \in A means x is an element of A; xAx \notin A means it is not.

AB={xxA or xB}A \cup B = \{x \mid x \in A \text{ or } x \in B\}
AB={xxA and xB}A \cap B = \{x \mid x \in A \text{ and } x \in B\}
AB={xxA and xB}A \setminus B = \{x \mid x \in A \text{ and } x \notin B\}
AB=(AB)(BA)A \triangle B = (A \setminus B) \cup (B \setminus A)

The symmetric difference contains elements in exactly one of the two sets. Two sets are disjoint when AB=A \cap B = \emptyset.

Venn Diagrams

A Venn diagram shows all possible logical relations between a finite collection of sets. Each circle represents a set; overlapping regions show shared elements.

For two sets A and B, there are four regions: only in A, only in B, in both (the intersection), and in neither (outside both, inside U). For three sets there are eight regions.

The complement A=UAA' = U \setminus A contains everything in the universal set U that is not in A. In a Venn diagram it is the area outside circle A but inside the rectangle for U.

The power set P(A)\mathcal{P}(A) is the set of all subsets of A. If A=n|A| = n, then P(A)=2n|\mathcal{P}(A)| = 2^n. For A = {1, 2}, the power set has 4 elements: ,{1},{2},{1,2}\emptyset, \{1\}, \{2\}, \{1,2\}.

De Morgan's Laws

De Morgan's laws relate complements of unions and intersections. They are among the most useful identities in set theory and logic.

(AB)=AB(A \cup B)' = A' \cap B'
(AB)=AB(A \cap B)' = A' \cup B'

The first law says: everything outside the union is outside both sets. The second says: everything outside the intersection is outside at least one set.

These laws extend to any finite collection of sets and are the foundation of Boolean algebra and digital logic design (NOT(A OR B) = (NOT A) AND (NOT B)).

Inclusion-Exclusion Principle

The inclusion-exclusion principle counts elements in a union without double-counting those in intersections.

AB=A+BAB|A \cup B| = |A| + |B| - |A \cap B|

For three sets, each pairwise intersection is subtracted once, but the triple intersection was subtracted three times, so it must be added back once.

ABC=A+B+CABACBC+ABC|A \cup B \cup C| = |A|+|B|+|C| - |A\cap B| - |A\cap C| - |B\cap C| + |A\cap B\cap C|

The Cartesian product A×BA \times B is the set of all ordered pairs with the first from A and the second from B. Its cardinality is AB|A| \cdot |B|.