monoid同态到底是什么? [英] What is monoid homomorphism exactly?
问题描述
我已经从 Monoid形态,产品和副产品,并且无法理解100%.
I've read about monoid homomorphism from Monoid Morphisms, Products, and Coproducts and could not understand 100%.
作者说(强调原文):
length
函数从String
映射到Int
,同时保留 单体结构.这样的功能,可以将一个半身像映射到 另一个以这种保存方式被称为 monoid homomorphism .在 一般而言,对于MonoidM
和N
,同态f: M => N
和所有值x:M
,y:M
,以下等式成立:
The
length
function maps fromString
toInt
while preserving the monoid structure. Such a function, that maps from one monoid to another in such a preserving way, is called a monoid homomorphism. In general, for monoidsM
andN
, a homomorphismf: M => N
, and all valuesx:M
,y:M
, the following equations hold:
f(x |+| y) == (f(x) |+| f(y))
f(mzero[M]) == mzero[N]
他的意思是说,由于数据类型String
和Int
是单面体,并且函数length
映射String => Int
保留单面体结构(Int
是一个单面体),因此称为单面体同态,对吧?
Does he mean that, since the datatypes String
and Int
are monoids, and the function length
maps String => Int
preserving the monoid structure (Int
is a monoid), it is called monoid homomorphism, right?
推荐答案
他的意思是说,数据类型String和Int是等宽的.
Does he mean, the datatype String and Int are monoid.
否,String
和Int
都不是类半体动物. id半群是一个三元组(S,&oplus ;, e),其中⊕是二元运算符⊕ :S× S→ S ,这样对于所有元素 a,b,c∈ S 都认为(a⊕ b)⊕ c = a⊕(b⊕ c),而 e∈ S 是一个身份元素",因此 a⊕ e = e⊕ a = a . String
和Int
是类型,因此基本上是一组值,但不是三元组.
No, neither String
nor Int
are monoids. A monoid is a 3-tuple (S, ⊕, e) where ⊕ is a binary operator ⊕ : S×S → S, such that for all elements a, b, c∈S it holds that (a⊕b)⊕c=a⊕(b⊕c), and e∈S is an "identity element" such that a⊕e=e⊕a=a. String
and Int
are types, so basically sets of values, but not 3-tuples.
文章说:
让我们将
String
串联和Int
添加 有关系的示例 monoids .
Let's take the
String
concatenation andInt
addition as example monoids that have a relationship.
因此,作者显然也提到了二进制运算符(在String
情况下为(++)
,在Int
情况下为(+)
).身份(在String
情况下为空字符串,在Int
情况下为0
)保留为隐式;在非正式英语语篇中,将身份作为一种练习留给读者是很常见的.
So the author clearly also mentions the binary operators ((++)
in case of String
, and (+)
in case of Int
). The identities (empty string in case of String
and 0
in case of Int
) are left implicit; leaving the identities as an exercise for the reader is common in informal English discourse.
现在假设我们有两个单半体结构(M,&oplus ;, e m )和(N,&otimes ;, e n ),函数 f:M→ N (例如length
)然后称为 monoid同态 [wiki] ,因为它认为 f(m 1 ⊕ m 2 )= f(m 1 )⊗ f(m 2 )用于所有元素 m 1 ,m 2 ∈ M 并且该映射还保留了标识元素: f(e m )= e n .
Now given that we have two monoid structures (M, ⊕, em) and (N, ⊗, en), a function f : M → N (like length
) is then called a monoid homomorphism [wiki] given it holds that f(m1⊕m2)=f(m1)⊗f(m2) for all elements m1, m2∈M and that mapping also preserves the identity element: f(em)=en.
例如length :: String -> Int
是一个单面体同态,因为我们可以考虑这些单面体(String
,(++)
,""
)和(Int
,0
)
For example length :: String -> Int
is a monoid homomorphism, since we can consider the monoids (String
, (++)
, ""
) and (Int
, (+)
, 0
). It holds that:
-
length (s1 ++ s2) == length s1 + length s2
(对于所有String
ss1
和s2
);和 -
length "" == 0
.
length (s1 ++ s2) == length s1 + length s2
(for allString
ss1
ands2
); andlength "" == 0
.
这篇关于monoid同态到底是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!