]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/dynamic/nta_preserve.ma
update in basic_2 and apps_2
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / dynamic / nta_preserve.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "basic_2/rt_equivalence/cpcs_cprs.ma".
16 include "basic_2/dynamic/cnv_preserve.ma".
17 include "basic_2/dynamic/nta.ma".
18
19 (* NATIVE TYPE ASSIGNMENT FOR TERMS *****************************************)
20
21 (* Properties based on preservation *****************************************)
22
23 lemma cnv_cpms_nta (a) (h) (G) (L):
24       ∀T. ⦃G,L⦄ ⊢ T ![a,h] → ∀U.⦃G,L⦄ ⊢ T ➡*[1,h] U → ⦃G,L⦄ ⊢ T :[a,h] U.
25 /3 width=4 by cnv_cast, cnv_cpms_trans/ qed.
26
27 lemma cnv_nta_sn (a) (h) (G) (L):
28       ∀T. ⦃G,L⦄ ⊢ T ![a,h] → ∃U. ⦃G,L⦄ ⊢ T :[a,h] U.
29 #a #h #G #L #T #HT
30 elim (cnv_fwd_cpm_SO … HT) #U #HTU
31 /4 width=2 by cnv_cpms_nta, cpm_cpms, ex_intro/
32 qed-.
33
34 (* Basic_1: was: ty3_typecheck *)
35 lemma nta_typecheck (a) (h) (G) (L):
36       ∀T,U. ⦃G,L⦄ ⊢ T :[a,h] U → ∃T0. ⦃G,L⦄ ⊢ ⓝU.T :[a,h] T0.
37 /3 width=1 by cnv_cast, cnv_nta_sn/ qed-.
38
39 (* Basic_1: was: ty3_correct *)
40 (* Basic_2A1: was: ntaa_fwd_correct *)
41 lemma nta_fwd_correct (a) (h) (G) (L):
42       ∀T,U. ⦃G,L⦄ ⊢ T :[a,h] U → ∃T0. ⦃G,L⦄ ⊢ U :[a,h] T0.
43 /3 width=2 by nta_fwd_cnv_dx, cnv_nta_sn/ qed-.
44
45 lemma nta_pure_cnv (h) (G) (L):
46       ∀T,U. ⦃G,L⦄ ⊢ T :*[h] U →
47       ∀V. ⦃G,L⦄ ⊢ ⓐV.U !*[h] → ⦃G,L⦄ ⊢ ⓐV.T :*[h] ⓐV.U.
48 #h #G #L #T #U #H1 #V #H2
49 elim (cnv_inv_cast … H1) -H1 #X0 #HU #HT #HUX0 #HTX0
50 elim (cnv_inv_appl … H2) #n #p #X1 #X2 #_ #HV #_ #HVX1 #HUX2
51 elim (cnv_cpms_conf … HU … HUX0 … HUX2) -HU -HUX2
52 <minus_O_n <minus_n_O #X #HX0 #H
53 elim (cpms_inv_abst_sn … H) -H #X3 #X4 #HX13 #HX24 #H destruct
54 @(cnv_cast … (ⓐV.X0)) [2:|*: /2 width=1 by cpms_appl_dx/ ]
55 @(cnv_appl … X3) [4: |*: /2 width=7 by cpms_trans, cpms_cprs_trans/ ]
56 #H destruct
57 qed.
58
59 (* Inversion lemmas based on preservation ***********************************)
60
61 lemma nta_inv_bind_sn_cnv (a) (h) (p) (I) (G) (K) (X2):
62       ∀V,T. ⦃G,K⦄ ⊢ ⓑ{p,I}V.T :[a,h] X2 →
63       ∃∃U. ⦃G,K⦄ ⊢ V ![a,h] & ⦃G,K.ⓑ{I}V⦄ ⊢ T :[a,h] U & ⦃G,K⦄ ⊢ ⓑ{p,I}V.U ⬌*[h] X2 & ⦃G,K⦄ ⊢ X2 ![a,h].
64 #a #h #p * #G #K #X2 #V #T #H
65 elim (cnv_inv_cast … H) -H #X1 #HX2 #H1 #HX21 #H2
66 elim (cnv_inv_bind … H1) -H1 #HV #HT
67 [ elim (cpms_inv_abbr_sn_dx … H2) -H2 *
68   [ #V0 #U #HV0 #HTU #H destruct
69     /4 width=5 by cnv_cpms_nta, cprs_div, cpms_bind, ex4_intro/
70   | #U #HTU #HX1U #H destruct
71     /4 width=5 by cnv_cpms_nta, cprs_div, cpms_zeta, ex4_intro/
72   ]
73 | elim (cpms_inv_abst_sn … H2) -H2 #V0 #U #HV0 #HTU #H destruct
74   /4 width=5 by cnv_cpms_nta, cprs_div, cpms_bind, ex4_intro/
75 ]
76 qed-.
77
78 (* Basic_1: uses: ty3_gen_appl *)
79 lemma nta_inv_appl_sn (h) (G) (L) (X2):
80       ∀V,T. ⦃G,L⦄ ⊢ ⓐV.T :[h] X2 →
81       ∃∃p,W,U. ⦃G,L⦄ ⊢ V :[h] W & ⦃G,L⦄ ⊢ T :[h] ⓛ{p}W.U & ⦃G,L⦄ ⊢ ⓐV.ⓛ{p}W.U ⬌*[h] X2 & ⦃G,L⦄ ⊢ X2 ![h].
82 #h #G #L #X2 #V #T #H
83 elim (cnv_inv_cast … H) -H #X #HX2 #H1 #HX2 #H2
84 elim (cnv_inv_appl … H1) * [ | #n ] #p #W #U #Hn #HV #HT #HVW #HTU
85 [ lapply (cnv_cpms_trans … HT … HTU) #H
86   elim (cnv_inv_bind … H) -H #_ #HU
87   elim (cnv_fwd_cpm_SO … HU) #U0 #HU0 -HU
88   lapply (cpms_step_dx … HTU 1 (ⓛ{p}W.U0) ?) -HTU [ /2 width=1 by cpm_bind/ ] #HTU
89 | lapply (le_n_O_to_eq n ?) [ /3 width=1 by le_S_S_to_le/ ] -Hn #H destruct
90 ]
91 lapply (cpms_appl_dx … V V … HTU) [1,3: // ] #HVTU
92 elim (cnv_cpms_conf … H1 … H2 … HVTU) -H1 -H2 -HVTU <minus_n_n #X0 #HX0 #HUX0
93 @ex4_3_intro [6,13: |*: /2 width=5 by cnv_cpms_nta/ ]
94 /3 width=5 by cprs_div, cprs_trans/
95 qed-.
96
97 (* Basic_2A1: uses: nta_inv_cast1 *)
98 lemma nta_inv_cast_sn (a) (h) (G) (L) (X2):
99       ∀U,T. ⦃G,L⦄ ⊢ ⓝU.T :[a,h] X2 →
100       ∧∧ ⦃G,L⦄ ⊢ T :[a,h] U & ⦃G,L⦄ ⊢ U ⬌*[h] X2 & ⦃G,L⦄ ⊢ X2 ![a,h].
101 #a #h #G #L #X2 #U #T #H
102 elim (cnv_inv_cast … H) -H #X0 #HX2 #H1 #HX20 #H2
103 elim (cnv_inv_cast … H1) #X #HU #HT #HUX #HTX
104 elim (cpms_inv_cast1 … H2) -H2 [ * || * ]
105 [ #U0 #T0 #HU0 #HT0 #H destruct -HU -HU0
106   elim (cnv_cpms_conf … HT … HTX … HT0) -HT -HTX -HT0
107   <minus_n_n #T1 #HXT1 #HT01
108   @and3_intro // @(cprs_div … T1) /3 width=4 by cprs_trans, cpms_eps/ (**) (* full auto too slow *)
109 | #HTX0 -HU
110   elim (cnv_cpms_conf … HT … HTX … HTX0) -HT -HTX -HTX0
111   <minus_n_n #T1 #HXT1 #HXT01
112   @and3_intro // @(cprs_div … T1) /2 width=3 by cprs_trans/ (**) (* full auto too slow *)
113 | #m #HUX0 #H destruct -HT -HTX
114   elim (cnv_cpms_conf … HU … HUX … HUX0) -HU -HUX0
115   <minus_n_n #U1 #HXU1 #HXU01
116   @and3_intro // @(cprs_div … U1) /2 width=3 by cprs_trans/ (**) (* full auto too slow *)
117 ]
118 qed-.
119
120 (* Basic_1: uses: ty3_gen_cast *)
121 lemma nta_inv_cast_sn_old (a) (h) (G) (L) (X2):
122       ∀T0,T1. ⦃G,L⦄ ⊢ ⓝT1.T0 :[a,h] X2 →
123       ∃∃T2. ⦃G,L⦄ ⊢ T0 :[a,h] T1 & ⦃G,L⦄ ⊢ T1 :[a,h] T2 & ⦃G,L⦄ ⊢ ⓝT2.T1 ⬌*[h] X2 & ⦃G,L⦄ ⊢ X2 ![a,h].
124 #a #h #G #L #X2 #T0 #T1 #H
125 elim (cnv_inv_cast … H) -H #X0 #HX2 #H1 #HX20 #H2
126 elim (cnv_inv_cast … H1) #X #HT1 #HT0 #HT1X #HT0X
127 elim (cpms_inv_cast1 … H2) -H2 [ * || * ]
128 [ #U1 #U0 #HTU1 #HTU0 #H destruct
129   elim (cnv_cpms_conf … HT0 … HT0X … HTU0) -HT0 -HT0X -HTU0
130   <minus_n_n #X0 #HX0 #HUX0
131   lapply (cprs_trans … HT1X … HX0) -X #HT1X0
132   /5 width=7 by cnv_cpms_nta, cpcs_cprs_div, cprs_div, cpms_cast, ex4_intro/
133 | #HTX0
134   elim (cnv_cpms_conf … HT0 … HT0X … HTX0) -HT0 -HT0X -HTX0
135   <minus_n_n #X1 #HX1 #HX01
136   elim (cnv_nta_sn … HT1) -HT1 #U1 #HTU1
137   lapply (cprs_trans … HT1X … HX1) -X #HTX1
138   lapply (cprs_trans … HX20 … HX01) -X0 #HX21
139   /4 width=5 by cprs_div, cpms_eps, ex4_intro/
140 | #n #HT1X0 #H destruct -X -HT0
141   elim (cnv_nta_sn … HT1) -HT1 #U1 #HTU1
142   /4 width=5 by cprs_div, cpms_eps, ex4_intro/
143 ]
144 qed-.
145
146 (* Forward lemmas based on preservation *************************************)
147
148 (* Basic_1: was: ty3_unique *)
149 theorem nta_mono (a) (h) (G) (L) (T):
150         ∀U1. ⦃G,L⦄ ⊢ T :[a,h] U1 → ∀U2. ⦃G,L⦄ ⊢ T :[a,h] U2 → ⦃G,L⦄  ⊢ U1 ⬌*[h] U2.
151 #a #h #G #L #T #U1 #H1 #U2 #H2
152 elim (cnv_inv_cast … H1) -H1 #X1 #_ #_ #HUX1 #HTX1
153 elim (cnv_inv_cast … H2) -H2 #X2 #_ #HT #HUX2 #HTX2
154 elim (cnv_cpms_conf … HT … HTX1 … HTX2) -T <minus_n_n #X #HX1 #HX2
155 /3 width=5 by cprs_div, cprs_trans/
156 qed-.