]> matita.cs.unibo.it Git - helm.git/blob - helm/coq-contribs/LAMBDA-TYPES/ty0_sred.v
some reorganization and some corrections
[helm.git] / helm / coq-contribs / LAMBDA-TYPES / ty0_sred.v
1 Require lift_gen.
2 Require subst1_gen.
3 Require csubst1_defs.
4 Require pr0_lift.
5 Require pr0_subst1.
6 Require cpr0_defs.
7 Require pc3_props.
8 Require pc3_gen.
9 Require ty0_defs.
10 Require ty0_lift.
11 Require ty0_props.
12 Require ty0_subst0.
13 Require ty0_gen_context.
14 Require csub0_defs.
15
16 (*#* #caption "subject reduction" #clauses *)
17
18 (*#* #stop file *)
19
20    Section ty0_sred_cpr0_pr0. (**********************************************)
21
22       Tactic Definition IH H c2 t2 :=
23          LApply (H c2); [ Intros H_x | XEAuto ];
24          LApply H_x; [ Clear H_x; Intros H_x | XAuto ];
25          LApply (H_x t2); [ Clear H_x; Intros | XEAuto ].
26
27       Tactic Definition IH0 :=
28          Match Context With
29             [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 ?2 c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4);
30               H2: (cpr0 ?2 ?5); H3: (ty0 ?1 ?2 ?3 ?4) |- ? ] ->
31                IH H1 ?5 ?3.
32
33       Tactic Definition IH0c :=
34          Match Context With
35             [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 ?2 c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4);
36               H2: (cpr0 ?2 ?5); H3: (ty0 ?1 ?2 ?3 ?4) |- ? ] ->
37                IH H1 ?5 ?3; Clear H1.
38
39       Tactic Definition IH0B :=
40          Match Context With
41             [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 (CTail ?2 (Bind ?6) ?7) c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4);
42               H2: (cpr0 ?2 ?5); H3: (ty0 ?1 (CTail ?2 (Bind ?6) ?7) ?3 ?4) |- ? ] ->
43                IH H1 '(CTail ?5 (Bind ?6) ?7) ?3.
44
45       Tactic Definition IH0Bc :=
46          Match Context With
47             [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 (CTail ?2 (Bind ?6) ?7) c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4);
48               H2: (cpr0 ?2 ?5); H3: (ty0 ?1 (CTail ?2 (Bind ?6) ?7) ?3 ?4) |- ? ] ->
49                IH H1 '(CTail ?5 (Bind ?6) ?7) ?3; Clear H1.
50
51       Tactic Definition IH1 :=
52          Match Context With
53             [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 ?2 c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4);
54               H2: (cpr0 ?2 ?5); H3: (pr0 ?3 ?6) |- ? ] ->
55             IH H1 ?5 ?6.
56
57       Tactic Definition IH1c :=
58          Match Context With
59             [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 ?2 c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4);
60               H2: (cpr0 ?2 ?5); H3: (pr0 ?3 ?6) |- ? ] ->
61             IH H1 ?5 ?6; Clear H1.
62
63       Tactic Definition IH1Bc :=
64          Match Context With
65             [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 (CTail ?2 (Bind ?7) ?8) c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4);
66               H2: (cpr0 ?2 ?5); H3: (pr0 ?3 ?6) |- ? ] ->
67             IH H1 '(CTail ?5 (Bind ?7) ?8) ?6; Clear H1.
68
69       Tactic Definition IH1BLc :=
70          Match Context With
71             [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 (CTail ?2 (Bind ?7) ?8) c2)->(t2:T)(pr0 (lift ?10 ?11 ?3) t2)->(ty0 ?1 c2 t2 ?4);
72               H2: (cpr0 ?2 ?5); H3: (pr0 ?3 ?6) |- ? ] ->
73             IH H1 '(CTail ?5 (Bind ?7) ?8) '(lift ?10 ?11 ?6); Clear H1.
74
75       Tactic Definition IH1T :=
76          Match Context With
77             [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 ?2 c2)->(t2:T)(pr0 (TTail ?7 ?8 ?3) t2)->(ty0 ?1 c2 t2 ?4);
78               H2: (cpr0 ?2 ?5); H3: (pr0 ?3 ?6) |- ? ] ->
79             IH H1 ?5 '(TTail ?7 ?8 ?6).
80
81       Tactic Definition IH1T2c :=
82          Match Context With
83             [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 ?2 c2)->(t2:T)(pr0 (TTail ?7 ?8 ?3) t2)->(ty0 ?1 c2 t2 ?4);
84               H2: (cpr0 ?2 ?5); H3: (pr0 ?3 ?6); H4: (pr0 ?8 ?9) |- ? ] ->
85             IH H1 ?5 '(TTail ?7 ?9 ?6); Clear H1.
86
87       Tactic Definition IH3B :=
88          Match Context With
89             [ H1: (c2:C) (wf0 ?1 c2)->(cpr0 (CTail ?2 (Bind ?7) ?8) c2)->(t2:T)(pr0 ?3 t2)->(ty0 ?1 c2 t2 ?4);
90               H2: (cpr0 ?2 ?5); H3: (pr0 ?3 ?6); H4: (pr0 ?8 ?9) |- ? ] ->
91             IH H1 '(CTail ?5 (Bind ?7) ?9) ?6.
92
93 (*#* #start file *)
94
95 (*#* #caption "base case" *)
96 (*#* #cap #cap c1, c2 #alpha t1 in T, t2 in T1, t in T2 *)
97
98       Theorem ty0_sred_cpr0_pr0: (g:?; c1:?; t1,t:?) (ty0 g c1 t1 t) ->
99                                  (c2:?) (wf0 g c2) -> (cpr0 c1 c2) ->
100                                  (t2:?) (pr0 t1 t2) -> (ty0 g c2 t2 t).
101
102 (*#* #stop file *)
103
104       Intros until 1; XElim H; Intros.
105 (* case 1: ty0_conv *)
106       IH1c; IH0c; EApply ty0_conv; XEAuto.
107 (* case 2: ty0_sort *)
108       Inversion H2; XAuto.
109 (* case 3: ty0_abbr *)
110       Inversion H5; Cpr0Drop; IH1c; XEAuto.
111 (* case 4: ty0_abst *)
112       Intros; Inversion H5; Cpr0Drop; IH0; IH1.
113       EApply ty0_conv;
114       [ EApply ty0_lift; [ Idtac | XAuto | XEAuto ]
115       | EApply ty0_abst
116       | EApply pc3_lift ]; XEAuto.
117 (* case 5: ty0_bind *)
118       Intros; Inversion H7; Clear H7.
119 (* case 5.1: pr0_refl *)
120       IH0c; IH0Bc; IH0Bc.
121       EApply ty0_bind; XEAuto.
122 (* case 5.2: pr0_cont *)
123       IH0; IH0B; Ty0Correct; IH3B; Ty0Correct.
124       EApply ty0_conv; [ EApply ty0_bind | EApply ty0_bind | Idtac ]; XEAuto.
125 (* case 5.3: pr0_delta *)
126       Rewrite <- H8 in H1; Rewrite <- H8 in H2;
127       Rewrite <- H8 in H3; Rewrite <- H8 in H4; Clear H8 b.
128       IH0; IH0B; Ty0Correct; IH3B; Ty0Correct.
129       EApply ty0_conv; [ EApply ty0_bind | EApply ty0_bind | Idtac ]; XEAuto.
130 (* case 5.4: pr0_zeta *)
131       Rewrite <- H11 in H1; Rewrite <- H11 in H2; Clear H8 H9 H10 H11 b0 t2 t7 u0.
132       IH0; IH1BLc; Move H3 after H8; IH0Bc; Ty0Correct; Move H8 after H4; Clear H H0 H1 H3 H6 c c1 t t1;
133       NewInduction b.
134 (* case 5.4.1: Abbr *)
135       Ty0GenContext; Subst1Gen; LiftGen; Rewrite H in H1; Clear H x0.
136       EApply ty0_conv;
137       [ EApply ty0_bind; XEAuto | XEAuto
138       | EApply pc3_pr3_x;
139         EApply (pr3_t (TTail (Bind Abbr) u (lift (1) (0) x1))); XEAuto ].
140 (* case 5.4.2: Abst *)
141       EqFalse.
142 (* case 5.4.3: Void *)
143       Ty0GenContext; Rewrite H0; Rewrite H0 in H2; Clear H0 t3.
144       LiftGen; Rewrite <- H in H1; Clear H x0.
145       EApply ty0_conv; [ EApply ty0_bind; XEAuto | XEAuto | XAuto ].
146 (* case 6: ty0_appl *)
147       Intros; Inversion H5; Clear H5.
148 (* case 6.1: pr0_refl *)
149       IH0c; IH0c; EApply ty0_appl; XEAuto.
150 (* case 6.2: pr0_cont *)
151       Clear H6 H7 H8 H9 c1 k t t1 t2 t3 u1.
152       IH0; Ty0Correct; Ty0GenBase; IH1c; IH0; IH1c.
153       EApply ty0_conv;
154       [ EApply ty0_appl; [ XEAuto | EApply ty0_bind; XEAuto ]
155       | EApply ty0_appl; XEAuto
156       | XEAuto ].
157 (* case 6.3: pr0_beta *)
158       Rewrite <- H7 in H1; Rewrite <- H7 in H2; Clear H6 H7 H9 c1 t t1 t2 v v1.
159       IH1T; IH0c; Ty0Correct; Ty0GenBase; IH0; IH1c.
160       Move H5 after H13; Ty0GenBase; Pc3Gen; Repeat CSub0Ty0.
161       EApply ty0_conv;
162       [ Apply ty0_appl; [ Idtac | EApply ty0_bind ]
163       | EApply ty0_bind
164       | Apply (pc3_t (TTail (Bind Abbr) v2 t0))
165       ]; XEAuto.
166 (* case 6.4: pr0_delta *)
167       Rewrite <- H7 in H1; Rewrite <- H7 in H2; Clear H6 H7 H11 c1 t t1 t2 v v1.
168       IH1T2c; Clear H1; Ty0Correct; NonLinear; Ty0GenBase; IH1; IH0c.
169       Move H5 after H1; Ty0GenBase; Pc3Gen; Rewrite lift_bind in H0.
170       Move H1 after H0; Ty0Lift b u2; Rewrite lift_bind in H17.
171       Ty0GenBase.
172       EApply ty0_conv;
173       [ Apply ty0_appl; [ Idtac | EApply ty0_bind ]; XEAuto
174       | EApply ty0_bind;
175         [ Idtac
176         | EApply ty0_appl; [ EApply ty0_lift | EApply ty0_conv ]
177         | EApply ty0_appl; [ EApply ty0_lift | EApply ty0_bind ]
178         ]; XEAuto
179       | Idtac ].
180       Rewrite <- lift_bind; Apply pc3_pc1;
181       Apply (pc1_u (TTail (Flat Appl) v2 (TTail (Bind b) u2 (lift (1) (0) (TTail (Bind Abst) u t0))))); XAuto.
182 (* case 7: ty0_cast *)
183       Intros; Inversion H5; Clear H5.
184 (* case 7.1: pr0_refl *)
185       IH0c; IH0c; EApply ty0_cast; XEAuto.
186 (* case 7.2: pr0_cont *)
187       Clear H6 H7 H8 H9 c1 k u1 t t1 t4 t5.
188       IH0; IH1c; IH1c.
189       EApply ty0_conv;
190       [ XEAuto
191       | EApply ty0_cast; [ EApply ty0_conv; XEAuto | XEAuto ]
192       | XAuto ].
193 (* case 7.3: pr0_epsilon *)
194       XAuto.
195       Qed.
196
197    End ty0_sred_cpr0_pr0.
198
199    Section ty0_sred_pr3. (**********************************************)
200
201       Theorem ty0_sred_pr1: (c:?; t1,t2:?) (pr1 t1 t2) ->
202                             (g:?; t:?) (ty0 g c t1 t) ->
203                             (ty0 g c t2 t).
204       Intros until 1; XElim H; Intros.
205 (* case 1: pr1_r *)
206       XAuto.
207 (* case 2: pr1_u *)
208       EApply H1; EApply ty0_sred_cpr0_pr0; XEAuto.
209       Qed.
210
211       Theorem ty0_sred_pr2: (c:?; t1,t2:?) (pr2 c t1 t2) ->
212                             (g:?; t:?) (ty0 g c t1 t) ->
213                             (ty0 g c t2 t).
214       Intros until 1; XElim H; Intros.
215 (* case 1: pr2_free *)
216       EApply ty0_sred_cpr0_pr0; XEAuto.
217 (* case 2: pr2_u *)
218       EApply ty0_subst0; Try EApply ty0_sred_cpr0_pr0; XEAuto.
219       Qed.
220
221 (*#* #start file *)
222
223 (*#* #caption "general case" *)
224 (*#* #cap #cap c #alpha t1 in T, t2 in T1, t in T2 *)
225
226       Theorem ty0_sred_pr3: (c:?; t1,t2:?) (pr3 c t1 t2) ->
227                             (g:?; t:?) (ty0 g c t1 t) ->
228                             (ty0 g c t2 t).
229
230 (*#* #stop file *)
231
232       Intros until 1; XElim H; Intros.
233 (* case 1: pr3_refl *)
234       XAuto.
235 (* case 2: pr3_sing *)
236       EApply H1; EApply ty0_sred_pr2; XEAuto.
237       Qed.
238
239    End ty0_sred_pr3.
240
241       Tactic Definition Ty0SRed :=
242          Match Context With
243             | [ H1: (pr3 ?1 ?2 ?3); H2: (ty0 ?4 ?1 ?2 ?5) |- ? ] ->
244                LApply (ty0_sred_pr3 ?1 ?2 ?3); [ Intros H_x | XAuto ];
245                LApply (H_x ?4 ?5); [ Clear H2 H_x; Intros | XAuto ].
246
247 (*#* #start file *)
248
249 (*#* #single *)