讀書筆記: 範疇論

讀書筆記: 範疇論

基本概念

範疇論

  • 數學構造(Mathematical structure)
    在數學上,在集合上的一個構造是一個附加的數學對象,賦予這個集合某種意義。

  • 範疇論(category theory)
    範疇論的目的是:規範化數學構造。
    方法爲:使用帶標籤的有向圖。
    研究內容:各種數學結構之間的關係。

範疇(category)

一個範疇是一個帶標籤的有向圖,其節點爲對象(object),帶有標籤的有向邊爲箭頭(arrow or morphism)。

一個範疇C包含3個數學實體:

  • 對象集合:ob(C)
    每個元素都是一個對象,一個對象又可以認爲是一個集合。

  • 態射集合: hom(C)
    態射集合的每個元素是一個態射, \(f: a \to b\),每個態射f有一個源對象(source object) a和目標對象(target object)b。
    \(hom(a, b)\)表示從a到b的所有態射。

  • 性質:二元操作:態射結合(composition of morphisms): \(\circ\)
    \(f: a \to b, g: b \to c\) 的結合是 \(g \circ f\)。具有
    • 滿足結合律(Associativity): $ h \circ ( g \circ f ) = ( h \circ g ) \circ f $
    • 存在恆等態射(identity):
      對於每個對象x,存在一個恆等態射(identity morphism) \(1_x: x \to x\)
      其性質爲,對於任何態射\(f: a \to b\),有\(1_b \circ f = f = f \circ 1_a\)
      恆等態射的含義是:定義了相同關係(equality relation A = B)。
      可以簡單的認爲是;\(f(x) = x\)

態射(morphism)

態射可以理解爲一個函數,在範疇論中,往往表示爲一個對象和另一個對象的map關係。
態射作爲函數理解的時候,不用糾結於參數的個數。

