-
Notifications
You must be signed in to change notification settings - Fork 0
/
Basic_Prop_lex.v
349 lines (330 loc) · 14.1 KB
/
Basic_Prop_lex.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
(********************************************************************************
* Formalization of lambda ex *
* *
* Flavio L. C. de Moura & Daniel L. Ventura, & Washington R. Segundo, 2016 *
*********************************************************************************)
Set Implicit Arguments.
Require Import Metatheory LambdaES_Defs LambdaES_Infra LambdaES_FV.
Require Import Rewriting.
Require Import Equation_C Lambda_Ex.
(** Basic properties **)
Lemma basic_prop1 : forall t t', ((t -->ex t') \/ (t -->lex t')) -> (fv t' << fv t).
Proof.
intros t t' H x; destruct H.
assert (Q : red_fv ex).
apply red_fv_mod_eqC.
apply sys_x_fv.
unfold red_fv in Q.
apply Q; trivial.
assert (Q : red_fv lex).
apply red_fv_mod_eqC.
apply sys_Bx_fv.
unfold red_fv in Q.
apply Q; trivial.
Qed.
Lemma ex_basic_prop2 : forall t t' u, t -->ex t' -> body u ->
((u ^^ t) -->ex* (u ^^ t')).
Proof.
(* intros t t' u H B; unfold open. *)
(* apply body_size_induction with (t := u); *)
(* simpl; trivial. apply star_trans_reduction. *)
(* apply one_step_reduction; trivial. *)
(* intro x. apply reflexive_reduction. *)
(* intros t1 B1 H1. apply in_star_abs_ex with (L := (fv t1)). *)
(* intros x Fr. unfold open. *)
(* apply ctx_sys_ex_regular in H. destruct H. *)
(* replace ({0 ~> pterm_fvar x}({1 ~> t}t1)) with *)
(* ({0 ~> t}({1 ~> pterm_fvar x}(& t1))). *)
(* replace ({0 ~> pterm_fvar x}({1 ~> t'}t1)) with *)
(* ({0 ~> t'}({1 ~> pterm_fvar x}(& t1))). *)
(* apply H1 with (t2 := & t1). *)
(* unfold bswap. rewrite fv_bswap_rec; trivial. *)
(* rewrite (size_bswap_rec 0). reflexivity. *)
(* rewrite body_eq_body'. apply lc_at_open; trivial. *)
(* apply lc_at_bswap; try omega; trivial. *)
(* rewrite subst_com; trivial. rewrite open_bswap; trivial. *)
(* rewrite bswap_rec_id. reflexivity. *)
(* rewrite subst_com; trivial. rewrite open_bswap; trivial. *)
(* rewrite bswap_rec_id. reflexivity. *)
(* intros t1 t2 B1 B2 Ht1 Ht2. *)
(* apply ctx_sys_ex_regular in H. destruct H. *)
(* apply star_closure_composition with *)
(* (u := pterm_app ({0 ~> t'}t1) ({0 ~> t}t2)). *)
(* apply left_star_app_ex; trivial. *)
(* apply body_open_term; trivial. *)
(* apply right_star_app_ex; trivial. *)
(* apply body_open_term; trivial. *)
(* intros t1 t3 B1 B3 Ht3 Ht1. *)
(* apply ctx_sys_ex_regular in H. destruct H. *)
(* apply star_closure_composition with *)
(* (u := ({1 ~> t'}t1 [{0 ~> t}t3])). *)
(* apply left_star_subst_ex with (L := (fv t1)). *)
(* apply body_open_term; trivial. *)
(* intros x Fr. unfold open. *)
(* replace ({0 ~> pterm_fvar x}({1 ~> t}t1)) with *)
(* ({0 ~> t}({1 ~> pterm_fvar x}(& t1))). *)
(* replace ({0 ~> pterm_fvar x}({1 ~> t'}t1)) with *)
(* ({0 ~> t'}({1 ~> pterm_fvar x}(& t1))). *)
(* apply Ht1 with (t2 := & t1). *)
(* unfold bswap. rewrite fv_bswap_rec; trivial. *)
(* rewrite (size_bswap_rec 0). reflexivity. *)
(* rewrite body_eq_body'. apply lc_at_open; trivial. *)
(* apply lc_at_bswap; try omega; trivial. *)
(* rewrite subst_com; trivial. rewrite open_bswap; trivial. *)
(* rewrite bswap_rec_id. reflexivity. *)
(* rewrite subst_com; trivial. rewrite open_bswap; trivial. *)
(* rewrite bswap_rec_id. reflexivity. *)
(* apply right_star_subst_ex; trivial. rewrite body_eq_body'. *)
(* apply lc_at_open; trivial. *)
(* Qed. *)
Admitted.
Lemma lex_basic_prop2 : forall t t' u, t -->lex t' -> body u ->
((u ^^ t) -->lex* (u ^^ t')).
Proof.
(* intros t t' u H B; unfold open. *)
(* apply body_size_induction with (t := u); *)
(* simpl; trivial. apply star_trans_reduction. *)
(* apply one_step_reduction; trivial. *)
(* intro x. apply reflexive_reduction. *)
(* intros t1 B1 H1. apply in_star_abs_lex with (L := (fv t1)). *)
(* intros x Fr. unfold open. *)
(* apply ctx_sys_Bex_regular in H. destruct H. *)
(* replace ({0 ~> pterm_fvar x}({1 ~> t}t1)) with *)
(* ({0 ~> t}({1 ~> pterm_fvar x}(& t1))). *)
(* replace ({0 ~> pterm_fvar x}({1 ~> t'}t1)) with *)
(* ({0 ~> t'}({1 ~> pterm_fvar x}(& t1))). *)
(* apply H1 with (t2 := & t1). *)
(* unfold bswap. rewrite fv_bswap_rec; trivial. *)
(* rewrite (size_bswap_rec 0). reflexivity. *)
(* rewrite body_eq_body'. apply lc_at_open; trivial. *)
(* apply lc_at_bswap; try omega; trivial. *)
(* rewrite subst_com; trivial. rewrite open_bswap; trivial. *)
(* rewrite bswap_rec_id. reflexivity. *)
(* rewrite subst_com; trivial. rewrite open_bswap; trivial. *)
(* rewrite bswap_rec_id. reflexivity. *)
(* intros t1 t2 B1 B2 Ht1 Ht2. *)
(* apply ctx_sys_Bex_regular in H. destruct H. *)
(* apply star_closure_composition with *)
(* (u := pterm_app ({0 ~> t'}t1) ({0 ~> t}t2)). *)
(* apply left_star_app_lex; trivial. *)
(* apply body_open_term; trivial. *)
(* apply right_star_app_lex; trivial. *)
(* apply body_open_term; trivial. *)
(* intros t1 t3 B1 B3 Ht3 Ht1. *)
(* apply ctx_sys_Bex_regular in H. destruct H. *)
(* apply star_closure_composition with *)
(* (u := ({1 ~> t'}t1 [{0 ~> t}t3])). *)
(* apply left_star_subst_lex with (L := (fv t1)). *)
(* apply body_open_term; trivial. *)
(* intros x Fr. unfold open. *)
(* replace ({0 ~> pterm_fvar x}({1 ~> t}t1)) with *)
(* ({0 ~> t}({1 ~> pterm_fvar x}(& t1))). *)
(* replace ({0 ~> pterm_fvar x}({1 ~> t'}t1)) with *)
(* ({0 ~> t'}({1 ~> pterm_fvar x}(& t1))). *)
(* apply Ht1 with (t2 := & t1). *)
(* unfold bswap. rewrite fv_bswap_rec; trivial. *)
(* rewrite (size_bswap_rec 0). reflexivity. *)
(* rewrite body_eq_body'. apply lc_at_open; trivial. *)
(* apply lc_at_bswap; try omega; trivial. *)
(* rewrite subst_com; trivial. rewrite open_bswap; trivial. *)
(* rewrite bswap_rec_id. reflexivity. *)
(* rewrite subst_com; trivial. rewrite open_bswap; trivial. *)
(* rewrite bswap_rec_id. reflexivity. *)
(* apply right_star_subst_lex; trivial. rewrite body_eq_body'. *)
(* apply lc_at_open; trivial. *)
(* Qed. *)
Admitted.
Lemma ex_compat : forall k u t t', (t -->ex t') -> ((open_rec k u t) -->ex (open_rec k u t')).
Proof.
(* intros k u t t' H. *)
(* generalize dependent u. *)
(* generalize dependent k. *)
(* induction H. *)
(* destruct H. destruct H. destruct H0. *)
(* rewrite <- H in H0. *)
(* (* flavio: tbd *) *)
Admitted.
Lemma ex_compat_prop : forall x t t' u, ((t ^ x) -->ex (t' ^ x)) -> ((t ^^ u) -->ex (t' ^^ u)).
Proof.
(* intros x t t' u H. *)
(* case H. clear H. *)
(* intros t0 H. *)
(* destruct H. destruct H. destruct H0. *)
(* exists ((close t0 x) ^^ u) ((close t' x) ^^ u). split. *)
Admitted.
Lemma ex_basic_prop3 : forall t t' u L, term u ->
(forall x, x \notin L -> (t ^ x) -->ex (t' ^ x)) ->
((t ^^ u) -->ex (t' ^^ u)).
Proof.
(* intros t t' u L T H. *)
(* case var_fresh with (L := L \u (fv t) \u (fv t')). *)
(* intros x Fr. apply notin_union in Fr. destruct Fr. *)
(* apply notin_union in H0. destruct H0. *)
(* case (H x); trivial; clear H. *)
(* intros t0 H. case H; clear H; intros t1 H. *)
(* destruct H. destruct H3. *)
(* exists ((close t0 x) ^^ u) ((close t1 x) ^^ u). split. *)
(* apply ctx_sys_x_regular in H3. *)
(* apply eqC_open_var with (x := x); trivial. *)
(* apply fv_close'. rewrite H. *)
(* rewrite <- (open_close_var x). reflexivity. apply H3. split. *)
(* clear H H1 H2 H4 t t'. *)
(* gen_eq t : (close t0 x). gen_eq t' : (close t1 x). *)
(* intros H1 H2. *)
(* replace t0 with (t ^ x) in H3. replace t1 with (t' ^ x) in H3. *)
(* rewrite subst_intro with (x := x). *)
(* rewrite subst_intro with (x := x) (t := t'). *)
(* apply ctx_sys_x_red_out; trivial. *)
(* rewrite H1; apply fv_close'. rewrite H2; apply fv_close'. *)
(* rewrite H1. rewrite open_close_var with (x := x); trivial. *)
(* apply ctx_sys_x_regular in H3. apply H3. *)
(* rewrite H2. rewrite open_close_var with (x := x); trivial. *)
(* apply ctx_sys_x_regular in H3. apply H3. *)
(* apply ctx_sys_x_regular in H3. apply eqC_sym. *)
(* apply eqC_open_var with (x := x); trivial. *)
(* apply fv_close'. rewrite <- H4. *)
(* rewrite <- (open_close_var x). reflexivity. apply H3. *)
(* Qed. *)
Admitted.
Lemma lex_basic_prop3: forall t t' u L, term u ->
(forall x, x \notin L -> (t ^ x) -->lex (t' ^ x)) ->
((t ^^ u) -->lex (t' ^^ u)).
Proof.
(* intros t t' u L T H. *)
(* case var_fresh with (L := L \u (fv t) \u (fv t')). *)
(* intros x Fr. apply notin_union in Fr. destruct Fr. *)
(* apply notin_union in H0. destruct H0. *)
(* case (H x); trivial; clear H. *)
(* intros t0 H. case H; clear H; intros t1 H. *)
(* destruct H. destruct H3. *)
(* exists ((close t0 x) ^^ u) ((close t1 x) ^^ u). split. *)
(* apply ctx_sys_Bx_regular in H3. *)
(* apply eqC_open_var with (x := x); trivial. *)
(* apply fv_close'. rewrite H. *)
(* rewrite <- (open_close_var x). reflexivity. apply H3. split. *)
(* clear H H1 H2 H4 t t'. *)
(* gen_eq t : (close t0 x). gen_eq t' : (close t1 x). *)
(* intros H1 H2. *)
(* replace t0 with (t ^ x) in H3. replace t1 with (t' ^ x) in H3. *)
(* rewrite subst_intro with (x := x). *)
(* rewrite subst_intro with (x := x) (t := t'). *)
(* apply ctx_sys_Bx_red_out; trivial. *)
(* rewrite H1; apply fv_close'. rewrite H2; apply fv_close'. *)
(* rewrite H1. rewrite open_close_var with (x := x); trivial. *)
(* apply ctx_sys_Bx_regular in H3. apply H3. *)
(* rewrite H2. rewrite open_close_var with (x := x); trivial. *)
(* apply ctx_sys_Bx_regular in H3. apply H3. *)
(* apply ctx_sys_Bx_regular in H3. apply eqC_sym. *)
(* apply eqC_open_var with (x := x); trivial. *)
(* apply fv_close'. rewrite <- H4. *)
(* rewrite <- (open_close_var x). reflexivity. apply H3. *)
(* Qed. *)
Admitted.
(** flavio: tests 2016/02/16 *)
Lemma ex_basic_trivial1 : forall x, SN ex (pterm_fvar x).
Proof.
intro x.
exists 0.
apply NF_to_SN0.
unfold NF.
intro t'. intro H.
inversion H.
destruct H0. destruct H0.
apply eqC_fvar_term in H0. subst.
destruct H1.
inversion H0.
inversion H2.
Qed.
Lemma ex_basic_trivial2 : forall n, SN ex (pterm_bvar n).
Proof.
intro n.
exists 0.
apply NF_to_SN0.
unfold NF.
intro t'. intro H.
inversion H.
destruct H0. destruct H0.
apply eqC_bvar_term in H0. subst.
destruct H1.
inversion H0.
inversion H2.
Qed.
Lemma ex_basic_prop4_test : forall t u, SN ex (t ^^ u) -> SN ex t.
Proof.
(* intros t u H. *)
(* unfold SN in H. *)
(* destruct H. *)
(* exists x. *)
(* induction x. *)
(* apply NF_to_SN0. *)
(* apply SN0_to_NF in H. *)
(* unfold NF in *. *)
(* intro t'. intro H'. *)
(* pick_fresh x. *)
(* gen_eq t0 : (close t' x). *)
(* intro H0. *)
(* assert ((t ^^ u) -->ex (t0 ^^ u)). *)
(* apply ex_basic_prop3 with (L := (fv t) \u (fv t0)). *)
Admitted.
Lemma ex_basic_prop4 : forall x t u, SN ex (t ^^ u) ->
term u -> (x \notin fv t) ->
SN ex (t ^ x).
Proof.
(* intros x t u H0 T H1. unfold SN in H0. case H0; clear H0. *)
(* intros n H0. exists n. generalize t H1 H0. clear H0 H1 t. *)
(* induction n. intros. apply NF_to_SN0. apply SN0_to_NF in H0. unfold NF in *|-*. *)
(* intros t' H2. gen_eq t0 : (close t' x). intro H3. replace t' with (t0 ^ x) in H2. *)
(* assert (Q: (t ^^ u) -->ex (t0 ^^ u)). *)
(* apply ex_basic_prop3 with (L := (fv t) \u (fv t0)); trivial. *)
(* intros z H4. apply notin_union in H4. destruct H4. *)
(* apply ctx_sys_ex_red_rename with (x := x); trivial. *)
(* rewrite H3. apply fv_close'. *)
(* assert (Q': ~ (t ^^ u) -->ex (t0 ^^ u)). *)
(* apply H0. *)
(* contradiction. rewrite H3. rewrite open_close_var with (x := x). *)
(* reflexivity. apply ctx_sys_ex_regular in H2. apply H2. *)
(* intros. destruct H0. apply SN_intro. intros. exists n. split; try omega. *)
(* gen_eq t0 : (close t' x). intro H2. *)
(* replace t' with (t0 ^ x). replace t' with (t0 ^ x) in H0. *)
(* apply IHn; trivial. rewrite H2. apply fv_close'. case (H (t0 ^^ u)); trivial. *)
(* apply ex_basic_prop3 with (L := (fv t) \u (fv t0)); trivial. *)
(* intros z H3. apply notin_union in H3. *)
(* apply ctx_sys_ex_red_rename with (x := x); trivial. *)
(* rewrite H2. apply fv_close'. intros k H3. apply WSN with (k := k); try omega. *)
(* apply H3. rewrite H2. rewrite open_close_var with (x := x); trivial. *)
(* apply ctx_sys_ex_regular in H0. apply H0. rewrite H2. *)
(* rewrite open_close_var with (x := x); trivial. *)
(* apply ctx_sys_ex_regular in H0. apply H0. *)
(* Qed. *)
Admitted.
Lemma lex_basic_prop4 : forall x t u, SN lex (t ^^ u) ->
term u -> (x \notin fv t) ->
SN lex (t ^ x).
Proof.
(* intros x t u H0 T H1. unfold SN in H0. case H0; clear H0. *)
(* intros n H0. exists n. generalize t H1 H0. clear H0 H1 t. *)
(* induction n. intros. apply NF_to_SN0. apply SN0_to_NF in H0. unfold NF in *|-*. *)
(* intros t' H2. gen_eq t0 : (close t' x). intro H3. replace t' with (t0 ^ x) in H2. *)
(* assert (Q: (t ^^ u) -->lex (t0 ^^ u)). *)
(* apply lex_basic_prop3 with (L := (fv t) \u (fv t0)); trivial. *)
(* intros z H4. apply notin_union in H4. destruct H4. *)
(* apply ctx_sys_lex_red_rename with (x := x); trivial. *)
(* rewrite H3. apply fv_close'. *)
(* assert (Q': ~ (t ^^ u) -->lex (t0 ^^ u)). *)
(* apply H0. *)
(* contradiction. rewrite H3. rewrite open_close_var with (x := x). *)
(* reflexivity. apply ctx_sys_Bex_regular in H2. apply H2. *)
(* intros. destruct H0. apply SN_intro. intros. exists n. split; try omega. *)
(* gen_eq t0 : (close t' x). intro H2. *)
(* replace t' with (t0 ^ x). replace t' with (t0 ^ x) in H0. *)
(* apply IHn; trivial. rewrite H2. apply fv_close'. case (H (t0 ^^ u)); trivial. *)
(* apply lex_basic_prop3 with (L := (fv t) \u (fv t0)); trivial. *)
(* intros z H3. apply notin_union in H3. *)
(* apply ctx_sys_lex_red_rename with (x := x); trivial. *)
(* rewrite H2. apply fv_close'. intros k H3. apply WSN with (k := k); try omega. *)
(* apply H3. rewrite H2. rewrite open_close_var with (x := x); trivial. *)
(* apply ctx_sys_Bex_regular in H0. apply H0. rewrite H2. *)
(* rewrite open_close_var with (x := x); trivial. *)
(* apply ctx_sys_Bex_regular in H0. apply H0. *)
(* Qed. *)
Admitted.