【问题标题】:What is the standard Cartesian-product construction for Ensemble?Ensemble 的标准笛卡尔积构造是什么?
【发布时间】:2019-05-18 17:03:29
【问题描述】:

我在Coq.Sets.Ensemble 中使用Ensemble 类型的集合。这个库定义了UnionIntersection,但我找不到笛卡尔积的任何构造。

具体来说,我正在寻找一个构造函数,它接受一个Ensemble U 和一个Ensemble V 并返回一个Ensemble (U * V),其中包含所有有序对的集合(u, v),其中u ∈ Uv ∈ V

明确称为Cartesian 的东西会很棒。或者也许有一些方法可以使用普通产品类型嵌入相同的想法?

我试图构建一个这样的引理:

Lemma cartesian_inclusion : forall A B C D : Ensemble U,
    Included U A C /\ Included U B D -> Included (U * U) (A, B) (C, D).

但我收到以下错误:

The term "(A, B)" has type "(Ensemble U * Ensemble U)%type" while it is expected to have type "Ensemble (U * U)".

这种错误是有道理的。 (A, B) 给你一套产品,而我想要的是一套产品。我如何在 Coq 中表达这一点?

【问题讨论】:

    标签: coq cartesian-product set-theory


    【解决方案1】:

    Ensemble U 类型被简单地定义为U -> Prop。我们可以很容易地为集成定义笛卡尔积,如下所示:

    Require Import Coq.Sets.Ensembles.
    
    Definition Cartesian (U V : Type) (A : Ensemble U) (B : Ensemble V) 
      : Ensemble (U * V) :=
      fun x => In _ A (fst x) /\ In _ B (snd x).
    

    这是你所说的引理的证明:

    Lemma cartesian_inclusion U V A B C D :
      Included U A C /\ Included V B D ->
      Included (U * V) (Cartesian _ _ A B) (Cartesian _ _ C D).
    Proof.
    intros [HU HV] [x y] [HA HB].
    split.
    - now apply HU.
    - now apply HV.
    Qed.
    

    顺便说一句,在现代 Coq 开发中很少使用 ensemble 库 —— 它不会给你带来任何东西,而不仅仅是使用谓词。

    【讨论】:

    • 感谢您的回答,这非常有效!您的最后一条评论是“简单地处理谓词通常要容易得多”,这很有趣。您有指向该样式示例的链接吗?
    • @MatthewPiziak 例如,列表上的Forall 谓词(在Coq.Lists.List 中)具有forall A, (A -> Prop) -> list A -> Prop 类型,而不是将集合作为其参数。另外,我认为我在回答中没有清楚地表达自己:使用谓词并不完全是更容易,只是集成是不必要的间接级别。
    猜你喜欢
    • 2017-03-31
    • 1970-01-01
    • 1970-01-01
    • 2011-05-01
    • 2017-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多