DEV Community

Cover image for About Sets
Kenta Takeuchi
Kenta Takeuchi

Posted on • Originally published at bmf-tech.com

About Sets

This article was originally published on bmf-tech.com.

Overview

Summarizing the basics of sets.

What is a Set

In set theory, a set is a collection of elements that satisfy specific conditions.

The elements contained in a set are referred to as members (in this article, they are referred to as elements).

Software Engineers and Sets

For software engineers, sets are a fundamental concept in data structures and algorithms. Concepts of sets are related to arrays, maps, graph theory, combinatorial theory, and more.

In RDB, set theory is a very important concept, and relations, tuples, and SQL can be considered as sets themselves.

cf. bmf-tech.com - Practical Database Introduction from Theory ~ Efficient SQL with Relational Model

Set theory is also related to logic, and sets are sometimes used as expressions of logic.

Additionally, it is useful for organizing abstract thoughts about problems, thus relating to foundational skills for problem-solving.

Sets are a fundamental concept in software engineering, allowing optimal handling of data structures and algorithms. By utilizing them as an element for problem-solving, one can also develop problem-solving skills.

Basic Sets

a ∈ A

a is an element of set A.

A = {a, b, c, ...}
a ∈ A
Enter fullscreen mode Exit fullscreen mode

a ∈ A

a ∉ A

a is not an element of set A.

A = {a, b, , ...}
a ∉ A
Enter fullscreen mode Exit fullscreen mode

a ∉ A

A ⊂ B

Set A is a subset of set B. A = B is also applicable.

A = {1, 2, 3}
B = {1, 2, 3, 4, 5}
A ⊂ B
Enter fullscreen mode Exit fullscreen mode

A ⊂ B

A ⊃ B

Set B is a subset of set A. Equivalent to B ⊂ A.

A = {1, 2, 3, 4, 5}
B = {2, 3}
A ⊃ B
Enter fullscreen mode Exit fullscreen mode

A ⊃ B

φ (Empty Set)

A set with no elements.

φ = {}
Enter fullscreen mode Exit fullscreen mode

φ (Empty Set)

A ∪ B (Union Set)

A set that combines sets A and B. Elements belong to either set A or set B, or both. (≒ Belong to at least one of the sets.)

A = {1, 2, 3}
B = {3, 4, 5}
A ∪ B = {1, 2, 3, 4, 5}
Enter fullscreen mode Exit fullscreen mode

A ∪ B (Union Set)

A ∩ B (Intersection Set)

The common set of sets A and B. Elements belong to both set A and set B.

A = {1, 2, 3}
B = {3, 4, 5}
A ∩ B = {3}
Enter fullscreen mode Exit fullscreen mode

A ∩ B (Intersection Set)

A × B (Cartesian Product)

Pairs formed by taking one element each from sets A and B.

A = {1, 2}
B = {x, y}
A × B = {(1, x), (1, y), (2, x), (2, y)}
Enter fullscreen mode Exit fullscreen mode

A \ B (Difference Set)

A set obtained by removing elements belonging to set B from set A.

A = {1, 2, 3, 4}
B = {3, 4, 5}
A \ B = {1, 2}
Enter fullscreen mode Exit fullscreen mode

A \ B (Difference Set)

Complement Set

As a symbol, when a set is A, a bar is placed above A.

When set A is a subset of the universal set U, the set obtained by removing set A from the universal set U.

U = {1, 2, 3, 4, 5}  # Universal set
A = {1, 2, 3}
A' = {4, 5}
Enter fullscreen mode Exit fullscreen mode

Complement Set

References

Top comments (0)