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/psubstevalalt_6.ma".
16 include "basic_2/substitution/cpye_lift.ma".
18 (* EVALUATION FOR CONTEXT-SENSITIVE EXTENDED SUBSTITUTION ON TERMS **********)
20 (* Note: alternative definition of cpye *)
21 inductive cpyea: ynat → ynat → relation4 genv lenv term term ≝
22 | cpyea_sort : ∀G,L,d,e,k. cpyea d e G L (⋆k) (⋆k)
23 | cpyea_free : ∀G,L,d,e,i. |L| ≤ i → cpyea d e G L (#i) (#i)
24 | cpyea_top : ∀G,L,d,e,i. d + e ≤ yinj i → cpyea d e G L (#i) (#i)
25 | cpyea_skip : ∀G,L,d,e,i. yinj i < d → cpyea d e G L (#i) (#i)
26 | cpyea_subst: ∀I,G,L,K,V1,V2,W2,i,d,e. d ≤ yinj i → yinj i < d+e →
27 ⇩[i] L ≡ K.ⓑ{I}V1 → cpyea (yinj 0) (⫰(d+e-yinj i)) G K V1 V2 →
28 ⇧[0, i+1] V2 ≡ W2 → cpyea d e G L (#i) W2
29 | cpyea_gref : ∀G,L,d,e,p. cpyea d e G L (§p) (§p)
30 | cpyea_bind : ∀a,I,G,L,V1,V2,T1,T2,d,e.
31 cpyea d e G L V1 V2 → cpyea (⫯d) e G (L.ⓑ{I}V1) T1 T2 →
32 cpyea d e G L (ⓑ{a,I}V1.T1) (ⓑ{a,I}V2.T2)
33 | cpyea_flat : ∀I,G,L,V1,V2,T1,T2,d,e.
34 cpyea d e G L V1 V2 → cpyea d e G L T1 T2 →
35 cpyea d e G L (ⓕ{I}V1.T1) (ⓕ{I}V2.T2)
39 "evaluation for context-sensitive extended substitution (term) alternative"
40 'PSubstEvalAlt G L T1 T2 d e = (cpyea d e G L T1 T2).
42 (* Main properties **********************************************************)
44 theorem cpye_cpyea: ∀G,L,T1,T2,d,e. ⦃G, L⦄ ⊢ T1 ▶*[d, e] 𝐍⦃T2⦄ → ⦃G, L⦄ ⊢ T1 ▶▶*[d, e] 𝐍⦃T2⦄.
45 #G #L #T1 @(fqup_wf_ind_eq … G L T1) -G -L -T1
46 #Z #Y #X #IH #G #L * *
47 [ #k #_ #_ #_ #T2 #d #e #H -X -Y -Z >(cpye_inv_sort1 … H) -H //
48 | #i #HG #HL #HT #T2 #d #e #H destruct
49 elim (cpye_inv_lref1 … H) -H *
50 /4 width=7 by cpyea_subst, cpyea_free, cpyea_top, cpyea_skip, fqup_lref/
51 | #p #_ #_ #_ #T2 #d #e #H -X -Y -Z >(cpye_inv_gref1 … H) -H //
52 | #a #I #V1 #T1 #HG #HL #HT #T #d #e #H destruct
53 elim (cpye_inv_bind1 … H) -H /3 width=1 by cpyea_bind/
54 | #I #V1 #T1 #HG #HL #HT #T #d #e #H destruct
55 elim (cpye_inv_flat1 … H) -H /3 width=1 by cpyea_flat/
59 (* Main inversion properties ************************************************)
61 theorem cpyea_inv_cpye: ∀G,L,T1,T2,d,e. ⦃G, L⦄ ⊢ T1 ▶▶*[d, e] 𝐍⦃T2⦄ → ⦃G, L⦄ ⊢ T1 ▶*[d, e] 𝐍⦃T2⦄.
62 #G #L #T1 #T2 #d #e #H elim H -G -L -T1 -T2 -d -e
63 /2 width=7 by cpye_subst, cpye_flat, cpye_bind, cpye_skip, cpye_top, cpye_free/
66 (* Advanced eliminators *****************************************************)
68 lemma cpye_ind_alt: ∀R:ynat→ynat→relation4 genv lenv term term.
69 (∀G,L,d,e,k. R d e G L (⋆k) (⋆k)) →
70 (∀G,L,d,e,i. |L| ≤ i → R d e G L (#i) (#i)) →
71 (∀G,L,d,e,i. d + e ≤ yinj i → R d e G L (#i) (#i)) →
72 (∀G,L,d,e,i. yinj i < d → R d e G L (#i) (#i)) →
73 (∀I,G,L,K,V1,V2,W2,i,d,e. d ≤ yinj i → yinj i < d + e →
74 ⇩[i] L ≡ K.ⓑ{I}V1 → ⦃G, K⦄ ⊢ V1 ▶*[yinj O, ⫰(d+e-yinj i)] 𝐍⦃V2⦄ →
75 ⇧[O, i+1] V2 ≡ W2 → R (yinj O) (⫰(d+e-yinj i)) G K V1 V2 → R d e G L (#i) W2
77 (∀G,L,d,e,p. R d e G L (§p) (§p)) →
78 (∀a,I,G,L,V1,V2,T1,T2,d,e. ⦃G, L⦄ ⊢ V1 ▶*[d, e] 𝐍⦃V2⦄ →
79 ⦃G, L.ⓑ{I}V1⦄ ⊢ T1 ▶*[⫯d, e] 𝐍⦃T2⦄ → R d e G L V1 V2 →
80 R (⫯d) e G (L.ⓑ{I}V1) T1 T2 → R d e G L (ⓑ{a,I}V1.T1) (ⓑ{a,I}V2.T2)
82 (∀I,G,L,V1,V2,T1,T2,d,e. ⦃G, L⦄ ⊢ V1 ▶*[d, e] 𝐍⦃V2⦄ →
83 ⦃G, L⦄ ⊢ T1 ▶*[d, e] 𝐍⦃T2⦄ → R d e G L V1 V2 →
84 R d e G L T1 T2 → R d e G L (ⓕ{I}V1.T1) (ⓕ{I}V2.T2)
86 ∀d,e,G,L,T1,T2. ⦃G, L⦄ ⊢ T1 ▶*[d, e] 𝐍⦃T2⦄ → R d e G L T1 T2.
87 #R #H1 #H2 #H3 #H4 #H5 #H6 #H7 #H8 #d #e #G #L #T1 #T2 #H elim (cpye_cpyea … H) -G -L -T1 -T2 -d -e
88 /3 width=8 by cpyea_inv_cpye/