我施加的条件在类别 theory/Set 理论中有名称吗?
Does My imposed Condition have a name in category theory/Set theory?
我对完全和参考透明函数的签名提出了要求:
def add[T](a: T)(b: T): T
//requirement is type T under e.g. addition must always bear antoher type T
// and is not allowed to throw runtime arithmetic exceptions or such.
对于Int
、String
、Nat
(自然数)等多种类型都可以轻松满足此要求; yet 也很容易被 NonZeroInt
等类型违反,因为两个非零整数的相加实际上可以为零。
我的问题是这种情况有一个新的术语吗?想到了幺半群,但很明显我没有在这里强加所有关于幺半群的规则。
没有任何法律要求,这只是对集合 T 的一次操作,仅此而已。如果 add
是联合的,你可以称它为半群。
如果我理解您的问题,那么您要查找的术语是 "closure" 用于给定操作的集合。参考维基百科中的数学定义here。简而言之:
A set has closure under an operation if performance of that operation
on members of the set always produces a member of the same set
然而,"closure"在计算机科学中似乎有不同的含义。参见 link here。我在 Scala 上下文中搜索有关闭包的内容,即使将其放在数学或集合论的上下文中,也不会产生任何有用的结果。也许这就是为什么您很难找到这个创造的术语。
我对完全和参考透明函数的签名提出了要求:
def add[T](a: T)(b: T): T
//requirement is type T under e.g. addition must always bear antoher type T
// and is not allowed to throw runtime arithmetic exceptions or such.
对于Int
、String
、Nat
(自然数)等多种类型都可以轻松满足此要求; yet 也很容易被 NonZeroInt
等类型违反,因为两个非零整数的相加实际上可以为零。
我的问题是这种情况有一个新的术语吗?想到了幺半群,但很明显我没有在这里强加所有关于幺半群的规则。
没有任何法律要求,这只是对集合 T 的一次操作,仅此而已。如果 add
是联合的,你可以称它为半群。
如果我理解您的问题,那么您要查找的术语是 "closure" 用于给定操作的集合。参考维基百科中的数学定义here。简而言之:
A set has closure under an operation if performance of that operation on members of the set always produces a member of the same set
然而,"closure"在计算机科学中似乎有不同的含义。参见 link here。我在 Scala 上下文中搜索有关闭包的内容,即使将其放在数学或集合论的上下文中,也不会产生任何有用的结果。也许这就是为什么您很难找到这个创造的术语。