用声明调用函子

时间:2015-10-02 10:59:29

标签: coq

我想实现几组元素。为此,我复制了MSetWeakList的Make仿函数。它最初定义如下:

Module Make (X: DecidableType) <: WSets with Module E := X.

所以我尝试做同样的事情,但有两个DecidableType

Require Import MSets.

Module DecidablePair (DT1:DecidableType) (DT2:DecidableType) <: DecidableType.
  Definition t : Type := DT1.t * DT2.t.
  Definition eq x y := DT1.eq (fst x) (fst y) /\ DT2.eq (snd x) (snd y).
  Lemma eq_equiv : Equivalence eq.
  Proof.
    split.
    - split; reflexivity.
    - split; symmetry; apply H.
    - split.
      + transitivity (fst y). apply H. apply H0.
      + transitivity (snd y). apply H. apply H0.
  Qed.
  Lemma eq_dec : forall x y, {eq x y} + {~ eq x y}.
  Proof.
    intros.
    destruct (DT1.eq_dec (fst x) (fst y)).
    - destruct (DT2.eq_dec (snd x) (snd y)).
      + left. split; assumption.
      + right. intros contra. apply n. apply contra.
    - right. intros contra. apply n. apply contra.
  Qed.
End DecidablePair.

Module MakePair (DT1: DecidableType) (DT2:DecidableType) <: WSets
  with Module E := DecidablePair DT1 DT2.

但是Coq不接受使用声明的函子的调用。我怎样才能编写MakePair返回的模块类型?

0 个答案:

没有答案