Sets, functions and relations
Введено
5:38
Дискретная математика
Discrete mathematics is the mathematics of objects you can list: statements, sets, graphs and arrangements. The first three units build the proof engine…
Озвучивание на английском · переключаемые субтитры на английском и китайском языках
В этом уроке
| English | Значение |
|---|---|
| injective/ɪnˈdʒektɪv/ | Инъективное отображение |
| surjective/sɜːˈdʒektɪv/ | Сюръективное отображение |
| set/set/ | множество |
| relation/rɪˈleɪʃn/ | Отношение |
| member/ˈmembə/ | Элемент |
| power set/ˈpaʊə set/ | Мощность множества |
| bijective/baɪˈdʒektɪv/ | Биективное отображение |
| equivalence relation/ɪˈkwɪvələns rɪˈleɪʃn/ | Отношение эквивалентности |
One student ID, one student
- A university gives every student an ID. Two students must never share one, and an ID that belongs to nobody is wasted. Those two demands are exactly "injective" and "surjective 满射".
- Sets, functions and relations are the data model under databases, type systems and graphs. This lesson gives each one a precise test.
Sets and their algebra
- A set 集合 is an unordered collection with no repeats. $A \cup B$ (union), $A \cap B$ (intersection), $A - B$ (difference) and the complement build new sets.
- $x \in A$ means $x$ is a member 元素 of $A$; $B \subseteq A$ means every member of $B$ is in $A$. $\{1\} \subseteq \{1, 2\}$, but $\{1\} \notin \{1, 2\}$.
Union, intersection, difference
Switch between the set operations and watch which region of the diagram each one keeps.
{1} ⊆ {1, 2}, and also {1} ∈ {1, 2}.
Сложность 1/5 · 100 монет + небольшой бонус за первое завершение сегодня
{1} is a subset of {1, 2}, but it is not a member: the members are the numbers 1 and 2.
The power set pairs with bit strings
- The power set 幂集 $\mathcal{P}(A)$ is the set of all subsets of $A$. For $A = \{a, b, c\}$, each element is either in a subset or out: one bit each.
- So subsets match bit strings of length $|A|$ one-to-one, and $|\mathcal{P}(A)| = 2^{|A|}$. Here that is $2^3 = 8$, counting $\varnothing$ and $A$ itself.
How many subsets does a set with 5 elements have?
Сложность 2/5 · 140 монет + небольшой бонус за первое завершение сегодня
Each element is in or out, one bit each, so $2^5 = 32$, counting the empty set and the whole set.
Classify a function by its arrows
- Injective 单射: no two inputs share an output. Surjective 满射: every output is hit. Bijective 双射: both, a perfect pairing that can be reversed.
- On the integers, $f(n) = 2n$ is injective but not surjective (odd numbers are never hit); $h(n) = -n$ is bijective and is its own inverse.

Match each function on the integers to its type.
Сложность 2/5 · 140 монет + небольшой бонус за первое завершение сегодня
Doubling never hits odd numbers; halving down sends 4 and 5 to 2; negation pairs perfectly; squaring sends 2 and −2 to 4 and never hits 3.
Composition reads right to left
- $(g \circ f)(x) = g(f(x))$: apply $f$ first, then $g$. With $f(x) = x + 1$ and $g(x) = 2x$, $(g \circ f)(3) = g(4) = 8$ but $(f \circ g)(3) = f(6) = 7$.
- A bijection between $A$ and $B$ proves $|A| = |B|$ without listing either set 集合. Finding one is a counting proof.
f(x) = x + 1 and g(x) = 2x. What is (g ∘ f)(5)?
Сложность 2/5 · 140 монет + небольшой бонус за первое завершение сегодня
Apply f first: f(5) = 6, then g(6) = 12.
Relations and their four properties
- A relation 关系 on $A$ is a set of ordered pairs. Reflexive: every $(a, a)$ is in it. Symmetric: $(a, b)$ brings $(b, a)$. Transitive: $(a, b)$ and $(b, c)$ bring $(a, c)$.
- Antisymmetric: $(a, b)$ and $(b, a)$ together force $a = b$. An equivalence relation 等价关系 is reflexive, symmetric and transitive; it splits $A$ into classes.
On $\{1, 2, 3\}$, $R = \{(1,1), (2,2), (3,3), (1,2), (2,1)\}$. Reflexive: all three loops. Symmetric: $(1,2)$ and $(2,1)$. Transitive: the only chains are $(1,2),(2,1)$, which need $(1,1)$, and $(2,1),(1,2)$, which need $(2,2)$; both are present. So $R$ is an equivalence relation with classes $\{1, 2\}$ and $\{3\}$.
A relation's matrix equals its own transpose. The relation is —
Сложность 1/5 · 100 монет + небольшой бонус за первое завершение сегодня
Entry (a, b) equals entry (b, a) for every pair, which is exactly symmetry.
Which properties must an equivalence relation have? Select all that apply.
Сложность 2/5 · 140 монет + небольшой бонус за первое завершение сегодня
Reflexive, symmetric and transitive. Antisymmetry belongs to orderings such as ≤.
Worked example: back to the student IDs
- Classify each mapping from the set of enrolled students.
| Mapping | Type, and why |
|---|---|
| student → their ID, onto the issued IDs | bijective: one each, none spare |
| student → their programme | surjective 满射 if every programme has a student; not injective (classmates share) |
| student → their birthday | not injective: two students can share a birthday; in a small class, not surjective either |
- A
UNIQUEconstraint together withNOT NULL(or a primary key) makes the mapping injective: the database refuses a second student with the same ID.
A table has a NOT NULL email column declared UNIQUE, with one row per user. Which property does that force on the mapping user → email?
Сложность 1/5 · 100 монет + небольшой бонус за первое завершение сегодня
UNIQUE means no two users may share an email, which is exactly "no two inputs share an output". It says nothing about every possible email being used.
Marks that slip away
- $\in$ for $\subseteq$. A member 元素 is not a subset: $2 \in \{1, 2\}$ but $\{2\} \subseteq \{1, 2\}$.
- Composition backwards. $g \circ f$ applies $f$ first.
- Checking one pair. Symmetry and transitivity must hold for every pair and every chain.
You've got it
- $|\mathcal{P}(A)| = 2^{|A|}$, because subsets pair with bit strings.
| Type | Means | On the integers |
|---|---|---|
| Injective | no shared outputs | $2n$ (odd numbers missed) |
| Surjective | every output hit | $\lfloor n/2 \rfloor$ (pairs share) |
| Bijective | both, so it inverts | $-n$ |
- $g \circ f$ applies $f$ first; an equivalence relation 等价关系 is reflexive, symmetric and transitive.
Что пошло не так? Это увидит только команда сайта.