-
Notifications
You must be signed in to change notification settings - Fork 0
/
typing_proofs.v
563 lines (543 loc) · 14.8 KB
/
typing_proofs.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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
(* This program is free software; you can redistribute it and/or *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1 *)
(* of the License, or (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU Lesser General Public *)
(* License along with this program; if not, write to the Free *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA *)
Require Import processus.
Require Import fresh.
Unset Standard Proposition Elimination Names.
Theorem gettype_not_added_name :
forall (G : env) (p q : PP) (t : type), p <> q -> addenv G p t q = G q.
Proof.
intros G p q t p_not_q.
unfold addenv in |- *.
case (PP_decidable p q).
intro absurd; elim p_not_q; assumption.
intro; reflexivity.
Qed.
Theorem gettype_added_name :
forall (G : env) (p : PP) (t : type), addenv G p t p = t.
Proof.
intros.
unfold addenv in |- *.
case (PP_decidable p p).
intro; reflexivity.
intro absurd; elim absurd; reflexivity.
Qed.
Theorem eqv_addenv :
forall (G D : env) (p : PP) (t : type),
eqvenv G D -> eqvenv (addenv G p t) (addenv D p t).
Proof.
intros G D p t eq1.
unfold eqvenv in |- *.
intro r; unfold addenv in |- *.
case (PP_decidable p r).
intro; reflexivity.
intro; apply eq1.
Qed.
Theorem eqv_trans :
forall G G' G'' : env, eqvenv G G' -> eqvenv G' G'' -> eqvenv G G''.
Proof.
intros.
unfold eqvenv in |- *.
intros.
transitivity (G' p).
apply H.
apply H0.
Qed.
Theorem eqv_typing :
forall G D : env, eqvenv G D -> forall P : proc, typing G P -> typing D P.
Proof.
cut
(forall (G : env) (P : proc),
typing G P -> forall D : env, eqvenv G D -> typing D P).
intro other.
intros G D eqv P typed.
apply other with (G := G).
assumption.
assumption.
intros G P typed; elim typed.
intros; apply tnil.
intros GG p x Q p_reads tail_typed hyprec.
intros D eqGGD.
apply tinp.
cut (D p = GG p).
intro same; rewrite same; assumption.
symmetry in |- *; apply eqGGD.
intros s fresh_s.
apply hyprec.
assumption.
cut (GG p = D p).
intro same; rewrite same.
apply eqv_addenv.
assumption.
apply eqGGD.
intros GG p q Q p_writes q_supported typed0 hyprec D eqv.
cut (D p = GG p).
intro same.
apply tout.
rewrite same.
assumption.
rewrite same.
cut (D q = GG q).
intro same2; rewrite same2.
assumption.
symmetry in |- *; apply eqv.
apply hyprec.
assumption.
symmetry in |- *; apply eqv.
intros GG Q R typedQ hyprecQ typedR hyprecR D eqv.
apply tpar.
apply hyprecQ; assumption.
apply hyprecR; assumption.
intros GG x t Q tail_typed hyprec.
intros D eqv.
apply tres.
intros s fresh_s.
apply hyprec.
assumption.
apply eqv_addenv.
assumption.
intros GG Q typed0 hyprec D eqv; apply tban; apply hyprec; assumption.
intros GG Q R typedQ hyprecQ typedR hyprecR.
intros D eqv; apply tsum.
apply hyprecQ; assumption.
apply hyprecR; assumption.
intros GG p q PP p_both q_both tail_typed hyprec D eqv.
apply tmat.
cut (D p = GG p).
intro same; rewrite same.
assumption.
symmetry in |- *; apply eqv.
cut (D q = GG q).
intro same; rewrite same.
assumption.
symmetry in |- *; apply eqv.
apply hyprec; assumption.
Qed.
Theorem switch_addenv :
forall (G : env) (p q : PP) (t1 t2 : type),
p <> q -> eqvenv (addenv (addenv G p t1) q t2) (addenv (addenv G q t2) p t1).
Proof.
intros G p q t1 t2 p_not_q.
unfold eqvenv in |- *.
intro r.
unfold addenv in |- *.
case (PP_decidable q r); case (PP_decidable p r).
intros p_is_r q_is_r.
rewrite p_is_r in p_not_q.
rewrite q_is_r in p_not_q.
elim p_not_q; reflexivity.
intros; reflexivity.
intros; reflexivity.
intros; reflexivity.
Qed.
Theorem trivial_addenv :
forall (G : env) (p : PP), eqvenv G (addenv G p (G p)).
Proof.
intros.
unfold eqvenv in |- *.
intros q.
unfold addenv in |- *.
case (PP_decidable p q).
intro same; rewrite same.
reflexivity.
intro; reflexivity.
Qed.
Theorem redundant_addenv :
forall (G : env) (P : proc),
typing G P ->
forall (D : env) (p : PP) (t : type),
fresh p P -> eqvenv G (addenv D p t) -> typing D P.
Proof.
intros G P typed.
elim typed.
intros; apply tnil.
(* *************************************************************************
Typage des INP
*************************************************************************
*)
intros G0 p x Q p_reads tail_typed.
intros hyprec D q t fresh_q.
intro eqv.
inversion_clear fresh_q.
apply tinp.
cut (D p = G0 p).
intro same; rewrite same; assumption.
cut (D p = addenv D q t p).
intro same; rewrite same; symmetry in |- *; apply eqv.
symmetry in |- *; apply gettype_not_added_name.
cut (pname p <> pname q).
intro notsame; red in |- *; intro absurd; rewrite absurd in notsame.
elim notsame; reflexivity.
apply freshname_is.
assumption.
intros s fresh_s.
case (PP_decidable q s).
intro same.
rewrite <- same.
cut (D p = G0 p).
intro same2; rewrite same2.
apply eqv_typing with (G := addenv G0 q (getobj (G0 p))).
apply eqv_trans with (G' := addenv (addenv D q t) q (getobj (G0 p))).
apply eqv_addenv.
assumption.
unfold eqvenv in |- *.
intro q0; unfold addenv in |- *.
case (PP_decidable q q0).
intro; reflexivity.
intro; reflexivity.
apply tail_typed.
assumption.
cut (pname p <> pname q).
intro.
cut (D p = addenv D q t p).
intro same2; rewrite same2.
symmetry in |- *; apply eqv.
symmetry in |- *; apply gettype_not_added_name.
red in |- *; intro absurd; rewrite absurd in H1.
elim H1; reflexivity.
apply freshname_is.
assumption.
intro.
apply hyprec with (p0 := q) (t := t).
assumption.
apply fresh_after_subs.
assumption.
assumption.
apply eqv_trans with (G' := addenv (addenv D q t) s (getobj (D p))).
cut (D p = G0 p).
intro same; rewrite same.
apply eqv_addenv.
assumption.
transitivity (addenv D q t p).
symmetry in |- *; apply gettype_not_added_name.
cut (pname p <> pname q).
intro; red in |- *; intro absurd.
rewrite absurd in H1; elim H1; reflexivity.
apply freshname_is; assumption.
symmetry in |- *; apply eqv.
apply switch_addenv.
assumption.
(* *****************************************************************
Typage des OUT
*****************************************************************
*)
intros GG p q Q p_writes q_correct tail_typed hyprec D r t fresh_r eqv.
inversion_clear fresh_r.
cut (D p = GG p).
intro same.
apply tout.
rewrite same.
assumption.
cut (D q = GG q).
intro same2.
rewrite same.
rewrite same2.
assumption.
transitivity (addenv D r t q).
symmetry in |- *; apply gettype_not_added_name.
cut (pname q <> pname r).
intro absurd; red in |- *; intro abs2; rewrite abs2 in absurd.
elim absurd; reflexivity.
apply freshname_is; assumption.
symmetry in |- *; apply eqv.
apply hyprec with (p := r) (t := t).
assumption.
assumption.
transitivity (addenv D r t p).
symmetry in |- *; apply gettype_not_added_name.
cut (pname p <> pname r).
intro absurd; red in |- *; intro abs2; rewrite abs2 in absurd.
elim absurd; reflexivity.
apply freshname_is; assumption.
symmetry in |- *; apply eqv.
(* ******************************************************************
Typage des PAR
******************************************************************
*)
intros GG Q R typQ hyprecQ typR hyprecR.
intros D p t fresh_p eqv.
inversion_clear fresh_p.
apply tpar.
apply hyprecQ with (p := p) (t := t); assumption.
apply hyprecR with (p := p) (t := t); assumption.
(* ******************************************************************
Typage des RES
******************************************************************
*)
intros GG x t Q tail_typed hyprec D p t' fresh_p eqv.
inversion_clear fresh_p.
apply tres.
intros s fresh_s.
case (PP_decidable p s).
intros same; rewrite <- same.
apply eqv_typing with (G := addenv GG p t).
apply eqv_trans with (G' := addenv (addenv D p t') p t).
apply eqv_addenv.
assumption.
unfold eqvenv in |- *.
unfold addenv in |- *.
intro; case (PP_decidable p p0).
intro; reflexivity.
intro; reflexivity.
apply tail_typed.
assumption.
intro not_same; apply hyprec with (p := p) (t0 := t').
assumption.
apply fresh_after_subs.
assumption.
assumption.
apply eqv_trans with (G' := addenv (addenv D p t') s t).
apply eqv_addenv; assumption.
apply switch_addenv.
assumption.
(* ********************************************************************
Typage du BAN et des autres...
********************************************************************
*)
intros GG Q tail_typed hyprec D p t fresh_p eqv.
inversion_clear fresh_p.
apply tban.
apply hyprec with (p := p) (t := t); assumption.
intros G0 Q R typQ hyprecQ typR hyprecR D p t fresh_p eqv.
inversion_clear fresh_p.
apply tsum.
apply hyprecQ with (p := p) (t := t); assumption.
apply hyprecR with (p := p) (t := t); assumption.
(* ********************************************************************
Typage des MAT
********************************************************************
*)
intros GG p q PP p_both q_both tail_typed hyprec DD r t fresh_r eqv.
cut (r <> p).
intro r_not_p.
cut (r <> q).
intro r_not_q.
apply tmat.
cut (DD p = GG p).
intro same; rewrite same.
assumption.
transitivity (addenv DD r t p).
symmetry in |- *; apply gettype_not_added_name.
assumption.
symmetry in |- *; apply eqv.
transitivity (getcap (GG q)).
cut (DD q = addenv DD r t q).
intro same; rewrite same.
cut (addenv DD r t q = GG q).
intro same2; rewrite same2.
reflexivity.
symmetry in |- *; apply eqv.
symmetry in |- *; apply gettype_not_added_name.
assumption.
assumption.
apply hyprec with (p := r) (t := t).
inversion fresh_r.
assumption.
assumption.
inversion_clear fresh_r.
red in |- *; intro.
rewrite H2 in H0.
inversion_clear H0.
elim H3.
reflexivity.
inversion_clear fresh_r.
red in |- *; intro.
rewrite H2 in H.
inversion_clear H.
elim H3; reflexivity.
Qed.
Theorem addenv_unused_name :
forall (G : env) (P : proc),
typing G P ->
forall (q : PP) (t : type), fresh q P -> typing (addenv G q t) P.
Proof.
intros G P typed.
elim typed.
intros; apply tnil.
(* *************************************************************
Typage des INP
*************************************************************
*)
intros GG p x Q.
intros p_reads tail_typed hyprec s t fresh_s.
inversion_clear fresh_s.
apply tinp.
cut (addenv GG s t p = GG p).
intro same; rewrite same.
assumption.
apply gettype_not_added_name.
cut (pname p <> pname s).
intro; red in |- *; intro.
rewrite H2 in H1; elim H1; reflexivity.
apply freshname_is.
assumption.
intros r fresh_r.
cut (addenv GG s t p = GG p).
intro same; rewrite same.
case (PP_decidable r s).
intros same2; rewrite same2.
apply eqv_typing with (G := addenv GG s (getobj (GG p))).
unfold eqvenv in |- *.
unfold addenv in |- *.
intro.
case (PP_decidable s p0).
intros; reflexivity.
intros; reflexivity.
apply tail_typed.
assumption.
intro not_same.
apply eqv_typing with (G := addenv (addenv GG r (getobj (GG p))) s t).
apply switch_addenv.
assumption.
apply hyprec.
assumption.
apply fresh_after_subs.
red in |- *; intro; elim not_same; symmetry in |- *; assumption.
assumption.
apply gettype_not_added_name.
cut (pname p <> pname s).
intro absurd; red in |- *; intro abs2; rewrite abs2 in absurd; elim absurd;
reflexivity.
apply freshname_is; assumption.
(* *******************************************************************
Typage des OUT
*******************************************************************
*)
intros GG p q Q p_writes q_correct tail_typed hyprec r t fresh_r.
inversion_clear fresh_r.
cut (r <> p).
intro r_not_p.
cut (r <> q).
intro r_not_q.
apply tout.
cut (addenv GG r t p = GG p).
intro same; rewrite same.
assumption.
apply gettype_not_added_name.
assumption.
cut (addenv GG r t q = GG q).
intro same; rewrite same.
cut (addenv GG r t p = GG p).
intro same2; rewrite same2; assumption.
apply gettype_not_added_name.
assumption.
apply gettype_not_added_name; assumption.
apply hyprec.
assumption.
cut (pname q <> pname r).
intro absurd; red in |- *; intro abs; rewrite abs in absurd; elim absurd;
reflexivity.
apply freshname_is; assumption.
cut (pname p <> pname r).
intro absurd; red in |- *; intro abs; rewrite abs in absurd; elim absurd;
reflexivity.
apply freshname_is; assumption.
(* *******************************************************************
Typage des PAR
*******************************************************************
*)
intros GG Q R typQ hyprecQ typR hyprecR q t fresh_q.
inversion_clear fresh_q.
apply tpar.
apply hyprecQ.
assumption.
apply hyprecR.
assumption.
(* *******************************************************************
Typage des RES
*******************************************************************
*)
intros GG x t Q tail_typed hyprec q t' fresh_q.
inversion_clear fresh_q.
apply tres.
intros r fresh_r.
case (PP_decidable q r).
intro same; rewrite same.
apply eqv_typing with (G := addenv GG r t).
unfold eqvenv in |- *.
unfold addenv in |- *.
intro s.
case (PP_decidable r s).
intro; reflexivity.
intro; reflexivity.
apply tail_typed.
assumption.
intro not_same.
apply eqv_typing with (G := addenv (addenv GG r t) q t').
apply switch_addenv.
red in |- *; intro; elim not_same; symmetry in |- *; assumption.
apply hyprec.
assumption.
apply fresh_after_subs.
assumption.
assumption.
intros GG Q typed0 hyprec q t fresh_q.
inversion_clear fresh_q.
apply tban.
apply hyprec; assumption.
intros G0 Q R typQ hyprecQ typR hyprecR q t fresh_q.
inversion_clear fresh_q.
apply tsum.
apply hyprecQ; assumption.
apply hyprecR; assumption.
(* ****************************************************************
Typage des MATCH
****************************************************************
*)
intros GG p q PP p_both q_both tail_typed hyprec r t fresh_r.
inversion_clear fresh_r.
apply tmat.
cut (addenv GG r t p = GG p).
intro same; rewrite same.
assumption.
apply gettype_not_added_name.
red in |- *; intro same.
rewrite same in H.
inversion_clear H.
elim H2; reflexivity.
cut (addenv GG r t q = GG q).
intro same; rewrite same.
assumption.
apply gettype_not_added_name.
red in |- *; intro same; rewrite same in H0.
inversion_clear H0.
elim H2; reflexivity.
apply hyprec.
assumption.
Qed.
Theorem eqe_refl : forall G : env, eqvenv G G.
Proof.
intro; unfold eqvenv in |- *.
intro p; reflexivity.
Qed.
Theorem eqe_sym : forall G D : env, eqvenv G D -> eqvenv D G.
Proof.
intros G D.
intro e.
unfold eqvenv in |- *.
intros.
symmetry in |- *; apply e.
Qed.
Theorem eqe_mask :
forall (G : env) (p : PP) (t1 t2 : type),
eqvenv (addenv (addenv G p t1) p t2) (addenv G p t2).
Proof.
intros.
unfold eqvenv in |- *.
intro r.
unfold addenv in |- *.
case (PP_decidable p r).
intro; reflexivity.
intro; reflexivity.
Qed.