我有两个不同的模块签名到两个不同的文件。他们有相同的字段名称但行为不同。设计仿函数能够使用不同的模块
而functor里面定义了另一个函子。
PI.v
Module Type TPI.
Parameter sig : Signature.
Parameter trsInt: forall f, pi f.
End TPI.
Module P (Export T: TPI).
Lemma A...
Module Export Mono <: MonoType.
End P.
和
MI.v
Module Type TMI.
Parameter sig : Signature.
Parameter trsInt : forall f, mi f.
End TMI.
Module M (Export TM: TMI).
Lemma B ...
Module Export Mono <: MonoType.
End M.
凡MonoType
另一个文件例如Mono.v
里面这是我的情况。
我有另一个文件叫B.v
里面我需要在文件PI.v
和MI.v
这两个文件中使用定义和引理。
和我需要使用它们的一个定义为例。
Definition redPair R is :=
match is with
| Type_PI => pi_int R is
| Type_MI => mi_int R is
end.
我在R
有一个问题,因为pi_int R
和mi_int R
具有不同sig
(签名),其中使用pi_int
的trsInt
模块签名TPI
和mint_int
使用trsInt
的模块签名TMI
内部内。
这里是我定义的方式:
Module PI (Import P : TPI).
Definition pi_int R is := P.trsInt ...
(* inside PI I define another functor for MI *)
Module MI (Import M : TMI).
Definition mi_int R is := M.trsInt ...
Definition redPair R is :=
match is with
| Type_PI => pi_int R is
| Type_MI => mi_int R is (* error here saying that it used the sig of
P.sig but in this case mi_int used the sig of M.sig *)
end.
End MI.
End PI.
我的问题是,在那里我可以有模块的结构好,我可以在定义redPair
具有相同签名的方法吗?感谢您的帮助。
谢谢!你是对的!我可以用Record来完成。但是因为我正在使用Module结构提供的库。非常感谢您的帮助。我选择了第二个,它现在起作用了。 :) – Quyen 2013-04-04 05:10:01