-
Notifications
You must be signed in to change notification settings - Fork 0
/
betapar.v
613 lines (582 loc) · 16.3 KB
/
betapar.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
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
(* Contribution to the Coq Library V6.3 (July 1999) *)
(****************************************************************************)
(* The Calculus of Inductive Constructions *)
(* *)
(* Projet Coq *)
(* *)
(* INRIA ENS-CNRS *)
(* Rocquencourt Lyon *)
(* *)
(* Coq V5.10 *)
(* Nov 25th 1994 *)
(* *)
(****************************************************************************)
(* betapar.v *)
(****************************************************************************)
(*****************************************************************************)
(* Projet Coq - Calculus of Inductive Constructions V5.8 *)
(*****************************************************************************)
(* *)
(* Meta-theory of the explicit substitution calculus lambda-env *)
(* Amokrane Saibi *)
(* *)
(* September 1993 *)
(* *)
(*****************************************************************************)
(* relation bata_par: Beta|| *)
Require Import TS.
Require Import sur_les_relations.
Inductive e_beta_par : forall b : wsort, TS b -> TS b -> Prop :=
| var_bpar : forall n : nat, e_beta_par wt (var n) (var n)
| id_bpar : e_beta_par ws id id
| shift_bpar : e_beta_par ws shift shift
| app_bpar :
forall M N M' N' : terms,
e_beta_par wt M M' ->
e_beta_par wt N N' -> e_beta_par wt (app M N) (app M' N')
| lambda_bpar :
forall M M' : terms,
e_beta_par wt M M' -> e_beta_par wt (lambda M) (lambda M')
| env_bpar :
forall (M M' : terms) (s s' : sub_explicits),
e_beta_par wt M M' ->
e_beta_par ws s s' -> e_beta_par wt (env M s) (env M' s')
| beta_bpar :
forall M N M' N' : terms,
e_beta_par wt M M' ->
e_beta_par wt N N' ->
e_beta_par wt (app (lambda M) N) (env M' (cons N' id))
| cons_bpar :
forall (M M' : terms) (s s' : sub_explicits),
e_beta_par wt M M' ->
e_beta_par ws s s' -> e_beta_par ws (cons M s) (cons M' s')
| lift_bpar :
forall s s' : sub_explicits,
e_beta_par ws s s' -> e_beta_par ws (lift s) (lift s')
| comp_bpar :
forall s s' t t' : sub_explicits,
e_beta_par ws s s' ->
e_beta_par ws t t' -> e_beta_par ws (comp s t) (comp s' t')
| metaX_bpar : forall n : nat, e_beta_par wt (meta_X n) (meta_X n)
| metax_bpar : forall n : nat, e_beta_par ws (meta_x n) (meta_x n).
Hint Resolve var_bpar id_bpar shift_bpar app_bpar lambda_bpar env_bpar
beta_bpar cons_bpar lift_bpar comp_bpar metaX_bpar metax_bpar.
Notation beta_par := (e_beta_par _) (only parsing).
(* <Warning> : Syntax is discontinued *)
Goal forall (b : wsort) (M : TS b), e_beta_par _ M M.
simple induction M; auto.
Save refl_betapar.
Hint Resolve refl_betapar.
Definition e_betapar_inv (b : wsort) (M N : TS b) :=
match M in (TS b) return Prop with
| var n =>
(* var *)
match N in (TS b) return Prop with
| var m =>
(* var *) n = m
(* app *)
| app N1 N2 => False
(* lam *)
| lambda N1 => False
(* env *)
| env N1 N2 => False
(* id *)
| id => False
(* | *)
| shift => False
(* . *)
| cons N1 N2 => False
(* o *)
| comp N1 N2 => False
(* || *)
| lift N1 => False
(* X *)
| meta_X n => False
(* x *)
| meta_x n => False
end
(* app *)
| app M1 M2 =>
match N in (TS b) return Prop with
| var n =>
(* var *) False
(* app *)
| app N1 N2 => e_beta_par _ M1 N1 /\ e_beta_par _ M2 N2
(* lam *)
| lambda N1 => False
(* env *)
| env N1 N2 =>
exists M3 : terms,
(exists N3 : terms,
M1 = lambda M3 /\
e_beta_par _ M3 N1 /\ N2 = cons N3 id /\ e_beta_par _ M2 N3)
(* id *)
| id => False
(* | *)
| shift => False
(* . *)
| cons N1 N2 => False
(* o *)
| comp N1 N2 => False
(* || *)
| lift N1 => False
(* X *)
| meta_X n => False
(* x *)
| meta_x n => False
end
(* lam *)
| lambda M1 =>
match N in (TS b) return Prop with
| var n =>
(* var *) False
(* app *)
| app N1 N2 => False
(* lam *)
| lambda N1 => e_beta_par _ M1 N1
(* env *)
| env N1 N2 => False
(* id *)
| id => False
(* | *)
| shift => False
(* . *)
| cons N1 N2 => False
(* o *)
| comp N1 N2 => False
(* || *)
| lift N1 => False
(* X *)
| meta_X n => False
(* x *)
| meta_x n => False
end
(* env *)
| env M1 M2 =>
match N in (TS b) return Prop with
| var n =>
(* var *) False
(* app *)
| app N1 N2 => False
(* lam *)
| lambda N1 => False
(* env *)
| env N1 N2 => e_beta_par _ M1 N1 /\ e_beta_par _ M2 N2
(* id *)
| id => False
(* | *)
| shift => False
(* . *)
| cons N1 N2 => False
(* o *)
| comp N1 N2 => False
(* || *)
| lift N1 => False
(* X *)
| meta_X n => False
(* x *)
| meta_x n => False
end
(* id *)
| id =>
match N in (TS b) return Prop with
| var n =>
(* var *) False
(* app *)
| app N1 N2 => False
(* lam *)
| lambda N1 => False
(* env *)
| env N1 N2 => False
(* id *)
| id => True
(* | *)
| shift => False
(* . *)
| cons N1 N2 => False
(* o *)
| comp N1 N2 => False
(* || *)
| lift N1 => False
(* X *)
| meta_X n => False
(* x *)
| meta_x n => False
end
(* | *)
| shift =>
match N in (TS b) return Prop with
| var n =>
(* var *) False
(* app *)
| app N1 N2 => False
(* lam *)
| lambda N1 => False
(* env *)
| env N1 N2 => False
(* id *)
| id => False
(* | *)
| shift => True
(* . *)
| cons N1 N2 => False
(* o *)
| comp N1 N2 => False
(* || *)
| lift N1 => False
(* X *)
| meta_X n => False
(* x *)
| meta_x n => False
end
(* . *)
| cons M1 M2 =>
match N in (TS b) return Prop with
| var n =>
(* var *) False
(* app *)
| app N1 N2 => False
(* lam *)
| lambda N1 => False
(* env *)
| env N1 N2 => False
(* id *)
| id => False
(* | *)
| shift => False
(* . *)
| cons N1 N2 => e_beta_par _ M1 N1 /\ e_beta_par _ M2 N2
(* o *)
| comp N1 N2 => False
(* || *)
| lift N1 => False
(* X *)
| meta_X n => False
(* x *)
| meta_x n => False
end
(* o *)
| comp M1 M2 =>
match N in (TS b) return Prop with
| var n =>
(* var *) False
(* app *)
| app N1 N2 => False
(* lam *)
| lambda N1 => False
(* env *)
| env N1 N2 => False
(* id *)
| id => False
(* | *)
| shift => False
(* . *)
| cons N1 N2 => False
(* o *)
| comp N1 N2 => e_beta_par _ M1 N1 /\ e_beta_par _ M2 N2
(* || *)
| lift N1 => False
(* X *)
| meta_X n => False
(* x *)
| meta_x n => False
end
(* || *)
| lift M1 =>
match N in (TS b) return Prop with
| var n =>
(* var *) False
(* app *)
| app N1 N2 => False
(* lam *)
| lambda N1 => False
(* env *)
| env N1 N2 => False
(* id *)
| id => False
(* | *)
| shift => False
(* . *)
| cons N1 N2 => False
(* o *)
| comp N1 N2 => False
(* || *)
| lift N1 => e_beta_par _ M1 N1
(* X *)
| meta_X n => False
(* x *)
| meta_x n => False
end
(* X *)
| meta_X n =>
match N in (TS b) return Prop with
| var n =>
(* var *) False
(* app *)
| app N1 N2 => False
(* lam *)
| lambda N1 => False
(* env *)
| env N1 N2 => False
(* id *)
| id => False
(* | *)
| shift => False
(* . *)
| cons N1 N2 => False
(* o *)
| comp N1 N2 => False
(* || *)
| lift N1 => False
(* X *)
| meta_X m => n = m
(* x *)
| meta_x m => False
end
(* x *)
| meta_x n =>
match N in (TS b) return Prop with
| var n =>
(* var *) False
(* app *)
| app N1 N2 => False
(* lam *)
| lambda N1 => False
(* env *)
| env N1 N2 => False
(* id *)
| id => False
(* | *)
| shift => False
(* . *)
| cons N1 N2 => False
(* o *)
| comp N1 N2 => False
(* || *)
| lift N1 => False
(* X *)
| meta_X m => False
(* x *)
| meta_x m => n = m
end
end.
Notation betapar_inv := (e_betapar_inv _) (only parsing).
(* <Warning> : Syntax is discontinued *)
Goal
forall (b : wsort) (M N : TS b), e_beta_par _ M N -> e_betapar_inv _ M N.
simple induction 1; intros; simpl in |- *; auto.
(* beta *)exists M0; exists N'; auto.
Save lemma1_inv_betapar.
Hint Resolve lemma1_inv_betapar.
Goal
forall (P : terms -> Prop) (n : nat),
P (var n) -> forall M : terms, e_beta_par _ (var n) M -> P M.
intros P n H M H0; cut (e_betapar_inv _ (var n) M).
2: auto.
pattern M in |- *; apply terms_ind.
(* var *)
simple induction 1; assumption.
(* app *)
simple induction 3.
(* lam *)
simple induction 2.
(* env *)
simple induction 2.
(* X *)simple induction 1.
Save case_bvar.
Goal
forall (P : terms -> Prop) (a b : terms),
(forall a' b' : terms,
e_beta_par _ a a' -> e_beta_par _ b b' -> P (app a' b')) ->
(forall a1 a1' b' : terms,
a = lambda a1 ->
e_beta_par _ a1 a1' -> e_beta_par _ b b' -> P (env a1' (cons b' id))) ->
forall M : terms, e_beta_par _ (app a b) M -> P M.
intros P a b H H0 M H1; cut (e_betapar_inv _ (app a b) M).
2: auto.
pattern M in |- *; apply terms_ind.
(* var *)
simple induction 1.
(* app *)
unfold e_betapar_inv at 3 in |- *; intros a' b' H2 H3 H4.
elim H4; intros H5 H6.
apply H; assumption.
(* lam *)
simple induction 2.
(* env *)
unfold e_betapar_inv at 2 in |- *; intros a1' H2 s H3.
elim H3; intros a1 H4; elim H4; intros b' H5.
elim H5; intros H6 H7; elim H7; intros H8 H9; elim H9; intros H10 H11.
try rewrite H6; try rewrite H10; apply (H0 a1); assumption.
(* X *)simple induction 1.
Save case_bapp.
Goal
forall (P : terms -> Prop) (a : terms),
(forall a' : terms, e_beta_par _ a a' -> P (lambda a')) ->
forall M : terms, e_beta_par _ (lambda a) M -> P M.
intros P a H M H0; cut (e_betapar_inv _ (lambda a) M).
2: auto.
pattern M in |- *; apply terms_ind.
(* var *)
simple induction 1.
(* app *)
simple induction 3.
(* lam *)
unfold e_betapar_inv at 2 in |- *; intros a' H1 H2.
apply H; assumption.
(* env *)
simple induction 2.
(* X *)simple induction 1.
Save case_blambda.
Goal
forall (P : terms -> Prop) (a : terms) (s : sub_explicits),
(forall (a' : terms) (s' : sub_explicits),
e_beta_par _ a a' -> e_beta_par _ s s' -> P (env a' s')) ->
forall M : terms, e_beta_par _ (env a s) M -> P M.
intros P a s H M H0; cut (e_betapar_inv _ (env a s) M).
2: auto.
pattern M in |- *; apply terms_ind.
(* var *)
simple induction 1.
(* app *)
simple induction 3.
(* lam *)
simple induction 2.
(* env *)
unfold e_betapar_inv at 2 in |- *; intros a' H1 s' H2.
elim H2; intros; apply H; assumption.
(* X *)simple induction 1.
Save case_benv.
Goal
forall P : sub_explicits -> Prop,
P id -> forall M : sub_explicits, e_beta_par _ id M -> P M.
intros P H M H0; cut (e_betapar_inv _ id M).
2: auto.
pattern M in |- *; apply sub_explicits_ind.
(* id *)
intro; assumption.
(* | *)
simple induction 1.
(* . *)
simple induction 2.
(* o *)
simple induction 3.
(* || *)
simple induction 2.
(* x *)simple induction 1.
Save case_bid.
Goal
forall P : sub_explicits -> Prop,
P shift -> forall M : sub_explicits, e_beta_par _ shift M -> P M.
intros P H M H0; cut (e_betapar_inv _ shift M).
2: auto.
pattern M in |- *; apply sub_explicits_ind.
(* id *)
simple induction 1.
(* | *)
intro; assumption.
(* . *)
simple induction 2.
(* o *)
simple induction 3.
(* || *)
simple induction 2.
(* x *)simple induction 1.
Save case_bshift.
Goal
forall (P : sub_explicits -> Prop) (a : terms) (s : sub_explicits),
(forall (a' : terms) (s' : sub_explicits),
e_beta_par _ a a' -> e_beta_par _ s s' -> P (cons a' s')) ->
forall M : sub_explicits, e_beta_par _ (cons a s) M -> P M.
intros P a s H M H0; cut (e_betapar_inv _ (cons a s) M).
2: auto.
pattern M in |- *; apply sub_explicits_ind.
(* id *)
simple induction 1.
(* | *)
simple induction 1.
(* . *)
unfold e_betapar_inv at 2 in |- *; intros s' H1 a' H2.
elim H2; intros.
apply H; assumption.
(* o *)
simple induction 3.
(* || *)
simple induction 2.
(* x *)simple induction 1.
Save case_bcons.
Goal
forall (P : sub_explicits -> Prop) (s t : sub_explicits),
(forall s' t' : sub_explicits,
e_beta_par _ s s' -> e_beta_par _ t t' -> P (comp s' t')) ->
forall M : sub_explicits, e_beta_par _ (comp s t) M -> P M.
intros P s t H M H0; cut (e_betapar_inv _ (comp s t) M).
2: auto.
pattern M in |- *; apply sub_explicits_ind.
(* id *)
simple induction 1.
(* | *)
simple induction 1.
(* . *)
simple induction 2.
(* o *)
unfold e_betapar_inv at 3 in |- *.
intros s' t' H1 H2 H3; elim H3; intros; apply H; assumption.
(* || *)
simple induction 2.
(* x *)simple induction 1.
Save case_bcomp.
Goal
forall (P : sub_explicits -> Prop) (s : sub_explicits),
(forall s' : sub_explicits, e_beta_par _ s s' -> P (lift s')) ->
forall M : sub_explicits, e_beta_par _ (lift s) M -> P M.
intros P s H M H0; cut (e_betapar_inv _ (lift s) M).
2: auto.
pattern M in |- *; apply sub_explicits_ind.
(* id *)
simple induction 1.
(* | *)
simple induction 1.
(* . *)
simple induction 2.
(* o *)
simple induction 3.
(* || *)
unfold e_betapar_inv at 2 in |- *.
intros s' H1 H2; apply H; assumption.
(* x *)simple induction 1.
Save case_blift.
Goal
forall (P : terms -> Prop) (n : nat),
P (meta_X n) -> forall M : terms, e_beta_par _ (meta_X n) M -> P M.
intros P n H M H0; cut (e_betapar_inv _ (meta_X n) M).
2: auto.
pattern M in |- *; apply terms_ind.
(* var *)
simple induction 1.
(* app *)
simple induction 3.
(* lam *)
simple induction 2.
(* env *)
simple induction 2.
(* X *)simple induction 1; assumption.
Save case_bmetaX.
Goal
forall (P : sub_explicits -> Prop) (n : nat),
P (meta_x n) -> forall M : sub_explicits, e_beta_par _ (meta_x n) M -> P M.
intros P n H M H0; cut (e_betapar_inv _ (meta_x n) M).
2: auto.
pattern M in |- *; apply sub_explicits_ind.
(* id *)
simple induction 1.
(* | *)
simple induction 1.
(* . *)
simple induction 2.
(* o *)
simple induction 3.
(* || *)
simple induction 2.
(* x *)simple induction 1; assumption.
Save case_bmetax.