-
Notifications
You must be signed in to change notification settings - Fork 15
/
HahnMaxElt.v
365 lines (293 loc) · 9.25 KB
/
HahnMaxElt.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
(******************************************************************************)
(** * Maximal elements of relations *)
(******************************************************************************)
Require Import HahnBase HahnList HahnSets HahnRelationsBasic.
Require Import HahnEquational HahnRewrite.
Require Import Arith Setoid.
Set Implicit Arguments.
Definition max_elt A (r: relation A) (a : A) :=
forall b (REL: r a b), False.
Definition wmax_elt A (r: relation A) (a : A) :=
forall b (REL: r a b), a = b.
Section BasicProperties.
Variable A : Type.
Variables r r' r'' : relation A.
Variable a : A.
Lemma set_subset_max_elt (S: r' ⊆ r) : max_elt r ⊆₁ max_elt r'.
Proof. unfold max_elt, inclusion, set_subset in *; intuition; eauto. Qed.
Lemma set_subset_wmax_elt (S: r' ⊆ r) : wmax_elt r ⊆₁ wmax_elt r'.
Proof. unfold wmax_elt, inclusion, set_subset in *; intuition; eauto. Qed.
Lemma set_equiv_max_elt (S: r ≡ r') : max_elt r ≡₁ max_elt r'.
Proof. unfold max_elt, same_relation, set_equiv, set_subset in *; intuition; eauto. Qed.
Lemma set_equiv_wmax_elt (S: r ≡ r') : wmax_elt r ≡₁ wmax_elt r'.
Proof. unfold wmax_elt, same_relation, set_equiv in *; intuition; eauto. Qed.
Lemma max_elt_weaken : max_elt r a -> wmax_elt r a.
Proof.
red; ins; exfalso; eauto.
Qed.
Lemma max_elt_union : max_elt r a -> max_elt r' a -> max_elt (r +++ r') a.
Proof.
unfold union; red; ins; desf; eauto.
Qed.
Lemma wmax_elt_union : wmax_elt r a -> wmax_elt r' a -> wmax_elt (r +++ r') a.
Proof.
unfold union; red; ins; desf; eauto.
Qed.
Lemma max_elt_t : max_elt r a -> max_elt (r⁺) a.
Proof.
red; ins; apply clos_trans_t1n in REL; induction REL; eauto.
Qed.
Lemma wmax_elt_rt : wmax_elt r a -> wmax_elt (r*) a.
Proof.
red; ins; apply clos_rt_rtn1 in REL; induction REL; desf; eauto.
Qed.
Lemma wmax_elt_t : wmax_elt r a -> wmax_elt (r⁺) a.
Proof.
by red; ins; eapply wmax_elt_rt, inclusion_t_rt.
Qed.
Lemma wmax_elt_eqv (f: A -> Prop) : wmax_elt (eqv_rel f) a.
Proof.
unfold eqv_rel; red; ins; desf.
Qed.
Lemma wmax_elt_restr_eq B (f: A -> B) :
wmax_elt r a -> wmax_elt (restr_eq_rel f r) a.
Proof.
unfold restr_eq_rel in *; red; ins; desf; eauto.
Qed.
Lemma max_elt_restr_eq B (f: A -> B) :
max_elt r a -> max_elt (restr_eq_rel f r) a.
Proof.
unfold restr_eq_rel in *; red; ins; desf; eauto.
Qed.
Lemma wmax_elt_r :
wmax_elt r a -> wmax_elt (r^?) a.
Proof.
unfold clos_refl; red; ins; desf; eauto.
Qed.
Lemma max_elt_seq1 : max_elt r a -> max_elt (r ⨾ r') a.
Proof.
unfold seq; red; ins; desf; apply H in REL; desf; eauto.
Qed.
Lemma wmax_elt_seq2 : wmax_elt r a -> wmax_elt r' a -> wmax_elt (r ⨾ r') a.
Proof.
unfold seq; red; ins; desf; apply H in REL; desf; eauto.
Qed.
Lemma wmax_elt_seq1 : max_elt r a -> wmax_elt (r ⨾ r') a.
Proof.
unfold seq; red; ins; desf; apply H in REL; desf; eauto.
Qed.
Lemma max_elt_seq2 : wmax_elt r a -> max_elt r' a -> max_elt (r ⨾ r') a.
Proof.
unfold seq; red; ins; desf; apply H in REL; desf; eauto.
Qed.
End BasicProperties.
Global Hint Immediate max_elt_weaken : hahn.
Global Hint Resolve wmax_elt_union max_elt_union : hahn.
Global Hint Resolve wmax_elt_t wmax_elt_r wmax_elt_rt max_elt_t : hahn.
Global Hint Resolve max_elt_restr_eq wmax_elt_restr_eq : hahn.
Global Hint Resolve max_elt_seq1 max_elt_seq2 wmax_elt_seq1 wmax_elt_seq2 : hahn.
Section MoreProperties.
Variable A : Type.
Implicit Type r : relation A.
Lemma seq_max r r' b
(MAX: max_elt r' b) (COD: forall x y, r x y -> y = b) :
r ⨾ r' ≡ ∅₂.
Proof.
unfold seq; split; red; ins; desf.
apply COD in H; desf; eauto.
Qed.
Lemma seq_max_t r r' b
(MAX: max_elt r' b) (COD: forall x y, r x y -> y = b) :
r⨾ r' ⁺ ≡ ∅₂.
Proof.
eauto using seq_max with hahn.
Qed.
Lemma seq_max_rt r r' b
(MAX: max_elt r' b) (COD: forall x y, r x y -> y = b) :
r ⨾ r'* ≡ r.
Proof.
rewrite rtE; relsf; rewrite seq_max_t; relsf.
Qed.
Lemma seq_max_r r r' b
(MAX: max_elt r' b) (COD: forall x y, r x y -> y = b) :
r ⨾ r'^? ≡ r.
Proof.
rewrite crE; relsf; rewrite seq_max; relsf.
Qed.
Lemma seq_eq_max r b (MAX: max_elt r b) :
⦗eq b⦘ ⨾ r ≡ ∅₂.
Proof.
eapply seq_max; unfold eqv_rel; ins; desf; eauto.
Qed.
Lemma seq_eq_max_t r b (MAX: max_elt r b) :
⦗eq b⦘ ⨾ r⁺ ≡ ∅₂.
Proof.
eauto using seq_eq_max with hahn.
Qed.
Lemma seq_eq_max_rt r b (MAX: max_elt r b) :
⦗eq b⦘ ⨾ r* ≡ ⦗eq b⦘.
Proof.
rewrite rtE; relsf; rewrite seq_eq_max_t; relsf.
Qed.
Lemma seq_eq_max_r r b (MAX: max_elt r b) :
⦗eq b⦘ ⨾ r^? ≡ ⦗eq b⦘.
Proof.
rewrite crE; relsf; rewrite seq_eq_max; relsf.
Qed.
Lemma seq_singl_max r a b (MAX: max_elt r b) :
singl_rel a b ⨾ r ≡ ∅₂.
Proof.
unfold singl_rel, seq; split; red; ins; desf; eauto.
Qed.
Lemma seq_singl_max_t r a b (MAX: max_elt r b) :
singl_rel a b ⨾ r⁺ ≡ ∅₂.
Proof.
eauto using seq_singl_max with hahn.
Qed.
Lemma seq_singl_max_rt r a b (MAX: max_elt r b) :
singl_rel a b ⨾ r* ≡ singl_rel a b.
Proof.
rewrite rtE; relsf; rewrite seq_singl_max_t; relsf.
Qed.
Lemma seq_singl_max_r r a b (MAX: max_elt r b) :
singl_rel a b ⨾ r^? ≡ singl_rel a b.
Proof.
rewrite crE; relsf; rewrite seq_singl_max; relsf.
Qed.
Lemma seq_eqv_max r :
⦗max_elt r⦘ ⨾ r ≡ (∅₂).
Proof.
basic_solver.
Qed.
Lemma seq_eqv_max_t r :
⦗max_elt r⦘ ⨾ r⁺ ≡ (∅₂).
Proof.
rewrite ct_begin; seq_rewrite seq_eqv_max; basic_solver.
Qed.
Lemma seq_eqv_max_rt r :
⦗max_elt r⦘ ⨾ r* ≡ ⦗max_elt r⦘.
Proof.
rewrite rtE; relsf; rewrite seq_eqv_max_t; relsf.
Qed.
Lemma seq_eqv_max_r r :
⦗max_elt r⦘ ⨾ r^? ≡ ⦗max_elt r⦘.
Proof.
rewrite crE; relsf; rewrite seq_eqv_max; relsf.
Qed.
Lemma transp_seq_eqv_max r :
r⁻¹ ⨾ ⦗max_elt r⦘ ≡ (∅₂).
Proof.
basic_solver.
Qed.
Lemma transp_seq_eqv_max_t r :
(r⁻¹)⁺ ⨾ ⦗max_elt r⦘ ≡ (∅₂).
Proof.
rewrite ct_end, !seqA; seq_rewrite transp_seq_eqv_max; basic_solver.
Qed.
Lemma transp_seq_eqv_max_rt r :
(r⁻¹)* ⨾ ⦗max_elt r⦘ ≡ ⦗max_elt r⦘.
Proof.
rewrite rtE; relsf; rewrite transp_seq_eqv_max_t; relsf.
Qed.
Lemma transp_seq_eqv_max_r r :
(r⁻¹)^? ⨾ ⦗max_elt r⦘ ≡ ⦗max_elt r⦘.
Proof.
rewrite crE; relsf; rewrite transp_seq_eqv_max; relsf.
Qed.
Lemma seq_wmax r r' b
(MAX: wmax_elt r' b) (COD: forall x y, r x y -> y = b) :
r⨾ r' ⊆ r.
Proof.
unfold seq; red; ins; desf; eauto.
specialize (COD _ _ H); desf; apply MAX in H0; desf.
Qed.
Lemma seq_wmax_t r r' b
(MAX: wmax_elt r' b) (COD: forall x y, r x y -> y = b) :
r⨾ r' ⁺ ⊆ r.
Proof.
eauto using seq_wmax with hahn.
Qed.
Lemma seq_wmax_rt r r' b
(MAX: wmax_elt r' b) (COD: forall x y, r x y -> y = b) :
r⨾ r' * ≡ r.
Proof.
rewrite rtE; split; relsf; rewrite seq_wmax_t; relsf.
Qed.
Lemma seq_wmax_r r r' b
(MAX: wmax_elt r' b) (COD: forall x y, r x y -> y = b) :
r⨾ r' ^? ≡ r.
Proof.
rewrite crE; split; relsf; rewrite seq_wmax; relsf.
Qed.
Lemma seq_eq_wmax r b (MAX: wmax_elt r b) :
⦗eq b⦘⨾ r ⊆ ⦗eq b⦘.
Proof.
eapply seq_wmax; unfold eqv_rel; ins; desf.
Qed.
Lemma seq_eq_wmax_t r b (MAX: wmax_elt r b) :
⦗eq b⦘⨾ r ⁺ ⊆ ⦗eq b⦘.
Proof.
eauto using seq_eq_wmax with hahn.
Qed.
Lemma seq_eq_wmax_rt r b (MAX: wmax_elt r b) :
⦗eq b⦘⨾ r * ≡ ⦗eq b⦘.
Proof.
rewrite rtE; split; relsf; rewrite seq_eq_wmax_t; relsf.
Qed.
Lemma seq_eq_wmax_r r b (MAX: wmax_elt r b) :
⦗eq b⦘⨾ r ^? ≡ ⦗eq b⦘.
Proof.
rewrite crE; split; relsf; rewrite seq_eq_wmax; relsf.
Qed.
Lemma seq_singl_wmax r a b (MAX: wmax_elt r b) :
singl_rel a b⨾ r ⊆ singl_rel a b.
Proof.
unfold singl_rel, seq; red; ins; desf; eauto.
apply MAX in H0; desf.
Qed.
Lemma seq_singl_wmax_t r a b (MAX: wmax_elt r b) :
singl_rel a b⨾ r ⁺ ⊆ singl_rel a b.
Proof.
eauto using seq_singl_wmax with hahn.
Qed.
Lemma seq_singl_wmax_rt r a b (MAX: wmax_elt r b) :
singl_rel a b⨾ r * ≡ singl_rel a b.
Proof.
rewrite rtE; split; relsf; rewrite seq_singl_wmax_t; relsf.
Qed.
Lemma seq_singl_wmax_r r a b (MAX: wmax_elt r b) :
singl_rel a b⨾ r ^? ≡ singl_rel a b.
Proof.
rewrite crE; split; relsf; rewrite seq_singl_wmax; relsf.
Qed.
End MoreProperties.
Global Hint Unfold max_elt wmax_elt : unfolderDb.
Require Import Morphisms.
#[export]
Instance max_elt_Proper A : Proper (_ --> _) _ := set_subset_max_elt (A:=A).
#[export]
Instance wmax_elt_Proper A : Proper (_ --> _) _ := set_subset_wmax_elt (A:=A).
#[export]
Instance max_elt_Propere A : Proper (_ ==> _) _ := set_equiv_max_elt (A:=A).
#[export]
Instance wmax_elt_Propere A : Proper (_ ==> _) _ := set_equiv_wmax_elt (A:=A).
Add Parametric Morphism A : (@max_elt A) with signature
inclusion --> eq ==> Basics.impl as max_elt_mori.
Proof.
unfold inclusion, max_elt, Basics.impl; eauto.
Qed.
Add Parametric Morphism A : (@wmax_elt A) with signature
inclusion --> eq ==> Basics.impl as wmax_elt_mori.
Proof.
unfold inclusion, wmax_elt, Basics.impl; eauto.
Qed.
Add Parametric Morphism A : (@max_elt A) with signature
same_relation --> eq ==> iff as max_elt_more.
Proof.
unfold same_relation, inclusion, max_elt; firstorder.
Qed.
Add Parametric Morphism A : (@wmax_elt A) with signature
same_relation --> eq ==> iff as wmax_elt_more.
Proof.
unfold same_relation, inclusion, wmax_elt; firstorder.
Qed.