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