如何使用Coq为cobordisms建立一个归纳类型?

时间:2014-11-02 18:57:13

标签: coq algebraic-data-types

我正在尝试使用Coq建立一种用于cobordism的归纳类型,以便可以证明cobordism(1- groupoid和2-groupoid)的某些属性。我使用以下Coq代码:

 Unset Automatic Introduction.
 Inductive  Topo : Set := t | nt.
 Definition F (i j : Topo) :=  
 match i, j with
 | t, t => t
 | t, nt => nt
 | nt, t => nt
 | nt, nt => nt
 end.

我正在考虑用于cobordisms的两种拓扑:平凡(t)和非平凡(nt)。琐碎的cobordisms是被认为像1-组中的单位的圆柱体。函数F给出了拓扑的组合。

归纳类型的cobordism假设为:

Inductive cobordisms {A} : A -> A -> Topo -> Type := idcobordism : forall
                           x : A, cobordisms x x t.

用战术:

Hint Resolve @idcobordism.

Ltac cobordism_induction :=
   intros; repeat progress (
   match goal with
  | [ p : cobordisms _ _ _  |- _ ] => induction p 
  | _ => idtac
  end
   ); auto.

cobordisms的组成根据:

引入
Definition concat {A} {x y z : A} {i j : Topo} : cobordisms x y i  -> cobordisms y z j   
 ->    cobordisms x z (F i j) .
Proof.
  cobordism_induction.
Defined.

Notation "p @ q" := (concat p q) (at level 60).

给定cobordism的逆定义如下:

Definition opposite {A} {x y : A} {i : Topo} : cobordisms x y i -> cobordisms y x i .
Proof.
  cobordism_induction.
Defined.

Notation "! p" := (opposite p) (at level 50).

直到现在一切都还好。但是当我试图证明1-groupid的第一属性时,即左派:

Lemma idcobordism_left_unit A (x y : A) (i : Topo) (p : cobordisms x y i) : 
           (idcobordism x)  @ p =  p.

我收到以下错误消息:

Error: In environment
A : Type
x : A
y : A
i : Topo
p : cobordisms x y i
The term "p" has type "cobordisms x y i" while it is expected to have type
"cobordisms x y (F t i)".

然后我的问题是,如何根据之前(F t i)的定义,让Coq认为i相当于所有i的{​​{1}}?

2 个答案:

答案 0 :(得分:1)

问题在于,F的定义总是在其第二个参数上生成match,即使它不是必需的。因此,当F t i不是构造函数时,ii在定义上不会相等。解决方案是更改F的定义,以便您想要的相等变为显式:

Definition F (i j : Topo) :=  
match i with
| t => j
| nt => nt
end.

不幸的是,在显示正确的身份时,您将无法执行相同的技巧,因为那样您就会遇到相反的问题。在这种情况下,解决方案是使用显式转换来关联两个路径:

Definition cast_cb {A} {x y : A} i : cobordisms x y (F i t) -> cobordisms x y i :=
  match i with t => fun x => x | nt => fun x => x end.

Lemma right_id A (x y : A) i (p : cobordisms x y i) :
  cast_cb i (p @ (idcobordism y)) = p.

答案 1 :(得分:1)

使用Arthur Azevedo De Amori提出的策略,可以完成对于cobordisms的1-quasigroupoid结构的证明:

   (** The following lemmas say that the cobordisms form a
   1-quasi-groupoid. *)


Lemma idcobordism_left_unit A (x y : A) (i : Topo) (p : cobordisms x y i) : (idcobordism x) @ p =  p.
Proof.
  cobordism_induction.
Defined.





Definition cast_cb {A} {x y : A} i : cobordisms x y (F i t) -> cobordisms x y i :=
  match i with t => fun x => x | nt => fun x => x end.

Lemma idcobordism_right_unit A (x y : A) i (p : cobordisms x y i) :
  cast_cb i (p @ (idcobordism y)) = p.
Proof.
  cobordism_induction.
Defined.


Definition cast_cb2 {A} {x y : A} i j : cobordisms x y (F j i) -> cobordisms x y (F i j) :=
  match i,j with t,t => fun x => x | t,nt => fun x => x | nt,t => fun x => x | nt,nt => fun x => x  end.


Lemma opposite_concat A (x y z : A) (i j k : Topo) (p : cobordisms x y i) (q : cobordisms y z j) :  !(p @ q) = cast_cb2 i j (!q @ !p).
Proof.
  cobordism_induction.
Defined.




Lemma opposite_idcobordism A (x : A) : !(idcobordism x) = idcobordism x.
Proof.
  auto.
Defined.


Lemma opposite_opposite A (x y : A) (i : Topo) (p : cobordisms x y i) : !(! p) = p.
Proof.
  cobordism_induction.
Defined.

Definition cast_cb3 {A} {x y : A} i j k : cobordisms x y (F i (F j k)) -> cobordisms x y (F (F i j) k) :=
  match i,j,k with t,t,t => fun x => x | t,t,nt => fun x => x | t,nt,t => fun x => x | t,nt,nt => fun x => x 
                   | nt,t,t => fun x => x | nt,t,nt => fun x => x | nt,nt,t => fun x => x | nt,nt,nt => fun x => x end.



Lemma concat_associativity A (x y z w : A) (i j k : Topo) (p : cobordisms x y i) (q : cobordisms y z j) (r : cobordisms z w k) :
  (p @ q) @ r = cast_cb3 i j k (p @ (q @ r)).
Proof.
  cobordism_induction.
Defined.