]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2A/multiple/cpys.ma
update in lambdadelta
[helm.git] / matita / matita / contribs / lambdadelta / basic_2A / multiple / 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_2A/notation/relations/psubststar_6.ma".
16 include "basic_2A/substitution/cpy.ma".
17
18 (* CONTEXT-SENSITIVE EXTENDED MULTIPLE SUBSTITUTION FOR TERMS ***************)
19
20 definition cpys: ynat → ynat → relation4 genv lenv term term ≝
21                  λl,m,G. LTC … (cpy l m G).
22
23 interpretation "context-sensitive extended multiple substritution (term)"
24    'PSubstStar G L T1 l m T2 = (cpys l m G L T1 T2).
25
26 (* Basic eliminators ********************************************************)
27
28 lemma cpys_ind: ∀G,L,T1,l,m. ∀R:predicate term. R T1 →
29                 (∀T,T2. ⦃G, L⦄ ⊢ T1 ▶*[l, m] T → ⦃G, L⦄ ⊢ T ▶[l, m] T2 → R T → R T2) →
30                 ∀T2. ⦃G, L⦄ ⊢ T1 ▶*[l, m] T2 → R T2.
31 #G #L #T1 #l #m #R #HT1 #IHT1 #T2 #HT12
32 @(TC_star_ind … HT1 IHT1 … HT12) //
33 qed-.
34
35 lemma cpys_ind_dx: ∀G,L,T2,l,m. ∀R:predicate term. R T2 →
36                    (∀T1,T. ⦃G, L⦄ ⊢ T1 ▶[l, m] T → ⦃G, L⦄ ⊢ T ▶*[l, m] T2 → R T → R T1) →
37                    ∀T1. ⦃G, L⦄ ⊢ T1 ▶*[l, m] T2 → R T1.
38 #G #L #T2 #l #m #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,l,m. ⦃G, L⦄ ⊢ T1 ▶[l, m] T2 → ⦃G, L⦄ ⊢ T1 ▶*[l, m] T2.
45 /2 width=1 by inj/ qed.
46
47 lemma cpys_strap1: ∀G,L,T1,T,T2,l,m.
48                    ⦃G, L⦄ ⊢ T1 ▶*[l, m] T → ⦃G, L⦄ ⊢ T ▶[l, m] T2 → ⦃G, L⦄ ⊢ T1 ▶*[l, m] T2.
49 normalize /2 width=3 by step/ qed-.
50
51 lemma cpys_strap2: ∀G,L,T1,T,T2,l,m.
52                    ⦃G, L⦄ ⊢ T1 ▶[l, m] T → ⦃G, L⦄ ⊢ T ▶*[l, m] T2 → ⦃G, L⦄ ⊢ T1 ▶*[l, m] T2.
53 normalize /2 width=3 by TC_strap/ qed-.
54
55 lemma lsuby_cpys_trans: ∀G,l,m. lsub_trans … (cpys l m G) (lsuby l m).
56 /3 width=5 by lsuby_cpy_trans, LTC_lsub_trans/
57 qed-.
58
59 lemma cpys_refl: ∀G,L,l,m. reflexive … (cpys l m G L).
60 /2 width=1 by cpy_cpys/ qed.
61
62 lemma cpys_bind: ∀G,L,V1,V2,l,m. ⦃G, L⦄ ⊢ V1 ▶*[l, m] V2 →
63                  ∀I,T1,T2. ⦃G, L.ⓑ{I}V1⦄ ⊢ T1 ▶*[⫯l, m] T2 →
64                  ∀a. ⦃G, L⦄ ⊢ ⓑ{a,I}V1.T1 ▶*[l, m] ⓑ{a,I}V2.T2.
65 #G #L #V1 #V2 #l #m #HV12 @(cpys_ind … HV12) -V2
66 [ #I #T1 #T2 #HT12 @(cpys_ind … HT12) -T2 /3 width=5 by cpys_strap1, cpy_bind/
67 | /3 width=5 by cpys_strap1, cpy_bind/
68 ]
69 qed.
70
71 lemma cpys_flat: ∀G,L,V1,V2,l,m. ⦃G, L⦄ ⊢ V1 ▶*[l, m] V2 →
72                  ∀T1,T2. ⦃G, L⦄ ⊢ T1 ▶*[l, m] T2 →
73                  ∀I. ⦃G, L⦄ ⊢ ⓕ{I}V1.T1 ▶*[l, m] ⓕ{I}V2.T2.
74 #G #L #V1 #V2 #l #m #HV12 @(cpys_ind … HV12) -V2
75 [ #T1 #T2 #HT12 @(cpys_ind … HT12) -T2 /3 width=5 by cpys_strap1, cpy_flat/
76 | /3 width=5 by cpys_strap1, cpy_flat/
77 qed.
78
79 lemma cpys_weak: ∀G,L,T1,T2,l1,m1. ⦃G, L⦄ ⊢ T1 ▶*[l1, m1] T2 →
80                  ∀l2,m2. l2 ≤ l1 → l1 + m1 ≤ l2 + m2 →
81                  ⦃G, L⦄ ⊢ T1 ▶*[l2, m2] T2.
82 #G #L #T1 #T2 #l1 #m1 #H #l1 #l2 #Hl21 #Hlm12 @(cpys_ind … H) -T2
83 /3 width=7 by cpys_strap1, cpy_weak/
84 qed-.
85
86 lemma cpys_weak_top: ∀G,L,T1,T2,l,m.
87                      ⦃G, L⦄ ⊢ T1 ▶*[l, m] T2 → ⦃G, L⦄ ⊢ T1 ▶*[l, |L| - l] T2.
88 #G #L #T1 #T2 #l #m #H @(cpys_ind … H) -T2
89 /3 width=4 by cpys_strap1, cpy_weak_top/
90 qed-.
91
92 lemma cpys_weak_full: ∀G,L,T1,T2,l,m.
93                       ⦃G, L⦄ ⊢ T1 ▶*[l, m] T2 → ⦃G, L⦄ ⊢ T1 ▶*[0, |L|] T2.
94 #G #L #T1 #T2 #l #m #H @(cpys_ind … H) -T2
95 /3 width=5 by cpys_strap1, cpy_weak_full/
96 qed-.
97
98 (* Basic forward lemmas *****************************************************)
99
100 lemma cpys_fwd_up: ∀G,L,U1,U2,lt,mt. ⦃G, L⦄ ⊢ U1 ▶*[lt, mt] U2 →
101                    ∀T1,l,m. ⬆[l, m] T1 ≡ U1 →
102                    l ≤ lt → l + m ≤ lt + mt →
103                    ∃∃T2. ⦃G, L⦄ ⊢ U1 ▶*[l+m, lt+mt-(l+m)] U2 & ⬆[l, m] T2 ≡ U2.
104 #G #L #U1 #U2 #lt #mt #H #T1 #l #m #HTU1 #Hllt #Hlmlmt @(cpys_ind … H) -U2
105 [ /2 width=3 by ex2_intro/
106 | -HTU1 #U #U2 #_ #HU2 * #T #HU1 #HTU
107   elim (cpy_fwd_up … HU2 … HTU) -HU2 -HTU /3 width=3 by cpys_strap1, ex2_intro/
108 ]
109 qed-.
110
111 lemma cpys_fwd_tw: ∀G,L,T1,T2,l,m. ⦃G, L⦄ ⊢ T1 ▶*[l, m] T2 → ♯{T1} ≤ ♯{T2}.
112 #G #L #T1 #T2 #l #m #H @(cpys_ind … H) -T2 //
113 #T #T2 #_ #HT2 #IHT1 lapply (cpy_fwd_tw … HT2) -HT2
114 /2 width=3 by transitive_le/
115 qed-.
116
117 (* Basic inversion lemmas ***************************************************)
118
119 (* Note: this can be derived from cpys_inv_atom1 *)
120 lemma cpys_inv_sort1: ∀G,L,T2,k,l,m. ⦃G, L⦄ ⊢ ⋆k ▶*[l, m] T2 → T2 = ⋆k.
121 #G #L #T2 #k #l #m #H @(cpys_ind … H) -T2 //
122 #T #T2 #_ #HT2 #IHT1 destruct
123 >(cpy_inv_sort1 … HT2) -HT2 //
124 qed-.
125
126 (* Note: this can be derived from cpys_inv_atom1 *)
127 lemma cpys_inv_gref1: ∀G,L,T2,p,l,m. ⦃G, L⦄ ⊢ §p ▶*[l, m] T2 → T2 = §p.
128 #G #L #T2 #p #l #m #H @(cpys_ind … H) -T2 //
129 #T #T2 #_ #HT2 #IHT1 destruct
130 >(cpy_inv_gref1 … HT2) -HT2 //
131 qed-.
132
133 lemma cpys_inv_bind1: ∀a,I,G,L,V1,T1,U2,l,m. ⦃G, L⦄ ⊢ ⓑ{a,I}V1.T1 ▶*[l, m] U2 →
134                       ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ▶*[l, m] V2 &
135                                ⦃G, L.ⓑ{I}V1⦄ ⊢ T1 ▶*[⫯l, m] T2 &
136                                U2 = ⓑ{a,I}V2.T2.
137 #a #I #G #L #V1 #T1 #U2 #l #m #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_bind1 … HU2) -HU2 #V2 #T2 #HV2 #HT2 #H
141   lapply (lsuby_cpy_trans … HT2 (L.ⓑ{I}V1) ?) -HT2
142   /3 width=5 by cpys_strap1, lsuby_succ, ex3_2_intro/
143 ]
144 qed-.
145
146 lemma cpys_inv_flat1: ∀I,G,L,V1,T1,U2,l,m. ⦃G, L⦄ ⊢ ⓕ{I}V1.T1 ▶*[l, m] U2 →
147                       ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ▶*[l, m] V2 & ⦃G, L⦄ ⊢ T1 ▶*[l, m] T2 &
148                                U2 = ⓕ{I}V2.T2.
149 #I #G #L #V1 #T1 #U2 #l #m #H @(cpys_ind … H) -U2
150 [ /2 width=5 by ex3_2_intro/
151 | #U #U2 #_ #HU2 * #V #T #HV1 #HT1 #H destruct
152   elim (cpy_inv_flat1 … HU2) -HU2
153   /3 width=5 by cpys_strap1, ex3_2_intro/
154 ]
155 qed-.
156
157 lemma cpys_inv_refl_O2: ∀G,L,T1,T2,l. ⦃G, L⦄ ⊢ T1 ▶*[l, 0] T2 → T1 = T2.
158 #G #L #T1 #T2 #l #H @(cpys_ind … H) -T2 //
159 #T #T2 #_ #HT2 #IHT1 <(cpy_inv_refl_O2 … HT2) -HT2 //
160 qed-.
161
162 lemma cpys_inv_lift1_eq: ∀G,L,U1,U2. ∀l,m:nat.
163                          ⦃G, L⦄ ⊢ U1 ▶*[l, m] U2 → ∀T1. ⬆[l, m] T1 ≡ U1 → U1 = U2.
164 #G #L #U1 #U2 #l #m #H #T1 #HTU1 @(cpys_ind … H) -U2
165 /2 width=7 by cpy_inv_lift1_eq/
166 qed-.