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/notation/relations/psubststaralt_6.ma".
16 include "basic_2/multiple/cpys_lift.ma".
18 (* CONTEXT-SENSITIVE EXTENDED MULTIPLE SUBSTITUTION FOR TERMS ***************)
20 (* alternative definition of cpys *)
21 inductive cpysa: ynat → ynat → relation4 genv lenv term term ≝
22 | cpysa_atom : ∀I,G,L,l,m. cpysa l m G L (⓪{I}) (⓪{I})
23 | cpysa_subst: ∀I,G,L,K,V1,V2,W2,i,l,m. l ≤ yinj i → i < l+m →
24 ⬇[i] L ≡ K.ⓑ{I}V1 → cpysa 0 (⫰(l+m-i)) G K V1 V2 →
25 ⬆[0, i+1] V2 ≡ W2 → cpysa l m G L (#i) W2
26 | cpysa_bind : ∀a,I,G,L,V1,V2,T1,T2,l,m.
27 cpysa l m G L V1 V2 → cpysa (⫯l) m G (L.ⓑ{I}V1) T1 T2 →
28 cpysa l m G L (ⓑ{a,I}V1.T1) (ⓑ{a,I}V2.T2)
29 | cpysa_flat : ∀I,G,L,V1,V2,T1,T2,l,m.
30 cpysa l m G L V1 V2 → cpysa l m G L T1 T2 →
31 cpysa l m G L (ⓕ{I}V1.T1) (ⓕ{I}V2.T2)
35 "context-sensitive extended multiple substritution (term) alternative"
36 'PSubstStarAlt G L T1 l m T2 = (cpysa l m G L T1 T2).
38 (* Basic properties *********************************************************)
40 lemma lsuby_cpysa_trans: ∀G,l,m. lsub_trans … (cpysa l m G) (lsuby l m).
41 #G #l #m #L1 #T1 #T2 #H elim H -G -L1 -T1 -T2 -l -m
43 | #I #G #L1 #K1 #V1 #V2 #W2 #i #l #m #Hli #Hilm #HLK1 #_ #HVW2 #IHV12 #L2 #HL12
44 elim (lsuby_drop_trans_be … HL12 … HLK1) -HL12 -HLK1 /3 width=7 by cpysa_subst/
45 | /4 width=1 by lsuby_succ, cpysa_bind/
46 | /3 width=1 by cpysa_flat/
50 lemma cpysa_refl: ∀G,T,L,l,m. ⦃G, L⦄ ⊢ T ▶▶*[l, m] T.
52 #I elim I -I /2 width=1 by cpysa_bind, cpysa_flat/
55 lemma cpysa_cpy_trans: ∀G,L,T1,T,l,m. ⦃G, L⦄ ⊢ T1 ▶▶*[l, m] T →
56 ∀T2. ⦃G, L⦄ ⊢ T ▶[l, m] T2 → ⦃G, L⦄ ⊢ T1 ▶▶*[l, m] T2.
57 #G #L #T1 #T #l #m #H elim H -G -L -T1 -T -l -m
58 [ #I #G #L #l #m #X #H
59 elim (cpy_inv_atom1 … H) -H // * /2 width=7 by cpysa_subst/
60 | #I #G #L #K #V1 #V2 #W2 #i #l #m #Hli #Hilm #HLK #_ #HVW2 #IHV12 #T2 #H
61 lapply (drop_fwd_drop2 … HLK) #H0LK
62 lapply (cpy_weak … H 0 (l+m) ? ?) -H // #H
63 elim (cpy_inv_lift1_be … H … H0LK … HVW2) -H -H0LK -HVW2
64 /3 width=7 by cpysa_subst, ylt_fwd_le_succ1/
65 | #a #I #G #L #V1 #V #T1 #T #l #m #_ #_ #IHV1 #IHT1 #X #H
66 elim (cpy_inv_bind1 … H) -H #V2 #T2 #HV2 #HT2 #H destruct
67 /5 width=5 by cpysa_bind, lsuby_cpy_trans, lsuby_succ/
68 | #I #G #L #V1 #V #T1 #T #l #m #_ #_ #IHV1 #IHT1 #X #H
69 elim (cpy_inv_flat1 … H) -H #V2 #T2 #HV2 #HT2 #H destruct /3 width=1 by cpysa_flat/
73 lemma cpys_cpysa: ∀G,L,T1,T2,l,m. ⦃G, L⦄ ⊢ T1 ▶*[l, m] T2 → ⦃G, L⦄ ⊢ T1 ▶▶*[l, m] T2.
74 /3 width=8 by cpysa_cpy_trans, cpys_ind/ qed.
76 (* Basic inversion lemmas ***************************************************)
78 lemma cpysa_inv_cpys: ∀G,L,T1,T2,l,m. ⦃G, L⦄ ⊢ T1 ▶▶*[l, m] T2 → ⦃G, L⦄ ⊢ T1 ▶*[l, m] T2.
79 #G #L #T1 #T2 #l #m #H elim H -G -L -T1 -T2 -l -m
80 /2 width=7 by cpys_subst, cpys_flat, cpys_bind, cpy_cpys/
83 (* Advanced eliminators *****************************************************)
85 lemma cpys_ind_alt: ∀R:ynat→ynat→relation4 genv lenv term term.
86 (∀I,G,L,l,m. R l m G L (⓪{I}) (⓪{I})) →
87 (∀I,G,L,K,V1,V2,W2,i,l,m. l ≤ yinj i → i < l + m →
88 ⬇[i] L ≡ K.ⓑ{I}V1 → ⦃G, K⦄ ⊢ V1 ▶*[O, ⫰(l+m-i)] V2 →
89 ⬆[O, i+1] V2 ≡ W2 → R O (⫰(l+m-i)) G K V1 V2 → R l m G L (#i) W2
91 (∀a,I,G,L,V1,V2,T1,T2,l,m. ⦃G, L⦄ ⊢ V1 ▶*[l, m] V2 →
92 ⦃G, L.ⓑ{I}V1⦄ ⊢ T1 ▶*[⫯l, m] T2 → R l m G L V1 V2 →
93 R (⫯l) m G (L.ⓑ{I}V1) T1 T2 → R l m G L (ⓑ{a,I}V1.T1) (ⓑ{a,I}V2.T2)
95 (∀I,G,L,V1,V2,T1,T2,l,m. ⦃G, L⦄ ⊢ V1 ▶*[l, m] V2 →
96 ⦃G, L⦄ ⊢ T1 ▶*[l, m] T2 → R l m G L V1 V2 →
97 R l m G L T1 T2 → R l m G L (ⓕ{I}V1.T1) (ⓕ{I}V2.T2)
99 ∀l,m,G,L,T1,T2. ⦃G, L⦄ ⊢ T1 ▶*[l, m] T2 → R l m G L T1 T2.
100 #R #H1 #H2 #H3 #H4 #l #m #G #L #T1 #T2 #H elim (cpys_cpysa … H) -G -L -T1 -T2 -l -m
101 /3 width=8 by cpysa_inv_cpys/