]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/substitution/lsubr.ma
milestone in basic_2
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / substitution / 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/relocation/ldrop.ma".
16
17 (* LOCAL ENVIRONMENT REFINEMENT FOR SUBSTITUTION ****************************)
18
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)
23 .
24
25 interpretation
26   "local environment refinement (substitution)"
27   'CrSubEq L1 L2 = (lsubr L1 L2).
28
29 (* Basic properties *********************************************************)
30
31 lemma lsubr_bind: ∀I,L1,L2,V. L1 ⊑ L2 → L1. ⓑ{I} V ⊑ L2.ⓑ{I} V.
32 * /2 width=1/ qed.
33
34 lemma lsubr_abbr: ∀I,L1,L2,V. L1 ⊑ L2 → L1. ⓓV ⊑ L2. ⓑ{I}V.
35 * /2 width=1/ qed.
36
37 lemma lsubr_refl: ∀L. L ⊑ L.
38 #L elim L -L // /2 width=1/
39 qed.
40
41 (* Basic inversion lemmas ***************************************************)
42
43 fact lsubr_inv_atom1_aux: ∀L1,L2. L1 ⊑ L2 → L1 = ⋆ → L2 = ⋆.
44 #L1 #L2 * -L1 -L2 //
45 [ #L1 #L2 #V #_ #H destruct
46 | #I #L1 #L2 #V1 #V2 #_ #H destruct
47 ]
48 qed-.
49
50 lemma lsubr_inv_atom1: ∀L2. ⋆ ⊑ L2 → L2 = ⋆.
51 /2 width=3 by lsubr_inv_atom1_aux/ qed-.
52
53 fact lsubr_inv_abbr2_aux: ∀L1,L2. L1 ⊑ L2 → ∀K2,W. L2 = K2.ⓓW →
54                           ∃∃K1. K1 ⊑ K2 & L1 = K1.ⓓW.
55 #L1 #L2 * -L1 -L2
56 [ #L #K2 #W #H destruct
57 | #L1 #L2 #V #HL12 #K2 #W #H destruct /2 width=3/
58 | #I #L1 #L2 #V1 #V2 #_ #K2 #W #H destruct
59 ]
60 qed-.
61
62 lemma lsubr_inv_abbr2: ∀L1,K2,W. L1 ⊑ K2.ⓓW →
63                        ∃∃K1. K1 ⊑ K2 & L1 = K1.ⓓW.
64 /2 width=3 by lsubr_inv_abbr2_aux/ qed-.
65
66 fact lsubr_inv_abst2_aux: ∀L1,L2. L1 ⊑ L2 → ∀K2,W2. L2 = K2.ⓛW2 →
67                           ∃∃I,K1,W1. K1 ⊑ K2 & L1 = K1.ⓑ{I}W1.
68 #L1 #L2 * -L1 -L2
69 [ #L #K2 #W2 #H destruct
70 | #L1 #L2 #V #_ #K2 #W2 #H destruct
71 | #I #L1 #L2 #V1 #V2 #HL12 #K2 #W2 #H destruct /2 width=5/
72 ]
73 qed-.
74
75 lemma lsubr_inv_abst2: ∀L1,K2,W2. L1 ⊑ K2.ⓛW2 →
76                        ∃∃I,K1,W1. K1 ⊑ K2 & L1 = K1.ⓑ{I}W1.
77 /2 width=4 by lsubr_inv_abst2_aux/ qed-.
78
79 (* Basic forward lemmas *****************************************************)
80
81 lemma lsubr_fwd_length: ∀L1,L2. L1 ⊑ L2 → |L2| ≤ |L1|.
82 #L1 #L2 #H elim H -L1 -L2 // /2 width=1/
83 qed-.
84
85 lemma lsubr_fwd_ldrop2_abbr: ∀L1,L2. L1 ⊑ L2 →
86                              ∀K2,W,i. ⇩[0, i] L2 ≡ K2. ⓓW →
87                              ∃∃K1. K1 ⊑ K2 & ⇩[0, i] L1 ≡ K1. ⓓW.
88 #L1 #L2 #H elim H -L1 -L2
89 [ #L #K2 #W #i #H
90   elim (ldrop_inv_atom1 … H) -H #H destruct
91 | #L1 #L2 #V #HL12 #IHL12 #K2 #W #i #H
92   elim (ldrop_inv_O1_pair1 … H) -H * #Hi #HLK2 destruct [ -IHL12 | -HL12 ]
93   [ /2 width=3/
94   | elim (IHL12 … HLK2) -IHL12 -HLK2 /3 width=3/
95   ]
96 | #I #L1 #L2 #V1 #V2 #_ #IHL12 #K2 #W #i #H
97   elim (ldrop_inv_O1_pair1 … H) -H * #Hi #HLK2 destruct
98   elim (IHL12 … HLK2) -IHL12 -HLK2 /3 width=3/
99 ]
100 qed-.