Functor與Natural transformation [GC75]

Functor是範疇之間的變換,例如 F:C→DF : \mathcal{C} \to \mathcal{D} 可以記成

figure tex9766

Functor必須滿足 F(f∘g)=F(f)∘F(g)F(f \circ g) = F(f) \circ F(g),但這件事在我們目前用的string diagram表示法裡面看起來像是廢話所以就不畫了。Natural transformation是functors之間的變換,例如 α:F⇒G\alpha : F \Rightarrow G 可以記成

figure tex9767

Natural transformation必須滿足等式 G(f)∘αX=αY∘F(f)G(f) \circ \alpha_X = \alpha_Y \circ F(f),稱之為naturality

figure tex9768

用string diagram繪製之後,naturality就像是在說:我們可以把串珠在線上移來移去而不會改變意義。因此這又叫「電梯等式」,我們當然沒有必要侷限在objects跟morphisms上,所以更通用的形式是

figure tex9769

這種string diagram的語言在Introducing String Diagrams: The Art of Category Theory裡面有更多的介紹

Example 程式作為natural transformation [631K]

如果一些類型構成category,可以用functor表示參數化類型。例如我們可以定義natural transformation α:Maybe→List\alpha : \text{Maybe} \to \text{List} 為

αX:Maybe(X)→List(X)αX(Nothing)=[]αX(Some x)=[x]\begin{aligned} &\alpha_X : \text{Maybe}(X) \to \text{List}(X) \\ &\alpha_X(\text{Nothing}) &= [] \\ &\alpha_X(\text{Some}\ x) &= [x] \end{aligned}
figure tex7646

或是取出List中的最大值

figure tex7647