What is a set
A set is an unordered collection of distinct elements. It is written with curly braces, for example A = {1, 2, 3}. Sets support the operations of union, intersection, difference, and complement, as well as the Cartesian product.
In plain words:
Union is "gluing" two lists into one: take every element present in at least one of the sets. Duplicate elements are written only once.
Example:
- A (fruits you like) = {apple, banana, kiwi}
- B (fruits for breakfast) = {banana, pear}
- A∪B (all fruits without repeats) = {apple, banana, kiwi, pear}
Main rule:
An element belongs to the union if it is in A OR in B: being in "at least one" of the sets is enough.
In plain words:
Intersection is the "shared zone": only the elements present in both sets at once remain. The easiest way to imagine it is mutual friends of two people.
Example:
- A (students who know Python) = {Masha, Petya, Olya}
- B (students who know English) = {Petya, Olya, Ivan}
- A∩B (know both subjects) = {Petya, Olya}
Main rule:
The intersection is never larger than the original sets: A∩B⊆A and A∩B⊆B. If there are no common elements, then A∩B=∅.
In plain words:
Difference means "cancel what is foreign": we take set A and remove from it everything that is in B. Direction matters: A∖B and B∖A are different sets.
Example:
- A (books on the shelf) = {novel, detective, fairy tale}
- B (books already read) = {detective, poetry}
- A∖B (not yet read) = {novel, fairy tale}
Main rule:
The difference can be written as an intersection with the complement: A∖B=A∩B.
In plain words:
The complement is "everything else". We take the overall list (U) and simply cross out the elements of set A.
Example:
- U (all days of the week) = {Mon, Tue, Wed, Thu, Fri, Sat, Sun}
- A (weekend) = {Sat, Sun}
- A (complement — workdays) = {Mon, Tue, Wed, Thu, Fri}
Main rule:
A and A together always make up the whole universe but never intersect: A∪A=U and A∩A=∅.
In plain words:
Counting unique members: add the sizes of the two groups and subtract once those who are in both, so no one is counted twice.
Example:
- ∣A∣ (know Python) = 10 students
- ∣B∣ (know English) = 8 students
- ∣A∩B∣ (know both) = 3 students
- ∣A∪B∣=10+8−3=15 unique students
Main rule:
Common elements are subtracted exactly once. If A∩B=∅, then ∣A∪B∣=∣A∣+∣B∣.
In plain words:
The Cartesian product is "each with each": from every element of the first set and every element of the second set we build all possible pairs. The first coordinate always comes from A, the second from B.
Example:
- A (t-shirt sizes) = {S, M}
- B (colors) = {black, white}
- A×B (all options) = {(S, black), (S, white), (M, black), (M, white)}
Main rule:
Order in a pair matters: (a,b) and (b,a) are different pairs. That is why there are exactly ∣A∣⋅∣B∣ pairs.
In plain words:
The power set is a "catalog of all subsets": every combination you can make from a set's elements, including the empty set and the set itself.
Example:
- A (files to send) = {report, budget}
- Subsets: ∅, {report}, {budget}, {report, budget}
- ∣P(A)∣=22=4 ways to choose what to send
Main rule:
Each element gets a choice "take it or not" — two options. Hence the power of two: 2n subsets for n elements.
In plain words:
"Not (this and that)" means "not this OR not that". If an element is not in both sets at once, then it is missing from at least one of them.
Example:
- A (swimming pool pass) = {Masha, Petya}
- B (gym pass) = {Petya, Olya}
- A∩B (don't have both) = {Masha, Olya, Ivan}
- A∪B (missing at least one) = {Olya, Ivan, Masha} — the same list
Main rule:
Negation "flips" the sign: AND becomes OR — A∩B=A∪B.
In plain words:
"Not (this or that)" means "neither this nor that". An element is not in the union only if it is in neither set.
Example:
- U (all guests at the party) = {Anna, Borya, Vera, Gosha}
- A (drink coffee) = {Anna, Borya}
- B (drink tea) = {Borya, Vera}
- A∪B = A∩B = {Gosha}
Main rule:
Negating a union "turns" OR into AND: A∪B=A∩B.