Coq中的PHOAS:类型不匹配

时间:2017-06-26 17:30:04

标签: coq

我在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".

那令人讨厌。如何进行此代码类型检查?

2 个答案:

答案 0 :(得分:2)

以下是有效的代码:

Example id : tm := fun _ => Abs Var.

问题是你试图在没有lambda(forall)的情况下构造一个函数(fun类型的东西)。

答案 1 :(得分:0)

Example id : tm := fun (X : Set) => Abs Var.