Skip to content

Commit a831683

Browse files
committed
port Wellfounded and Sorting to RelationClasses
1 parent a84f351 commit a831683

File tree

8 files changed

+101
-24
lines changed

8 files changed

+101
-24
lines changed

theories/Relations/Operators_Properties.v

Lines changed: 85 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ Section Properties.
2929
Arguments clos_trans [A] R x _.
3030
Arguments clos_trans_1n [A] R x _.
3131
Arguments clos_trans_n1 [A] R x _.
32-
Arguments inclusion [A] R1 R2.
33-
Arguments preorder [A] R.
3432

3533
Variable A : Type.
3634
Variable R : relation A.
@@ -43,56 +41,88 @@ Section Properties.
4341

4442
(** Correctness of the reflexive-transitive closure operator *)
4543

46-
Lemma clos_rt_is_preorder : preorder R*.
44+
#[export] Instance PreOrder_clos_rt : PreOrder R*.
4745
Proof.
46+
split.
47+
- exact (rt_refl A R).
48+
- exact (rt_trans A R).
49+
Qed.
50+
51+
#[deprecated(since="9.1", use=PreOrder_clos_rt)]
52+
#[warning="-deprecated"]
53+
Lemma clos_rt_is_preorder : preorder _ R*.
54+
Proof.
55+
#[warning="-deprecated"]
4856
apply Build_preorder.
4957
- exact (rt_refl A R).
5058
- exact (rt_trans A R).
5159
Qed.
5260

5361
(** Idempotency of the reflexive-transitive closure operator *)
5462

55-
Lemma clos_rt_idempotent : inclusion (R*)* R*.
63+
#[export] Instance subrelation_clos_rt_idemp : subrelation (R*)* R*.
5664
Proof.
57-
red.
5865
induction 1 as [x y H|x|x y z H IH H0 IH0]; auto with sets.
5966
apply rt_trans with y; auto with sets.
6067
Qed.
6168

69+
#[deprecated(since="9.1", use=subrelation_clos_rt_idemp)]
70+
#[warning="-deprecated"]
71+
Lemma clos_rt_idempotent : inclusion _ (R*)* R*.
72+
Proof. apply subrelation_clos_rt_idemp. Qed.
73+
6274
End Clos_Refl_Trans.
6375

6476
Section Clos_Refl_Sym_Trans.
6577

6678
(** Reflexive-transitive closure is included in the
6779
reflexive-symmetric-transitive closure *)
6880

69-
Lemma clos_rt_clos_rst :
70-
inclusion (clos_refl_trans R) (clos_refl_sym_trans R).
81+
#[export] Instance subrelation_clos_rt_clos_rst :
82+
subrelation (clos_refl_trans R) (clos_refl_sym_trans R).
7183
Proof.
7284
red.
7385
induction 1 as [x y H|x|x y z H IH H0 IH0]; auto with sets.
7486
apply rst_trans with y; auto with sets.
7587
Qed.
7688

89+
#[deprecated(since="9.1", use=subrelation_clos_rt_clos_rst)]
90+
#[warning="-deprecated"]
91+
Lemma clos_rt_clos_rst :
92+
inclusion _ (clos_refl_trans R) (clos_refl_sym_trans R).
93+
Proof. apply subrelation_clos_rt_clos_rst. Qed.
94+
7795
(** Reflexive closure is included in the
7896
reflexive-transitive closure *)
7997

80-
Lemma clos_r_clos_rt :
81-
inclusion (clos_refl R) (clos_refl_trans R).
98+
#[export] Instance subrelation_clos_r_clos_rt :
99+
subrelation (clos_refl R) (clos_refl_trans R).
82100
Proof.
83101
induction 1 as [? ?| ].
84102
- constructor; auto.
85103
- constructor 2.
86104
Qed.
87105

88-
Lemma clos_t_clos_rt :
89-
inclusion (clos_trans R) (clos_refl_trans R).
106+
#[deprecated(since="9.1", use=subrelation_clos_r_clos_rt)]
107+
#[warning="-deprecated"]
108+
Lemma clos_r_clos_rt :
109+
inclusion _ (clos_refl R) (clos_refl_trans R).
110+
Proof. apply subrelation_clos_r_clos_rt. Qed.
111+
112+
#[export] Instance subrelation_clos_t_clos_rt :
113+
subrelation (clos_trans R) (clos_refl_trans R).
90114
Proof.
91115
induction 1 as [? ?| ].
92116
- constructor. auto.
93117
- econstructor 3; eassumption.
94118
Qed.
95119

