(**************************************************************************) (* ___ *) (* ||M|| *) (* ||A|| A project by Andrea Asperti *) (* ||T|| *) (* ||I|| Developers: *) (* ||T|| The HELM team. *) (* ||A|| http://helm.cs.unibo.it *) (* \ / *) (* \ / This file is distributed under the terms of the *) (* v GNU General Public License Version 2 *) (* *) (**************************************************************************) include "basic_2/notation/relations/statictypestar_6.ma". include "basic_2/grammar/genv.ma". include "basic_2/substitution/drop.ma". include "basic_2/static/sh.ma". (* NAT-ITERATED STATIC TYPE ASSIGNMENT FOR TERMS ****************************) (* activate genv *) inductive lstas (h): nat → relation4 genv lenv term term ≝ | lstas_sort: ∀G,L,d,s. lstas h d G L (⋆s) (⋆((next h)^d s)) | lstas_ldef: ∀G,L,K,V,W,U,i,d. ⬇[i] L ≡ K.ⓓV → lstas h d G K V W → ⬆[0, i+1] W ≡ U → lstas h d G L (#i) U | lstas_zero: ∀G,L,K,W,V,i. ⬇[i] L ≡ K.ⓛW → lstas h 0 G K W V → lstas h 0 G L (#i) (#i) | lstas_succ: ∀G,L,K,W,V,U,i,d. ⬇[i] L ≡ K.ⓛW → lstas h d G K W V → ⬆[0, i+1] V ≡ U → lstas h (d+1) G L (#i) U | lstas_bind: ∀a,I,G,L,V,T,U,d. lstas h d G (L.ⓑ{I}V) T U → lstas h d G L (ⓑ{a,I}V.T) (ⓑ{a,I}V.U) | lstas_appl: ∀G,L,V,T,U,d. lstas h d G L T U → lstas h d G L (ⓐV.T) (ⓐV.U) | lstas_cast: ∀G,L,W,T,U,d. lstas h d G L T U → lstas h d G L (ⓝW.T) U . interpretation "nat-iterated static type assignment (term)" 'StaticTypeStar h G L d T U = (lstas h d G L T U). (* Basic inversion lemmas ***************************************************) fact lstas_inv_sort1_aux: ∀h,G,L,T,U,d. ⦃G, L⦄ ⊢ T •*[h, d] U → ∀s0. T = ⋆s0 → U = ⋆((next h)^d s0). #h #G #L #T #U #d * -G -L -T -U -d [ #G #L #d #s #s0 #H destruct // | #G #L #K #V #W #U #i #d #_ #_ #_ #s0 #H destruct | #G #L #K #W #V #i #_ #_ #s0 #H destruct | #G #L #K #W #V #U #i #d #_ #_ #_ #s0 #H destruct | #a #I #G #L #V #T #U #d #_ #s0 #H destruct | #G #L #V #T #U #d #_ #s0 #H destruct | #G #L #W #T #U #d #_ #s0 #H destruct qed-. (* Basic_1: was just: sty0_gen_sort *) lemma lstas_inv_sort1: ∀h,G,L,X,s,d. ⦃G, L⦄ ⊢ ⋆s •*[h, d] X → X = ⋆((next h)^d s). /2 width=5 by lstas_inv_sort1_aux/ qed-. fact lstas_inv_lref1_aux: ∀h,G,L,T,U,d. ⦃G, L⦄ ⊢ T •*[h, d] U → ∀j. T = #j → ∨∨ (∃∃K,V,W. ⬇[j] L ≡ K.ⓓV & ⦃G, K⦄ ⊢ V •*[h, d] W & ⬆[0, j+1] W ≡ U ) | (∃∃K,W,V. ⬇[j] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, 0] V & U = #j & d = 0 ) | (∃∃K,W,V,d0. ⬇[j] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, d0] V & ⬆[0, j+1] V ≡ U & d = d0+1 ). #h #G #L #T #U #d * -G -L -T -U -d [ #G #L #d #s #j #H destruct | #G #L #K #V #W #U #i #d #HLK #HVW #HWU #j #H destruct /3 width=6 by or3_intro0, ex3_3_intro/ | #G #L #K #W #V #i #HLK #HWV #j #H destruct /3 width=5 by or3_intro1, ex4_3_intro/ | #G #L #K #W #V #U #i #d #HLK #HWV #HWU #j #H destruct /3 width=8 by or3_intro2, ex4_4_intro/ | #a #I #G #L #V #T #U #d #_ #j #H destruct | #G #L #V #T #U #d #_ #j #H destruct | #G #L #W #T #U #d #_ #j #H destruct ] qed-. lemma lstas_inv_lref1: ∀h,G,L,X,i,d. ⦃G, L⦄ ⊢ #i •*[h, d] X → ∨∨ (∃∃K,V,W. ⬇[i] L ≡ K.ⓓV & ⦃G, K⦄ ⊢ V •*[h, d] W & ⬆[0, i+1] W ≡ X ) | (∃∃K,W,V. ⬇[i] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, 0] V & X = #i & d = 0 ) | (∃∃K,W,V,d0. ⬇[i] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, d0] V & ⬆[0, i+1] V ≡ X & d = d0+1 ). /2 width=3 by lstas_inv_lref1_aux/ qed-. lemma lstas_inv_lref1_O: ∀h,G,L,X,i. ⦃G, L⦄ ⊢ #i •*[h, 0] X → (∃∃K,V,W. ⬇[i] L ≡ K.ⓓV & ⦃G, K⦄ ⊢ V •*[h, 0] W & ⬆[0, i+1] W ≡ X ) ∨ (∃∃K,W,V. ⬇[i] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, 0] V & X = #i ). #h #G #L #X #i #H elim (lstas_inv_lref1 … H) -H * /3 width=6 by ex3_3_intro, or_introl, or_intror/ #K #W #V #d #_ #_ #_