態射的種類(\(f: a \to b\)):

  • 單態射(monomorphism or monic)
    如果\(f \circ g_1 = f \circ g_2 \implies g_1 = g_2, \forall g_1, g_2: x \to a\)
    其含義是:不存在兩個a中元素 map 到同一個b中的元素。
    \(\forall a_1, a_2 \in A, a_1 \neq a_2 \implies f(a_1) \neq f(a_2)\)

  • 滿態射(epimorphism or epic)
    如果\(g_1 \circ f = g_2 \circ f \implies g_1 = g_2, \forall g_1, g_2: b \to x\)
    其含義是:每一個b中的元素,都在a中有至少一個 source mapper。

  • 雙態射(bimorphism)
    即是單態射,有時滿態射。

  • 同構(isomorphism)
    如果存在一個同構\(g:b \to a\),有\(f \circ g = 1_b, g \circ f = 1_a\)
    其含義是:a,b兩個對象的元素存在一對一的 map 關係。
    同構 = 雙態射 + 存在逆態射。
    g稱爲逆態射,也是一個同構,g 的逆態射是 f。
    比如:f是加法,g是減法。

  • 自態射(endomorphism)
    表示一個態射源對象和目標對象是同一個, \(f: a \to a\)。記爲:end(a)。

  • 自同構(automorphism)
    如果f既是一種自態射,又是具有同構性。記爲:aut(a)。

  • 撤回射(retraction)
    如果存在一個f的右逆,也就是說,如果存在: $g : b \to a, f \circ g = 1_b。
    f 是另一個態射g的撤回射,其含義是:g 可以通過f找到 source element。f必定是一個滿態射(epimorphism)。

  • 部分射(section)
    如果f的左逆是存在的,也就是說,如果存在: $g : b \to a, g \circ f = 1_a。
    f 是另一個態射g的部分射,其含義是:f 確定了g的同構部分。f必定是一個單態射(monomorphism)。
    是不是可以理解爲f的g應用的一個條件???

  • 同態(homomorphism)
    同態(homomorphism)是一個態射,表示一個數學結構\mathcal{A}(C, , e)到另一個數學結構\mathcal{B}(C', ', e')的map關係,並且維持了數學結構上的的每一種操作*。
    同態(homomorphism) \(f: \mathcal{A} \to \mathcal{B}\),有:
    \(f(x * y) = f(x) *' f(y)\)

    同一種操作在不同的數學結構上定義可以不同。
    比如:指數函數是一個同態。

\[ f : \mathbb{R} \to \mathbb{R} \\ f(x) = e^x \\ e^{x + y} = e^x e^y \to f(x * y) = f(x) * f(y) \\ where \\ f \text{ exponential function is a homomorphism} \\ \text{the source is A} = \mathbb{R} \\ \text{the target is B} = \mathbb{R} \\ * = + \text{ in A} \\ * = \times \text{ in B} \]

  • 域(domain)/協域(codomain)
    對於一個態射(morphism) \(f : S \to T\)。 域(domain)是這個態射的源,協域(codomain)是這個態射目標。

  • 範疇的表達
    1. 表達1

\[ C = (Ob(C), Hom_C(x,y), id_x, \circ) \\ where \\ Ob(C) \in Set_{object} \\ Hom_C(x, y) \in Set_{morphism} \ | \ x, y \in Ob(C) \\ id_x \in Hom_C(x, x) \text{ : identity morphism of x} \\ \circ : Hom_C(y, z) \times Hom_C(x, y) \to Hom_C(x, z) \text{ : composition formula} \\ \text{Identity Law:} \\ \forall x, y \in Ob(C), f: x \to y \\ f \circ id_x = f \\ id_y \circ f= f \\ \text{Associative Law:} \\ \forall w, x, y, z \in Ob(C), h: w \to x, g: x \to y, f: y \to z \\ (h \circ g) \circ f = h \circ ( g \circ f) \in Hom_C(w, z) \]

函子(functor)

函子是範疇之間的map關係。可以理解爲範疇之間的態射。

  • 協變(covariant)函子
    \(F: C \to D\), F包含:
    • 對於每一個 C 中的對象x,對應一個 D 中的F(x)。
    • 對於每一個C中的態射\(f: x \to y\),對應D的態射\(F(f): F(x) \to F(y)\)
  • 逆變(contravariant)函子
    和協變函子類似,只不過態射的方向是從D到C。

自然轉換(Natural transformation)

自然轉換是兩個函子之間的關係。函子描述“自然構造(natural constructions)”,自然轉換描述兩個這樣構造的"自然同態(natural homomorphisms)"。
homomorphism的意思是相同的形狀。

其它

  • 本體(olog)
  • 交換圖(commutative diagram)
  • 通用性質(universal property)
    如果,兩個數學結構是同構(isomorphism),那麼它們之間就存在通用性質。
    同構意味着兩個數學結構X和Y中的元素是存在一一對應。
    那麼,Y上的性質(態射)意味着X上存在一個對應的性質(態射)。比如:
    X = {A, B, C}
    Y = {1, 2, 3}
    A --> 1
    B --> 2
    C --> 3
    如果+(1, 2) = 3,我們也可以認爲存在 +(A, B) = C。起點性質。
    如果+(1, 2),我們也可以認爲存在 +(C) = (A, B)。起點性質。
    通用性質(universal property)要麼是一個起點性質(initial property),要麼是一個終點性質(terminal property)。

    • 起點性質(initial property)
      唯一存在
      \[ U: D \to C \\ D \{ A, Y \} \\ C \{ X, U(A), U(Y), \phi: X \to U(A) \} \\ \therefore \\ \text{initial property:} \\ \forall f: X \to U(Y) \\ \exists g, g: A \to Y \\ \exists U(g), g: U(A) \to U(Y) \\ \]
    • 終點性質(terminal property)
      唯一存在
      \[ U: D \to C \\ D \{ A, Y \} \\ C \{ X, U(A), U(Y), \phi: U(A) \to X \} \\ \therefore \\ \text{terminal property:} \\ \forall f: U(Y) \to X \\ \exists g, g: Y \to A \\ \exists U(g), g: U(Y) \to U(A) \\ \]
    • 起點性質示例
      \[ X = (L : (a,b,c), A:L \times L, B: L) \\ Y = (N : (1,2,3), A_y:N \times N, B_y: N, C_y: A_y) \\ \phi: C_y \to A_y = c \\ \text{e.g. } (1, 2) = (1, 2) \\ f: C_y \to B_y = c_1 + c_2 \\ \text{e.g. } 1 + 2 = 3 \\ \therefore \\ \exists g: A \to B \\ \text{e.g. } a + b = c \]
    • 終點性質示例
      \[ X = (L : (a,b,c), A:L \times L, B: L) \\ Y = (N : (1,2,3), A_y:N \times N, B_y: N, C_y: B_y) \\ \phi: A_y \to C_y = a_1 + a_2 \\ \text{e.g. } 1 + 2 = 3 \\ f: B_y \to C_y = b \\ \text{e.g. } 3 = 3 \\ \therefore \\ \exists g: B \to A \\ \text{e.g. } c = a + b \]
  • 拉回(pullback)
  • 推出(pushout)
  • limit/colimit

關係

  • 二元關係(binary relation)
    一個基於集合X的二元關係,是一個\(R \subseteq X \times X\)的子集。

  • 等價關係(equivalence relations)
    一個集合X上的等價關係\(\sim\),是一個\(R \subseteq X \times X\)的子集,具有
    • 自反性(Reflexivity)
      \((x, x) \in R\)
    • 對稱性(Symmetry)
      $(x, y) \in R \text{, iff } \((y, x) \in R\)$
    • 傳遞性(Transitivity)
      $\text{if } (x, y) \in R, (y, z) \in R \text{, then } \((x, z) \in R\)$

幺半羣(monoid)

幺半羣可以代表一個序列或者列表。

  • 幺半羣(monoid)
    一個幺半羣是一個序列(sequence)\((M, e, \star)\)。M是一個集合,
    \(e \in M\)是一個元素,成爲單位元素(identity element)。
    \(\star : M \times M \to M\)是一個函數,稱爲乘法公式(multiplication formula)。
    幺半羣具有以下屬性:
    • 同一律(identity law)
      \(m \star e = m\)
      \(e \star m = m\)
    • 結合律(associativity law)
      \((m \star n) \star p = m \star ( n \star p)\)
      比如:字符串就是一個幺半羣,e = "", \(\star\) = +。
  • List in set
    集合X,在X上的List是
    \[ (n, f) \\ where \\ n \in \mathbb{N} \text{ : the length of the list} \\ f: \underline{n} \to X \\ \underline{n} = \{ 1,2, \cdots, n\} \]
    記做:
    \[ (n, f) = [f(1), f(2), \cdots, f(n)] \]

  • 列表單體(free monoid generated by X)
    \(M: = (List(X), [], ++)\)
    List(X);集合X的元素列表集合。
    []是一個空列表。
    ++是連接操作(concatenation)。

  • 顯示幺半羣(presented monoid)

    顯示幺半羣的作用是提供了替換方法。
    由有限集合G和等價關係產生的顯示幺半羣(the monoid presented by generators G and relation $ { (m_i, m'_i) | 1 \le i \le n } $)

\[ M = \{ M, e, \star \} \\ where \\ \{ (xm_iy \sim xm'_iy) | x, y \in List(G), 1 \le i \le n \} \text{ : equivalence relation} \\ M = List(G)/\sim \\ e = [] \\ \star \text{ : concatenating operation} \]

  • 循環(cyclic)幺半羣

    循環幺半羣的作用是提供了一個環形列表的定義方法。
    循環(cyclic)幺半羣是隻有一個等價關係的顯示幺半羣。

  • 幺半羣行動(monoid actions)
    在集合S上的幺半羣\((M, e, \star)\)的行動爲函數:
    \[ \hookrightarrow \]

符號

術語 English Notation
單態射 monomorphisms $ \hookrightarrow $
滿態射 epimorphisms $ \twoheadrightarrow $
同構 isomorphisms $ \overset{\sim}{\to} $

羣(group)

group是一個monoid,並且每個元素都有一個倒數(inverse)。
推論:倒數具有唯一性。

圖形(graphs)

圖形(graphs)是由多個頂點(vertex)和頂點之間的箭頭(arrow)定義而成。
路徑(path)

順序(order)

  • 預次序關係(preorder)
    預次序關係(preorder)\((S, \leq)\)是一個基於集合S的二元關係\(R \subseteq S \times S\)
    R的關係:\(\text{if } (s, s') \in R, \text{then } s \leq s'\)
    並且有
    • 自反性(Reflexivity): \(s \leq s\)
    • 傳遞性(Transitivity): \(\text{if } s \leq s' \text{and } s' \leq s", \text{then } s \leq s"\)
  • 部分有序(partial order)
    部分有序(partial order)是預次序關係,並且
    • 反對稱性(Antisymmetry)
      如果s <= s', 並且 s' <= s, 則 s = s'。
  • 線性有序(linear order)
    線性有序(linear order)是部分有序,並且
    • 可比較性(Comparability)
      要麼 s <= s', 要麼 s' <= s。
  • 派系(clique)
    派系(clique)中的每兩個點都是毗鄰的(adjacent)。
    \[ clique \doteq S' \\ where \\ (S, \leqslant) \text{ is a preorder}\\ S' \subseteq S \\ a \leqslant b, \forall a,b \in S' \]

  • meet 和 join
    \((S, \leqslant)\)是一個preorder。\(s, t \in S\)
    s和t的meet(the biggest thing smaller than both)是一個元素\(w \in S\)
    表示爲:$ w \cong s \land t $
    具有:
    \[ w \leqslant s \\ w \leqslant t \\ x \leqslant w \ | \ \forall x \in S, x \leqslant s \ \And \ x \leqslant t \]
    s和t的join(the smallest thing bigger than both)是一個元素\(w \in S\)
    表示爲:$ w \cong s \lor t $
    具有:
    \[ s \leqslant w \\ t \leqslant w \\ w \leqslant x \ | \ \forall x \in S, s \leqslant x \ \And \ t \leqslant x \]
    meet 和 join 不一定是唯一的。任何兩個meet一定在同一個派系內。

digraph finite_state_machine {
    rankdir=LR;
    size="8,5"

    node [shape = doublecircle]; S;
    node [shape = point ]; qi

    node [shape = circle];
    qi -> S;
    S  -> q1 [ label = "a" ];
    S  -> S  [ label = "a" ];
    q1 -> S  [ label = "a" ];
    q1 -> q2 [ label = "ddb" ];
    q2 -> q1 [ label = "b" ];
    q2 -> q2 [ label = "b" ];
}
  • 反順序(Opposite order)
    \(S := (S, \leqslant)\)是一個預次序(preorder),則反順序\(S^{op} := (s, \leqslant^{op})\),
    有:
    $ s \leqslant s' \iff s' \leqslant s $

  • 次序的態射(morphism of orders)
    \(S := (S, \leqslant)\)\(S' := (S', \leqslant')\)次序的態射f,表示爲\(f: S \to S'\)
    \[ \text{if } s_1 \leqslant s_2 \text{, then } f(s_1) \leqslant f(s_2) \]

Database vs Graph

  • 路徑等價聲明(path equivalence declaration)
    圖形\(G := (V, A, src, tgt)\), \(Path_G\)爲G中所有路徑的集合。
    \(p \simeq q | p,g \in Path_G\)爲路徑等價聲明,表示p,g有相同的起點和終點。
    在G上的一個一致(congruence) 是一個在\(Path_G\)上的 等價關係\(\simeq\),具有:
  1. \(\simeq\)是一個等價關係.
  2. 如果 \(p \simeq q\),則src(p) = src(q).
  3. 如果 \(p \simeq q\),則tgt(p) = tgt(q).
  4. 假設 \(p,q: b \to c\)是路徑,並且\(m: a \to b\)。如果 \(p \simeq q\),則\(mp \simeq mq\).
  5. 假設 \(p,q: b \to c\)是路徑,並且\(n: b \to c\)。如果 \(p \simeq q\),則\(pn \simeq qn\).

    \(\simeq\) 是一個集合,定義了圖形上的所有約束。

  • 引理:假設\(p simeq q : a \to b, r \simeq s: b \to c\),則\(pr \simeq qs\)

  • Database Schema
    Database Schema \(C := (G, \simeq)\),G是一個圖形,\(\simeq\)是G上的一致。

  • Olog = Database Schema

  • 實例(instance)
    一個頂點對應的集合,和出入箭頭的所有路徑上的節點集合。
    \[ (PK, FK) : C \to Set \text{ is an instance} \\ where \\ C = (G, \simeq) \\ G = (V, A, src, tgt) \\ PK : V \to Set \text{, one set for one vertex} \\ FK(a) : PK(v) \to PK(w) \ | \ v = src(a), w = tgt(a), \forall a \in A \]

  • 路徑法則(Law 1 - Path through a database)
    \[ FK(a_m) \circ \dots \circ FK(a_1) (x) = FK(a'_n) \circ \dots \circ FK(a'_1) (x) = PK(w), \forall x \in PK(v) \\ where \\ p = v a_1 a_2 \dots a_m : v \to w \\ q = v a'_1 a'_2 \dots a'_n : v \to w \\ p \simeq q \]

範疇化

如何將一個monoid/order group/group index通過一個函子轉化成一個範疇。

Database Schema present categories

參照

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章