120+
#[deprecated(since="9.1", use=subrelation_clos_t_clos_rt)]
121+
#[warning="-deprecated"]
122+
Lemma clos_t_clos_rt :
123+
inclusion _ (clos_trans R) (clos_refl_trans R).
124+
Proof. apply subrelation_clos_t_clos_rt. Qed.
125+
96126
Lemma clos_rt_t : forall x y z,
97127
clos_refl_trans R x y -> clos_trans R y z ->
98128
clos_trans R x z.
@@ -104,25 +134,42 @@ Section Properties.
104134

105135
(** Correctness of the reflexive-symmetric-transitive closure *)
106136

137+
#[export] Instance Equivalence_clos_rst_is : Equivalence (clos_refl_sym_trans R).
138+
Proof.
139+
split.
140+
- exact (rst_refl A R).
141+
- exact (rst_sym A R).
142+
- exact (rst_trans A R).
143+
Qed.
144+
145+
#[deprecated(since="9.1", use=Equivalence_clos_rst_is)]
146+
#[warning="-deprecated"]
107147
Lemma clos_rst_is_equiv : equivalence A (clos_refl_sym_trans R).
108148
Proof.
109-
apply Build_equivalence.
149+
split.
110150
- exact (rst_refl A R).
111151
- exact (rst_trans A R).
112152
- exact (rst_sym A R).
113153
Qed.
114154

115155
(** Idempotency of the reflexive-symmetric-transitive closure operator *)
116156

117-
Lemma clos_rst_idempotent :
118-
inclusion (clos_refl_sym_trans (clos_refl_sym_trans R))
157+
#[export] Instance subrelation_clos_rst_idemp :
158+
subrelation (clos_refl_sym_trans (clos_refl_sym_trans R))
119159
(clos_refl_sym_trans R).
120160
Proof.
121161
red.
122162
induction 1 as [x y H|x|x y H IH|x y z H IH H0 IH0]; auto with sets.
123163
apply rst_trans with y; auto with sets.
124164
Qed.
125165

166+
#[deprecated(since="9.1", use=subrelation_clos_rst_idemp)]
167+
#[warning="-deprecated"]
168+
Lemma clos_rst_idempotent :
169+
inclusion _ (clos_refl_sym_trans (clos_refl_sym_trans R))
170+
(clos_refl_sym_trans R).
171+
Proof. apply subrelation_clos_rst_idemp. Qed.
172+
126173
End Clos_Refl_Sym_Trans.
127174

128175
Section Equivalences.
@@ -424,33 +471,57 @@ End Properties.
424471

425472
(* begin hide *)
426473
(* Compatibility *)
474+
#[deprecated(since="2009", use=clos_trans_tn1)]
427475
Notation trans_tn1 := clos_trans_tn1 (only parsing).
476+
#[deprecated(since="2009", use=clos_tn1_trans)]
428477
Notation tn1_trans := clos_tn1_trans (only parsing).
478+
#[deprecated(since="2009", use=clos_trans_tn1_iff)]
429479
Notation tn1_trans_equiv := clos_trans_tn1_iff (only parsing).
430480

481+
#[deprecated(since="2009", use=clos_trans_t1n)]
431482
Notation trans_t1n := clos_trans_t1n (only parsing).
483+
#[deprecated(since="2009", use=clos_t1n_trans)]
432484
Notation t1n_trans := clos_t1n_trans (only parsing).
485+
#[deprecated(since="2009", use=clos_trans_t1n_iff)]
433486
Notation t1n_trans_equiv := clos_trans_t1n_iff (only parsing).
434487

