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/notation/relations/statictypestaralt_7.ma".
16 include "basic_2/unfold/lsstas_lift.ma".
18 (* NAT-ITERATED STRATIFIED STATIC TYPE ASSIGNMENT FOR TERMS *****************)
20 (* alternative definition of lsstas *)
21 inductive lsstasa (h) (g): genv → relation4 lenv nat term term ≝
22 | lsstasa_O : ∀G,L,T. lsstasa h g G L 0 T T
23 | lsstasa_sort: ∀G,L,l,k. lsstasa h g G L l (⋆k) (⋆((next h)^l k))
24 | lsstasa_ldef: ∀G,L,K,V,W,U,i,l. ⇩[i] L ≡ K.ⓓV → lsstasa h g G K (l+1) V W →
25 ⇧[0, i+1] W ≡ U → lsstasa h g G L (l+1) (#i) U
26 | lsstasa_ldec: ∀G,L,K,W,V,U,i,l,l0. ⇩[i] L ≡ K.ⓛW → ⦃G, K⦄ ⊢ W ▪[h, g] l0 →
27 lsstasa h g G K l W V → ⇧[0, i+1] V ≡ U → lsstasa h g G L (l+1) (#i) U
28 | lsstasa_bind: ∀a,I,G,L,V,T,U,l. lsstasa h g G (L.ⓑ{I}V) l T U →
29 lsstasa h g G L l (ⓑ{a,I}V.T) (ⓑ{a,I}V.U)
30 | lsstasa_appl: ∀G,L,V,T,U,l. lsstasa h g G L l T U → lsstasa h g G L l (ⓐV.T) (ⓐV.U)
31 | lsstasa_cast: ∀G,L,W,T,U,l. lsstasa h g G L (l+1) T U → lsstasa h g G L (l+1) (ⓝW.T) U
34 interpretation "nat-iterated stratified static type assignment (term) alternative"
35 'StaticTypeStarAlt h g G L l T U = (lsstasa h g G L l T U).
37 (* Base properties **********************************************************)
39 lemma ssta_lsstasa: ∀h,g,G,L,T,U. ⦃G, L⦄ ⊢ T •[h, g] U → ⦃G, L⦄ ⊢ T ••*[h, g, 1] U.
40 #h #g #G #L #T #U #H elim H -G -L -T -U
41 /2 width=8 by lsstasa_O, lsstasa_sort, lsstasa_ldef, lsstasa_ldec, lsstasa_bind, lsstasa_appl, lsstasa_cast/
44 lemma lsstasa_step_dx: ∀h,g,G,L,T1,T,l. ⦃G, L⦄ ⊢ T1 ••*[h, g, l] T →
45 ∀T2. ⦃G, L⦄ ⊢ T •[h, g] T2 → ⦃G, L⦄ ⊢ T1 ••*[h, g, l+1] T2.
46 #h #g #G #L #T1 #T #l #H elim H -G -L -T1 -T -l
48 | #G #L #l #k #X #H >(ssta_inv_sort1 … H) -X >commutative_plus //
49 | #G #L #K #V #W #U #i #l #HLK #_ #HWU #IHVW #U2 #HU2
50 lapply (ldrop_fwd_drop2 … HLK) #H
51 elim (ssta_inv_lift1 … HU2 … H … HWU) -H -U /3 width=6 by lsstasa_ldef/
52 | #G #L #K #W #V #U #i #l #l0 #HLK #HWl0 #_ #HVU #IHWV #U2 #HU2
53 lapply (ldrop_fwd_drop2 … HLK) #H
54 elim (ssta_inv_lift1 … HU2 … H … HVU) -H -U /3 width=8 by lsstasa_ldec/
55 | #a #I #G #L #V #T1 #U1 #l #_ #IHTU1 #X #H
56 elim (ssta_inv_bind1 … H) -H #U #HU1 #H destruct /3 width=1 by lsstasa_bind/
57 | #G #L #V #T1 #U1 #l #_ #IHTU1 #X #H
58 elim (ssta_inv_appl1 … H) -H #U #HU1 #H destruct /3 width=1 by lsstasa_appl/
59 | /3 width=1 by lsstasa_cast/
63 (* Main properties **********************************************************)
65 theorem lsstas_lsstasa: ∀h,g,G,L,T,U,l. ⦃G, L⦄ ⊢ T •*[h, g, l] U → ⦃G, L⦄ ⊢ T ••*[h, g, l] U.
66 #h #g #G #L #T #U #l #H @(lsstas_ind_dx … H) -U -l /2 width=3 by lsstasa_step_dx, lsstasa_O/
69 (* Main inversion lemmas ****************************************************)
71 theorem lsstasa_inv_lsstas: ∀h,g,G,L,T,U,l. ⦃G, L⦄ ⊢ T ••*[h, g, l] U → ⦃G, L⦄ ⊢ T •*[h, g, l] U.
72 #h #g #G #L #T #U #l #H elim H -G -L -T -U -l
73 /2 width=8 by lsstas_inv_SO, lsstas_ldec, lsstas_ldef, lsstas_cast, lsstas_appl, lsstas_bind/
76 (* Advanced eliminators *****************************************************)
78 lemma lsstas_ind_alt: ∀h,g. ∀R:genv→relation4 lenv nat term term.
79 (∀G,L,T. R G L O T T) →
80 (∀G,L,l,k. R G L l (⋆k) (⋆((next h)^l k))) → (
82 ⇩[i] L ≡ K.ⓓV → ⦃G, K⦄ ⊢ V •*[h, g, l+1] W → ⇧[O, i+1] W ≡ U →
83 R G K (l+1) V W → R G L (l+1) (#i) U
86 ⇩[i] L ≡ K.ⓛW → ⦃G, K⦄ ⊢ W ▪[h, g] l0 →
87 ⦃G, K⦄ ⊢ W •*[h, g, l]V → ⇧[O, i+1] V ≡ U →
88 R G K l W V → R G L (l+1) (#i) U
90 ∀a,I,G,L,V,T,U,l. ⦃G, L.ⓑ{I}V⦄ ⊢ T •*[h, g, l] U →
91 R G (L.ⓑ{I}V) l T U → R G L l (ⓑ{a,I}V.T) (ⓑ{a,I}V.U)
93 ∀G,L,V,T,U,l. ⦃G, L⦄ ⊢ T •*[h, g, l] U →
94 R G L l T U → R G L l (ⓐV.T) (ⓐV.U)
96 ∀G,L,W,T,U,l. ⦃G, L⦄⊢ T •*[h, g, l+1] U →
97 R G L (l+1) T U → R G L (l+1) (ⓝW.T) U
99 ∀G,L,l,T,U. ⦃G, L⦄ ⊢ T •*[h, g, l] U → R G L l T U.
100 #h #g #R #IH1 #IH2 #IH3 #IH4 #IH5 #IH6 #IH7 #G #L #l #T #U #H
101 elim (lsstas_lsstasa … H) /3 width=10 by lsstasa_inv_lsstas/