集合と写像の基本
informationdiscrete-mathundergraduatelecture
1導入
この講義では、集合の基本演算と写像の性質を定義し、アルゴリズムの入出力やグラフの頂点集合を記述するための基礎を構成する。
2集合と包含
集合とは、対象を要素としてまとめたものである。x が集合 A の要素であることを x\in A、要素でないことを x\notin A と記す。要素を一つも持たない集合を空集合といい、\varnothing と記す。
任意の x について x\in A ならば x\in B であるとき、A は B の部分集合であるといい、A\subseteq B と記す。A\subseteq B かつ B\subseteq A であることと A=B であることは同値である。
3集合演算
集合 A,B に対して、和集合、共通部分、差集合を
A\cup B=\{x\mid x\in A\text{ または }x\in B\},
A\cap B=\{x\mid x\in A\text{ かつ }x\in B\},
\qquad
A\setminus B=\{x\mid x\in A\text{ かつ }x\notin B\}
と定義する。補集合には、考察対象を含む全体集合 U の指定が必要である。A\subseteq U の補集合は
A^{\mathsf c}=U\setminus A
である。したがって、全体集合を変更すれば補集合も変化する。
集合 A,B の直積は、順序対の集合
A\times B=\{(a,b)\mid a\in A,\ b\in B\}
である。一般には (a,b)\ne(b,a) であり、順序を区別する。
4関係
集合 A,B の二項関係 R とは、直積の部分集合 R\subseteq A\times B である。(a,b)\in R のとき、a と b の間に関係 R が成立するといい、aRb とも記す。A=B の場合は、A 上の関係という。
有向グラフの辺集合 E\subseteq V\times V は、頂点集合 V 上の二項関係である。無向グラフでは端点の順序を区別せず、二要素部分集合 {\{u,v\}} を辺として使用する。この相違は、後続するグラフの講義で厳密に定義する。
5写像
集合 A,B に対して、写像 f:A\to B とは、A の各要素 a に B の要素をただ一つ対応させる規則である。A を定義域、B を終域といい、a に対応する要素を f(a) と記す。定義域の全要素に値が指定され、しかも各要素の値が一意であることが必要である。
部分集合 S\subseteq A の像と、T\subseteq B の逆像を
f(S)=\{f(a)\mid a\in S\},
\qquad
f^{-1}(T)=\{a\in A\mid f(a)\in T\}
と定義する。特に f(A) を f の像という。f(A)\subseteq B であり、像と終域は必ずしも一致しない。また、f^{-1}(T) という記法は、f が逆写像を持たない場合にも使用できる。
6単射・全射・全単射
写像 f:A\to B が単射であるとは、
f(a_1)=f(a_2)\Longrightarrow a_1=a_2
がすべての a_1,a_2\in A について成立することである。すなわち、異なる入力は異なる出力を持つ。
f が全射であるとは、すべての b\in B に対して f(a)=b となる a\in A が存在することである。これは f(A)=B と同値である。単射かつ全射である写像を全単射という。全単射に限り、各 b\in B をその唯一の原像へ対応させる逆写像 f^{-1}:B\to A が存在する。
7例
A=\{1,2,3\}、B=\{a,b,c,d\} とし、
f(1)=a,\qquad f(2)=b,\qquad f(3)=b
とする。このとき f(A)=\{a,b\} であり、f^{-1}(\{b,c\})=\{2,3\} である。f(2)=f(3) なので f は単射でなく、c,d が像に含まれないので全射でもない。
8情報科学への接続
長さ n の配列は、添字集合 \{0,1,\ldots,n-1\} から値の終域への写像として表現できる。各入力に出力が一意に定まる決定的なアルゴリズムは、許容入力集合から出力集合への写像として仕様化できる。複数の正解を許容する問題の出力仕様は、入力と許容出力の関係として表現できる。一方、グラフ G=(V,E) は、頂点集合 V と、直積または V の二要素部分集合からなる辺集合 E によって記述される。
data/lecture/information/algorithm/algorithms-portal.lecture.n.md
data/lecture/information/graph/graph-basics.lecture.n.md
9まとめ
- 集合は要素の所属によって定まり、A\subseteq B は任意の x について x\in A\Rightarrow x\in B が成立することを意味する。
- 補集合の定義には全体集合が必要であり、直積では順序を区別する。
- 写像は定義域の各要素に終域の要素を一意に対応させる。
- 単射では異なる入力が異なる出力に対応し、全射では終域の全要素が像に含まれ、全単射では一対一対応が成立する。
Sets and Maps
1Introduction
This lecture defines the basic operations on sets and the principal properties of maps. These concepts provide the language for specifying algorithmic input and output and for defining the vertex set of a graph.
2Sets and inclusion
A set is a collection of objects called its elements. The notation x\in A states that x is an element of A, whereas x\notin A states that it is not. The empty set, denoted by \varnothing, has no elements.
A set A is a subset of a set B, written A\subseteq B, if x\in A implies x\in B for every x. The conjunction of A\subseteq B and B\subseteq A is equivalent to A=B.
3Operations on sets
For sets A and B, their union, intersection, and difference are defined by
A\cup B=\{x\mid x\in A\text{ or }x\in B\},
A\cap B=\{x\mid x\in A\text{ and }x\in B\},
\qquad
A\setminus B=\{x\mid x\in A\text{ and }x\notin B\}.
A complement requires a specified universal set U containing the objects under consideration. For A\subseteq U, the complement of A is
A^{\mathsf c}=U\setminus A.
Changing the universal set can therefore change the complement.
The Cartesian product of sets A and B is the set of ordered pairs
A\times B=\{(a,b)\mid a\in A,\ b\in B\}.
Order matters: in general, (a,b)\ne(b,a).
4Relations
A binary relation R from a set A to a set B is a subset R\subseteq A\times B of their Cartesian product. If (a,b)\in R, we say that a is related to b by R and may write aRb. When A=B, this is called a relation on A.
The edge set E\subseteq V\times V of a directed graph is a binary relation on its vertex set V. In an undirected graph, the order of endpoints is ignored, and a two-element subset {\{u,v\}} is used as an edge. The following graph lecture defines this distinction precisely.
5Maps
For sets A and B, a map f:A\to B is a rule that assigns exactly one element of B to every element a of A. The set A is the domain, the set B is the codomain, and the assigned element is denoted by f(a). Thus every domain element must receive a value, and that value must be unique.
For S\subseteq A and T\subseteq B, the image of S and the preimage of T are
f(S)=\{f(a)\mid a\in S\},
\qquad
f^{-1}(T)=\{a\in A\mid f(a)\in T\}.
In particular, f(A) is the image of the map. Although f(A)\subseteq B, the image need not equal the codomain. The notation f^{-1}(T) for a preimage remains valid even when f has no inverse map.
6Injective, surjective, and bijective maps
A map f:A\to B is injective if
f(a_1)=f(a_2)\Longrightarrow a_1=a_2
for all a_1,a_2\in A. Equivalently, distinct inputs have distinct outputs.
The map is surjective if, for every b\in B, there exists a\in A such that f(a)=b. This condition is equivalent to f(A)=B. A map that is both injective and surjective is bijective. Exactly for a bijection, there is an inverse map f^{-1}:B\to A that assigns each b\in B its unique preimage.
7Example
Let A=\{1,2,3\} and B=\{a,b,c,d\}, and define
f(1)=a,\qquad f(2)=b,\qquad f(3)=b.
Then f(A)=\{a,b\} and f^{-1}(\{b,c\})=\{2,3\}. Because f(2)=f(3), the map is not injective. Because c and d do not belong to its image, it is not surjective either.
8Connections to computer science
An array of length n can be represented as a map from the index set \{0,1,\ldots,n-1\} to a codomain of values. A deterministic algorithm whose output is uniquely determined for every input can be specified as a map from its set of admissible inputs to its set of outputs. When a problem permits more than one correct output, its output specification can instead be represented as a relation between inputs and admissible outputs. A graph G=(V,E) is described by a vertex set V and an edge set E whose elements are ordered pairs in a Cartesian product or two-element subsets of V.
data/lecture/information/algorithm/algorithms-portal.lecture.n.md
data/lecture/information/graph/graph-basics.lecture.n.md
9Summary
- A set is determined by element membership, and A\subseteq B means that x\in A\Rightarrow x\in B holds for every x.
- A complement requires a universal set, while a Cartesian product distinguishes the order of its coordinates.
- A map assigns exactly one codomain element to every domain element.
- Under an injective map, distinct inputs have distinct outputs; under a surjective map, every codomain element lies in the image; and a bijection gives a one-to-one correspondence.