在Coq / Ssreflect中将鳍集转换为finType

时间:2018-12-06 23:24:16

标签: coq ssreflect

我正在学习Ssreflect,我想知道如何解决这种情况。我的想法是定义一个图(作为记录),然后生成另一个图。在下面,我展示了一段不言自明的代码(从较大的代码中提取):

Require Import ssreflect ssrbool ssrfun.
From mathcomp Require Import eqtype ssrnat fintype finset.

Section Example.

Record ugraph := UGraph { T : finType ;
                          V : {set T} ;
                          E : {set {set T}} ;
        edges_have_vertices : forall e : {set T}, e \in E -> e \subset V ;
             edges_size_two : forall e : {set T}, e \in E -> #|e| == 2}.

Variable G : ugraph.

Definition closed_neigh : T G -> {set T G} := fun u => [set v | [set u; v] \in E G] :|: [set u].
Notation "N[ x ]" := (closed_neigh x) (at level 0, x at level 99).

Definition T_Gp := prod_finType (T G) (T G).

(* V' is the set of (u, v) such that u \in V and v \in N[u] *)
Definition V_Gp := [set x : T_Gp | (x.1 \in V G) && (x.2 \in (N[x.1]))].

(* E' is the set of edges {uv, zr} such that uv, zr \in V', uv != zr and z \in N[v] *)
Definition E_Gp := [set e : {set T_Gp} | [exists x : T_Gp, [exists y : T_Gp, (e == [set x; y]) && (x != y) && (x \in V_Gp) && (y \in V_Gp) && (y.1 \in N[x.2])]]].

Lemma edges_have_vertices_Gp : forall e : {set T_Gp}, e \in E_Gp -> e \subset V_Gp.
Admitted.

Lemma edges_size_two_Gp : forall e : {set T_Gp}, e \in E_Gp -> #|e| == 2.
Admitted.

Definition gen_Gp := @UGraph T_Gp V_Gp E_Gp edges_have_vertices_Gp edges_size_two_Gp.

End Example.

请注意,我目前使用的是 finType T ,因此,顶点集在某种程度上是T的子集。但是,我觉得我可以通过将顶点集视为finType本身,并避免了“ edges_have_vertices”的证明,如下所示:

Require Import ssreflect ssrbool ssrfun.
From mathcomp Require Import eqtype ssrnat fintype finset.

Section Example.

Record ugraph := UGraph { V : finType ;
                          E : {set {set V}} ;
             edges_size_two : forall e : {set V}, e \in E -> #|e| == 2}.

Variable G : ugraph.

Definition closed_neigh : V G -> {set V G} := fun u => [set v | [set u; v] \in E G] :|: [set u].
Notation "N[ x ]" := (closed_neigh x) (at level 0, x at level 99).

Definition V_Gp := [set x : prod_finType (V G) (V G) | (x.1 \in V G) && (x.2 \in (N[x.1]))].

Definition E_Gp := [set e : {set V_Gp} | ...]. (* <--- error *)

但是,然后,我收到有关V_Gp(新图的顶点集)的错误,该错误应为finType类型而不是{set _}。有没有办法在finType中“转换” V_Gp?

0 个答案:

没有答案