-
Notifications
You must be signed in to change notification settings - Fork 0
/
inversionSL.v
410 lines (389 loc) · 16 KB
/
inversionSL.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
(* 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 *)
(* *)
(****************************************************************************)
(* inversionSL.v *)
(****************************************************************************)
(*****************************************************************************)
(* *)
(* Meta-theory of the explicit substitution calculus lambda-env *)
(* Amokrane Saibi *)
(* *)
(* September 1993 *)
(* *)
(*****************************************************************************)
(* Inversion de sigma_lift (relSL) *)
Require Import sur_les_relations.
Require Import TS.
Require Import sigma_lift.
(*****************
Definition e_invSL:=[b:wsort][M:(TS b)][N:(TS b)]
(<[b:wsort]Prop>Case M of
(* var *) [n:nat] False
(* app *) [M1,M2:terms]
(<[b:wsort]Prop>Case N of
(* var *) [n:nat]False
(* app *) [N1,N2:terms]
((relSL M1 N1) /\ (M2=N2))
\/ ((M1=N1) /\ (relSL M2 N2))
(* lam *) [N1:terms]False
(* env *) [N1:terms][N2:sub_explicits]False
(* id *) False
(* | *) False
(* . *) [N1:terms][N2:sub_explicits]False
(* o *) [N1,N2:sub_explicits]False
(* || *) [N1:sub_explicits]False
(* X *) [n:nat]False
(* x *) [n:nat]False end)
(* lam *) [M1:terms]
(<[b:wsort]Prop>Case N of
(* var *) [n:nat]False
(* app *) [N1,N2:terms]False
(* lam *) [N1:terms](relSL M1 N1)
(* env *) [N1:terms][N2:sub_explicits]False
(* id *) False
(* | *) False
(* . *) [N1:terms][N2:sub_explicits]False
(* o *) [N1,N2:sub_explicits]False
(* || *) [N1:sub_explicits]False
(* X *) [n:nat]False
(* x *) [n:nat]False end)
(* env *) [M1:terms][M2:sub_explicits]
(<[b:wsort]Prop>Case N of
(* var *) [n:nat]
(Ex( ([m:nat] (M1=(var m)) /\ (n=(S m)) /\ (M2=shift) )))
\/ (Ex( ([s:sub_explicits] (M1=(var O)) /\
(M2=(lift s)) /\ (n=O) )))
\/ (Ex( ([s:sub_explicits] (M1=(var O)) /\
(M2=(cons (var n) s)) )))
\/ ((M1=(var n)) /\ (M2=id))
(* app *) [N1,N2:terms]
(Ex( ([a:terms] (Ex( ([b:terms] (M1=(app a b))
/\ (N1=(env a M2)) /\ (N2=(env b M2)) ))) )))
\/ (Ex( ([s:sub_explicits] (M1=(var O)) /\
(M2=(cons (app N1 N2) s)) )))
\/ ((M1=(app N1 N2)) /\ (M2=id))
(* lam *) [N1:terms]
(Ex( ([a:terms] (M1=(lambda a))
/\ (N1=(env a (lift M2))) )))
\/ (Ex( ([s:sub_explicits] (M1=(var O)) /\
(M2=(cons (lambda N1) s)) )))
\/ ((M1=(lambda N1)) /\ (M2=id) )
(* env *) [N1:terms][N2:sub_explicits]
(Ex( ([s:sub_explicits] (M1=(env N1 s)) /\
(N2=(comp s M2)) )))
\/ (Ex( ([n:nat] (M1=(var n)) /\
(M2=(comp shift N2)) /\ (N1=(var (S n))) )))
\/ (Ex( ([s:sub_explicits] (M1=(var O)) /\
(M2=(cons (env N1 N2) s)) )))
\/ (Ex( ([s:sub_explicits] (M1=(var O)) /\
(M2=(comp (lift s) N2)) /\ (N1=(var O)) )))
\/ (Ex( ([n:nat] (Ex( ([a:terms] (M1=(var (S n))) /\
(M2=(cons a N2)) /\ (N1=(var n)) ))) )))
\/ (Ex( ([n:nat] (Ex( ([s:sub_explicits]
(M1=(var (S n))) /\ (M2=(lift s)) /\
(N1=(var n)) /\ (N2=(comp s shift)) ))) )))
\/ (Ex( ([n:nat] (Ex( ([s:sub_explicits]
(Ex( ([t:sub_explicits] (M1=(var (S n))) /\
(M2=(comp (lift s) t)) /\ (N1=(var n)) /\
(N2=(comp s (comp shift t))) ))) ))) )))
\/ ((M1=(env N1 N2)) /\ (M2=id))
\/ ((relSL M1 N1) /\ (M2=N2))
\/ ((M1=N1) /\ (relSL M2 N2))
(* id *) False
(* | *) False
(* . *) [N1:terms][N2:sub_explicits]False
(* o *) [N1,N2:sub_explicits]False
(* || *) [N1:sub_explicits]False
(* X *) [n:nat]
(Ex( ([s:sub_explicits] (M1=(var O)) /\
(M2=(cons (meta_X n) s)) )))
\/ ((M1=(meta_X n)) /\ (M2=id))
(* x *) [n:nat]False end)
(* id *) False
(* | *) False
(* . *) [M1:terms][M2:sub_explicits]
(<[b:wsort]Prop>Case N of
(* var *) [n:nat]False
(* app *) [N1,N2:terms]False
(* lam *) [N1:terms]False
(* env *) [N1:terms][N2:sub_explicits]False
(* id *) False
(* | *) False
(* . *) [N1:terms][N2:sub_explicits]
((relSL M1 N1) /\ (M2=N2))
\/ ((M1=N1) /\ (relSL M2 N2))
(* o *) [N1,N2:sub_explicits]False
(* || *) [N1:sub_explicits]False
(* X *) [n:nat]False
(* x *) [n:nat]False end)
(* o *) [M1,M2:sub_explicits]
(<[b:wsort]Prop>Case N of
(* var *) [n:nat]False
(* app *) [N1,N2:terms]False
(* lam *) [N1:terms]False
(* env *) [N1:terms][N2:sub_explicits]False
(* id *) (Ex( ([a:terms] (M1=shift) /\
(M2=(cons a id)) )))
\/ ((M1=id) /\ (M2=id))
(* | *) (Ex( ([a:terms] (M1=shift) /\
(M2=(cons a shift)) )))
\/ ((M1=id) /\ (M2=shift))
\/ ((M1=shift) /\ (M2=id))
(* . *) [N1:terms][N2:sub_explicits]
(Ex( ([a:terms](Ex( ([s:sub_explicits]
(M1=(cons a s)) /\ (N1=(env a M2)) /\
(N2=(comp s M2)) ))) )))
\/ (Ex( ([a:terms] (M1=shift) /\
(M2=(cons a (cons N1 N2))) )))
\/ (Ex( ([s:sub_explicits]
(Ex( ([t:sub_explicits] (M1=(lift s)) /\ (M2=(cons N1 t))
/\ (N2=(comp s t)) ))) )))
\/ ((M1=id) /\ (M2=(cons N1 N2)))
\/ ((M1=(cons N1 N2)) /\ (M2=id))
(* o *) [N1,N2:sub_explicits]
(Ex( ([t:sub_explicits]
(M1=(comp N1 t)) /\ (N2=(comp t M2)) )))
\/ (Ex( ([a:terms] (M1=shift) /\ (M2=(cons a (comp N1 N2))) )))
\/ ((M1=shift) /\ (M2=(lift N1)) /\ (N2=shift))
\/ (Ex( ([t:sub_explicits] (M1=shift) /\
(M2=(comp (lift N1) t)) /\ (N2=(comp shift t)) )))
\/ (Ex( ([s:sub_explicits]
(Ex( ([t:sub_explicits] (M1=(lift s)) /\
(M2=(comp (lift t) N2)) /\ (N1=(lift (comp s t)))))))))
\/ ((M1=id) /\ (M2=(comp N1 N2)))
\/ ((M1=(comp N1 N2)) /\ (M2=id))
\/ ((relSL M1 N1) /\ (M2=N2))
\/ ((M1=N1) /\ (relSL M2 N2))
(* || *) [N1:sub_explicits]
(Ex( ([a:terms] (M1=shift) /\ (M2=(cons a (lift N1))))))
\/ (Ex( ([s:sub_explicits]
(Ex( ([t:sub_explicits] (M1=(lift s)) /\
(M2=(lift t)) /\ (N1=(comp s t)) ))) )))
\/ ((M1=id) /\ (M2=(lift N1)))
\/ ((M1=(lift N1)) /\ (M2=id))
(* X *) [n:nat]False
(* x *) [n:nat]
(Ex( ([a:terms] (M1=shift) /\ (M2=(cons a (meta_x n))))))
\/ ((M1=id) /\ (M2=(meta_x n)))
\/ ((M1=(meta_x n)) /\ (M2=id)) end)
(* || *) [M1:sub_explicits]
(<[b:wsort]Prop>Case N of
(* var *) [n:nat]False
(* app *) [N1,N2:terms]False
(* lam *) [N1:terms]False
(* env *) [N1:terms][N2:sub_explicits]False
(* id *) (M1=id)
(* | *) False
(* . *) [N1:terms][N2:sub_explicits]False
(* o *) [N1,N2:sub_explicits]False
(* || *) [N1:sub_explicits](relSL M1 N1)
(* X *) [n:nat]False
(* x *) [n:nat]False end)
(* X *) [n:nat]False
(* x *) [n:nat]False end).
****************)
Definition e_invSL (b : wsort) (M N : TS b) :=
match M, N with
| lift M1, id => M1 = id
| lift M1, lift N1 => e_relSL _ M1 N1
| lambda M1, lambda N1 => e_relSL _ M1 N1
| app M1 M2, app N1 N2 =>
e_relSL _ M1 N1 /\ M2 = N2 \/ M1 = N1 /\ e_relSL _ M2 N2
| env M1 M2, var n as V =>
(exists m : nat, M1 = var m /\ n = S m /\ M2 = shift) \/
(exists s : sub_explicits, M1 = var 0 /\ M2 = lift s /\ n = 0) \/
(exists s : sub_explicits, M1 = var 0 /\ M2 = cons V s) \/
M1 = V /\ M2 = id
| env M1 M2, app N1 N2 as A =>
(exists a : terms,
(exists b : terms, M1 = app a b /\ N1 = env a M2 /\ N2 = env b M2)) \/
(exists s : sub_explicits, M1 = var 0 /\ M2 = cons A s) \/
M1 = A /\ M2 = id
| env M1 M2, lambda N1 as L =>
(exists a : terms, M1 = lambda a /\ N1 = env a (lift M2)) \/
(exists s : sub_explicits, M1 = var 0 /\ M2 = cons L s) \/
M1 = L /\ M2 = id
| env M1 M2, env N1 N2 as E =>
(exists s : sub_explicits, M1 = env N1 s /\ N2 = comp s M2) \/
(exists n : nat, M1 = var n /\ M2 = comp shift N2 /\ N1 = var (S n)) \/
(exists s : sub_explicits, M1 = var 0 /\ M2 = cons E s) \/
(exists s : sub_explicits,
M1 = var 0 /\ M2 = comp (lift s) N2 /\ N1 = var 0) \/
(exists n : nat,
(exists a : terms, M1 = var (S n) /\ M2 = cons a N2 /\ N1 = var n)) \/
(exists n : nat,
(exists s : sub_explicits,
M1 = var (S n) /\ M2 = lift s /\ N1 = var n /\ N2 = comp s shift)) \/
(exists n : nat,
(exists s : sub_explicits,
(exists t : sub_explicits,
M1 = var (S n) /\
M2 = comp (lift s) t /\
N1 = var n /\ N2 = comp s (comp shift t)))) \/
M1 = E /\ M2 = id \/
e_relSL _ M1 N1 /\ M2 = N2 \/ M1 = N1 /\ e_relSL _ M2 N2
| env M1 M2, meta_X n =>
(exists s : sub_explicits, M1 = var 0 /\ M2 = cons (meta_X n) s) \/
M1 = meta_X n /\ M2 = id
| cons M1 M2, cons N1 N2 =>
e_relSL _ M1 N1 /\ M2 = N2 \/ M1 = N1 /\ e_relSL _ M2 N2
| comp M1 M2, id =>
(exists a : terms, M1 = shift /\ M2 = cons a id) \/ M1 = id /\ M2 = id
| comp M1 M2, shift =>
(exists a : terms, M1 = shift /\ M2 = cons a shift) \/
M1 = id /\ M2 = shift \/ M1 = shift /\ M2 = id
| comp M1 M2, cons N1 N2 as C =>
(exists a : terms,
(exists s : sub_explicits,
M1 = cons a s /\ N1 = env a M2 /\ N2 = comp s M2)) \/
(exists a : terms, M1 = shift /\ M2 = cons a C) \/
(exists s : sub_explicits,
(exists t : sub_explicits,
M1 = lift s /\ M2 = cons N1 t /\ N2 = comp s t)) \/
M1 = id /\ M2 = C \/ M1 = C /\ M2 = id
| comp M1 M2, comp N1 N2 =>
(exists t : sub_explicits, M1 = comp N1 t /\ N2 = comp t M2) \/
(exists a : terms, M1 = shift /\ M2 = cons a (comp N1 N2)) \/
M1 = shift /\ M2 = lift N1 /\ N2 = shift \/
(exists t : sub_explicits,
M1 = shift /\ M2 = comp (lift N1) t /\ N2 = comp shift t) \/
(exists s : sub_explicits,
(exists t : sub_explicits,
M1 = lift s /\ M2 = comp (lift t) N2 /\ N1 = lift (comp s t))) \/
M1 = id /\ M2 = comp N1 N2 \/
M1 = comp N1 N2 /\ M2 = id \/
e_relSL _ M1 N1 /\ M2 = N2 \/ M1 = N1 /\ e_relSL _ M2 N2
| comp M1 M2, lift N1 as L =>
(exists a : terms, M1 = shift /\ M2 = cons a L) \/
(exists s : sub_explicits,
(exists t : sub_explicits,
M1 = lift s /\ M2 = lift t /\ N1 = comp s t)) \/
M1 = id /\ M2 = L \/ M1 = L /\ M2 = id
| comp M1 M2, meta_x n as x =>
(exists a : terms, M1 = shift /\ M2 = cons a x) \/
M1 = id /\ M2 = x \/ M1 = x /\ M2 = id
| _, _ => False
end.
(***********)
Notation invSL := (e_invSL _) (only parsing).
(* <Warning> : Syntax is discontinued *)
Goal forall (b : wsort) (M N : TS b), e_systemSL _ M N -> e_invSL _ M N.
simple induction 1; simple induction 1; intros.
(* app *)
simpl in |- *; left; exists a0; exists b1; auto.
(* lambda *)
simpl in |- *; left; exists a0; auto.
(* clos *)
simpl in |- *; left; exists s; auto.
(* varshift1 *)
simpl in |- *; left; exists n; auto.
(* varshift2 *)
simpl in |- *; right; left; exists n; auto.
(* fvarcons *)
pattern a0 in |- *; apply terms_ind; intros; simpl in |- *.
(* var *)
do 2 right; left; exists s; auto.
(* app *)
right; left; exists s; auto.
(* lam *)
right; left; exists s; auto.
(* env *)
do 2 right; left; exists s; auto.
(* X *)
left; exists s; auto.
(* fvarlift1 *)
simpl in |- *; right; left; exists s; auto.
(* fvarlift2 *)
simpl in |- *; do 3 right; left; exists s; auto.
(* rvarcons *)
simpl in |- *; do 4 right; left; exists n; exists a0; auto.
(* rvarlift1 *)
simpl in |- *; do 5 right; left; exists n; exists s; auto.
(* rvarlift2 *)
simpl in |- *; do 6 right; left; exists n; exists s; exists t; auto.
(* assenv *)
simpl in |- *; left; exists t0; auto.
(* mapenv *)
simpl in |- *; left; exists a; exists s0; auto.
(* shiftcons *)
pattern s0 in |- *; apply sub_explicits_ind; intros; simpl in |- *.
(* id *)
left; exists a; auto.
(*| *)
left; exists a; auto.
(* . *)
right; left; exists a; auto.
(* o *)
right; left; exists a; auto.
(*|| *)
left; exists a; auto.
(* x *)
left; exists a; auto.
(* shiftlift1 *)
simpl in |- *; do 2 right; left; auto.
(* shiftlift2 *)
simpl in |- *; do 3 right; left; exists t0; auto.
(* lift1 *)
simpl in |- *; right; left; exists s0; exists t0; auto.
(* lift2 *)
simpl in |- *; do 4 right; left; exists s0; exists t0; auto.
(* liftenv *)
simpl in |- *; right; right; left; exists s0; exists t0; auto.
(* idl *)
pattern s0 in |- *; apply sub_explicits_ind; intros; simpl in |- *.
(* id *)
right; auto.
(*| *)
right; left; auto.
(* . *)
do 3 right; left; auto.
(* o *)
do 5 right; left; auto.
(*|| *)
do 2 right; left; auto.
(* x *)
right; left; auto.
(* idr *)
pattern s0 in |- *; apply sub_explicits_ind; intros; simpl in |- *.
(* id *)
right; auto.
(*| *)
right; right; auto.
(* . *)
do 4 right; auto.
(* o *)
do 6 right; left; auto.
(*|| *)
do 3 right; auto.
(* x *)
right; right; auto.
(* liftid *)
simpl in |- *; auto.
(* id *)
pattern a0 in |- *; apply terms_ind; intros; simpl in |- *.
(* var *)
do 3 right; auto.
(* app *)
do 2 right; auto.
(* lam *)
do 2 right; auto.
(* env *)
do 7 right; left; auto.
(* X *)
right; auto.
Save lemma1_inv_systemSL.
Hint Resolve lemma1_inv_systemSL.
Goal forall (b : wsort) (M N : TS b), e_relSL _ M N -> e_invSL _ M N.
simple induction 1; intros; simpl in |- *; auto 11.
Save lemma1_invSL.
Hint Resolve lemma1_invSL.