1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "basic_2/computation/cprs.ma".
16 include "basic_2/computation/xprs.ma".
17 include "basic_2/equivalence/cpcs.ma".
19 (* STRATIFIED NATIVE VALIDITY FOR TERMS *************************************)
21 inductive snv (h:sh) (g:sd h): lenv → predicate term ≝
22 | snv_sort: ∀L,k. snv h g L (⋆k)
23 | snv_lref: ∀I,L,K,V,i. ⇩[0, i] L ≡ K.ⓑ{I}V → snv h g K V → snv h g L (#i)
24 | snv_bind: ∀a,I,L,V,T. snv h g L V → snv h g (L.ⓑ{I}V) T → snv h g L (ⓑ{a,I}V.T)
25 | snv_appl: ∀a,L,V,W,W0,T,U,l. snv h g L V → snv h g L T →
26 ⦃h, L⦄ ⊢ V •[g, l + 1] W → L ⊢ W ➡* W0 →
27 ⦃h, L⦄ ⊢ T •➡*[g] ⓛ{a}W0.U → snv h g L (ⓐV.T)
28 | snv_cast: ∀L,W,T,U,l. snv h g L W → snv h g L T →
29 ⦃h, L⦄ ⊢ T •[g, l + 1] U → L ⊢ W ⬌* U → snv h g L (ⓝW.T)
32 interpretation "stratified native validity (term)"
33 'NativeValid h g L T = (snv h g L T).
35 (* Basic inversion lemmas ***************************************************)
37 fact snv_inv_lref_aux: ∀h,g,L,X. ⦃h, L⦄ ⊩ X :[g] → ∀i. X = #i →
38 ∃∃I,K,V. ⇩[0, i] L ≡ K.ⓑ{I}V & ⦃h, K⦄ ⊩ V :[g].
40 [ #L #k #i #H destruct
41 | #I #L #K #V #i0 #HLK #HV #i #H destruct /2 width=5/
42 | #a #I #L #V #T #_ #_ #i #H destruct
43 | #a #L #V #W #W0 #T #U #l #_ #_ #_ #_ #_ #i #H destruct
44 | #L #W #T #U #l #_ #_ #_ #_ #i #H destruct
48 lemma snv_inv_lref: ∀h,g,L,i. ⦃h, L⦄ ⊩ #i :[g] →
49 ∃∃I,K,V. ⇩[0, i] L ≡ K.ⓑ{I}V & ⦃h, K⦄ ⊩ V :[g].
52 fact snv_inv_bind_aux: ∀h,g,L,X. ⦃h, L⦄ ⊩ X :[g] → ∀a,I,V,T. X = ⓑ{a,I}V.T →
53 ⦃h, L⦄ ⊩ V :[g] ∧ ⦃h, L.ⓑ{I}V⦄ ⊩ T :[g].
55 [ #L #k #a #I #V #T #H destruct
56 | #I0 #L #K #V0 #i #_ #_ #a #I #V #T #H destruct
57 | #b #I0 #L #V0 #T0 #HV0 #HT0 #a #I #V #T #H destruct /2 width=1/
58 | #b #L #V0 #W0 #W00 #T0 #U0 #l #_ #_ #_ #_ #_ #a #I #V #T #H destruct
59 | #L #W0 #T0 #U0 #l #_ #_ #_ #_ #a #I #V #T #H destruct
63 lemma snv_inv_bind: ∀h,g,a,I,L,V,T. ⦃h, L⦄ ⊩ ⓑ{a,I}V.T :[g] →
64 ⦃h, L⦄ ⊩ V :[g] ∧ ⦃h, L.ⓑ{I}V⦄ ⊩ T :[g].
67 fact snv_inv_appl_aux: ∀h,g,L,X. ⦃h, L⦄ ⊩ X :[g] → ∀V,T. X = ⓐV.T →
68 ∃∃a,W,W0,U,l. ⦃h, L⦄ ⊩ V :[g] & ⦃h, L⦄ ⊩ T :[g] &
69 ⦃h, L⦄ ⊢ V •[g, l + 1] W & L ⊢ W ➡* W0 &
70 ⦃h, L⦄ ⊢ T •➡*[g] ⓛ{a}W0.U.
72 [ #L #k #V #T #H destruct
73 | #I #L #K #V0 #i #_ #_ #V #T #H destruct
74 | #a #I #L #V0 #T0 #_ #_ #V #T #H destruct
75 | #a #L #V0 #W0 #W00 #T0 #U0 #l #HV0 #HT0 #HVW0 #HW00 #HTU0 #V #T #H destruct /2 width=8/
76 | #L #W0 #T0 #U0 #l #_ #_ #_ #_ #V #T #H destruct
80 lemma snv_inv_appl: ∀h,g,L,V,T. ⦃h, L⦄ ⊩ ⓐV.T :[g] →
81 ∃∃a,W,W0,U,l. ⦃h, L⦄ ⊩ V :[g] & ⦃h, L⦄ ⊩ T :[g] &
82 ⦃h, L⦄ ⊢ V •[g, l + 1] W & L ⊢ W ➡* W0 &
83 ⦃h, L⦄ ⊢ T •➡*[g] ⓛ{a}W0.U.
86 fact snv_inv_cast_aux: ∀h,g,L,X. ⦃h, L⦄ ⊩ X :[g] → ∀W,T. X = ⓝW.T →
87 ∃∃U,l. ⦃h, L⦄ ⊩ W :[g] & ⦃h, L⦄ ⊩ T :[g] &
88 L ⊢ W ⬌* U & ⦃h, L⦄ ⊢ T •[g, l + 1] U.
90 [ #L #k #W #T #H destruct
91 | #I #L #K #V #i #_ #_ #W #T #H destruct
92 | #a #I #L #V #T0 #_ #_ #W #T #H destruct
93 | #a #L #V #W0 #W00 #T0 #U #l #_ #_ #_ #_ #_ #W #T #H destruct
94 | #L #W0 #T0 #U0 #l #HW0 #HT0 #HTU0 #HWU0 #W #T #H destruct /2 width=4/
98 lemma snv_inv_cast: ∀h,g,L,W,T. ⦃h, L⦄ ⊩ ⓝW.T :[g] →
99 ∃∃U,l. ⦃h, L⦄ ⊩ W :[g] & ⦃h, L⦄ ⊩ T :[g] &
100 L ⊢ W ⬌* U & ⦃h, L⦄ ⊢ T •[g, l + 1] U.