简体   繁体   English

我如何让 Agda 的宇宙检查器相信我所做的事情是有根据的?

[英]How do I convince Agda's universe checker that what I'm doing is well-founded?

I have a function that maps natural numbers to their corresponding Agda universe level.我有一个 function 将自然数映射到它们相应的 Agda 宇宙级别。

level : Nat -> Level
level zero = lzero
level (suc l) = lsuc (level l)

Setn : (l : Nat) -> Set (level (suc l))
Setn l = Set (level l)

I use this function in the definition an inductive datatype in this manner:我以这种方式在定义归纳数据类型中使用这个 function:

data U l : Setn l where
  ...
  Lift : {l' : Nat} -> {l' <= l} -> U l' -> U l

Here, Agda complains that Set (level l') is not less than or equal to Set (level l) , which is clearly false, though I understand that Agda is not equipped to derive that Set (level l') <= Set (level l) from l' <= l .在这里,Agda 抱怨Set (level l')不小于或等于Set (level l) ,这显然是错误的,尽管我知道 Agda 没有能力推导出Set (level l') <= Set (level l)l' <= l How do I hint to Agda's universe checker that this definition is indeed well-founded?我如何向 Agda 的宇宙检查器暗示这个定义确实是有根据的?

You don't.你没有。

That's probably not the answer you want to hear, but there are good reasons Agda rejects this type even though the way you are using universe levels seems to be correct.这可能不是你想听到的答案,但 Agda 拒绝这种类型是有充分理由的,即使你使用 Universe 关卡的方式似乎是正确的。 In particular, if Agda would allow this then strong normalization (and hence decidability of typechecking) would be lost: in an open context with a proof of 1 <= 0 , you'd be able to exploit this datatype (or a variant thereof) to define a datatype that does not respect the universe hierarchy, which can then be used (through Girard's paradox) to define a non-terminating term.特别是,如果 Agda 允许这样做,那么强大的规范化(以及因此类型检查的可判定性)将丢失:在具有1 <= 0证明的开放上下文中,您将能够利用此数据类型(或其变体)定义不尊重 Universe 层次结构的数据类型,然后可以使用(通过 Girard 悖论)定义非终止项。 Since Agda cannot decide whether an assumption is consistent or not, it rules out these kind of user-proven level inequalities altogether and only trusts its own solver.由于 Agda 无法确定假设是否一致,因此它完全排除了这种经过用户验证的级别不等式,并且只信任自己的求解器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM