-
Notifications
You must be signed in to change notification settings - Fork 0
/
standard.v
286 lines (260 loc) · 8.96 KB
/
standard.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
(* This file contains the definition of standard terms and the
formalisation of their basic properties (including those stated in
lemma 9) *)
Require Import general.
Require Import list_facts.
Require Import iterms.
Require Import lterms.
Require Import subterms.
Require Import erasure.
Require Import sred.
Definition Std t :=
match t with
| itm _ => True
| ltup x y l =>
is_ltup x = false /\ is_ltup y = false /\ forall x, In x l -> is_ltup x = false
| _ =>
Sterm t /\ (forall t', Red_clc_s t t' -> Sterm t') /\
match t with
| C1 @l z @l _ @l _ => sNF z -> z = T1 \/ z = F1
| C2 @l _ @l x @l y => ErasedEqv x y
| S1 l @l x @l y @l z => is_ltup y = true /\ is_ltup z = true /\
(forall n, In n l -> n > 0) /\
lst_sum l < length (tuple_of_lterm z) /\
(length (tuple_of_lterm y) = length l)
| S2 n @l x @l y @l z => is_ltup y = false /\ is_ltup z = true /\
n > 0 /\ n < length (tuple_of_lterm z)
| _ => True
end
end.
Definition Standard t := forall x, Subterm x t -> Std x.
Definition StronglyStandard t := forall x, Red_clc_s t x -> Standard x.
Definition Leadsto t t' := StronglyStandard t /\ (forall x, Red_clc_s t x -> sNF x -> t' = x).
Hint Unfold sNF Std Standard StronglyStandard Leadsto : unfold_hints.
Lemma lem_subterm_standard : forall x, Standard x -> forall y, Subterm y x -> Standard y.
Proof.
intro x; lterm_induction x; unfold Standard in *; intros; destruct y;
try solve [ pose_subterm; iauto 1 ].
Qed.
Lemma lem_reduce_subterm_strongly_standard :
forall x, StronglyStandard x -> forall y, Red_clc_s x y ->
forall z, Subterm z y -> StronglyStandard z.
Proof.
autounfold with unfold_hints.
pose lem_subterm_standard.
intros.
assert (exists y', Red_clc_s y y' /\ Subterm x0 y').
pose_red_s; ycrush.
simp_hyps.
assert (exists y', Red_clc_s x y' /\ Subterm x0 y').
pose_red_s; ycrush.
simp_hyps; eauto.
Qed.
Lemma lem_subterm_strongly_standard :
forall x, StronglyStandard x -> forall y, Subterm y x -> StronglyStandard y.
Proof.
pose lem_reduce_subterm_strongly_standard; unfold Red_clc_s in *; pose_rt; ycrush.
Qed.
Lemma lem_standard_not_reduces_to_tuple :
forall x, Standard x -> is_ltup x = false ->
forall y, Red_clc_s x y -> is_ltup y = false.
Proof.
unfold Standard.
intros.
yinversion H0.
assert (Std x) by (pose_subterm; eauto).
Ltac mytac :=
match goal with
| [ H : Red_clc_s ?x ?y |- ?G ] =>
assert (y = x) by (pose lem_red_s_basic; unfold lterm_basic in *; yelles 1);
sintuition
end.
ydestruct x; simpl in *; simp_hyps; try mytac.
assert (Sterm y) by auto.
sterm_tac 1.
Qed.
Lemma lem_strongly_standard_c1_red_s :
forall x, StronglyStandard x -> forall z y1 y2, Subterm (C1 @l z @l y1 @l y2) x ->
Red_clc_s z T1 \/ Red_clc_s z F1.
Proof.
intros.
generalize (lem_red_s_wn z); yintro.
assert (StronglyStandard (C1 @l z @l y1 @l y2)).
pose lem_reduce_subterm_strongly_standard; pose lem_red_s_refl; ycrush.
assert (Red_clc_s (C1 @l z @l y1 @l y2) (C1 @l x0 @l y1 @l y2)).
eauto using lem_red_s_refl, lem_red_s_cong_l, lem_red_s_cong_r.
assert (Std (C1 @l x0 @l y1 @l y2)).
unfold StronglyStandard, Standard in *; pose_red_s; pose_subterm; ycrush.
ycrush.
Qed.
Lemma lem_standard_implies_std : forall x, Standard x -> Std x.
Proof.
unfold Standard in *; pose_subterm; ycrush.
Qed.
Lemma lem_strongly_standard_implies_std : forall x, StronglyStandard x -> Std x.
Proof.
unfold StronglyStandard in *; pose_subterm; ycrush.
Qed.
Lemma lem_strongly_standard_implies_standard : forall x, StronglyStandard x -> Standard x.
Proof.
unfold StronglyStandard in *; pose_subterm; ycrush.
Qed.
Lemma lem_s_term_erasure_k :
forall t q0 q1, Sterm t -> Erasure t (K @i q0 @i q1) ->
exists t0 t1, t = K1 @l t0 @l t1 /\ Erasure t0 q0 /\ Erasure t1 q1.
Proof.
intros.
yinversion H0; try iauto 1.
yinversion H4; try solve [ yinversion H; iauto 1 ].
yinversion H3; try solve [ yinversion H; iauto 3 ].
Qed.
Lemma lem_s_term_erasure_c :
forall t q0 q1 q2, Sterm t -> Erasure t (C @i q0 @i q1 @i q2) ->
exists t0 t1 t2,
(t = C1 @l t0 @l t1 @l t2 \/ t = C2 @l t0 @l t1 @l t2) /\
Erasure t0 q0 /\ Erasure t1 q1 /\ Erasure t2 q2.
Proof.
intros.
yinversion H0; try iauto 1.
yinversion H4; try solve [ yinversion H; iauto 1 ].
yinversion H3; try solve [ yinversion H; iauto 2 ].
yinversion H4; yinversion H; try iauto 3; ycrush.
Qed.
Lemma lem_standard_ltup : forall x y z l, Standard (ltup x y (z :: l)) -> Standard (ltup x y l).
Proof.
unfold Standard; intros.
yinversion H0.
assert (Std (ltup x y (z :: l))).
pose_subterm; ycrush.
unfold Std in *; ycrush.
pose_subterm; ycrush.
pose_subterm; ycrush.
assert (In z0 (z :: l)).
auto with datatypes.
pose_subterm; ycrush.
Qed.
Lemma lem_strongly_standard_ltup :
forall x y z l, StronglyStandard (ltup x y (z :: l)) -> StronglyStandard (ltup x y l).
Proof.
unfold StronglyStandard; intros.
generalize (lem_red_s_ltup_inv x y l x0 H0); yintro; subst.
assert (Red_clc_s (ltup x y (z :: l)) (ltup x1 x2 (z :: x3))).
pose lem_red_s_ltup_closure; pose_lc; pose lem_red_s_refl; ycrush.
pose lem_standard_ltup; ycrush.
Qed.
Lemma lem_std_ltup : forall x y z l, Std (ltup x y (z :: l)) -> Std (ltup x y l).
Proof.
pose lem_standard_ltup; unfold Standard in *; pose_subterm; ycrush.
Qed.
Lemma lem_standard_sterm : forall x y, Standard x -> Sterm x -> Red_clc_s x y -> Sterm y.
Proof.
unfold Standard; intros.
assert (Std x) by (pose_subterm; ycrush).
ydestruct x; try yelles 1.
Qed.
Lemma lem_standard_no_nested_tuple :
forall x, Standard x -> forall y, In y (tuple_of_lterm x) -> is_ltup y = false.
Proof.
intros.
assert (is_ltup x = true \/ is_ltup x = false) by ycrush.
yintuition; simpl in *.
ydestruct x; yisolve; simpl in *.
pose lem_standard_implies_std; pose_subterm; ycrush.
assert (HH: tuple_of_lterm x = x :: nil) by ycrush.
rewrite HH in *; clear HH.
simpl in *; ycrush.
Qed.
Lemma lem_standard_basic_app_1 :
forall a x, Sterm a -> lterm_basic a -> a <> I1 -> Standard x -> Standard (a @l x).
Proof.
intros.
unfold Standard; intros.
yinversion H3.
unfold Std.
yintuition.
pose_sterm; ycrush.
pose lem_red_s_basic_app_1; pose_sterm; ycrush.
ydestruct a; simpl in *; yisolve; yinversion H0; ycrush.
yinversion H6; try yelles 1.
unfold Std.
ydestruct a; yisolve.
pose lem_red_s_basic; ycrush.
pose lem_red_s_basic; ycrush.
pose lem_red_s_basic; ycrush.
pose lem_red_s_basic; ycrush.
pose lem_red_s_basic; ycrush.
pose lem_red_s_basic; ycrush.
pose lem_red_s_basic; ycrush.
yinversion H0; ycrush.
yinversion H0; ycrush.
yinversion H0; ycrush.
unfold Standard in *; ycrush.
Qed.
Lemma lem_standard_basic_app_2 :
forall a x y, Sterm a -> lterm_basic a -> a <> I1 -> a <> K1 -> Standard x -> Standard y ->
Standard (a @l x @l y).
Proof.
intros.
unfold Standard; intros.
yinversion H5.
unfold Std.
yintuition.
pose_sterm; ycrush.
pose lem_red_s_basic_app_2; pose_sterm; ycrush.
ydestruct a; simpl in *; yisolve; yinversion H0; ycrush.
assert (Standard (a @l x)).
pose lem_standard_basic_app_1; ycrush.
unfold Standard in *; ycrush.
unfold Standard in *; ycrush.
Qed.
Lemma lem_iterm_standard : forall x y, is_iterm x = true -> Subterm y x -> Standard y.
Proof.
unfold Standard; pose lem_subterm_trans; ycrush.
Qed.
Lemma lem_basic_standard : forall x, lterm_basic x -> Standard x.
Proof.
unfold Standard; intros.
ydestruct x; yisolve.
yinversion H0; pose lem_red_s_basic; ycrush.
yinversion H0; pose lem_red_s_basic; ycrush.
yinversion H0; pose lem_red_s_basic; ycrush.
yinversion H0; pose lem_red_s_basic; ycrush.
yinversion H0; pose lem_red_s_basic; ycrush.
yinversion H0; pose lem_red_s_basic; ycrush.
yinversion H0; pose lem_red_s_basic; ycrush.
yinversion H0; pose lem_red_s_basic; ycrush.
yinversion H0; pose lem_red_s_basic; ycrush.
yinversion H; ycrush.
yinversion H; ycrush.
Qed.
Lemma lem_standard_lterm_of_tuple :
forall l, Standard (lterm_of_tuple l) -> forall x, In x l -> Standard x.
Proof.
induction l.
ycrush.
ydestruct l; simpl in *.
ycrush.
ydestruct l0; simpl in *.
unfold Standard in *; pose_subterm; ycrush.
intros.
assert (Standard (ltup l l0 l1)).
clear -H.
assert (Standard l).
unfold Standard in *; pose_subterm; ycrush.
assert (forall x, In x (l0 :: l1) -> Standard x).
unfold Standard in *; pose_subterm; ycrush.
simpl in *.
assert (Std (ltup a l (l0 :: l1))).
unfold Standard in *; pose_subterm; ycrush.
simpl in *; simp_hyps.
assert (Std (ltup l l0 l1)) by ycrush.
unfold Standard; intros.
yinversion H8.
trivial.
ycrush.
unfold Standard in *; pose_subterm; ycrush.
unfold Standard in *; pose_subterm; ycrush.
destruct H0.
unfold Standard in *; pose_subterm; ycrush.
auto.
Qed.