forked from vafeiadis/hahn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HahnMinElt.v
370 lines (297 loc) · 9.54 KB
/
HahnMinElt.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
(******************************************************************************)
(** * Minimal elements of relations *)
(******************************************************************************)
Require Import HahnBase HahnList HahnSets HahnRelationsBasic.
Require Import HahnEquational HahnRewrite HahnMaxElt.
Require Import NPeano Omega Setoid.
Set Implicit Arguments.
Definition min_elt A (r: relation A) (a : A) :=
forall b (REL: r b a), False.
Definition wmin_elt A (r: relation A) (a : A) :=
forall b (REL: r b a), a = b.
Section BasicProperties.
Variable A : Type.
Variables r r' r'' : relation A.
Variable a : A.
Lemma min_transp : min_elt r⁻¹ ≡₁ max_elt r.
Proof.
split; unfold min_elt, max_elt, transp, set_subset; ins; desf.
Qed.
Lemma max_transp : max_elt r⁻¹ ≡₁ min_elt r.
Proof.
split; unfold min_elt, max_elt, transp, set_subset; ins; desf.
Qed.
Lemma set_subset_min_elt (S: r' ⊆ r) : min_elt r ⊆₁ min_elt r'.
Proof. unfold min_elt, inclusion, set_subset in *; intuition; eauto. Qed.
Lemma set_subset_wmin_elt (S: r' ⊆ r) : wmin_elt r ⊆₁ wmin_elt r'.
Proof. unfold wmin_elt, inclusion, set_subset in *; intuition; eauto. Qed.
Lemma set_equiv_min_elt (S: r ≡ r') : min_elt r ≡₁ min_elt r'.
Proof. unfold min_elt, same_relation, set_equiv, set_subset in *; intuition; eauto. Qed.
Lemma set_equiv_wmin_elt (S: r ≡ r') : wmin_elt r ≡₁ wmin_elt r'.
Proof. unfold wmin_elt, same_relation, set_equiv in *; intuition; eauto. Qed.
Lemma min_elt_weaken : min_elt r a -> wmin_elt r a.
Proof.
red; ins; exfalso; eauto.
Qed.
Lemma min_elt_union : min_elt r a -> min_elt r' a -> min_elt (r +++ r') a.
Proof.
unfold union; red; ins; desf; eauto.
Qed.
Lemma wmin_elt_union : wmin_elt r a -> wmin_elt r' a -> wmin_elt (r +++ r') a.
Proof.
unfold union; red; ins; desf; eauto.
Qed.
Lemma min_elt_t : min_elt r a -> min_elt (r⁺) a.
Proof.
red; ins; apply clos_trans_t1n in REL; induction REL; eauto.
Qed.
Lemma wmin_elt_rt : wmin_elt r a -> wmin_elt (r*) a.
Proof.
red; ins; apply clos_rt_rt1n in REL; induction REL; intuition; desf; eauto.
Qed.
Lemma wmin_elt_t : wmin_elt r a -> wmin_elt (r⁺) a.
Proof.
by red; ins; eapply wmin_elt_rt, inclusion_t_rt.
Qed.
Lemma wmin_elt_eqv (f: A -> Prop) : wmin_elt (eqv_rel f) a.
Proof.
unfold eqv_rel; red; ins; desf.
Qed.
Lemma wmin_elt_restr_eq B (f: A -> B) :
wmin_elt r a -> wmin_elt (restr_eq_rel f r) a.
Proof.
unfold restr_eq_rel in *; red; ins; desf; eauto.
Qed.
Lemma min_elt_restr_eq B (f: A -> B) :
min_elt r a -> min_elt (restr_eq_rel f r) a.
Proof.
unfold restr_eq_rel in *; red; ins; desf; eauto.
Qed.
Lemma wmin_elt_r :
wmin_elt r a -> wmin_elt (r^?) a.
Proof.
unfold clos_refl; red; ins; desf; eauto.
Qed.
Lemma min_elt_seq1 : min_elt r' a -> min_elt (r ⨾ r') a.
Proof.
unfold seq; red; ins; desf; apply H in REL0; desf; eauto.
Qed.
Lemma wmin_elt_seq2 : wmin_elt r a -> wmin_elt r' a -> wmin_elt (r ⨾ r') a.
Proof.
unfold seq; red; ins; desf; apply H0 in REL0; desf; eauto.
Qed.
Lemma wmin_elt_seq1 : min_elt r' a -> wmin_elt (r ⨾ r') a.
Proof.
unfold seq; red; ins; desf; apply H in REL0; desf; eauto.
Qed.
Lemma min_elt_seq2 : min_elt r a -> wmin_elt r' a -> min_elt (r ⨾ r') a.
Proof.
unfold seq; red; ins; desf; apply H0 in REL0; desf; eauto.
Qed.
End BasicProperties.
Hint Immediate min_elt_weaken : hahn.
Hint Resolve wmin_elt_union min_elt_union : hahn.
Hint Resolve wmin_elt_t wmin_elt_r wmin_elt_rt min_elt_t : hahn.
Hint Resolve min_elt_restr_eq wmin_elt_restr_eq : hahn.
Hint Resolve min_elt_seq1 min_elt_seq2 wmin_elt_seq1 wmin_elt_seq2 : hahn.
Section MoreProperties.
Variable A : Type.
Implicit Type r : relation A.
Lemma seq_min r r' b
(MAX: min_elt r b) (DOM: forall x y, r' x y -> x = b) :
r ⨾ r' ≡ ∅₂.
Proof.
unfold seq; split; red; ins; desf.
apply DOM in H0; desf; eauto.
Qed.
Lemma seq_min_t r r' b
(MAX: min_elt r b) (DOM: forall x y, r' x y -> x = b) :
r ⁺ ⨾ r' ≡ ∅₂.
Proof.
eauto using seq_min with hahn.
Qed.
Lemma seq_min_rt r r' b
(MAX: min_elt r b) (COD: forall x y, r' x y -> x = b) :
r * ⨾ r' ≡ r'.
Proof.
rewrite rtE; relsf; rewrite seq_min_t; relsf.
Qed.
Lemma seq_min_r r r' b
(MAX: min_elt r b) (COD: forall x y, r' x y -> x = b) :
r ^? ⨾ r' ≡ r'.
Proof.
rewrite crE; relsf; rewrite seq_min; relsf.
Qed.
Lemma seq_min_eq r b (MAX: min_elt r b) :
r ⨾⦗eq b⦘ ≡ ∅₂.
Proof.
eapply seq_min; unfold eqv_rel; ins; desf; eauto.
Qed.
Lemma seq_min_t_eq r b (MAX: min_elt r b) :
r⁺ ⨾⦗eq b⦘ ≡ ∅₂.
Proof.
eauto using seq_min_eq with hahn.
Qed.
Lemma seq_min_rt_eq r b (MAX: min_elt r b) :
r* ⨾⦗eq b⦘ ≡ ⦗eq b⦘.
Proof.
rewrite rtE; relsf; rewrite seq_min_t_eq; relsf.
Qed.
Lemma seq_min_r_eq r b (MAX: min_elt r b) :
r^? ⨾⦗eq b⦘ ≡ ⦗eq b⦘.
Proof.
rewrite crE; relsf; rewrite seq_min_eq; relsf.
Qed.
Lemma seq_min_singl r a b (MAX: min_elt r a) :
r ⨾ singl_rel a b ≡ ∅₂.
Proof.
unfold singl_rel, seq; split; red; ins; desf; eauto.
Qed.
Lemma seq_min_t_singl r a b (MAX: min_elt r a) :
r⁺ ⨾ singl_rel a b ≡ ∅₂.
Proof.
eauto using seq_min_singl with hahn.
Qed.
Lemma seq_min_rt_singl r a b (MAX: min_elt r a) :
r* ⨾ singl_rel a b ≡ singl_rel a b.
Proof.
rewrite rtE; relsf; rewrite seq_min_t_singl; relsf.
Qed.
Lemma seq_min_r_singl r a b (MAX: min_elt r a) :
r^? ⨾ singl_rel a b ≡ singl_rel a b.
Proof.
rewrite crE; relsf; rewrite seq_min_singl; relsf.
Qed.
Lemma seq_eqv_min r :
r ⨾ ⦗min_elt r⦘ ≡ ∅₂.
Proof.
basic_solver.
Qed.
Lemma seq_t_eqv_min r :
r⁺ ⨾ ⦗min_elt r⦘ ≡ ∅₂.
Proof.
rewrite ct_end, seqA; seq_rewrite seq_eqv_min; basic_solver.
Qed.
Lemma seq_rt_eqv_min r :
r* ⨾ ⦗min_elt r⦘ ≡ ⦗min_elt r⦘.
Proof.
rewrite rtE; relsf; rewrite seq_t_eqv_min; relsf.
Qed.
Lemma seq_r_eqv_min r :
r^? ⨾ ⦗min_elt r⦘ ≡ ⦗min_elt r⦘.
Proof.
rewrite crE; relsf; rewrite seq_eqv_min; relsf.
Qed.
Lemma seq_eqv_min_transp r :
⦗min_elt r⦘ ⨾ r⁻¹ ≡ ∅₂.
Proof.
basic_solver.
Qed.
Lemma seq_eqv_min_transp_t r :
⦗min_elt r⦘ ⨾ (r⁻¹)⁺ ≡ ∅₂.
Proof.
rewrite ct_begin; seq_rewrite seq_eqv_min_transp; basic_solver.
Qed.
Lemma seq_eqv_min_transp_rt r :
⦗min_elt r⦘ ⨾ (r⁻¹)* ≡ ⦗min_elt r⦘.
Proof.
rewrite rtE; relsf; rewrite seq_eqv_min_transp_t; relsf.
Qed.
Lemma seq_eqv_min_transp_r r :
⦗min_elt r⦘ ⨾ (r⁻¹)^? ≡ ⦗min_elt r⦘.
Proof.
rewrite crE; relsf; rewrite seq_eqv_min_transp; relsf.
Qed.
Lemma seq_wmin r r' b
(MAX: wmin_elt r b) (D: forall x y, r' x y -> x = b) :
r⨾ r' ⊆ r'.
Proof.
unfold seq; red; ins; desf; eauto.
specialize (D _ _ H0); desf; apply MAX in H; desf.
Qed.
Lemma seq_wmin_t r r' b
(MAX: wmin_elt r b) (D: forall x y, r' x y -> x = b) :
r ⁺⨾ r' ⊆ r'.
Proof.
eauto using seq_wmin with hahn.
Qed.
Lemma seq_wmin_rt r r' b
(MAX: wmin_elt r b) (COD: forall x y, r' x y -> x = b) :
r *⨾ r' ≡ r'.
Proof.
rewrite rtE; split; relsf; rewrite seq_wmin_t; relsf.
Qed.
Lemma seq_wmin_r r r' b
(MAX: wmin_elt r b) (COD: forall x y, r' x y -> x = b) :
r ^?⨾ r' ≡ r'.
Proof.
rewrite crE; split; relsf; rewrite seq_wmin; relsf.
Qed.
Lemma seq_wmin_eq r b (MAX: wmin_elt r b) :
r ⨾ ⦗eq b⦘ ⊆ ⦗eq b⦘.
Proof.
eapply seq_wmin; unfold eqv_rel; ins; desf.
Qed.
Lemma seq_wmin_t_eq r b (MAX: wmin_elt r b) :
r ⁺ ⨾ ⦗eq b⦘ ⊆ ⦗eq b⦘.
Proof.
eauto using seq_wmin_eq with hahn.
Qed.
Lemma seq_wmin_rt_eq r b (MAX: wmin_elt r b) :
r * ⨾ ⦗eq b⦘ ≡ ⦗eq b⦘.
Proof.
rewrite rtE; split; relsf; rewrite seq_wmin_t_eq; relsf.
Qed.
Lemma seq_wmin_r_eq r b (MAX: wmin_elt r b) :
r ^? ⨾ ⦗eq b⦘ ≡ ⦗eq b⦘.
Proof.
rewrite crE; split; relsf; rewrite seq_wmin_eq; relsf.
Qed.
Lemma seq_wmin_singl r a b (MAX: wmin_elt r a) :
r ⨾ singl_rel a b ⊆ singl_rel a b.
Proof.
unfold singl_rel, seq; red; ins; desf; eauto.
apply MAX in H; desf.
Qed.
Lemma seq_wmin_t_singl r a b (MAX: wmin_elt r a) :
r ⁺ ⨾ singl_rel a b ⊆ singl_rel a b.
Proof.
eauto using seq_wmin_singl with hahn.
Qed.
Lemma seq_wmin_rt_singl r a b (MAX: wmin_elt r a) :
r * ⨾ singl_rel a b ≡ singl_rel a b.
Proof.
rewrite rtE; split; relsf; rewrite seq_wmin_t_singl; relsf.
Qed.
Lemma seq_wmin_r_singl r a b (MAX: wmin_elt r a) :
r ^? ⨾ singl_rel a b ≡ singl_rel a b.
Proof.
rewrite crE; split; relsf; rewrite seq_wmin_singl; relsf.
Qed.
End MoreProperties.
Hint Unfold min_elt wmin_elt : unfolderDb.
Require Import Morphisms.
Instance min_elt_Proper A : Proper (inclusion --> set_subset) _ := set_subset_min_elt (A:=A).
Instance wmin_elt_Proper A : Proper (inclusion --> set_subset) _ := set_subset_wmin_elt (A:=A).
Instance min_elt_Propere A : Proper (same_relation ==> set_equiv) _ := set_equiv_min_elt (A:=A).
Instance wmin_elt_Propere A : Proper (same_relation ==> set_equiv) _ := set_equiv_wmin_elt (A:=A).
Add Parametric Morphism A : (@min_elt A) with signature
inclusion --> eq ==> Basics.impl as min_elt_mori.
Proof.
unfold inclusion, min_elt, Basics.impl; eauto.
Qed.
Add Parametric Morphism A : (@wmin_elt A) with signature
inclusion --> eq ==> Basics.impl as wmin_elt_mori.
Proof.
unfold inclusion, wmin_elt, Basics.impl; eauto.
Qed.
Add Parametric Morphism A : (@min_elt A) with signature
same_relation --> eq ==> iff as min_elt_more.
Proof.
unfold same_relation, inclusion, min_elt; firstorder.
Qed.
Add Parametric Morphism A : (@wmin_elt A) with signature
same_relation --> eq ==> iff as wmin_elt_more.
Proof.
unfold same_relation, inclusion, wmin_elt; firstorder.
Qed.