-
Notifications
You must be signed in to change notification settings - Fork 0
/
astd.v
288 lines (263 loc) · 9.79 KB
/
astd.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
(* This file contains the formalisation of lemmas 21, 22, 23 *)
Require Import general.
Require Import list_facts.
Require Import basic_defs.
Require Import lterms.
Require Import erase_facts.
Require Import subterms.
Require Import standard.
Require Import sred.
Require Import ared.
Require Import sexpand_std.
Require Import acommute.
(* lemma 21 *)
Lemma lem_standard_expand_below_a_redex :
forall r1 r2 t, RootContr_clc_a r1 r2 -> StronglyStandard r2 -> Subterm t r1 -> t <> r1 ->
Standard t.
Proof.
autounfold; intros.
invert_rcontr_clc_a.
assert (Standard r2).
unfold StronglyStandard in *; pose_red_s; ycrush.
yintuition; simp_hyps; subst; simpl in *.
yinversion H1; yisolve.
assert (Standard T1).
pose lem_basic_standard; ycrush.
assert (Sterm C1).
pose_sterm; ycrush.
assert (Standard (C1 @l T1 @l x)).
apply lem_standard_basic_app_2; ycrush.
pose lem_subterm_standard; ycrush.
pose lem_iterm_standard; ycrush.
yinversion H1; yisolve.
assert (Standard F1).
pose lem_basic_standard; ycrush.
assert (Standard x).
pose lem_iterm_standard; pose_subterm; ycrush.
assert (Sterm C1).
pose_sterm; ycrush.
assert (Standard (C1 @l F1 @l x)).
apply lem_standard_basic_app_2; ycrush.
pose lem_subterm_standard; ycrush.
pose lem_subterm_standard; ycrush.
yinversion H1; yisolve.
assert (Standard x1).
pose lem_iterm_standard; pose_subterm; ycrush.
assert (Standard x) by ycrush.
assert (Sterm C2) by ycrush.
assert (Standard (C2 @l x1 @l x)).
apply lem_standard_basic_app_2; ycrush.
pose lem_subterm_standard; ycrush.
pose lem_subterm_standard; ycrush.
yinversion H1; yisolve.
Reconstr.hobvious (@H0, @H6, @H)
(@subterms.lem_subterm_trans, @standard.lem_strongly_standard_implies_standard, @standard.lem_basic_standard, @standard.lem_subterm_standard)
(@standard.Standard, @standard.StronglyStandard, @sred.lterm_basic, @Coq.Logic.Decidable.decidable).
Reconstr.hobvious (@H, @H6)
(@standard.lem_subterm_standard)
Reconstr.Empty.
yinversion H1; yisolve.
assert (Sterm K1) by ycrush.
assert (Standard (K1 @l x)).
apply lem_standard_basic_app_1; ycrush.
pose lem_subterm_standard; ycrush.
pose lem_iterm_standard; ycrush.
apply lem_standard_expand_below_S_redex with (r1 := r1) (r2 := r2); ycrush.
Qed.
(* lemma 22 *)
Lemma lem_exp_a_sterm : forall y x, Contr_clc_a x y -> Sterm y -> Sterm x.
Proof.
induction y; try yelles 1;
intros x H H1; yinversion H; invert_rcontr_clc_a;
yintuition; try solve [ yintuition; pose_sterm; yelles 2 ];
invert_rcontr_S; yintuition; try solve [ yintuition; pose_sterm; yelles 3 ].
Qed.
Lemma lem_a_std : forall t1 t2, StronglyStandard t2 -> Contr_clc_a t1 t2 -> Std t1.
Proof.
Ltac mytac :=
solve [ invert_rcontr_clc_a; yisolve; yintuition; yintuition | yelles 1 |
exfalso; pose lem_contr_a_basic; yelles 2 ].
intros.
assert (Std t2).
pose lem_strongly_standard_implies_std; ycrush.
ydestruct t1; try yelles 1; try solve [ exfalso; pose lem_contr_a_basic; yelles 2 ].
unfold Std.
assert (Sterm t2).
invert_contr_clc_a; ycrush.
split.
pose lem_exp_a_sterm; ycrush.
split.
intros.
assert (exists u, (Contr_clc_a t' u \/ t' = u) /\ Red_clc_s t2 u).
pose lem_a_commute_red; ycrush.
simp_hyps.
assert (Sterm x).
unfold Std in *; ycrush.
pose lem_exp_a_sterm; ycrush.
ydestruct t1_1; yisolve.
ydestruct t1_1_1; yisolve.
ydestruct t1_1_1_1; yisolve.
repeat invert_contr_clc_a; pose lem_contr_a_snf; mytac.
repeat invert_contr_clc_a; try mytac.
invert_rcontr_clc_a; yintuition; yintuition;
yinversion H0; pose lem_red_s_implies_erased_eqv; pose_erased_eqv; ycrush.
simpl in *; simp_hyps; pose lem_contr_a_to_erased_eqv; pose_erased_eqv; ycrush.
simpl in *; simp_hyps; pose lem_contr_a_to_erased_eqv; pose_erased_eqv; ycrush.
repeat invert_contr_clc_a; try mytac.
simpl in *; simp_hyps.
assert (is_ltup t1_1_2 = true).
ydestruct y'; yisolve; yinversion H5; try invert_rcontr_clc_a; ycrush.
assert (length (tuple_of_lterm y') = length (tuple_of_lterm t1_1_2)).
ydestruct y'; yisolve.
yinversion H5.
invert_rcontr_clc_a; ycrush.
ycrush.
ycrush.
simpl; clear; induction l1; simpl; omega.
ycrush.
simpl in *; simp_hyps.
assert (is_ltup t1_2 = true).
ydestruct y'; yisolve; yinversion H6; try invert_rcontr_clc_a; ycrush.
assert (length (tuple_of_lterm y') = length (tuple_of_lterm t1_2)).
ydestruct y'; yisolve.
yinversion H6.
invert_rcontr_clc_a; ycrush.
ycrush.
ycrush.
simpl; clear; induction l1; simpl; omega.
ycrush.
repeat invert_contr_clc_a; try mytac.
simpl in *; simp_hyps.
assert (is_ltup t1_1_2 = false).
assert (HH: is_ltup t1_1_2 = true \/ is_ltup t1_1_2 = false) by ycrush.
destruct HH; pose lem_contr_a_preserves_is_ltup; ycrush.
ycrush.
simpl in *; simp_hyps.
assert (is_ltup t1_2 = true).
ydestruct y'; yisolve; yinversion H6; try invert_rcontr_clc_a; ycrush.
assert (length (tuple_of_lterm y') = length (tuple_of_lterm t1_2)).
ydestruct y'; yisolve.
yinversion H6.
invert_rcontr_clc_a; ycrush.
ycrush.
ycrush.
simpl; clear; induction l0; simpl; omega.
ycrush.
yinversion H0; simpl in *; fold Contr_clc_a in *; simp_hyps.
invert_rcontr_clc_a; yisolve.
pose lem_exp_a_preserves_not_ltup; ycrush.
pose lem_exp_a_preserves_not_ltup; ycrush.
yintuition; yisolve.
clear H.
induction l0.
pose lem_exp_a_preserves_not_ltup; ycrush.
ycrush.
Qed.
(* lemma 23 *)
Lemma lem_a_standard : forall t1 t2, StronglyStandard t2 -> Contr_clc_a t1 t2 -> Standard t1.
Proof.
unfold Standard; intros t1 t2 H0 H.
assert (HStd: Std t1).
eapply lem_a_std; ycrush.
induction H; fold Contr_clc_a in *.
intros.
assert (x = t1 \/ x <> t1).
apply classic.
destruct H2.
ycrush.
eapply lem_standard_expand_below_a_redex; ycrush.
assert (StronglyStandard x').
eapply lem_reduce_subterm_strongly_standard; pose_subterm; ycrush.
assert (Standard y).
pose lem_reduce_subterm_strongly_standard; apply lem_strongly_standard_implies_standard;
pose_red_s; pose_subterm; ycrush.
assert (Std x).
eapply lem_a_std; pose lem_strongly_standard_implies_std; ycrush.
assert (forall x0 : lterm, Subterm x0 x -> Std x0) by ycrush.
intros x0 HH; yinversion HH; unfold Standard in *; pose_subterm; ycrush.
assert (StronglyStandard y').
eapply lem_reduce_subterm_strongly_standard; pose_subterm; ycrush.
assert (Standard x).
pose lem_reduce_subterm_strongly_standard; apply lem_strongly_standard_implies_standard;
pose_red_s; pose_subterm; ycrush.
assert (Std y).
eapply lem_a_std; pose lem_strongly_standard_implies_std; ycrush.
assert (forall x : lterm, Subterm x y -> Std x) by ycrush.
intros x0 HH; yinversion HH; unfold Standard in *; pose_subterm; ycrush.
assert (StronglyStandard x').
eapply lem_reduce_subterm_strongly_standard; pose_subterm; ycrush.
assert (Standard y).
pose lem_reduce_subterm_strongly_standard; apply lem_strongly_standard_implies_standard;
pose_red_s; pose_subterm; ycrush.
assert (forall u, In u l -> Standard u).
pose lem_reduce_subterm_strongly_standard; pose lem_strongly_standard_implies_standard;
pose_red_s; pose_subterm; ycrush.
assert (Std x).
eapply lem_a_std; pose lem_strongly_standard_implies_std; ycrush.
assert (forall x0 : lterm, Subterm x0 x -> Std x0) by ycrush.
intros x0 HH; yinversion HH; unfold Standard in *; pose_subterm; ycrush.
assert (StronglyStandard y').
eapply lem_reduce_subterm_strongly_standard; pose_subterm; ycrush.
assert (Standard x).
pose lem_reduce_subterm_strongly_standard; apply lem_strongly_standard_implies_standard;
pose_red_s; pose_subterm; ycrush.
assert (forall u, In u l -> Standard u).
pose lem_reduce_subterm_strongly_standard; pose lem_strongly_standard_implies_standard;
pose_red_s; pose_subterm; ycrush.
assert (Std y).
eapply lem_a_std; pose lem_strongly_standard_implies_std; ycrush.
assert (forall x : lterm, Subterm x y -> Std x) by ycrush.
intros x0 HH; yinversion HH; unfold Standard in *; pose_subterm; ycrush.
assert (StronglyStandard z').
eapply lem_reduce_subterm_strongly_standard; pose_subterm; ycrush.
assert (Standard x).
pose lem_reduce_subterm_strongly_standard; apply lem_strongly_standard_implies_standard;
pose_red_s; pose_subterm; ycrush.
assert (Standard y).
pose lem_reduce_subterm_strongly_standard; apply lem_strongly_standard_implies_standard;
pose_red_s; pose_subterm; ycrush.
assert (Std z).
eapply lem_a_std; pose lem_strongly_standard_implies_std; ycrush.
assert (Standard z).
unfold Standard in *; ycrush.
assert (forall u, In u l' -> Standard u).
intros.
assert (In u (l ++ z' :: l')).
Reconstr.hobvious (@H6)
(@at_lem_in_app_2)
Reconstr.Empty.
pose lem_reduce_subterm_strongly_standard; pose lem_strongly_standard_implies_standard;
pose_red_s; pose_subterm; ycrush.
assert (forall u, In u l -> Standard u).
intros.
assert (In u (l ++ z' :: l')).
Reconstr.hobvious (@H7)
(@at_lem_in_app_2)
Reconstr.Empty.
pose lem_reduce_subterm_strongly_standard; pose lem_strongly_standard_implies_standard;
pose_red_s; pose_subterm; ycrush.
assert (forall u, In u (l ++ z :: l') -> Standard u).
induction l.
simpl in *; eauto.
ycrush.
simpl in *; simp_hyps.
assert (forall u : lterm, In u (l ++ z :: l') -> Standard u).
Reconstr.hsimple (@H6, @H5, @H7)
(@at_lem_in_app_1)
Reconstr.Empty.
ycrush.
clear -HStd H2 H3 H8.
unfold Standard in *; pose_subterm; ycrush.
Qed.
Lemma lem_a_strongly_standard :
forall t1 t2, StronglyStandard t2 -> Contr_clc_a t1 t2 -> StronglyStandard t1.
Proof.
intros.
unfold StronglyStandard.
intros.
assert (exists u, Red_clc_s t2 u /\ (Contr_clc_a x u \/ x = u)).
pose lem_a_commute_red; ycrush.
simp_hyps.
destruct H3; pose lem_reduce_subterm_strongly_standard;
pose lem_a_standard; pose_subterm; ycrush.
Qed.