类型的基数

发布于 2024-09-30 22:56:19 字数 96 浏览 6 评论 0原文

它是什么意思,以及以下类型的基数是什么,例如:

unit->int  

bool->(int->bool)

What does it mean, and also what is the cardinality of the next types for example:

unit->int  

bool->(int->bool)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

離殇 2024-10-07 22:56:19

类型的基数是该类型的可能合法值的数量。

对于函数类型,我们通常希望将每个输入返回相同值的两个函数视为“相同的函数”,至少出于基数目的(这称为“外延相等”)。

我假设这是一个家庭作业问题,并且我进一步假设不包含不终止或产生未定义值的函数(因为实际上,它们不会包含在典型的数学处理中) 。

原则上,表达可以具有有限数量的可能值的类型的基数相当容易,因为您可以只给出一个数字作为基数。然而,对于无限基数,从技术上讲,不同类型的无穷大之间存在区别。例如,不可数无穷大“大于”可数无穷大。 (说实话,我不确定你是否应该知道这一点,或者你是否应该给出“无限”的答案 - 检查你的课程笔记。)因此,最好指定哪个无穷大您正在谈论,例如通过引用“更简单”类型的基数。

因此 unit->int 的基数与 int 的基数相同(对于您可能选择而不是 的任何其他目标类型也是如此) int),因为 unit->X 类型的值必须是一个“忽略其输入”并返回 X 类型常量值的常量函数>。

我希望这个不完整的答案足以让您开始。

The cardinality of a type is the number of possible legal values that can be of that type.

With function types, we usually want to consider two functions that return the same value for every input to be "the same function", for cardinality purposes at least (this is known as "extensional equality").

I am assuming that this is a homework problem, and I am further going to assume that functions which don't terminate or yield undefined values are not to be included (as, indeed, they wouldn't be included in a typical mathematical treatment).

Expressing the cardinality of types which can have a finite number of possible values, is fairly easy in principle, because you can just give a number as the cardinality. However, with infinite cardinalities, technically there is a distinction between different kinds of infinities. For example, an uncountable infinity is "larger than" a countable infinity. (To be honest, I am not sure whether you are expected to know this, or whether you are just supposed to give an answer of "infinite" - check your course notes.) For this reason, it's a good idea to specify which infinity you are talking about, e.g. by referring to the cardinality of a "simpler" type.

So the cardinality of unit->int is the same as the cardinality of int (and the same goes for any other destination type which you might choose instead of int), because a value of type unit->X must necessarily be a constant function which "ignores its input" and returns a constant value of type X.

I hope this incomplete answer is enough to get you started.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文