]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/etc_2A1/cpr/lsubr.etc
update in binaries for λδ
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / etc_2A1 / cpr / lsubr.etc
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 notation "hvbox( L1 break ⊑ [ term 46 d , break term 46 e ] break term 46 L2 )"
16    non associative with precedence 45
17    for @{ 'SubEq $L1 $d $e $L2 }.
18
19 include "basic_2/grammar/lenv_length.ma".
20
21 (* LOCAL ENVIRONMENT REFINEMENT FOR SUBSTITUTION ****************************)
22
23 inductive lsubr: nat → nat → relation lenv ≝
24 | lsubr_sort: ∀d,e. lsubr d e (⋆) (⋆)
25 | lsubr_OO:   ∀L1,L2. lsubr 0 0 L1 L2
26 | lsubr_abbr: ∀L1,L2,V,e. lsubr 0 e L1 L2 →
27               lsubr 0 (e + 1) (L1. ⓓV) (L2.ⓓV)
28 | lsubr_abst: ∀L1,L2,I,V1,V2,e. lsubr 0 e L1 L2 →
29               lsubr 0 (e + 1) (L1. ⓑ{I}V1) (L2. ⓛV2)
30 | lsubr_skip: ∀L1,L2,I1,I2,V1,V2,d,e.
31               lsubr d e L1 L2 → lsubr (d + 1) e (L1. ⓑ{I1} V1) (L2. ⓑ{I2} V2)
32 .
33
34 interpretation
35   "local environment refinement (substitution)"
36   'SubEq L1 d e L2 = (lsubr d e L1 L2).
37
38 definition lsubr_trans: ∀S. (lenv → relation S) → Prop ≝ λS,R.
39                         ∀L2,s1,s2. R L2 s1 s2 →
40                         ∀L1,d,e. L1 ⊑ [d, e] L2 → R L1 s1 s2.
41
42 (* Basic properties *********************************************************)
43
44 lemma lsubr_bind_eq: ∀L1,L2,e. L1 ⊑ [0, e] L2 → ∀I,V.
45                      L1. ⓑ{I} V ⊑ [0, e + 1] L2.ⓑ{I} V.
46 #L1 #L2 #e #HL12 #I #V elim I -I /2 width=1/
47 qed.
48
49 lemma lsubr_abbr_lt: ∀L1,L2,V,e. L1 ⊑ [0, e - 1] L2 → 0 < e →
50                      L1. ⓓV ⊑ [0, e] L2.ⓓV.
51 #L1 #L2 #V #e #HL12 #He >(plus_minus_m_m e 1) // /2 width=1/
52 qed.
53
54 lemma lsubr_abst_lt: ∀L1,L2,I,V1,V2,e. L1 ⊑ [0, e - 1] L2 → 0 < e →
55                      L1. ⓑ{I}V1 ⊑ [0, e] L2. ⓛV2.
56 #L1 #L2 #I #V1 #V2 #e #HL12 #He >(plus_minus_m_m e 1) // /2 width=1/
57 qed.
58
59 lemma lsubr_skip_lt: ∀L1,L2,d,e. L1 ⊑ [d - 1, e] L2 → 0 < d →
60                      ∀I1,I2,V1,V2. L1. ⓑ{I1} V1 ⊑ [d, e] L2. ⓑ{I2} V2.
61 #L1 #L2 #d #e #HL12 #Hd >(plus_minus_m_m d 1) // /2 width=1/
62 qed.
63
64 lemma lsubr_bind_lt: ∀I,L1,L2,V,e. L1 ⊑ [0, e - 1] L2 → 0 < e →
65                      L1. ⓓV ⊑ [0, e] L2. ⓑ{I}V.
66 * /2 width=1/ qed.
67
68 lemma lsubr_refl: ∀d,e,L. L ⊑ [d, e] L.
69 #d elim d -d
70 [ #e elim e -e // #e #IHe #L elim L -L // /2 width=1/
71 | #d #IHd #e #L elim L -L // /2 width=1/
72 ]
73 qed.
74
75 lemma TC_lsubr_trans: ∀S,R. lsubr_trans S R → lsubr_trans S (λL. (TC … (R L))).
76 #S #R #HR #L1 #s1 #s2 #H elim H -s2
77 [ /3 width=5/
78 | #s #s2 #_ #Hs2 #IHs1 #L2 #d #e #HL12
79   lapply (HR … Hs2 … HL12) -HR -Hs2 -HL12 /3 width=3/
80 ]
81 qed.
82
83 (* Basic inversion lemmas ***************************************************)
84
85 fact lsubr_inv_atom1_aux: ∀L1,L2,d,e. L1 ⊑ [d, e] L2 → L1 = ⋆ →
86                           L2 = ⋆ ∨ (d = 0 ∧ e = 0).
87 #L1 #L2 #d #e * -L1 -L2 -d -e
88 [ /2 width=1/
89 | /3 width=1/
90 | #L1 #L2 #W #e #_ #H destruct
91 | #L1 #L2 #I #W1 #W2 #e #_ #H destruct
92 | #L1 #L2 #I1 #I2 #W1 #W2 #d #e #_ #H destruct
93 ]
94 qed.
95
96 lemma lsubr_inv_atom1: ∀L2,d,e. ⋆ ⊑ [d, e] L2 →
97                        L2 = ⋆ ∨ (d = 0 ∧ e = 0).
98 /2 width=3/ qed-.
99
100 fact lsubr_inv_skip1_aux: ∀L1,L2,d,e. L1 ⊑ [d, e] L2 →
101                           ∀I1,K1,V1. L1 = K1.ⓑ{I1}V1 → 0 < d →
102                           ∃∃I2,K2,V2. K1 ⊑ [d - 1, e] K2 & L2 = K2.ⓑ{I2}V2.
103 #L1 #L2 #d #e * -L1 -L2 -d -e
104 [ #d #e #I1 #K1 #V1 #H destruct
105 | #L1 #L2 #I1 #K1 #V1 #_ #H
106   elim (lt_zero_false … H)
107 | #L1 #L2 #W #e #_ #I1 #K1 #V1 #_ #H
108   elim (lt_zero_false … H)
109 | #L1 #L2 #I #W1 #W2 #e #_ #I1 #K1 #V1 #_ #H
110   elim (lt_zero_false … H)
111 | #L1 #L2 #J1 #J2 #W1 #W2 #d #e #HL12 #I1 #K1 #V1 #H #_ destruct /2 width=5/
112 ]
113 qed.
114
115 lemma lsubr_inv_skip1: ∀I1,K1,L2,V1,d,e. K1.ⓑ{I1}V1 ⊑ [d, e] L2 → 0 < d →
116                        ∃∃I2,K2,V2. K1 ⊑ [d - 1, e] K2 & L2 = K2.ⓑ{I2}V2.
117 /2 width=5/ qed-.
118
119 fact lsubr_inv_atom2_aux: ∀L1,L2,d,e. L1 ⊑ [d, e] L2 → L2 = ⋆ →
120                           L1 = ⋆ ∨ (d = 0 ∧ e = 0).
121 #L1 #L2 #d #e * -L1 -L2 -d -e
122 [ /2 width=1/
123 | /3 width=1/
124 | #L1 #L2 #W #e #_ #H destruct
125 | #L1 #L2 #I #W1 #W2 #e #_ #H destruct
126 | #L1 #L2 #I1 #I2 #W1 #W2 #d #e #_ #H destruct
127 ]
128 qed.
129
130 lemma lsubr_inv_atom2: ∀L1,d,e. L1 ⊑ [d, e] ⋆ →
131                        L1 = ⋆ ∨ (d = 0 ∧ e = 0).
132 /2 width=3/ qed-.
133
134 fact lsubr_inv_abbr2_aux: ∀L1,L2,d,e. L1 ⊑ [d, e] L2 →
135                           ∀K2,V. L2 = K2.ⓓV → d = 0 → 0 < e →
136                           ∃∃K1. K1 ⊑ [0, e - 1] K2 & L1 = K1.ⓓV.
137 #L1 #L2 #d #e * -L1 -L2 -d -e
138 [ #d #e #K1 #V #H destruct
139 | #L1 #L2 #K1 #V #_ #_ #H
140   elim (lt_zero_false … H)
141 | #L1 #L2 #W #e #HL12 #K1 #V #H #_ #_ destruct /2 width=3/
142 | #L1 #L2 #I #W1 #W2 #e #_ #K1 #V #H destruct
143 | #L1 #L2 #I1 #I2 #W1 #W2 #d #e #_ #K1 #V #_ >commutative_plus normalize #H destruct
144 ]
145 qed.
146
147 lemma lsubr_inv_abbr2: ∀L1,K2,V,e. L1 ⊑ [0, e] K2.ⓓV → 0 < e →
148                        ∃∃K1. K1 ⊑ [0, e - 1] K2 & L1 = K1.ⓓV.
149 /2 width=5/ qed-.
150
151 fact lsubr_inv_skip2_aux: ∀L1,L2,d,e. L1 ⊑ [d, e] L2 →
152                           ∀I2,K2,V2. L2 = K2.ⓑ{I2}V2 → 0 < d →
153                           ∃∃I1,K1,V1. K1 ⊑ [d - 1, e] K2 & L1 = K1.ⓑ{I1}V1.
154 #L1 #L2 #d #e * -L1 -L2 -d -e
155 [ #d #e #I1 #K1 #V1 #H destruct
156 | #L1 #L2 #I1 #K1 #V1 #_ #H
157   elim (lt_zero_false … H)
158 | #L1 #L2 #W #e #_ #I1 #K1 #V1 #_ #H
159   elim (lt_zero_false … H)
160 | #L1 #L2 #I #W1 #W2 #e #_ #I1 #K1 #V1 #_ #H
161   elim (lt_zero_false … H)
162 | #L1 #L2 #J1 #J2 #W1 #W2 #d #e #HL12 #I1 #K1 #V1 #H #_ destruct /2 width=5/
163 ]
164 qed.
165
166 lemma lsubr_inv_skip2: ∀I2,L1,K2,V2,d,e. L1 ⊑ [d, e] K2.ⓑ{I2}V2 → 0 < d →
167                        ∃∃I1,K1,V1. K1 ⊑ [d - 1, e] K2 & L1 = K1.ⓑ{I1}V1.
168 /2 width=5/ qed-.
169
170 (* Basic forward lemmas *****************************************************)
171
172 fact lsubr_fwd_length_full1_aux: ∀L1,L2,d,e. L1 ⊑ [d, e] L2 →
173                                  d = 0 → e = |L1| → |L1| ≤ |L2|.
174 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e normalize
175 [ //
176 | /2 width=1/
177 | /3 width=1/
178 | /3 width=1/
179 | #L1 #L2 #_ #_ #_ #_ #d #e #_ #_ >commutative_plus normalize #H destruct
180 ]
181 qed.
182
183 lemma lsubr_fwd_length_full1: ∀L1,L2. L1 ⊑ [0, |L1|] L2 → |L1| ≤ |L2|.
184 /2 width=5/ qed-.
185
186 fact lsubr_fwd_length_full2_aux: ∀L1,L2,d,e. L1 ⊑ [d, e] L2 →
187                                  d = 0 → e = |L2| → |L2| ≤ |L1|.
188 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e normalize
189 [ //
190 | /2 width=1/
191 | /3 width=1/
192 | /3 width=1/
193 | #L1 #L2 #_ #_ #_ #_ #d #e #_ #_ >commutative_plus normalize #H destruct
194 ]
195 qed.
196
197 lemma lsubr_fwd_length_full2: ∀L1,L2. L1 ⊑ [0, |L2|] L2 → |L2| ≤ |L1|.
198 /2 width=5/ qed-.