子集类型,细化类型,证明相关性和平等

时间:2017-10-29 17:46:31

标签: coq

我不太确定我应该使用哪个标题来解决这个问题。如果有人理解这里提出的问题,请随时提供更好的标题。

我已经定义了一个类型,用于对类型A上的类别结构进行建模。 A的实例代表箭头,而Category A的实例代表这些箭头上可用的操作以及提供类别法律满足保证的证明。这种观点有效地识别具有相应身份箭头的对象。

Record Category (A:Type) : Type := category
    { source    : A -> A
    ; target    : A -> A
    ; compose   : A -> A -> option A
    ; proof_ss  : forall f:A,      source (source f) = source f    
    ; proof_ts  : forall f:A,      target (source f) = source f
    ; proof_tt  : forall f:A,      target (target f) = target f
    ; proof_st  : forall f:A,      source (target f) = target f
    ; proof_dom : forall f g:A,    target f = source g <-> compose f g <> None
    ; proof_src : forall f g h:A,  compose f g = Some h -> source h = source f
    ; proof_tgt : forall f g h:A,  compose f g = Some h -> target h = target g
    ; proof_idl : forall a f:A,    a = source f -> compose a f = Some f
    ; proof_idr : forall a f:A,    a = target f -> compose f a = Some f
    ; proof_asc : forall f g h fg gh:A, compose f g = Some fg -> 
                                        compose g h = Some gh -> 
                                        compose f gh = compose fg h
    }
    .

现在更传统的观点是实际区分对象和箭头的观点,并考虑它们的两个独立的类(集合,类型)。所以我也定义了:

Record Category2 (Obj Mor:Type) : Type := category2
    { dom       : Mor -> Obj
    ; cod       : Mor -> Obj
    ; compose2  : Mor -> Mor -> option Mor
    ; id        : Obj -> Mor
    ; proof_sid : forall a:Obj, dom (id a) = a
    ; proof_tid : forall a:Obj, cod (id a) = a
    ; proof_dom2: forall f g:Mor, cod f = dom g <-> compose2 f g <> None
    ; proof_src2: forall f g h: Mor, compose2 f g = Some h -> dom h = dom f
    ; proof_tgt2: forall f g h: Mor, compose2 f g = Some h -> cod h = cod g
    ; proof_idl2: forall (a:Obj) (f:Mor), a = dom f -> compose2 (id a) f = Some f
    ; proof_idr2: forall (a:Obj) (f:Mor), a = cod f -> compose2 f (id a) = Some f
    ; proof_asc2: forall f g h fg gh: Mor,    compose2 f g = Some fg ->
                                              compose2 g h = Some gh ->
                                              compose2 f gh = compose2 fg h
    }
    .

当然,我们当然希望检查这两个观点在某种程度上是等同的。所以我们想写一个函数:

Definition toCategory (Obj Mor:Type) (c:Category2 Obj Mor) : Category Mor := ...
给定类型为Category2的结构的

返回类型为Category的结构。这个功能写起来不是很难。但是,我们还想采取另一种方式,在这里我们有一个直接的挑战:给定Category A类型的结构,在我们希望定义类型Category2的结构之前,我们需要选择一些基础类型ObjMor。选择Mor = A非常自然,我最初决定:

Definition Obj (A:Type) (c:Category A) : Type := { a:A | source c a = a }.

谓词fun (x:A) => source c x = x有效地挑出那些source运算符固定点的箭头,即那些是同一箭头的箭头,即那些可以被视为对象的箭头。

此定义的问题在于,为了构造类型为Category2 Obj Mor的实例,我需要提供对象之间相等的证明,例如dom (id a) = a。这些sig类型的对象实际上是三元组,包含谓词,值和证明该值满足谓词的证据,并且试图证明这些事物之间的平等并不能引导我到任何地方。因此,鉴于我目前对Coq的了解,我被困在我的设计中,并欢迎任何建议。

0 个答案:

没有答案
相关问题