]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/rt_transition/cpg.ma
- notational change for cpg and cpx
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / rt_transition / cpg.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 "ground_2/steps/rtc_shift.ma".
16 include "ground_2/steps/rtc_plus.ma".
17 include "basic_2/notation/relations/predty_6.ma".
18 include "basic_2/grammar/lenv.ma".
19 include "basic_2/grammar/genv.ma".
20 include "basic_2/relocation/lifts.ma".
21 include "basic_2/static/sh.ma".
22
23 (* COUNTED CONTEXT-SENSITIVE PARALLEL RT-TRANSITION FOR TERMS ***************)
24
25 (* avtivate genv *)
26 inductive cpg (h): rtc → relation4 genv lenv term term ≝
27 | cpg_atom : ∀I,G,L. cpg h (𝟘𝟘) G L (⓪{I}) (⓪{I})
28 | cpg_ess  : ∀G,L,s. cpg h (𝟘𝟙) G L (⋆s) (⋆(next h s))
29 | cpg_delta: ∀c,G,L,V1,V2,W2. cpg h c G L V1 V2 →
30              ⬆*[1] V2 ≡ W2 → cpg h c G (L.ⓓV1) (#0) W2
31 | cpg_ell  : ∀c,G,L,V1,V2,W2. cpg h c G L V1 V2 →
32              ⬆*[1] V2 ≡ W2 → cpg h ((↓c)+𝟘𝟙) G (L.ⓛV1) (#0) W2
33 | cpg_lref : ∀c,I,G,L,V,T,U,i. cpg h c G L (#i) T → 
34              ⬆*[1] T ≡ U → cpg h c G (L.ⓑ{I}V) (#⫯i) U
35 | cpg_bind : ∀cV,cT,p,I,G,L,V1,V2,T1,T2.
36              cpg h cV G L V1 V2 → cpg h cT G (L.ⓑ{I}V1) T1 T2 →
37              cpg h ((↓cV)+cT) G L (ⓑ{p,I}V1.T1) (ⓑ{p,I}V2.T2)
38 | cpg_flat : ∀cV,cT,I,G,L,V1,V2,T1,T2.
39              cpg h cV G L V1 V2 → cpg h cT G L T1 T2 →
40              cpg h ((↓cV)+cT) G L (ⓕ{I}V1.T1) (ⓕ{I}V2.T2)
41 | cpg_zeta : ∀c,G,L,V,T1,T,T2. cpg h c G (L.ⓓV) T1 T →
42              ⬆*[1] T2 ≡ T → cpg h ((↓c)+𝟙𝟘) G L (+ⓓV.T1) T2
43 | cpg_eps  : ∀c,G,L,V,T1,T2. cpg h c G L T1 T2 → cpg h ((↓c)+𝟙𝟘) G L (ⓝV.T1) T2
44 | cpg_ee   : ∀c,G,L,V1,V2,T. cpg h c G L V1 V2 → cpg h ((↓c)+𝟘𝟙) G L (ⓝV1.T) V2
45 | cpg_beta : ∀cV,cW,cT,p,G,L,V1,V2,W1,W2,T1,T2.
46              cpg h cV G L V1 V2 → cpg h cW G L W1 W2 → cpg h cT G (L.ⓛW1) T1 T2 →
47              cpg h ((↓cV)+(↓cW)+(↓cT)+𝟙𝟘) G L (ⓐV1.ⓛ{p}W1.T1) (ⓓ{p}ⓝW2.V2.T2)
48 | cpg_theta: ∀cV,cW,cT,p,G,L,V1,V,V2,W1,W2,T1,T2.
49              cpg h cV G L V1 V → ⬆*[1] V ≡ V2 → cpg h cW G L W1 W2 →
50              cpg h cT G (L.ⓓW1) T1 T2 →
51              cpg h ((↓cV)+(↓cW)+(↓cT)+𝟙𝟘) G L (ⓐV1.ⓓ{p}W1.T1) (ⓓ{p}W2.ⓐV2.T2)
52 .
53
54 interpretation
55    "counted context-sensitive parallel rt-transition (term)"
56    'PRedTy c h G L T1 T2 = (cpg h c G L T1 T2).
57
58 (* Basic properties *********************************************************)
59
60 (* Note: this is "∀h,g,L. reflexive … (cpg h (𝟘𝟘) L)" *)
61 lemma cpg_refl: ∀h,G,T,L. ⦃G, L⦄ ⊢ T ⬈[𝟘𝟘, h] T.
62 #h #G #T elim T -T // * /2 width=1 by cpg_bind, cpg_flat/
63 qed.
64
65 lemma cpg_pair_sn: ∀c,h,I,G,L,V1,V2. ⦃G, L⦄ ⊢ V1 ⬈[c, h] V2 →
66                    ∀T. ⦃G, L⦄ ⊢ ②{I}V1.T ⬈[↓c, h] ②{I}V2.T.
67 #c #h * /2 width=1 by cpg_bind, cpg_flat/
68 qed.
69
70 (* Basic inversion lemmas ***************************************************)
71
72 fact cpg_inv_atom1_aux: ∀c,h,G,L,T1,T2. ⦃G, L⦄ ⊢ T1 ⬈[c, h] T2 → ∀J. T1 = ⓪{J} →
73                         ∨∨ T2 = ⓪{J} ∧ c = 𝟘𝟘 
74                          | ∃∃s. J = Sort s & T2 = ⋆(next h s) & c = 𝟘𝟙
75                          | ∃∃cV,K,V1,V2. ⦃G, K⦄ ⊢ V1 ⬈[cV, h] V2 & ⬆*[1] V2 ≡ T2 &
76                                          L = K.ⓓV1 & J = LRef 0 & c = cV
77                          | ∃∃cV,K,V1,V2. ⦃G, K⦄ ⊢ V1 ⬈[cV, h] V2 & ⬆*[1] V2 ≡ T2 &
78                                          L = K.ⓛV1 & J = LRef 0 & c = (↓cV)+𝟘𝟙
79                          | ∃∃I,K,V,T,i. ⦃G, K⦄ ⊢ #i ⬈[c, h] T & ⬆*[1] T ≡ T2 &
80                                         L = K.ⓑ{I}V & J = LRef (⫯i).
81 #c #h #G #L #T1 #T2 * -c -G -L -T1 -T2
82 [ #I #G #L #J #H destruct /3 width=1 by or5_intro0, conj/
83 | #G #L #s #J #H destruct /3 width=3 by or5_intro1, ex3_intro/
84 | #c #G #L #V1 #V2 #W2 #HV12 #VW2 #J #H destruct /3 width=8 by or5_intro2, ex5_4_intro/
85 | #c #G #L #V1 #V2 #W2 #HV12 #VW2 #J #H destruct /3 width=8 by or5_intro3, ex5_4_intro/
86 | #c #I #G #L #V #T #U #i #HT #HTU #J #H destruct /3 width=9 by or5_intro4, ex4_5_intro/
87 | #cV #cT #p #I #G #L #V1 #V2 #T1 #T2 #_ #_ #J #H destruct
88 | #cV #cT #I #G #L #V1 #V2 #T1 #T2 #_ #_ #J #H destruct
89 | #c #G #L #V #T1 #T #T2 #_ #_ #J #H destruct
90 | #c #G #L #V #T1 #T2 #_ #J #H destruct
91 | #c #G #L #V1 #V2 #T #_ #J #H destruct
92 | #cV #cW #cT #p #G #L #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #J #H destruct
93 | #cV #cW #cT #p #G #L #V1 #V #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #J #H destruct
94 ]
95 qed-.
96
97 lemma cpg_inv_atom1: ∀c,h,J,G,L,T2. ⦃G, L⦄ ⊢ ⓪{J} ⬈[c, h] T2 →
98                      ∨∨ T2 = ⓪{J} ∧ c = 𝟘𝟘 
99                       | ∃∃s. J = Sort s & T2 = ⋆(next h s) & c = 𝟘𝟙
100                       | ∃∃cV,K,V1,V2. ⦃G, K⦄ ⊢ V1 ⬈[cV, h] V2 & ⬆*[1] V2 ≡ T2 &
101                                       L = K.ⓓV1 & J = LRef 0 & c = cV
102                       | ∃∃cV,K,V1,V2. ⦃G, K⦄ ⊢ V1 ⬈[cV, h] V2 & ⬆*[1] V2 ≡ T2 &
103                                       L = K.ⓛV1 & J = LRef 0 & c = (↓cV)+𝟘𝟙
104                       | ∃∃I,K,V,T,i. ⦃G, K⦄ ⊢ #i ⬈[c, h] T & ⬆*[1] T ≡ T2 &
105                                      L = K.ⓑ{I}V & J = LRef (⫯i).
106 /2 width=3 by cpg_inv_atom1_aux/ qed-.
107
108 lemma cpg_inv_sort1: ∀c,h,G,L,T2,s. ⦃G, L⦄ ⊢ ⋆s ⬈[c, h] T2 →
109                      (T2 = ⋆s ∧ c = 𝟘𝟘) ∨ (T2 = ⋆(next h s) ∧ c = 𝟘𝟙).
110 #c #h #G #L #T2 #s #H
111 elim (cpg_inv_atom1 … H) -H * /3 width=1 by or_introl, conj/
112 [ #s0 #H destruct /3 width=1 by or_intror, conj/
113 |2,3: #cV #K #V1 #V2 #_ #_ #_ #H destruct
114 | #I #K #V1 #V2 #i #_ #_ #_ #H destruct
115 ]
116 qed-.
117
118 lemma cpg_inv_zero1: ∀c,h,G,L,T2. ⦃G, L⦄ ⊢ #0 ⬈[c, h] T2 →
119                      ∨∨ (T2 = #0 ∧ c = 𝟘𝟘)
120                       | ∃∃cV,K,V1,V2. ⦃G, K⦄ ⊢ V1 ⬈[cV, h] V2 & ⬆*[1] V2 ≡ T2 &
121                                       L = K.ⓓV1 & c = cV
122                       | ∃∃cV,K,V1,V2. ⦃G, K⦄ ⊢ V1 ⬈[cV, h] V2 & ⬆*[1] V2 ≡ T2 &
123                                       L = K.ⓛV1 & c = (↓cV)+𝟘𝟙.
124 #c #h #G #L #T2 #H
125 elim (cpg_inv_atom1 … H) -H * /3 width=1 by or3_intro0, conj/
126 [ #s #H destruct
127 |2,3: #cV #K #V1 #V2 #HV12 #HVT2 #H1 #_ #H2 destruct /3 width=8 by or3_intro1, or3_intro2, ex4_4_intro/
128 | #I #K #V1 #V2 #i #_ #_ #_ #H destruct
129 ]
130 qed-.
131
132 lemma cpg_inv_lref1: ∀c,h,G,L,T2,i. ⦃G, L⦄ ⊢ #⫯i ⬈[c, h] T2 →
133                      (T2 = #(⫯i) ∧ c = 𝟘𝟘) ∨
134                      ∃∃I,K,V,T. ⦃G, K⦄ ⊢ #i ⬈[c, h] T & ⬆*[1] T ≡ T2 & L = K.ⓑ{I}V.
135 #c #h #G #L #T2 #i #H
136 elim (cpg_inv_atom1 … H) -H * /3 width=1 by or_introl, conj/
137 [ #s #H destruct
138 |2,3: #cV #K #V1 #V2 #_ #_ #_ #H destruct
139 | #I #K #V1 #V2 #j #HV2 #HVT2 #H1 #H2 destruct /3 width=7 by ex3_4_intro, or_intror/
140 ]
141 qed-.
142
143 lemma cpg_inv_gref1: ∀c,h,G,L,T2,l. ⦃G, L⦄ ⊢ §l ⬈[c, h] T2 → T2 = §l ∧ c = 𝟘𝟘.
144 #c #h #G #L #T2 #l #H
145 elim (cpg_inv_atom1 … H) -H * /2 width=1 by conj/
146 [ #s #H destruct
147 |2,3: #cV #K #V1 #V2 #_ #_ #_ #H destruct
148 | #I #K #V1 #V2 #i #_ #_ #_ #H destruct
149 ]
150 qed-.
151
152 fact cpg_inv_bind1_aux: ∀c,h,G,L,U,U2. ⦃G, L⦄ ⊢ U ⬈[c, h] U2 →
153                         ∀p,J,V1,U1. U = ⓑ{p,J}V1.U1 → (
154                         ∃∃cV,cT,V2,T2. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] V2 & ⦃G, L.ⓑ{J}V1⦄ ⊢ U1 ⬈[cT, h] T2 &
155                                        U2 = ⓑ{p,J}V2.T2 & c = (↓cV)+cT
156                         ) ∨
157                         ∃∃cT,T. ⦃G, L.ⓓV1⦄ ⊢ U1 ⬈[cT, h] T & ⬆*[1] U2 ≡ T &
158                                 p = true & J = Abbr & c = (↓cT)+𝟙𝟘.
159 #c #h #G #L #U #U2 * -c -G -L -U -U2
160 [ #I #G #L #q #J #W #U1 #H destruct
161 | #G #L #s #q #J #W #U1 #H destruct
162 | #c #G #L #V1 #V2 #W2 #_ #_ #q #J #W #U1 #H destruct
163 | #c #G #L #V1 #V2 #W2 #_ #_ #q #J #W #U1 #H destruct
164 | #c #I #G #L #V #T #U #i #_ #_ #q #J #W #U1 #H destruct
165 | #rv #cT #p #I #G #L #V1 #V2 #T1 #T2 #HV12 #HT12 #q #J #W #U1 #H destruct /3 width=8 by ex4_4_intro, or_introl/
166 | #rv #cT #I #G #L #V1 #V2 #T1 #T2 #_ #_ #q #J #W #U1 #H destruct
167 | #c #G #L #V #T1 #T #T2 #HT1 #HT2 #q #J #W #U1 #H destruct /3 width=5 by ex5_2_intro, or_intror/
168 | #c #G #L #V #T1 #T2 #_ #q #J #W #U1 #H destruct
169 | #c #G #L #V1 #V2 #T #_ #q #J #W #U1 #H destruct
170 | #rv #cW #cT #p #G #L #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #q #J #W #U1 #H destruct
171 | #rv #cW #cT #p #G #L #V1 #V #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #q #J #W #U1 #H destruct
172 ]
173 qed-.
174
175 lemma cpg_inv_bind1: ∀c,h,p,I,G,L,V1,T1,U2. ⦃G, L⦄ ⊢ ⓑ{p,I}V1.T1 ⬈[c, h] U2 → (
176                      ∃∃cV,cT,V2,T2. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] V2 & ⦃G, L.ⓑ{I}V1⦄ ⊢ T1 ⬈[cT, h] T2 &
177                                     U2 = ⓑ{p,I}V2.T2 & c = (↓cV)+cT
178                      ) ∨
179                      ∃∃cT,T. ⦃G, L.ⓓV1⦄ ⊢ T1 ⬈[cT, h] T & ⬆*[1] U2 ≡ T &
180                              p = true & I = Abbr & c = (↓cT)+𝟙𝟘.
181 /2 width=3 by cpg_inv_bind1_aux/ qed-.
182
183 lemma cpg_inv_abbr1: ∀c,h,p,G,L,V1,T1,U2. ⦃G, L⦄ ⊢ ⓓ{p}V1.T1 ⬈[c, h] U2 → (
184                      ∃∃cV,cT,V2,T2. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] V2 & ⦃G, L.ⓓV1⦄ ⊢ T1 ⬈[cT, h] T2 &
185                                     U2 = ⓓ{p}V2.T2 & c = (↓cV)+cT
186                      ) ∨
187                      ∃∃cT,T. ⦃G, L.ⓓV1⦄ ⊢ T1 ⬈[cT, h] T & ⬆*[1] U2 ≡ T &
188                              p = true & c = (↓cT)+𝟙𝟘.
189 #c #h #p #G #L #V1 #T1 #U2 #H elim (cpg_inv_bind1 … H) -H *
190 /3 width=8 by ex4_4_intro, ex4_2_intro, or_introl, or_intror/
191 qed-.
192
193 lemma cpg_inv_abst1: ∀c,h,p,G,L,V1,T1,U2. ⦃G, L⦄ ⊢ ⓛ{p}V1.T1 ⬈[c, h] U2 →
194                      ∃∃cV,cT,V2,T2. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] V2 & ⦃G, L.ⓛV1⦄ ⊢ T1 ⬈[cT, h] T2 &
195                                     U2 = ⓛ{p}V2.T2 & c = (↓cV)+cT.
196 #c #h #p #G #L #V1 #T1 #U2 #H elim (cpg_inv_bind1 … H) -H * 
197 [ /3 width=8 by ex4_4_intro/
198 | #c #T #_ #_ #_ #H destruct
199 ]
200 qed-.
201
202 fact cpg_inv_flat1_aux: ∀c,h,G,L,U,U2. ⦃G, L⦄ ⊢ U ⬈[c, h] U2 →
203                         ∀J,V1,U1. U = ⓕ{J}V1.U1 →
204                         ∨∨ ∃∃cV,cT,V2,T2. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] V2 & ⦃G, L⦄ ⊢ U1 ⬈[cT, h] T2 &
205                                           U2 = ⓕ{J}V2.T2 & c = (↓cV)+cT
206                          | ∃∃cT. ⦃G, L⦄ ⊢ U1 ⬈[cT, h] U2 & J = Cast & c = (↓cT)+𝟙𝟘
207                          | ∃∃cV. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] U2 & J = Cast & c = (↓cV)+𝟘𝟙
208                          | ∃∃cV,cW,cT,p,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] V2 & ⦃G, L⦄ ⊢ W1 ⬈[cW, h] W2 & ⦃G, L.ⓛW1⦄ ⊢ T1 ⬈[cT, h] T2 &
209                                                         J = Appl & U1 = ⓛ{p}W1.T1 & U2 = ⓓ{p}ⓝW2.V2.T2 & c = (↓cV)+(↓cW)+(↓cT)+𝟙𝟘
210                          | ∃∃cV,cW,cT,p,V,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] V & ⬆*[1] V ≡ V2 & ⦃G, L⦄ ⊢ W1 ⬈[cW, h] W2 & ⦃G, L.ⓓW1⦄ ⊢ T1 ⬈[cT, h] T2 &
211                                                           J = Appl & U1 = ⓓ{p}W1.T1 & U2 = ⓓ{p}W2.ⓐV2.T2 & c = (↓cV)+(↓cW)+(↓cT)+𝟙𝟘.
212 #c #h #G #L #U #U2 * -c -G -L -U -U2
213 [ #I #G #L #J #W #U1 #H destruct
214 | #G #L #s #J #W #U1 #H destruct
215 | #c #G #L #V1 #V2 #W2 #_ #_ #J #W #U1 #H destruct
216 | #c #G #L #V1 #V2 #W2 #_ #_ #J #W #U1 #H destruct
217 | #c #I #G #L #V #T #U #i #_ #_ #J #W #U1 #H destruct
218 | #rv #cT #p #I #G #L #V1 #V2 #T1 #T2 #_ #_ #J #W #U1 #H destruct
219 | #rv #cT #I #G #L #V1 #V2 #T1 #T2 #HV12 #HT12 #J #W #U1 #H destruct /3 width=8 by or5_intro0, ex4_4_intro/
220 | #c #G #L #V #T1 #T #T2 #_ #_ #J #W #U1 #H destruct
221 | #c #G #L #V #T1 #T2 #HT12 #J #W #U1 #H destruct /3 width=3 by or5_intro1, ex3_intro/
222 | #c #G #L #V1 #V2 #T #HV12 #J #W #U1 #H destruct /3 width=3 by or5_intro2, ex3_intro/
223 | #rv #cW #cT #p #G #L #V1 #V2 #W1 #W2 #T1 #T2 #HV12 #HW12 #HT12 #J #W #U1 #H destruct /3 width=15 by or5_intro3, ex7_9_intro/
224 | #rv #cW #cT #p #G #L #V1 #V #V2 #W1 #W2 #T1 #T2 #HV1 #HV2 #HW12 #HT12 #J #W #U1 #H destruct /3 width=17 by or5_intro4, ex8_10_intro/
225 ]
226 qed-.
227
228 lemma cpg_inv_flat1: ∀c,h,I,G,L,V1,U1,U2. ⦃G, L⦄ ⊢ ⓕ{I}V1.U1 ⬈[c, h] U2 →
229                      ∨∨ ∃∃cV,cT,V2,T2. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] V2 & ⦃G, L⦄ ⊢ U1 ⬈[cT, h] T2 &
230                                        U2 = ⓕ{I}V2.T2 & c = (↓cV)+cT
231                       | ∃∃cT. ⦃G, L⦄ ⊢ U1 ⬈[cT, h] U2 & I = Cast & c = (↓cT)+𝟙𝟘
232                       | ∃∃cV. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] U2 & I = Cast & c = (↓cV)+𝟘𝟙
233                       | ∃∃cV,cW,cT,p,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] V2 & ⦃G, L⦄ ⊢ W1 ⬈[cW, h] W2 & ⦃G, L.ⓛW1⦄ ⊢ T1 ⬈[cT, h] T2 &
234                                                      I = Appl & U1 = ⓛ{p}W1.T1 & U2 = ⓓ{p}ⓝW2.V2.T2 & c = (↓cV)+(↓cW)+(↓cT)+𝟙𝟘
235                       | ∃∃cV,cW,cT,p,V,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] V & ⬆*[1] V ≡ V2 & ⦃G, L⦄ ⊢ W1 ⬈[cW, h] W2 & ⦃G, L.ⓓW1⦄ ⊢ T1 ⬈[cT, h] T2 &
236                                                        I = Appl & U1 = ⓓ{p}W1.T1 & U2 = ⓓ{p}W2.ⓐV2.T2 & c = (↓cV)+(↓cW)+(↓cT)+𝟙𝟘.
237 /2 width=3 by cpg_inv_flat1_aux/ qed-.
238
239 lemma cpg_inv_appl1: ∀c,h,G,L,V1,U1,U2. ⦃G, L⦄ ⊢ ⓐV1.U1 ⬈[c, h] U2 →
240                      ∨∨ ∃∃cV,cT,V2,T2. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] V2 & ⦃G, L⦄ ⊢ U1 ⬈[cT, h] T2 &
241                                        U2 = ⓐV2.T2 & c = (↓cV)+cT
242                       | ∃∃cV,cW,cT,p,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] V2 & ⦃G, L⦄ ⊢ W1 ⬈[cW, h] W2 & ⦃G, L.ⓛW1⦄ ⊢ T1 ⬈[cT, h] T2 &
243                                                      U1 = ⓛ{p}W1.T1 & U2 = ⓓ{p}ⓝW2.V2.T2 & c = (↓cV)+(↓cW)+(↓cT)+𝟙𝟘
244                       | ∃∃cV,cW,cT,p,V,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] V & ⬆*[1] V ≡ V2 & ⦃G, L⦄ ⊢ W1 ⬈[cW, h] W2 & ⦃G, L.ⓓW1⦄ ⊢ T1 ⬈[cT, h] T2 &
245                                                        U1 = ⓓ{p}W1.T1 & U2 = ⓓ{p}W2.ⓐV2.T2 & c = (↓cV)+(↓cW)+(↓cT)+𝟙𝟘.
246 #c #h #G #L #V1 #U1 #U2 #H elim (cpg_inv_flat1 … H) -H *
247 [ /3 width=8 by or3_intro0, ex4_4_intro/
248 |2,3: #c #_ #H destruct
249 | /3 width=15 by or3_intro1, ex6_9_intro/
250 | /3 width=17 by or3_intro2, ex7_10_intro/
251 ]
252 qed-.
253
254 lemma cpg_inv_cast1: ∀c,h,G,L,V1,U1,U2. ⦃G, L⦄ ⊢ ⓝV1.U1 ⬈[c, h] U2 →
255                      ∨∨ ∃∃cV,cT,V2,T2. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] V2 & ⦃G, L⦄ ⊢ U1 ⬈[cT, h] T2 &
256                                        U2 = ⓝV2.T2 & c = (↓cV)+cT
257                       | ∃∃cT. ⦃G, L⦄ ⊢ U1 ⬈[cT, h] U2 & c = (↓cT)+𝟙𝟘
258                       | ∃∃cV. ⦃G, L⦄ ⊢ V1 ⬈[cV, h] U2 & c = (↓cV)+𝟘𝟙.
259 #c #h #G #L #V1 #U1 #U2 #H elim (cpg_inv_flat1 … H) -H *
260 [ /3 width=8 by or3_intro0, ex4_4_intro/
261 |2,3: /3 width=3 by or3_intro1, or3_intro2, ex2_intro/
262 | #rv #cW #cT #p #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #H destruct
263 | #rv #cW #cT #p #V #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #H destruct
264 ]
265 qed-.
266
267 (* Basic forward lemmas *****************************************************)
268
269 lemma cpg_fwd_bind1_minus: ∀c,h,I,G,L,V1,T1,T. ⦃G, L⦄ ⊢ -ⓑ{I}V1.T1 ⬈[c, h] T → ∀p.
270                            ∃∃V2,T2. ⦃G, L⦄ ⊢ ⓑ{p,I}V1.T1 ⬈[c, h] ⓑ{p,I}V2.T2 &
271                                     T = -ⓑ{I}V2.T2.
272 #c #h #I #G #L #V1 #T1 #T #H #p elim (cpg_inv_bind1 … H) -H *
273 [ #cV #cT #V2 #T2 #HV12 #HT12 #H1 #H2 destruct /3 width=4 by cpg_bind, ex2_2_intro/
274 | #c #T2 #_ #_ #H destruct
275 ]
276 qed-.