我一直在尝试互感类型,并决定定义自然数和向量的互感版本(列表及其类型中的大小)。我将它们和无限数定义为:
CoInductive conat : Set :=
| cozero : conat
| cosuc : conat -> conat.
CoInductive covec (A : Set) : conat -> Set :=
| conil : covec A cozero
| cocons : forall (n : conat), A -> covec A n -> covec A (cosuc n).
CoFixpoint infnum : conat := cosuc infnum.
除了我为无限协向量给出的定义之外,这一切都有效
CoFixpoint ones : covec nat infnum := cocons 1 ones.
这给出了以下类型不匹配
Error:
In environment
ones : covec nat infnum
The term "cocons 1 ones" has type "covec nat (cosuc infnum)" while it is expected to have type
"covec nat infnum".
我认为编译器会接受这个定义,因为根据定义,infnum = cosuc infnum。如何让编译器理解这些表达式是相同的?