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