Coq 中的 PHOAS:类型不匹配
PHOAS in Coq: type mismatch
我正在 Coq 中转录 2008 PHOAS paper 第 2.1 节中的(非正式)定义。
Inductive tm' {V : Set} : Set :=
| Var : V -> tm'
| App : tm' -> tm' -> tm'
| Abs : (V -> tm') -> tm'.
Definition tm := forall X, @tm' X.
Fail Example id : tm := Abs Var.
输出:
The term "Abs Var" has type "tm'" while it is expected to have type "tm".
这很令人讨厌。如何进行此代码类型检查?
Example id : tm := fun (X : Set) => Abs Var.
这是有效的代码:
Example id : tm := fun _ => Abs Var.
问题是您试图构建一个没有 lambda (fun
) 的函数(forall
类型的东西)。
我正在 Coq 中转录 2008 PHOAS paper 第 2.1 节中的(非正式)定义。
Inductive tm' {V : Set} : Set :=
| Var : V -> tm'
| App : tm' -> tm' -> tm'
| Abs : (V -> tm') -> tm'.
Definition tm := forall X, @tm' X.
Fail Example id : tm := Abs Var.
输出:
The term "Abs Var" has type "tm'" while it is expected to have type "tm".
这很令人讨厌。如何进行此代码类型检查?
Example id : tm := fun (X : Set) => Abs Var.
这是有效的代码:
Example id : tm := fun _ => Abs Var.
问题是您试图构建一个没有 lambda (fun
) 的函数(forall
类型的东西)。