]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/substitution/cpys.ma
the theory of extended multiple substitution for therms is complete
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / substitution / cpys.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/notation/relations/extpsubststar_6.ma".
16 include "basic_2/relocation/cpy.ma".
17
18 (* CONTEXT-SENSITIVE EXTENDED MULTIPLE SUBSTITUTION FOR TERMS ***************)
19
20 definition cpys: nat → nat → relation4 genv lenv term term ≝
21                  λd,e,G. LTC … (cpy d e G).
22
23 interpretation "context-sensitive extended multiple substritution (term)"
24    'ExtPSubstStar G L T1 d e T2 = (cpys d e G L T1 T2).
25
26 (* Basic eliminators ********************************************************)
27
28 lemma cpys_ind: ∀G,L,T1,d,e. ∀R:predicate term. R T1 →
29                 (∀T,T2. ⦃G, L⦄ ⊢ T1 ▶*×[d, e] T → ⦃G, L⦄ ⊢ T ▶×[d, e] T2 → R T → R T2) →
30                 ∀T2. ⦃G, L⦄ ⊢ T1 ▶*×[d, e] T2 → R T2.
31 #G #L #T1 #d #e #R #HT1 #IHT1 #T2 #HT12
32 @(TC_star_ind … HT1 IHT1 … HT12) //
33 qed-.
34
35 lemma cpys_ind_dx: ∀G,L,T2,d,e. ∀R:predicate term. R T2 →
36                    (∀T1,T. ⦃G, L⦄ ⊢ T1 ▶×[d, e] T → ⦃G, L⦄ ⊢ T ▶*×[d, e] T2 → R T → R T1) →
37                    ∀T1. ⦃G, L⦄ ⊢ T1 ▶*×[d, e] T2 → R T1.
38 #G #L #T2 #d #e #R #HT2 #IHT2 #T1 #HT12
39 @(TC_star_ind_dx … HT2 IHT2 … HT12) //
40 qed-.
41
42 (* Basic properties *********************************************************)
43
44 lemma cpy_cpys: ∀G,L,T1,T2,d,e. ⦃G, L⦄ ⊢ T1 ▶×[d, e] T2 → ⦃G, L⦄ ⊢ T1 ▶*×[d, e] T2.
45 /2 width=1 by inj/ qed.
46
47 lemma cpys_strap1: ∀G,L,T1,T,T2,d,e.
48                    ⦃G, L⦄ ⊢ T1 ▶*×[d, e] T → ⦃G, L⦄ ⊢ T ▶×[d, e] T2 → ⦃G, L⦄ ⊢ T1 ▶*×[d, e] T2.
49 normalize /2 width=3 by step/ qed-.
50
51 lemma cpys_strap2: ∀G,L,T1,T,T2,d,e.
52                    ⦃G, L⦄ ⊢ T1 ▶×[d, e] T → ⦃G, L⦄ ⊢ T ▶*×[d, e] T2 → ⦃G, L⦄ ⊢ T1 ▶*×[d, e] T2.
53 normalize /2 width=3 by TC_strap/ qed-.
54
55 lemma lsuby_cpys_trans: ∀G,d,e. lsub_trans … (cpys d e G) (lsuby d e).
56 /3 width=5 by lsuby_cpy_trans, LTC_lsub_trans/
57 qed-.
58
59 lemma cpys_refl: ∀G,L,d,e. reflexive … (cpys d e G L).
60 /2 width=1 by cpy_cpys/ qed.
61
62 lemma cpys_bind: ∀G,L,V1,V2,d,e. ⦃G, L⦄ ⊢ V1 ▶*×[d, e] V2 →
63                  ∀I,T1,T2. ⦃G, L.ⓑ{I}V2⦄ ⊢ T1 ▶*×[d+1, e] T2 →
64                  ∀a. ⦃G, L⦄ ⊢ ⓑ{a,I}V1.T1 ▶*×[d, e] ⓑ{a,I}V2.T2.
65 #G #L #V1 #V2 #d #e #HV12 @(cpys_ind … HV12) -V2
66 [ #I #T1 #T2 #HT12 @(cpys_ind … HT12) -T2 /3 width=5 by cpys_strap1, cpy_bind/
67 | #V #V2 #_ #HV2 #IHV1 #I #T1 #T2 #HT12 #a
68   lapply (lsuby_cpys_trans … HT12 (L.ⓑ{I}V) ?) -HT12
69   /3 width=5 by cpys_strap1, cpy_bind, lsuby_succ/
70 ]
71 qed.
72
73 lemma cpys_flat: ∀G,L,V1,V2,d,e. ⦃G, L⦄ ⊢ V1 ▶*×[d, e] V2 →
74                  ∀T1,T2. ⦃G, L⦄ ⊢ T1 ▶*×[d, e] T2 →
75                  ∀I. ⦃G, L⦄ ⊢ ⓕ{I}V1.T1 ▶*×[d, e] ⓕ{I}V2.T2.
76 #G #L #V1 #V2 #d #e #HV12 @(cpys_ind … HV12) -V2
77 [ #T1 #T2 #HT12 @(cpys_ind … HT12) -T2 /3 width=5 by cpys_strap1, cpy_flat/
78 | /3 width=5 by cpys_strap1, cpy_flat/
79 qed.
80
81 lemma cpys_weak: ∀G,L,T1,T2,d1,e1. ⦃G, L⦄ ⊢ T1 ▶*×[d1, e1] T2 →
82                  ∀d2,e2. d2 ≤ d1 → d1 + e1 ≤ d2 + e2 →
83                  ⦃G, L⦄ ⊢ T1 ▶*×[d2, e2] T2.
84 #G #L #T1 #T2 #d1 #e1 #H #d1 #d2 #Hd21 #Hde12 @(cpys_ind … H) -T2
85 /3 width=7 by cpys_strap1, cpy_weak/
86 qed-.
87
88 lemma cpys_weak_top: ∀G,L,T1,T2,d,e.
89                      ⦃G, L⦄ ⊢ T1 ▶*×[d, e] T2 → ⦃G, L⦄ ⊢ T1 ▶*×[d, |L| - d] T2.
90 #G #L #T1 #T2 #d #e #H @(cpys_ind … H) -T2
91 /3 width=4 by cpys_strap1, cpy_weak_top/
92 qed-.
93
94 lemma cpys_weak_full: ∀G,L,T1,T2,d,e.
95                       ⦃G, L⦄ ⊢ T1 ▶*×[d, e] T2 → ⦃G, L⦄ ⊢ T1 ▶*×[0, |L|] T2.
96 #G #L #T1 #T2 #d #e #H @(cpys_ind … H) -T2
97 /3 width=5 by cpys_strap1, cpy_weak_full/
98 qed-.
99
100 lemma cpys_append: ∀G,d,e. l_appendable_sn … (cpys d e G).
101 #G #d #e #K #T1 #T2 #H @(cpys_ind … H) -T2
102 /3 width=3 by cpys_strap1, cpy_append/
103 qed-.
104
105 (* Basic inversion lemmas ***************************************************)
106
107 (* Note: this can be derived from cpys_inv_atom1 *)
108 lemma cpys_inv_sort1: ∀G,L,T2,k,d,e. ⦃G, L⦄ ⊢ ⋆k ▶*×[d, e] T2 → T2 = ⋆k.
109 #G #L #T2 #k #d #e #H @(cpys_ind … H) -T2 //
110 #T #T2 #_ #HT2 #IHT1 destruct
111 >(cpy_inv_sort1 … HT2) -HT2 //
112 qed-.
113
114 (* Note: this can be derived from cpys_inv_atom1 *)
115 lemma cpys_inv_gref1: ∀G,L,T2,p,d,e. ⦃G, L⦄ ⊢ §p ▶*×[d, e] T2 → T2 = §p.
116 #G #L #T2 #p #d #e #H @(cpys_ind … H) -T2 //
117 #T #T2 #_ #HT2 #IHT1 destruct
118 >(cpy_inv_gref1 … HT2) -HT2 //
119 qed-.
120
121 lemma cpys_inv_bind1: ∀a,I,G,L,V1,T1,U2,d,e. ⦃G, L⦄ ⊢ ⓑ{a,I}V1.T1 ▶*×[d, e] U2 →
122                       ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ▶*×[d, e] V2 &
123                                ⦃G, L.ⓑ{I}V2⦄ ⊢ T1 ▶*×[d+1, e] T2 &
124                                U2 = ⓑ{a,I}V2.T2.
125 #a #I #G #L #V1 #T1 #U2 #d #e #H @(cpys_ind … H) -U2
126 [ /2 width=5 by ex3_2_intro/
127 | #U #U2 #_ #HU2 * #V #T #HV1 #HT1 #H destruct
128   elim (cpy_inv_bind1 … HU2) -HU2 #V2 #T2 #HV2 #HT2 #H
129   lapply (lsuby_cpys_trans … HT1 (L.ⓑ{I}V2) ?) -HT1
130   /3 width=5 by cpys_strap1, lsuby_succ, ex3_2_intro/
131 ]
132 qed-.
133
134 lemma cpys_inv_flat1: ∀I,G,L,V1,T1,U2,d,e. ⦃G, L⦄ ⊢ ⓕ{I}V1.T1 ▶*×[d, e] U2 →
135                       ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ▶*×[d, e] V2 & ⦃G, L⦄ ⊢ T1 ▶*×[d, e] T2 &
136                                U2 = ⓕ{I}V2.T2.
137 #I #G #L #V1 #T1 #U2 #d #e #H @(cpys_ind … H) -U2
138 [ /2 width=5 by ex3_2_intro/
139 | #U #U2 #_ #HU2 * #V #T #HV1 #HT1 #H destruct
140   elim (cpy_inv_flat1 … HU2) -HU2
141   /3 width=5 by cpys_strap1, ex3_2_intro/
142 ]
143 qed-.
144
145 lemma cpys_inv_refl_O2: ∀G,L,T1,T2,d. ⦃G, L⦄ ⊢ T1 ▶*×[d, 0] T2 → T1 = T2.
146 #G #L #T1 #T2 #d #H @(cpys_ind … H) -T2 //
147 #T #T2 #_ #HT2 #IHT1 <(cpy_inv_refl_O2 … HT2) -HT2 //
148 qed-.
149
150 (* Basic forward lemmas *****************************************************)
151
152 lemma cpys_fwd_tw: ∀G,L,T1,T2,d,e. ⦃G, L⦄ ⊢ T1 ▶*×[d, e] T2 → ♯{T1} ≤ ♯{T2}.
153 #G #L #T1 #T2 #d #e #H @(cpys_ind … H) -T2 //
154 #T #T2 #_ #HT2 #IHT1 lapply (cpy_fwd_tw … HT2) -HT2
155 /2 width=3 by transitive_le/
156 qed-.
157
158 lemma cpys_fwd_shift1: ∀G,L,L1,T1,T,d,e. ⦃G, L⦄ ⊢ L1 @@ T1 ▶*×[d, e] T →
159                        ∃∃L2,T2. |L1| = |L2| & T = L2 @@ T2.
160 #G #L #L1 #T1 #T #d #e #H @(cpys_ind … H) -T
161 [ /2 width=4 by ex2_2_intro/
162 | #T #X #_ #HX * #L0 #T0 #HL10 #H destruct
163   elim (cpy_fwd_shift1 … HX) -HX #L2 #T2 #HL02 #H destruct
164   /2 width=4 by ex2_2_intro/
165 ]
166 qed-.