]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/dynamic/cnv.ma
4b51fb944f4303ddf97276e27da8320eda32dbe5
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / dynamic / cnv.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 "static_2/syntax/ac.ma".
16 include "basic_2/notation/relations/exclaim_5.ma".
17 include "basic_2/rt_computation/cpms.ma".
18
19 (* CONTEXT-SENSITIVE NATIVE VALIDITY FOR TERMS ******************************)
20
21 (* activate genv *)
22 (* Basic_2A1: uses: snv *)
23 inductive cnv (h) (a): relation3 genv lenv term ≝
24 | cnv_sort: ∀G,L,s. cnv h a G L (⋆s)
25 | cnv_zero: ∀I,G,K,V. cnv h a G K V → cnv h a G (K.ⓑ{I}V) (#0)
26 | cnv_lref: ∀I,G,K,i. cnv h a G K (#i) → cnv h a G (K.ⓘ{I}) (#↑i)
27 | cnv_bind: ∀p,I,G,L,V,T. cnv h a G L V → cnv h a G (L.ⓑ{I}V) T → cnv h a G L (ⓑ{p,I}V.T)
28 | cnv_appl: ∀n,p,G,L,V,W0,T,U0. ad a n → cnv h a G L V → cnv h a G L T →
29             ⦃G,L⦄ ⊢ V ➡*[1,h] W0 → ⦃G,L⦄ ⊢ T ➡*[n,h] ⓛ{p}W0.U0 → cnv h a G L (ⓐV.T)
30 | cnv_cast: ∀G,L,U,T,U0. cnv h a G L U → cnv h a G L T →
31             ⦃G,L⦄ ⊢ U ➡*[h] U0 → ⦃G,L⦄ ⊢ T ➡*[1,h] U0 → cnv h a G L (ⓝU.T)
32 .
33
34 interpretation "context-sensitive native validity (term)"
35   'Exclaim h a G L T = (cnv h a G L T).
36
37 (* Basic inversion lemmas ***************************************************)
38
39 fact cnv_inv_zero_aux (h) (a):
40      ∀G,L,X. ⦃G,L⦄ ⊢ X ![h,a] → X = #0 →
41      ∃∃I,K,V. ⦃G,K⦄ ⊢ V ![h,a] & L = K.ⓑ{I}V.
42 #h #a #G #L #X * -G -L -X
43 [ #G #L #s #H destruct
44 | #I #G #K #V #HV #_ /2 width=5 by ex2_3_intro/
45 | #I #G #K #i #_ #H destruct
46 | #p #I #G #L #V #T #_ #_ #H destruct
47 | #n #p #G #L #V #W0 #T #U0 #_ #_ #_ #_ #_ #H destruct
48 | #G #L #U #T #U0 #_ #_ #_ #_ #H destruct
49 ]
50 qed-.
51
52 lemma cnv_inv_zero (h) (a):
53       ∀G,L. ⦃G,L⦄ ⊢ #0 ![h,a] →
54       ∃∃I,K,V. ⦃G,K⦄ ⊢ V ![h,a] & L = K.ⓑ{I}V.
55 /2 width=3 by cnv_inv_zero_aux/ qed-.
56
57 fact cnv_inv_lref_aux (h) (a):
58      ∀G,L,X. ⦃G,L⦄ ⊢ X ![h,a] → ∀i. X = #(↑i) →
59      ∃∃I,K. ⦃G,K⦄ ⊢ #i ![h,a] & L = K.ⓘ{I}.
60 #h #a #G #L #X * -G -L -X
61 [ #G #L #s #j #H destruct
62 | #I #G #K #V #_ #j #H destruct
63 | #I #G #L #i #Hi #j #H destruct /2 width=4 by ex2_2_intro/
64 | #p #I #G #L #V #T #_ #_ #j #H destruct
65 | #n #p #G #L #V #W0 #T #U0 #_ #_ #_ #_ #_ #j #H destruct
66 | #G #L #U #T #U0 #_ #_ #_ #_ #j #H destruct
67 ]
68 qed-.
69
70 lemma cnv_inv_lref (h) (a):
71       ∀G,L,i. ⦃G,L⦄ ⊢ #↑i ![h,a] →
72       ∃∃I,K. ⦃G,K⦄ ⊢ #i ![h,a] & L = K.ⓘ{I}.
73 /2 width=3 by cnv_inv_lref_aux/ qed-.
74
75 fact cnv_inv_gref_aux (h) (a): ∀G,L,X. ⦃G,L⦄ ⊢ X ![h,a] → ∀l. X = §l → ⊥.
76 #h #a #G #L #X * -G -L -X
77 [ #G #L #s #l #H destruct
78 | #I #G #K #V #_ #l #H destruct
79 | #I #G #K #i #_ #l #H destruct
80 | #p #I #G #L #V #T #_ #_ #l #H destruct
81 | #n #p #G #L #V #W0 #T #U0 #_ #_ #_ #_ #_ #l #H destruct
82 | #G #L #U #T #U0 #_ #_ #_ #_ #l #H destruct
83 ]
84 qed-.
85
86 (* Basic_2A1: uses: snv_inv_gref *)
87 lemma cnv_inv_gref (h) (a): ∀G,L,l. ⦃G,L⦄ ⊢ §l ![h,a] → ⊥.
88 /2 width=8 by cnv_inv_gref_aux/ qed-.
89
90 fact cnv_inv_bind_aux (h) (a):
91      ∀G,L,X. ⦃G,L⦄ ⊢ X ![h,a] →
92      ∀p,I,V,T. X = ⓑ{p,I}V.T →
93      ∧∧ ⦃G,L⦄ ⊢ V ![h,a] & ⦃G,L.ⓑ{I}V⦄ ⊢ T ![h,a].
94 #h #a #G #L #X * -G -L -X
95 [ #G #L #s #q #Z #X1 #X2 #H destruct
96 | #I #G #K #V #_ #q #Z #X1 #X2 #H destruct
97 | #I #G #K #i #_ #q #Z #X1 #X2 #H destruct
98 | #p #I #G #L #V #T #HV #HT #q #Z #X1 #X2 #H destruct /2 width=1 by conj/
99 | #n #p #G #L #V #W0 #T #U0 #_ #_ #_ #_ #_ #q #Z #X1 #X2 #H destruct
100 | #G #L #U #T #U0 #_ #_ #_ #_ #q #Z #X1 #X2 #H destruct
101 ]
102 qed-.
103
104 (* Basic_2A1: uses: snv_inv_bind *)
105 lemma cnv_inv_bind (h) (a):
106       ∀p,I,G,L,V,T. ⦃G,L⦄ ⊢ ⓑ{p,I}V.T ![h,a] →
107       ∧∧ ⦃G,L⦄ ⊢ V ![h,a] & ⦃G,L.ⓑ{I}V⦄ ⊢ T ![h,a].
108 /2 width=4 by cnv_inv_bind_aux/ qed-.
109
110 fact cnv_inv_appl_aux (h) (a):
111      ∀G,L,X. ⦃G,L⦄ ⊢ X ![h,a] → ∀V,T. X = ⓐV.T →
112      ∃∃n,p,W0,U0. ad a n & ⦃G,L⦄ ⊢ V ![h,a] & ⦃G,L⦄ ⊢ T ![h,a] &
113                   ⦃G,L⦄ ⊢ V ➡*[1,h] W0 & ⦃G,L⦄ ⊢ T ➡*[n,h] ⓛ{p}W0.U0.
114 #h #a #G #L #X * -L -X
115 [ #G #L #s #X1 #X2 #H destruct
116 | #I #G #K #V #_ #X1 #X2 #H destruct
117 | #I #G #K #i #_ #X1 #X2 #H destruct
118 | #p #I #G #L #V #T #_ #_ #X1 #X2 #H destruct
119 | #n #p #G #L #V #W0 #T #U0 #Ha #HV #HT #HVW0 #HTU0 #X1 #X2 #H destruct /3 width=7 by ex5_4_intro/
120 | #G #L #U #T #U0 #_ #_ #_ #_ #X1 #X2 #H destruct
121 ]
122 qed-.
123
124 (* Basic_2A1: uses: snv_inv_appl *)
125 lemma cnv_inv_appl (h) (a):
126       ∀G,L,V,T. ⦃G,L⦄ ⊢ ⓐV.T ![h,a] →
127       ∃∃n,p,W0,U0. ad a n & ⦃G,L⦄ ⊢ V ![h,a] & ⦃G,L⦄ ⊢ T ![h,a] &
128                    ⦃G,L⦄ ⊢ V ➡*[1,h] W0 & ⦃G,L⦄ ⊢ T ➡*[n,h] ⓛ{p}W0.U0.
129 /2 width=3 by cnv_inv_appl_aux/ qed-.
130
131 fact cnv_inv_cast_aux (h) (a):
132      ∀G,L,X. ⦃G,L⦄ ⊢ X ![h,a] → ∀U,T. X = ⓝU.T →
133      ∃∃U0. ⦃G,L⦄ ⊢ U ![h,a] & ⦃G,L⦄ ⊢ T ![h,a] &
134            ⦃G,L⦄ ⊢ U ➡*[h] U0 & ⦃G,L⦄ ⊢ T ➡*[1,h] U0.
135 #h #a #G #L #X * -G -L -X
136 [ #G #L #s #X1 #X2 #H destruct
137 | #I #G #K #V #_ #X1 #X2 #H destruct
138 | #I #G #K #i #_ #X1 #X2 #H destruct
139 | #p #I #G #L #V #T #_ #_ #X1 #X2 #H destruct
140 | #n #p #G #L #V #W0 #T #U0 #_ #_ #_ #_ #_ #X1 #X2 #H destruct
141 | #G #L #U #T #U0 #HV #HT #HU0 #HTU0 #X1 #X2 #H destruct /2 width=3 by ex4_intro/
142 ]
143 qed-.
144
145 (* Basic_2A1: uses: snv_inv_cast *)
146 lemma cnv_inv_cast (h) (a):
147       ∀G,L,U,T. ⦃G,L⦄ ⊢ ⓝU.T ![h,a] →
148       ∃∃U0. ⦃G,L⦄ ⊢ U ![h,a] & ⦃G,L⦄ ⊢ T ![h,a] &
149             ⦃G,L⦄ ⊢ U ➡*[h] U0 & ⦃G,L⦄ ⊢ T ➡*[1,h] U0.
150 /2 width=3 by cnv_inv_cast_aux/ qed-.
151
152 (* Basic forward lemmas *****************************************************)
153
154 lemma cnv_fwd_flat (h) (a) (I) (G) (L):
155       ∀V,T. ⦃G,L⦄ ⊢ ⓕ{I}V.T ![h,a] →
156       ∧∧ ⦃G,L⦄ ⊢ V ![h,a] & ⦃G,L⦄ ⊢ T ![h,a].
157 #h #a * #G #L #V #T #H
158 [ elim (cnv_inv_appl … H) #n #p #W #U #_ #HV #HT #_ #_
159 | elim (cnv_inv_cast … H) #U #HV #HT #_ #_
160 ] -H /2 width=1 by conj/
161 qed-.
162
163 lemma cnv_fwd_pair_sn (h) (a) (I) (G) (L):
164       ∀V,T. ⦃G,L⦄ ⊢ ②{I}V.T ![h,a] → ⦃G,L⦄ ⊢ V ![h,a].
165 #h #a * [ #p ] #I #G #L #V #T #H
166 [ elim (cnv_inv_bind … H) -H #HV #_
167 | elim (cnv_fwd_flat … H) -H #HV #_
168 ] //
169 qed-.
170
171 (* Basic_2A1: removed theorems 3:
172               shnv_cast shnv_inv_cast snv_shnv_cast
173 *)