488+
#[deprecated(since="2009", use=clos_rtn1_step)]
435489
Notation R_rtn1 := clos_rtn1_step (only parsing).
490+
#[deprecated(since="2009", use=clos_rt_rt1n)]
436491
Notation trans_rt1n := clos_rt_rt1n (only parsing).
492+
#[deprecated(since="2009", use=clos_rt1n_rt)]
437493
Notation rt1n_trans := clos_rt1n_rt (only parsing).
494+
#[deprecated(since="2009", use=clos_rt_rt1n_iff)]
438495
Notation rt1n_trans_equiv := clos_rt_rt1n_iff (only parsing).
439496

497+
#[deprecated(since="2009", use=clos_rt1n_step)]
440498
Notation R_rt1n := clos_rt1n_step (only parsing).
499+
#[deprecated(since="2009", use=clos_rt_rtn1)]
441500
Notation trans_rtn1 := clos_rt_rtn1 (only parsing).
501+
#[deprecated(since="2009", use=clos_rtn1_rt)]
442502
Notation rtn1_trans := clos_rtn1_rt (only parsing).
503+
#[deprecated(since="2009", use=clos_rt_rtn1_iff)]
443504
Notation rtn1_trans_equiv := clos_rt_rtn1_iff (only parsing).
444505

506+
#[deprecated(since="2009", use=clos_rst1n_rst)]
445507
Notation rts1n_rts := clos_rst1n_rst (only parsing).
508+
#[deprecated(since="2009", use=clos_rst1n_trans)]
446509
Notation rts_1n_trans := clos_rst1n_trans (only parsing).
510+
#[deprecated(since="2009", use=clos_rst1n_sym)]
447511
Notation rts1n_sym := clos_rst1n_sym (only parsing).
512+
#[deprecated(since="2009", use=clos_rst_rst1n)]
448513
Notation rts_rts1n := clos_rst_rst1n (only parsing).
514+
#[deprecated(since="2009", use=clos_rst_rst1n_iff)]
449515
Notation rts_rts1n_equiv := clos_rst_rst1n_iff (only parsing).
450516

517+
#[deprecated(since="2009", use=clos_rstn1_rst)]
451518
Notation rtsn1_rts := clos_rstn1_rst (only parsing).
519+
#[deprecated(since="2009", use=clos_rstn1_trans)]
452520
Notation rtsn1_trans := clos_rstn1_trans (only parsing).
521+
#[deprecated(since="2009", use=clos_rstn1_sym)]
453522
Notation rtsn1_sym := clos_rstn1_sym (only parsing).
523+
#[deprecated(since="2009", use=clos_rst_rstn1)]
454524
Notation rts_rtsn1 := clos_rst_rstn1 (only parsing).
525+
#[deprecated(since="2009", use=clos_rst_rstn1_iff)]
455526
Notation rts_rtsn1_equiv := clos_rst_rstn1_iff (only parsing).
456527
(* end hide *)

theories/Sorting/Heap.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
(* * GNU Lesser General Public License Version 2.1 *)
88
(* * (see LICENSE file for the text of the license) *)
99
(************************************************************************)
10+
Local Set Warnings "-deprecated".
1011

1112
(** This file is deprecated, for a tree on list, use [Mergesort.v]. *)
1213

theories/Sorting/PermutEq.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
(* * GNU Lesser General Public License Version 2.1 *)
88
(* * (see LICENSE file for the text of the license) *)
99
(************************************************************************)
10+
Local Set Warnings "-deprecated".
1011

1112
From Stdlib Require Import Relations Setoid SetoidList List Multiset PermutSetoid Permutation.
1213

theories/Sorting/PermutSetoid.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
(* * GNU Lesser General Public License Version 2.1 *)
88
(* * (see LICENSE file for the text of the license) *)
99
(************************************************************************)
10+
Local Set Warnings "-deprecated".
1011

1112
From Stdlib Require Import Lia Relations Multiset SetoidList.
1213

theories/Wellfounded/Inclusion.v

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
(** Author: Bruno Barras *)
1212

1313
From Stdlib Require Import Relation_Definitions.
14+
From Stdlib Require Import RelationClasses.
1415

1516
Section WfInclusion.
1617
Variable A : Type.
1718
Variables R1 R2 : A -> A -> Prop.
1819

