简体   繁体   English

Coq:关系组合的关联性

[英]Coq: Associativity of relational composition

I am working on verifying a system based on relation algebra.我正在验证基于关系代数的系统。 I found D. Pous's relation algebra library popular among the Coq society.我发现 D. Pous 的关系代数库在 Coq 社会中很受欢迎。

https://github.com/damien-pous/relation-algebra https://github.com/damien-pous/relation-algebra

On this page, binary relation hrel is defined together with its relational composition hrel_dot .在此页面上,二元关系hrel与其关系组合hrel_dot一起定义。

http://perso.ens-lyon.fr/damien.pous/ra/html/RelationAlgebra.rel.html http://perso.ens-lyon.fr/damien.pous/ra/html/RelationAlgebra.rel.html

In this library, a binary relation is defined as在这个库中,二元关系定义为

Universe U.
Definition hrel (n m: Type@{U}) := n -> m -> Prop.

And the relational composition of two binary relations is defined as并且两个二元关系的关系组合定义为

Definition hrel_dot n m p (x: hrel n m) (y: hrel m p): hrel n p :=
  fun i j => exists2 k, x i k & y k j.

I believe that the relational composition is associative, ie我相信关系组合是关联的,即

Lemma dot_assoc:
  forall m n p q (x: hrel m n) (y: hrel n p) (z: hrel p q),
  hrel_dot m p q (hrel_dot m n p x y) z = hrel_dot m n q x (hrel_dot n p q y z).

I got to the place where I think the LHS and RHS of the expressions are equivalent, but I have no clues about the next steps.我到了我认为表达式的 LHS 和 RHS 相等的地方,但我对接下来的步骤一无所知。

______________________________________(1/1)
(exists2 k : p,
   exists2 k0 : n, x x0 k0 & y k0 k & z k x1) =
(exists2 k : n,
   x x0 k & exists2 k0 : p, y k k0 & z k0 x1)

I don't know how to reason about the nested exists2 , although the results seem straightforward by exchanging the variables k and k0 .我不知道如何推断嵌套的exists2 ,尽管通过交换变量kk0看起来结果很简单。

Thanks in advance!提前致谢!

As Ana pointed out, it is not possible to prove this equality without assuming extra axioms.正如 Ana 指出的那样,如果不假设额外的公理,就不可能证明这个等式。 One possibility is to use functional and propositional extensionality:一种可能性是使用功能和命题外延性:

Require Import Coq.Logic.FunctionalExtensionality.
Require Import Coq.Logic.PropExtensionality.

Universe U.
Definition hrel (n m: Type@{U}) := n -> m -> Prop.

Definition hrel_dot n m p (x: hrel n m) (y: hrel m p): hrel n p :=
  fun i j => exists2 k, x i k & y k j.

Lemma dot_assoc:
  forall m n p q (x: hrel m n) (y: hrel n p) (z: hrel p q),
  hrel_dot m p q (hrel_dot m n p x y) z = hrel_dot m n q x (hrel_dot n p q y z).
Proof.
intros m n p q x y z.
apply functional_extensionality. intros a.
apply functional_extensionality. intros b.
apply propositional_extensionality.
unfold hrel_dot; split.
- intros [c [d ? ?] ?]. eauto.
- intros [c ? [d ? ?]]. eauto.
Qed.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM