]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/dynamic/snv.ma
partial commit: just the components before "static" ...
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / dynamic / snv.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/notation/relations/nativevalid_4.ma".
16 include "basic_2/computation/cpds.ma".
17 include "basic_2/equivalence/cpcs.ma".
18
19 (* STRATIFIED NATIVE VALIDITY FOR TERMS *************************************)
20
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             ⦃G, L⦄ ⊢ V •[h, g] ⦃l+1, W⦄ → ⦃G, L⦄ ⊢ W ➡* W0 →
27             ⦃G, L⦄ ⊢ T •*➡*[h, 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             ⦃G, L⦄ ⊢ T •[h, g] ⦃l+1, U⦄ → ⦃G, L⦄ ⊢ U ⬌* W → snv h g L (ⓝW.T)
30 .
31
32 interpretation "stratified native validity (term)"
33    'NativeValid h g L T = (snv h g L T).
34
35 (* Basic inversion lemmas ***************************************************)
36
37 fact snv_inv_lref_aux: ∀h,g,L,X. ⦃G, L⦄ ⊢ X ¡[h, g] → ∀i. X = #i →
38                        ∃∃I,K,V. ⇩[0, i] L ≡ K.ⓑ{I}V & ⦃h, K⦄ ⊢ V ¡[h, g].
39 #h #g #L #X * -L -X
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
45 ]
46 qed.
47
48 lemma snv_inv_lref: ∀h,g,L,i. ⦃G, L⦄ ⊢ #i ¡[h, g] →
49                     ∃∃I,K,V. ⇩[0, i] L ≡ K.ⓑ{I}V & ⦃h, K⦄ ⊢ V ¡[h, g].
50 /2 width=3/ qed-.
51
52 fact snv_inv_gref_aux: ∀h,g,L,X. ⦃G, L⦄ ⊢ X ¡[h, g] → ∀p. X = §p → ⊥.
53 #h #g #L #X * -L -X
54 [ #L #k #p #H destruct
55 | #I #L #K #V #i #_ #_ #p #H destruct
56 | #a #I #L #V #T #_ #_ #p #H destruct
57 | #a #L #V #W #W0 #T #U #l #_ #_ #_ #_ #_ #p #H destruct
58 | #L #W #T #U #l #_ #_ #_ #_ #p #H destruct
59 ]
60 qed.
61
62 lemma snv_inv_gref: ∀h,g,L,p. ⦃G, L⦄ ⊢ §p ¡[h, g] → ⊥.
63 /2 width=7/ qed-.
64
65 fact snv_inv_bind_aux: ∀h,g,L,X. ⦃G, L⦄ ⊢ X ¡[h, g] → ∀a,I,V,T. X = ⓑ{a,I}V.T →
66                        ⦃G, L⦄ ⊢ V ¡[h, g] ∧ ⦃h, L.ⓑ{I}V⦄ ⊢ T ¡[h, g].
67 #h #g #L #X * -L -X
68 [ #L #k #a #I #V #T #H destruct
69 | #I0 #L #K #V0 #i #_ #_ #a #I #V #T #H destruct
70 | #b #I0 #L #V0 #T0 #HV0 #HT0 #a #I #V #T #H destruct /2 width=1/
71 | #b #L #V0 #W0 #W00 #T0 #U0 #l #_ #_ #_ #_ #_ #a #I #V #T #H destruct
72 | #L #W0 #T0 #U0 #l #_ #_ #_ #_ #a #I #V #T #H destruct
73 ]
74 qed.
75
76 lemma snv_inv_bind: ∀h,g,a,I,L,V,T. ⦃G, L⦄ ⊢ ⓑ{a,I}V.T ¡[h, g] →
77                         ⦃G, L⦄ ⊢ V ¡[h, g] ∧ ⦃h, L.ⓑ{I}V⦄ ⊢ T ¡[h, g].
78 /2 width=4/ qed-.
79
80 fact snv_inv_appl_aux: ∀h,g,L,X. ⦃G, L⦄ ⊢ X ¡[h, g] → ∀V,T. X = ⓐV.T →
81                        ∃∃a,W,W0,U,l. ⦃G, L⦄ ⊢ V ¡[h, g] & ⦃G, L⦄ ⊢ T ¡[h, g] &
82                                    ⦃G, L⦄ ⊢ V •[h, g] ⦃l+1, W⦄ & ⦃G, L⦄ ⊢ W ➡* W0 &
83                                    ⦃G, L⦄ ⊢ T •*➡*[h, g] ⓛ{a}W0.U.
84 #h #g #L #X * -L -X
85 [ #L #k #V #T #H destruct
86 | #I #L #K #V0 #i #_ #_ #V #T #H destruct
87 | #a #I #L #V0 #T0 #_ #_ #V #T #H destruct
88 | #a #L #V0 #W0 #W00 #T0 #U0 #l #HV0 #HT0 #HVW0 #HW00 #HTU0 #V #T #H destruct /2 width=8/
89 | #L #W0 #T0 #U0 #l #_ #_ #_ #_ #V #T #H destruct
90 ]
91 qed.
92
93 lemma snv_inv_appl: ∀h,g,L,V,T. ⦃G, L⦄ ⊢ ⓐV.T ¡[h, g] →
94                     ∃∃a,W,W0,U,l. ⦃G, L⦄ ⊢ V ¡[h, g] & ⦃G, L⦄ ⊢ T ¡[h, g] &
95                                 ⦃G, L⦄ ⊢ V •[h, g] ⦃l+1, W⦄ & ⦃G, L⦄ ⊢ W ➡* W0 &
96                                 ⦃G, L⦄ ⊢ T •*➡*[h, g] ⓛ{a}W0.U.
97 /2 width=3/ qed-.
98
99 fact snv_inv_cast_aux: ∀h,g,L,X. ⦃G, L⦄ ⊢ X ¡[h, g] → ∀W,T. X = ⓝW.T →
100                        ∃∃U,l. ⦃G, L⦄ ⊢ W ¡[h, g] & ⦃G, L⦄ ⊢ T ¡[h, g] &
101                               ⦃G, L⦄ ⊢ T •[h, g] ⦃l+1, U⦄ & ⦃G, L⦄ ⊢ U ⬌* W.
102 #h #g #L #X * -L -X
103 [ #L #k #W #T #H destruct
104 | #I #L #K #V #i #_ #_ #W #T #H destruct
105 | #a #I #L #V #T0 #_ #_ #W #T #H destruct
106 | #a #L #V #W0 #W00 #T0 #U #l #_ #_ #_ #_ #_ #W #T #H destruct
107 | #L #W0 #T0 #U0 #l #HW0 #HT0 #HTU0 #HUW0 #W #T #H destruct /2 width=4/
108 ]
109 qed.
110
111 lemma snv_inv_cast: ∀h,g,L,W,T. ⦃G, L⦄ ⊢ ⓝW.T ¡[h, g] →
112                     ∃∃U,l. ⦃G, L⦄ ⊢ W ¡[h, g] & ⦃G, L⦄ ⊢ T ¡[h, g] &
113                            ⦃G, L⦄ ⊢ T •[h, g] ⦃l+1, U⦄ & ⦃G, L⦄ ⊢ U ⬌* W.
114 /2 width=3/ qed-.
115
116 (* Basic forward lemmas *****************************************************)
117
118 lemma snv_fwd_ssta: ∀h,g,L,T. ⦃G, L⦄ ⊢ T ¡[h, g] → ∃∃l,U. ⦃G, L⦄ ⊢ T •[h, g] ⦃l, U⦄.
119 #h #g #L #T #H elim H -L -T
120 [ #L #k elim (deg_total h g k) /3 width=3/
121 | * #L #K #V #i #HLK #_ * #l0 #W #HVW
122   [ elim (lift_total W 0 (i+1)) /3 width=8/
123   | elim (lift_total V 0 (i+1)) /3 width=8/
124   ]
125 | #a #I #L #V #T #_ #_ #_ * /3 width=3/
126 | #a #L #V #W #W1 #T0 #T1 #l #_ #_ #_ #_ #_ #_ * /3 width=3/
127 | #L #W #T #U #l #_ #_ #HTU #_ #_ #_ /3 width=3/ (**) (* auto fails without the last #_ *)
128 ]
129 qed-.