]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/static/ssta.ma
- test.ma on the disambiguation bug moved to ONAG (just out of the way)
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / static / ssta.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/statictype_7.ma".
16 include "basic_2/grammar/genv.ma".
17 include "basic_2/relocation/ldrop.ma".
18 include "basic_2/static/sd.ma".
19
20 (* STRATIFIED STATIC TYPE ASSIGNMENT ON TERMS *******************************)
21
22 (* activate genv *)
23 inductive ssta (h:sh) (g:sd h): nat → relation4 genv lenv term term ≝
24 | ssta_sort: ∀G,L,k,l. deg h g k l → ssta h g l G L (⋆k) (⋆(next h k))
25 | ssta_ldef: ∀G,L,K,V,W,U,i,l. ⇩[0, i] L ≡ K. ⓓV → ssta h g l G K V W →
26              ⇧[0, i + 1] W ≡ U → ssta h g l G L (#i) U
27 | ssta_ldec: ∀G,L,K,W,V,U,i,l. ⇩[0, i] L ≡ K. ⓛW → ssta h g l G K W V →
28              ⇧[0, i + 1] W ≡ U → ssta h g (l+1) G L (#i) U
29 | ssta_bind: ∀a,I,G,L,V,T,U,l. ssta h g l G (L. ⓑ{I} V) T U →
30              ssta h g l G L (ⓑ{a,I}V.T) (ⓑ{a,I}V.U)
31 | ssta_appl: ∀G,L,V,T,U,l. ssta h g l G L T U →
32              ssta h g l G L (ⓐV.T) (ⓐV.U)
33 | ssta_cast: ∀G,L,W,T,U,l. ssta h g l G L T U → ssta h g l G L (ⓝW.T) U
34 .
35
36 interpretation "stratified static type assignment (term)"
37    'StaticType h g G L T U l = (ssta h g l G L T U).
38
39 definition ssta_step: ∀h. sd h → relation4 genv lenv term term ≝
40                       λh,g,G,L,T,U. ∃l. ⦃G, L⦄ ⊢ T •[h, g] ⦃l+1, U⦄.
41
42 (* Basic inversion lemmas ************************************************)
43
44 fact ssta_inv_sort1_aux: ∀h,g,G,L,T,U,l. ⦃G, L⦄ ⊢ T •[h, g] ⦃l, U⦄ → ∀k0. T = ⋆k0 →
45                          deg h g k0 l ∧ U = ⋆(next h k0).
46 #h #g #G #L #T #U #l * -G -L -T -U -l
47 [ #G #L #k #l #Hkl #k0 #H destruct /2 width=1/
48 | #G #L #K #V #W #U #i #l #_ #_ #_ #k0 #H destruct
49 | #G #L #K #W #V #U #i #l #_ #_ #_ #k0 #H destruct
50 | #a #I #G #L #V #T #U #l #_ #k0 #H destruct
51 | #G #L #V #T #U #l #_ #k0 #H destruct
52 | #G #L #W #T #U #l #_ #k0 #H destruct
53 qed-.
54
55 (* Basic_1: was just: sty0_gen_sort *)
56 lemma ssta_inv_sort1: ∀h,g,G,L,U,k,l. ⦃G, L⦄ ⊢ ⋆k •[h, g] ⦃l, U⦄ →
57                       deg h g k l ∧ U = ⋆(next h k).
58 /2 width=5 by ssta_inv_sort1_aux/ qed-.
59
60 fact ssta_inv_lref1_aux: ∀h,g,G,L,T,U,l. ⦃G, L⦄ ⊢ T •[h, g] ⦃l, U⦄ → ∀j. T = #j →
61                          (∃∃K,V,W. ⇩[0, j] L ≡ K. ⓓV & ⦃G, K⦄ ⊢ V •[h, g] ⦃l, W⦄ &
62                                    ⇧[0, j + 1] W ≡ U
63                          ) ∨
64                          (∃∃K,W,V,l0. ⇩[0, j] L ≡ K. ⓛW & ⦃G, K⦄ ⊢ W •[h, g] ⦃l0, V⦄ &
65                                       ⇧[0, j + 1] W ≡ U & l = l0 + 1
66                          ).
67 #h #g #G #L #T #U #l * -G -L -T -U -l
68 [ #G #L #k #l #_ #j #H destruct
69 | #G #L #K #V #W #U #i #l #HLK #HVW #HWU #j #H destruct /3 width=6/
70 | #G #L #K #W #V #U #i #l #HLK #HWV #HWU #j #H destruct /3 width=8/
71 | #a #I #G #L #V #T #U #l #_ #j #H destruct
72 | #G #L #V #T #U #l #_ #j #H destruct
73 | #G #L #W #T #U #l #_ #j #H destruct
74 ]
75 qed-.
76
77 (* Basic_1: was just: sty0_gen_lref *)
78 lemma ssta_inv_lref1: ∀h,g,G,L,U,i,l. ⦃G, L⦄ ⊢ #i •[h, g] ⦃l, U⦄ →
79                       (∃∃K,V,W. ⇩[0, i] L ≡ K. ⓓV & ⦃G, K⦄ ⊢ V •[h, g] ⦃l, W⦄ &
80                                 ⇧[0, i + 1] W ≡ U
81                       ) ∨
82                       (∃∃K,W,V,l0. ⇩[0, i] L ≡ K. ⓛW & ⦃G, K⦄ ⊢ W •[h, g] ⦃l0, V⦄ &
83                                    ⇧[0, i + 1] W ≡ U & l = l0 + 1
84                       ).
85 /2 width=3 by ssta_inv_lref1_aux/ qed-.
86
87 fact ssta_inv_gref1_aux: ∀h,g,G,L,T,U,l. ⦃G, L⦄ ⊢ T •[h, g] ⦃l, U⦄ → ∀p0. T = §p0 → ⊥.
88 #h #g #G #L #T #U #l * -G -L -T -U -l
89 [ #G #L #k #l #_ #p0 #H destruct
90 | #G #L #K #V #W #U #i #l #_ #_ #_ #p0 #H destruct
91 | #G #L #K #W #V #U #i #l #_ #_ #_ #p0 #H destruct
92 | #a #I #G #L #V #T #U #l #_ #p0 #H destruct
93 | #G #L #V #T #U #l #_ #p0 #H destruct
94 | #G #L #W #T #U #l #_ #p0 #H destruct
95 qed-.
96
97 lemma ssta_inv_gref1: ∀h,g,G,L,U,p,l. ⦃G, L⦄ ⊢ §p •[h, g] ⦃l, U⦄ → ⊥.
98 /2 width=10 by ssta_inv_gref1_aux/ qed-.
99
100 fact ssta_inv_bind1_aux: ∀h,g,G,L,T,U,l. ⦃G, L⦄ ⊢ T •[h, g] ⦃l, U⦄ →
101                          ∀a,I,X,Y. T = ⓑ{a,I}Y.X →
102                          ∃∃Z. ⦃G, L.ⓑ{I}Y⦄ ⊢ X •[h, g] ⦃l, Z⦄ & U = ⓑ{a,I}Y.Z.
103 #h #g #G #L #T #U #l * -G -L -T -U -l
104 [ #G #L #k #l #_ #a #I #X #Y #H destruct
105 | #G #L #K #V #W #U #i #l #_ #_ #_ #a #I #X #Y #H destruct
106 | #G #L #K #W #V #U #i #l #_ #_ #_ #a #I #X #Y #H destruct
107 | #b #J #G #L #V #T #U #l #HTU #a #I #X #Y #H destruct /2 width=3/
108 | #G #L #V #T #U #l #_ #a #I #X #Y #H destruct
109 | #G #L #W #T #U #l #_ #a #I #X #Y #H destruct
110 ]
111 qed-.
112
113 (* Basic_1: was just: sty0_gen_bind *)
114 lemma ssta_inv_bind1: ∀h,g,a,I,G,L,Y,X,U,l. ⦃G, L⦄ ⊢ ⓑ{a,I}Y.X •[h, g] ⦃l, U⦄ →
115                       ∃∃Z. ⦃G, L.ⓑ{I}Y⦄ ⊢ X •[h, g] ⦃l, Z⦄ & U = ⓑ{a,I}Y.Z.
116 /2 width=3 by ssta_inv_bind1_aux/ qed-.
117
118 fact ssta_inv_appl1_aux: ∀h,g,G,L,T,U,l. ⦃G, L⦄ ⊢ T •[h, g] ⦃l, U⦄ → ∀X,Y. T = ⓐY.X →
119                          ∃∃Z. ⦃G, L⦄ ⊢ X •[h, g] ⦃l, Z⦄ & U = ⓐY.Z.
120 #h #g #G #L #T #U #l * -G -L -T -U -l
121 [ #G #L #k #l #_ #X #Y #H destruct
122 | #G #L #K #V #W #U #i #l #_ #_ #_ #X #Y #H destruct
123 | #G #L #K #W #V #U #i #l #_ #_ #_ #X #Y #H destruct
124 | #a #I #G #L #V #T #U #l #_ #X #Y #H destruct
125 | #G #L #V #T #U #l #HTU #X #Y #H destruct /2 width=3/
126 | #G #L #W #T #U #l #_ #X #Y #H destruct
127 ]
128 qed-.
129
130 (* Basic_1: was just: sty0_gen_appl *)
131 lemma ssta_inv_appl1: ∀h,g,G,L,Y,X,U,l. ⦃G, L⦄ ⊢ ⓐY.X •[h, g] ⦃l, U⦄ →
132                       ∃∃Z. ⦃G, L⦄ ⊢ X •[h, g] ⦃l, Z⦄ & U = ⓐY.Z.
133 /2 width=3 by ssta_inv_appl1_aux/ qed-.
134
135 fact ssta_inv_cast1_aux: ∀h,g,G,L,T,U,l. ⦃G, L⦄ ⊢ T •[h, g] ⦃l, U⦄ →
136                          ∀X,Y. T = ⓝY.X → ⦃G, L⦄ ⊢ X •[h, g] ⦃l, U⦄.
137 #h #g #G #L #T #U #l * -G -L -T -U -l
138 [ #G #L #k #l #_ #X #Y #H destruct
139 | #G #L #K #V #W #U #l #i #_ #_ #_ #X #Y #H destruct
140 | #G #L #K #W #V #U #l #i #_ #_ #_ #X #Y #H destruct
141 | #a #I #G #L #V #T #U #l #_ #X #Y #H destruct
142 | #G #L #V #T #U #l #_ #X #Y #H destruct
143 | #G #L #W #T #U #l #HTU #X #Y #H destruct //
144 ]
145 qed-.
146
147 (* Basic_1: was just: sty0_gen_cast *)
148 lemma ssta_inv_cast1: ∀h,g,G,L,X,Y,U,l. ⦃G, L⦄ ⊢ ⓝY.X •[h, g] ⦃l, U⦄ →
149                       ⦃G, L⦄ ⊢ X •[h, g] ⦃l, U⦄.
150 /2 width=4 by ssta_inv_cast1_aux/ qed-.