为什么 Agda typechecker 会在这个程序上崩溃

Why does the Agda typechecker crash on this program

考虑以下(无效的)Agda 代码

data Example : Example ex → Set where
  ex : Example ex

在 Agda 中可以通过以下方式有效地编写此类型,利用 Agda 允许值先赋类型后定义的特性

exampleex : Set
ex' : exampleex

data Example : exampleex → Set where
  ex : Example ex'

exampleex = Example ex'
ex' = ex

这一切都可以编译,Agda 正确地知道 ex : Example ex

但是,尝试使用模式匹配从 Example 中定义函数会导致编译器崩溃

test : (e : Example ex) → Example e → ℕ
test ex x = 0

当我将这个函数添加到文件中时,运行 "agda main.agda",agda 说 "Checking main" 但从未完成 运行ning。 Agda 中的类型检查不应该是可判定的吗?

此外,有什么方法可以解决这个问题并使测试函数可以定义吗?

这是 Agda 中的一个已知问题。您可以在 https://github.com/agda/agda/issues/1556.

的 Agda github 上找到相应的问题