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_2A/unfold/lstas_lift.ma".
17 (* NAT-ITERATED STATIC TYPE ASSIGNMENT FOR TERMS ****************************)
19 (* Main properties **********************************************************)
21 theorem lstas_trans: ∀h,G,L,T1,T,d1. ⦃G, L⦄ ⊢ T1 •*[h, d1] T →
22 ∀T2,d2. ⦃G, L⦄ ⊢ T •*[h, d2] T2 → ⦃G, L⦄ ⊢ T1 •*[h, d1+d2] T2.
23 #h #G #L #T1 #T #d1 #H elim H -G -L -T1 -T -d1
24 [ #G #L #d1 #k #X #d2 #H >(lstas_inv_sort1 … H) -X
25 <iter_plus /2 width=1 by lstas_sort/
26 | #G #L #K #V1 #V #U #i #d1 #HLK #_ #HVU #IHV1 #U2 #d2 #HU2
27 lapply (drop_fwd_drop2 … HLK) #H0
28 elim (lstas_inv_lift1 … HU2 … H0 … HVU)
29 /3 width=6 by lstas_ldef/
31 | #G #L #K #W1 #W #U #i #d1 #HLK #_ #HWU #IHW1 #U2 #d2 #HU2
32 lapply (drop_fwd_drop2 … HLK) #H0
33 elim (lstas_inv_lift1 … HU2 … H0 … HWU)
34 /3 width=6 by lstas_succ/
35 | #a #I #G #L #V #T1 #T #d1 #_ #IHT1 #X #d2 #H
36 elim (lstas_inv_bind1 … H) -H #T2 #HT2 #H destruct
37 /3 width=1 by lstas_bind/
38 | #G #L #V #T1 #T #d1 #_ #IHT1 #X #d2 #H
39 elim (lstas_inv_appl1 … H) -H #T2 #HT2 #H destruct
40 /3 width=1 by lstas_appl/
41 | /3 width=1 by lstas_cast/
45 theorem lstas_mono: ∀h,G,L,d. singlevalued … (lstas h d G L).
46 #h #G #L #d #T #T1 #H elim H -G -L -T -T1 -d
47 [ #G #L #d #k #X #H >(lstas_inv_sort1 … H) -X //
48 | #G #L #K #V #V1 #U1 #i #d #HLK #_ #HVU1 #IHV1 #X #H
49 elim (lstas_inv_lref1 … H) -H *
50 #K0 #V0 #W0 [3: #d0 ] #HLK0
51 lapply (drop_mono … HLK0 … HLK) -HLK -HLK0 #H destruct
52 #HVW0 #HX lapply (IHV1 … HVW0) -IHV1 -HVW0 #H destruct
53 /2 width=5 by lift_mono/
54 | #G #L #K #W #W1 #i #HLK #_ #_ #X #H
55 elim (lstas_inv_lref1_O … H) -H *
57 lapply (drop_mono … HLK0 … HLK) -HLK -HLK0 #H destruct //
58 | #G #L #K #W #W1 #U1 #i #d #HLK #_ #HWU1 #IHWV #X #H
59 elim (lstas_inv_lref1_S … H) -H * #K0 #W0 #V0 #HLK0
60 lapply (drop_mono … HLK0 … HLK) -HLK -HLK0 #H destruct
61 #HW0 #HX lapply (IHWV … HW0) -IHWV -HW0 #H destruct
62 /2 width=5 by lift_mono/
63 | #a #I #G #L #V #T #U1 #d #_ #IHTU1 #X #H
64 elim (lstas_inv_bind1 … H) -H #U2 #HTU2 #H destruct /3 width=1 by eq_f/
65 | #G #L #V #T #U1 #d #_ #IHTU1 #X #H
66 elim (lstas_inv_appl1 … H) -H #U2 #HTU2 #H destruct /3 width=1 by eq_f/
67 | #G #L #W #T #U1 #d #_ #IHTU1 #U2 #H
68 lapply (lstas_inv_cast1 … H) -H /2 width=1 by/
72 (* Advanced inversion lemmas ************************************************)
74 lemma lstas_correct: ∀h,G,L,T1,T,d1. ⦃G, L⦄ ⊢ T1 •*[h, d1] T →
75 ∀d2. ∃T2. ⦃G, L⦄ ⊢ T •*[h, d2] T2.
76 #h #G #L #T1 #T #d1 #H elim H -G -L -T1 -T -d1
77 [ /2 width=2 by lstas_sort, ex_intro/
78 | #G #L #K #V1 #V #U #i #d #HLK #_ #HVU #IHV1 #d2
79 elim (IHV1 d2) -IHV1 #V2
80 elim (lift_total V2 0 (i+1))
81 lapply (drop_fwd_drop2 … HLK) -HLK
82 /3 width=11 by ex_intro, lstas_lift/
83 | #G #L #K #W1 #W #i #HLK #HW1 #IHW1 #d2
84 @(nat_ind_plus … d2) -d2 /3 width=5 by lstas_zero, ex_intro/
85 #d2 #_ elim (IHW1 d2) -IHW1 #W2 #HW2
86 lapply (lstas_trans … HW1 … HW2) -W
87 elim (lift_total W2 0 (i+1))
88 /3 width=7 by lstas_succ, ex_intro/
89 | #G #L #K #W1 #W #U #i #d #HLK #_ #HWU #IHW1 #d2
90 elim (IHW1 d2) -IHW1 #W2
91 elim (lift_total W2 0 (i+1))
92 lapply (drop_fwd_drop2 … HLK) -HLK
93 /3 width=11 by ex_intro, lstas_lift/
94 | #a #I #G #L #V #T #U #d #_ #IHTU #d2
95 elim (IHTU d2) -IHTU /3 width=2 by lstas_bind, ex_intro/
96 | #G #L #V #T #U #d #_ #IHTU #d2
97 elim (IHTU d2) -IHTU /3 width=2 by lstas_appl, ex_intro/
98 | #G #L #W #T #U #d #_ #IHTU #d2
99 elim (IHTU d2) -IHTU /2 width=2 by ex_intro/
103 (* more main properties *****************************************************)
105 theorem lstas_conf_le: ∀h,G,L,T,U1,d1. ⦃G, L⦄ ⊢ T •*[h, d1] U1 →
106 ∀U2,d2. d1 ≤ d2 → ⦃G, L⦄ ⊢ T •*[h, d2] U2 →
107 ⦃G, L⦄ ⊢ U1 •*[h, d2-d1] U2.
108 #h #G #L #T #U1 #d1 #HTU1 #U2 #d2 #Hd12
109 >(plus_minus_m_m … Hd12) in ⊢ (%→?); -Hd12 >commutative_plus #H
110 elim (lstas_split … H) -H #U #HTU
111 >(lstas_mono … HTU … HTU1) -T //
114 theorem lstas_conf: ∀h,G,L,T0,T1,d1. ⦃G, L⦄ ⊢ T0 •*[h, d1] T1 →
115 ∀T2,d2. ⦃G, L⦄ ⊢ T0 •*[h, d2] T2 →
116 ∃∃T. ⦃G, L⦄ ⊢ T1 •*[h, d2] T & ⦃G, L⦄ ⊢ T2 •*[h, d1] T.
117 #h #G #L #T0 #T1 #d1 #HT01 #T2 #d2 #HT02
118 elim (lstas_lstas … HT01 (d1+d2)) #T #HT0
119 lapply (lstas_conf_le … HT01 … HT0) // -HT01 <minus_plus_m_m_commutative
120 lapply (lstas_conf_le … HT02 … HT0) // -T0 <minus_plus_m_m
121 /2 width=3 by ex2_intro/