不理解 Monoid 定义中的态射符号
Don't understand notation of morphisms in Monoid definition
我试图从范畴论的角度理解 Monoid
是什么,但我对用来描述它的符号有点困惑。这是维基百科:
In category theory, a monoid (or monoid object) (M, μ, η) in a monoidal category (C, ⊗, I) is an object M together with two morphisms
μ: M ⊗ M → M called multiplication,
η: I → M called unit
我的困惑是关于态射符号。为什么二元运算 ⊗
是态射符号的一部分?我对态射的理解是它是一种可以从一种类型映射到另一种类型(域到辅域)的函数,比如M → M
。为什么操作 ⊗
是定义中域的一部分?第二个困惑是关于I
。为什么 I
是域? Monoid
中根本没有 I
对象。它只是对象的一个中性元素 M
.
我明白Monoid
是一个范畴,有一个对象,一个恒等态射,一个定义在这个对象上的二元运算,但是符号让我觉得我不明白什么。
M ⊗ M
是否与笛卡尔积有某种关系,因此态射的域定义为 M x M
?
编辑: 我在 Mathematics Stack Exchange.
上的问题得到了非常有用的答案
Is M ⊗ M
some how related to cartesian product, so domain of the morphism is defined as M x M
?
没错。更具体地说,我们通过选择 Hask(类别所有 Haskell 类型作为对象,所有 Haskell 函数作为态射)作为 C,(,)
(对类型构造函数)作为 ⊗,()
(单位类型)为I。 μ和η的签名,翻译成Haskell,然后变成:
μ :: (M, M) -> M
η :: () -> M
通过柯里化 μ,并利用 () -> M
函数如何 one-to-one 对应于 M
值(所有这些看起来像 \() -> m
对于某些 m
),我们得到熟悉的 Monoid
方法:
mappend :: M -> M -> M
mempty :: M
请注意,分类定义远比 Monoid
更为笼统。例如,我们可能会继续在 Hask 中工作,同时将 (,)
和 ()
替换为它们的对偶 Either
和 Void
,从而得到:
μ :: Either A A -> A
η :: Void -> A
每个Haskell类型都是一个幺半群以这种特殊方式(μ是either id id
,并且η是absurd
).
另一个例子是 C 是 Haskell Functor
s 的类别(它们之间有自然转换——我将写为 type f ~> g = forall a. f a -> g a
-- 作为态射), Compose
as ⊗, and Identity
作为 I:
-- Note the arrows here are ~>, and not ->
μ :: Compose M M ~> M
η :: Identity ~> M
这两个一般写成:
-- "Inlining" the definitions of Compose, Identity, and ~>
join :: M (M a) -> M a
return :: a -> M a
换句话说,Monad
是 Functor
类别中的幺半群(它是 Hask 特定版本 "a monad is a monoid in the category of endofucntors").值得一提的是,与另一个示例一样,这并不是将幺半群从该类别中取出的唯一方法(请参阅 的最后一段以获取指针——实际上,其余部分可能是相关阅读,因为它讨论了幺半群类别的概念)。
我试图从范畴论的角度理解 Monoid
是什么,但我对用来描述它的符号有点困惑。这是维基百科:
In category theory, a monoid (or monoid object) (M, μ, η) in a monoidal category (C, ⊗, I) is an object M together with two morphisms
μ: M ⊗ M → M called multiplication,
η: I → M called unit
我的困惑是关于态射符号。为什么二元运算 ⊗
是态射符号的一部分?我对态射的理解是它是一种可以从一种类型映射到另一种类型(域到辅域)的函数,比如M → M
。为什么操作 ⊗
是定义中域的一部分?第二个困惑是关于I
。为什么 I
是域? Monoid
中根本没有 I
对象。它只是对象的一个中性元素 M
.
我明白Monoid
是一个范畴,有一个对象,一个恒等态射,一个定义在这个对象上的二元运算,但是符号让我觉得我不明白什么。
M ⊗ M
是否与笛卡尔积有某种关系,因此态射的域定义为 M x M
?
编辑: 我在 Mathematics Stack Exchange.
上的问题得到了非常有用的答案Is
M ⊗ M
some how related to cartesian product, so domain of the morphism is defined asM x M
?
没错。更具体地说,我们通过选择 Hask(类别所有 Haskell 类型作为对象,所有 Haskell 函数作为态射)作为 C,(,)
(对类型构造函数)作为 ⊗,()
(单位类型)为I。 μ和η的签名,翻译成Haskell,然后变成:
μ :: (M, M) -> M
η :: () -> M
通过柯里化 μ,并利用 () -> M
函数如何 one-to-one 对应于 M
值(所有这些看起来像 \() -> m
对于某些 m
),我们得到熟悉的 Monoid
方法:
mappend :: M -> M -> M
mempty :: M
请注意,分类定义远比 Monoid
更为笼统。例如,我们可能会继续在 Hask 中工作,同时将 (,)
和 ()
替换为它们的对偶 Either
和 Void
,从而得到:
μ :: Either A A -> A
η :: Void -> A
每个Haskell类型都是一个幺半群以这种特殊方式(μ是either id id
,并且η是absurd
).
另一个例子是 C 是 Haskell Functor
s 的类别(它们之间有自然转换——我将写为 type f ~> g = forall a. f a -> g a
-- 作为态射), Compose
as ⊗, and Identity
作为 I:
-- Note the arrows here are ~>, and not ->
μ :: Compose M M ~> M
η :: Identity ~> M
这两个一般写成:
-- "Inlining" the definitions of Compose, Identity, and ~>
join :: M (M a) -> M a
return :: a -> M a
换句话说,Monad
是 Functor
类别中的幺半群(它是 Hask 特定版本 "a monad is a monoid in the category of endofucntors").值得一提的是,与另一个示例一样,这并不是将幺半群从该类别中取出的唯一方法(请参阅