为什么我不能在 Agda 中仅使用索引来定义 `Eq`?
Why can't I define `Eq` using only indices in Agda?
为什么我不能像这样定义一个更明确的异构平等版本:
data Eq : (A : Set) -> A -> A -> Set where
Refl : (T : Set) -> (x : T) -> Eq T x x
当我这样做时,出现以下错误:
The type of the constructor does not fit in the sort of the
datatype, since Set₁ is not less or equal than Set
when checking the constructor Refl in the declaration of Eq
我知道这个错误与宇宙的等级制度有关,但我不知道具体是什么。它认为 Eq T x x
应该是 Set_1
,还是认为是但不应该?为什么这里有东西 Set_1
?
如果您定义的类型有一个类型在 Set n
中的索引,那么该类型本身必须至少在 Set n
中。在您的例子中,您的索引之一 A
具有类型 Set
,因此 其类型 是 in Set 1
(因为 Set : Set 1
)。因此,Eq
本身至少需要在 Set 1
中。
请注意,如果 A : Set
是 参数 而不是 索引 ,则上述内容不适用,即为什么同质平等可以在Set
。
为什么我不能像这样定义一个更明确的异构平等版本:
data Eq : (A : Set) -> A -> A -> Set where
Refl : (T : Set) -> (x : T) -> Eq T x x
当我这样做时,出现以下错误:
The type of the constructor does not fit in the sort of the
datatype, since Set₁ is not less or equal than Set
when checking the constructor Refl in the declaration of Eq
我知道这个错误与宇宙的等级制度有关,但我不知道具体是什么。它认为 Eq T x x
应该是 Set_1
,还是认为是但不应该?为什么这里有东西 Set_1
?
如果您定义的类型有一个类型在 Set n
中的索引,那么该类型本身必须至少在 Set n
中。在您的例子中,您的索引之一 A
具有类型 Set
,因此 其类型 是 in Set 1
(因为 Set : Set 1
)。因此,Eq
本身至少需要在 Set 1
中。
请注意,如果 A : Set
是 参数 而不是 索引 ,则上述内容不适用,即为什么同质平等可以在Set
。