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/grammar/lenv_length.ma".
17 (* LOCAL ENVIRONMENT REFINEMENT FOR SUBSTITUTION ****************************)
19 inductive lsubs: nat → nat → relation lenv ≝
20 | lsubs_sort: ∀d,e. lsubs d e (⋆) (⋆)
21 | lsubs_OO: ∀L1,L2. lsubs 0 0 L1 L2
22 | lsubs_abbr: ∀L1,L2,V,e. lsubs 0 e L1 L2 →
23 lsubs 0 (e + 1) (L1. ⓓV) (L2.ⓓV)
24 | lsubs_abst: ∀L1,L2,I,V1,V2,e. lsubs 0 e L1 L2 →
25 lsubs 0 (e + 1) (L1. ⓛV1) (L2.ⓑ{I} V2)
26 | lsubs_skip: ∀L1,L2,I1,I2,V1,V2,d,e.
27 lsubs d e L1 L2 → lsubs (d + 1) e (L1. ⓑ{I1} V1) (L2. ⓑ{I2} V2)
31 "local environment refinement (substitution)"
32 'SubEq L1 d e L2 = (lsubs d e L1 L2).
34 definition lsubs_conf: ∀S. (lenv → relation S) → Prop ≝ λS,R.
35 ∀L1,s1,s2. R L1 s1 s2 →
36 ∀L2,d,e. L1 [d, e] ≼ L2 → R L2 s1 s2.
38 (* Basic properties *********************************************************)
40 lemma TC_lsubs_conf: ∀S,R. lsubs_conf S R → lsubs_conf S (λL. (TC … (R L))).
41 #S #R #HR #L1 #s1 #s2 #H elim H -s2
43 | #s #s2 #_ #Hs2 #IHs1 #L2 #d #e #HL12
44 lapply (HR … Hs2 … HL12) -HR -Hs2 -HL12 /3 width=3/
48 lemma lsubs_bind_eq: ∀L1,L2,e. L1 [0, e] ≼ L2 → ∀I,V.
49 L1. ⓑ{I} V [0, e + 1] ≼ L2.ⓑ{I} V.
50 #L1 #L2 #e #HL12 #I #V elim I -I /2 width=1/
53 lemma lsubs_refl: ∀d,e,L. L [d, e] ≼ L.
55 [ #e elim e -e // #e #IHe #L elim L -L // /2 width=1/
56 | #d #IHd #e #L elim L -L // /2 width=1/
60 lemma lsubs_skip_lt: ∀L1,L2,d,e. L1 [d - 1, e] ≼ L2 → 0 < d →
61 ∀I1,I2,V1,V2. L1. ⓑ{I1} V1 [d, e] ≼ L2. ⓑ{I2} V2.
63 #L1 #L2 #d #e #HL12 #Hd >(plus_minus_m_m d 1) // /2 width=1/
66 (* Basic inversion lemmas ***************************************************)
68 (* Basic forward lemmas ***************************************************)
70 fact lsubs_fwd_length_full1_aux: ∀L1,L2,d,e. L1 [d, e] ≼ L2 →
71 d = 0 → e = |L1| → |L1| ≤ |L2|.
72 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e normalize
77 | #L1 #L2 #_ #_ #_ #_ #d #e #_ #_ >commutative_plus normalize #H destruct
81 lemma lsubs_fwd_length_full1: ∀L1,L2. L1 [0, |L1|] ≼ L2 → |L1| ≤ |L2|.
84 fact lsubs_fwd_length_full2_aux: ∀L1,L2,d,e. L1 [d, e] ≼ L2 →
85 d = 0 → e = |L2| → |L2| ≤ |L1|.
86 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e normalize
91 | #L1 #L2 #_ #_ #_ #_ #d #e #_ #_ >commutative_plus normalize #H destruct
95 lemma lsubs_fwd_length_full2: ∀L1,L2. L1 [0, |L2|] ≼ L2 → |L2| ≤ |L1|.