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/relocation/ldrop.ma".
17 (* LOCAL ENVIRONMENT REFINEMENT FOR SUBSTITUTION ****************************)
19 inductive lsubr: relation lenv ≝
20 | lsubr_sort: ∀L. lsubr L (⋆)
21 | lsubr_abbr: ∀L1,L2,V. lsubr L1 L2 → lsubr (L1. ⓓV) (L2.ⓓV)
22 | lsubr_abst: ∀I,L1,L2,V1,V2. lsubr L1 L2 → lsubr (L1. ⓑ{I}V1) (L2. ⓛV2)
26 "local environment refinement (substitution)"
27 'SubEq L1 L2 = (lsubr L1 L2).
29 definition lsubr_trans: ∀S. predicate (lenv → relation S) ≝ λS,R.
30 ∀L2,s1,s2. R L2 s1 s2 → ∀L1. L1 ⊑ L2 → R L1 s1 s2.
32 (* Basic properties *********************************************************)
34 lemma lsubr_bind: ∀I,L1,L2,V. L1 ⊑ L2 → L1. ⓑ{I} V ⊑ L2.ⓑ{I} V.
37 lemma lsubr_abbr: ∀I,L1,L2,V. L1 ⊑ L2 → L1. ⓓV ⊑ L2. ⓑ{I}V.
40 lemma lsubr_refl: ∀L. L ⊑ L.
41 #L elim L -L // /2 width=1/
44 lemma TC_lsubr_trans: ∀S,R. lsubr_trans S R → lsubr_trans S (LTC … R).
45 #S #R #HR #L1 #s1 #s2 #H elim H -s2
47 | #s #s2 #_ #Hs2 #IHs1 #L2 #HL12
48 lapply (HR … Hs2 … HL12) -HR -Hs2 /3 width=3/
52 (* Basic inversion lemmas ***************************************************)
54 fact lsubr_inv_atom1_aux: ∀L1,L2. L1 ⊑ L2 → L1 = ⋆ → L2 = ⋆.
56 [ #L1 #L2 #V #_ #H destruct
57 | #I #L1 #L2 #V1 #V2 #_ #H destruct
61 lemma lsubr_inv_atom1: ∀L2. ⋆ ⊑ L2 → L2 = ⋆.
62 /2 width=3 by lsubr_inv_atom1_aux/ qed-.
64 fact lsubr_inv_abbr2_aux: ∀L1,L2. L1 ⊑ L2 → ∀K2,W. L2 = K2.ⓓW →
65 ∃∃K1. K1 ⊑ K2 & L1 = K1.ⓓW.
67 [ #L #K2 #W #H destruct
68 | #L1 #L2 #V #HL12 #K2 #W #H destruct /2 width=3/
69 | #I #L1 #L2 #V1 #V2 #_ #K2 #W #H destruct
73 lemma lsubr_inv_abbr2: ∀L1,K2,W. L1 ⊑ K2.ⓓW →
74 ∃∃K1. K1 ⊑ K2 & L1 = K1.ⓓW.
75 /2 width=3 by lsubr_inv_abbr2_aux/ qed-.
77 fact lsubr_inv_abst2_aux: ∀L1,L2. L1 ⊑ L2 → ∀K2,W2. L2 = K2.ⓛW2 →
78 ∃∃I,K1,W1. K1 ⊑ K2 & L1 = K1.ⓑ{I}W1.
80 [ #L #K2 #W2 #H destruct
81 | #L1 #L2 #V #_ #K2 #W2 #H destruct
82 | #I #L1 #L2 #V1 #V2 #HL12 #K2 #W2 #H destruct /2 width=5/
86 lemma lsubr_inv_abst2: ∀L1,K2,W2. L1 ⊑ K2.ⓛW2 →
87 ∃∃I,K1,W1. K1 ⊑ K2 & L1 = K1.ⓑ{I}W1.
88 /2 width=4 by lsubr_inv_abst2_aux/ qed-.
90 (* Basic forward lemmas *****************************************************)
92 lemma lsubr_fwd_length: ∀L1,L2. L1 ⊑ L2 → |L2| ≤ |L1|.
93 #L1 #L2 #H elim H -L1 -L2 // /2 width=1/
96 lemma lsubr_fwd_ldrop2_abbr: ∀L1,L2. L1 ⊑ L2 →
97 ∀K2,W,i. ⇩[0, i] L2 ≡ K2. ⓓW →
98 ∃∃K1. K1 ⊑ K2 & ⇩[0, i] L1 ≡ K1. ⓓW.
99 #L1 #L2 #H elim H -L1 -L2
101 elim (ldrop_inv_atom1 … H) -H #H destruct
102 | #L1 #L2 #V #HL12 #IHL12 #K2 #W #i #H
103 elim (ldrop_inv_O1_pair1 … H) -H * #Hi #HLK2 destruct [ -IHL12 | -HL12 ]
105 | elim (IHL12 … HLK2) -IHL12 -HLK2 /3 width=3/
107 | #I #L1 #L2 #V1 #V2 #_ #IHL12 #K2 #W #i #H
108 elim (ldrop_inv_O1_pair1 … H) -H * #Hi #HLK2 destruct
109 elim (IHL12 … HLK2) -IHL12 -HLK2 /3 width=3/