19-
Lemma Acc_incl : inclusion A R1 R2 -> forall z:A, Acc R2 z -> Acc R1 z.
20+
Lemma Acc_incl : subrelation R1 R2 -> forall z:A, Acc R2 z -> Acc R1 z.
2021
Proof.
2122
induction 2.
2223
apply Acc_intro; auto with sets.
@@ -25,7 +26,7 @@ Section WfInclusion.
2526
#[local]
2627
Hint Resolve Acc_incl : core.
2728

28-
Theorem wf_incl : inclusion A R1 R2 -> well_founded R2 -> well_founded R1.
29+
Theorem wf_incl : subrelation R1 R2 -> well_founded R2 -> well_founded R1.
2930
Proof.
3031
unfold well_founded; auto with sets.
3132
Qed.

theories/Wellfounded/Lexicographic_Exponentiation.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Section Wf_Lexicographic_Exponentiation.
9494
apply Forall_app. split; [easy|].
9595
constructor; [|easy].
9696
eapply rt_trans.
97-
+ apply clos_r_clos_rt. eassumption.
97+
+ apply subrelation_clos_r_clos_rt. eassumption.
9898
+ apply Forall_app in IH as [_ IH].
9999
destruct l as [|? l].
100100
* now apply rt_refl.
@@ -204,7 +204,7 @@ Section Wf_Lexicographic_Exponentiation.
204204
intros. eapply clos_rt_t; [|apply t_step]; eassumption. }
205205
rewrite <-(app_nil_r (a :: l1)).
206206
apply (clos_trans_list_ext_app_l _ _ _ _ [b]); [assumption|].
207-
destruct l2; [apply rt_refl|apply clos_t_clos_rt].
207+
destruct l2; [apply rt_refl|apply subrelation_clos_t_clos_rt].
208208
now apply clos_trans_list_ext_nil_l.
209209
+ apply (dist_Desc_concat [a]) in Hl1 as [_ ?].
210210
apply (dist_Desc_concat [a]) in Hl2 as [_ ?].

theories/Wellfounded/Transitive_Closure.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Section Wf_Transitive_Closure.
1919

2020
Notation trans_clos := (clos_trans A R).
2121

22-
Lemma incl_clos_trans : inclusion A R trans_clos.
22+
Lemma incl_clos_trans : subrelation R trans_clos.
2323
red; auto with sets.
2424
Qed.
2525

theories/Wellfounded/Union.v

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ Section WfUnion.
2020

2121
Notation Union := (union A R1 R2).
2222

23+
Local Definition commut (R1 R2:relation A) : Prop :=
24+
forall x y:A, R1 y x -> forall z:A, R2 z y -> exists2 y' : A, R2 y' x & R1 z y'.
25+
Context (H : commut R1 R2).
26+
2327
Remark strip_commut :
24-
commut A R1 R2 ->
2528
forall x y:A,
2629
clos_trans A R1 y x ->
2730
forall z:A, R2 z y -> exists2 y' : A, R2 y' x & clos_trans A R1 z y'.
2831
Proof.
29-
induction 2 as [x y| x y z H0 IH1 H1 IH2]; intros.
32+
induction 1 as [x y| x y z H0 IH1 H1 IH2]; intros.
3033
- elim H with y x z; auto with sets; intros x0 H2 H3.
3134
exists x0; auto with sets.
3235

@@ -38,10 +41,9 @@ Section WfUnion.
3841

3942

4043
Lemma Acc_union :
41-
commut A R1 R2 ->
4244
(forall x:A, Acc R2 x -> Acc R1 x) -> forall a:A, Acc R2 a -> Acc Union a.
4345
Proof.
44-
induction 3 as [x H1 H2].
46+
induction 2 as [x H1 H2].
4547
apply Acc_intro; intros.
4648
elim H3; intros; auto with sets.
4749
cut (clos_trans A R1 y x); auto with sets.
@@ -65,7 +67,7 @@ Section WfUnion.
6567

6668

6769
Theorem wf_union :
68-
commut A R1 R2 -> well_founded R1 -> well_founded R2 -> well_founded Union.
70+
well_founded R1 -> well_founded R2 -> well_founded Union.
6971
Proof.
7072
unfold well_founded.
7173
intros.

0 commit comments

Comments
 (0)