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/grammar/lenv_append.ma".
17 (* SN POINTWISE EXTENSION OF A CONTEXT-SENSITIVE REALTION FOR TERMS *********)
19 inductive lpx_sn (R:lenv→relation term): relation lenv ≝
20 | lpx_sn_stom: lpx_sn R (⋆) (⋆)
21 | lpx_sn_pair: ∀I,K1,K2,V1,V2.
22 lpx_sn R K1 K2 → R K1 V1 V2 →
23 lpx_sn R (K1. ⓑ{I} V1) (K2. ⓑ{I} V2)
26 definition lpx_sn_confluent: relation (lenv→relation term) ≝ λR1,R2.
27 ∀L0,T0,T1. R1 L0 T0 T1 → ∀T2. R2 L0 T0 T2 →
28 ∀L1. lpx_sn R1 L0 L1 → ∀L2. lpx_sn R2 L0 L2 →
29 ∃∃T. R2 L1 T1 T & R1 L2 T2 T.
31 definition lpx_sn_transitive: relation (lenv→relation term) ≝ λR1,R2.
32 ∀L1,T1,T. R1 L1 T1 T → ∀L2. lpx_sn R1 L1 L2 →
33 ∀T2. R2 L2 T T2 → R1 L1 T1 T2.
35 (* Basic inversion lemmas ***************************************************)
37 fact lpx_sn_inv_atom1_aux: ∀R,L1,L2. lpx_sn R L1 L2 → L1 = ⋆ → L2 = ⋆.
40 | #I #K1 #K2 #V1 #V2 #_ #_ #H destruct
44 lemma lpx_sn_inv_atom1: ∀R,L2. lpx_sn R (⋆) L2 → L2 = ⋆.
45 /2 width=4 by lpx_sn_inv_atom1_aux/ qed-.
47 fact lpx_sn_inv_pair1_aux: ∀R,L1,L2. lpx_sn R L1 L2 → ∀I,K1,V1. L1 = K1. ⓑ{I} V1 →
48 ∃∃K2,V2. lpx_sn R K1 K2 & R K1 V1 V2 & L2 = K2. ⓑ{I} V2.
50 [ #J #K1 #V1 #H destruct
51 | #I #K1 #K2 #V1 #V2 #HK12 #HV12 #J #L #W #H destruct /2 width=5/
55 lemma lpx_sn_inv_pair1: ∀R,I,K1,V1,L2. lpx_sn R (K1. ⓑ{I} V1) L2 →
56 ∃∃K2,V2. lpx_sn R K1 K2 & R K1 V1 V2 & L2 = K2. ⓑ{I} V2.
57 /2 width=3 by lpx_sn_inv_pair1_aux/ qed-.
59 fact lpx_sn_inv_atom2_aux: ∀R,L1,L2. lpx_sn R L1 L2 → L2 = ⋆ → L1 = ⋆.
62 | #I #K1 #K2 #V1 #V2 #_ #_ #H destruct
66 lemma lpx_sn_inv_atom2: ∀R,L1. lpx_sn R L1 (⋆) → L1 = ⋆.
67 /2 width=4 by lpx_sn_inv_atom2_aux/ qed-.
69 fact lpx_sn_inv_pair2_aux: ∀R,L1,L2. lpx_sn R L1 L2 → ∀I,K2,V2. L2 = K2. ⓑ{I} V2 →
70 ∃∃K1,V1. lpx_sn R K1 K2 & R K1 V1 V2 & L1 = K1. ⓑ{I} V1.
72 [ #J #K2 #V2 #H destruct
73 | #I #K1 #K2 #V1 #V2 #HK12 #HV12 #J #K #W #H destruct /2 width=5/
77 lemma lpx_sn_inv_pair2: ∀R,I,L1,K2,V2. lpx_sn R L1 (K2. ⓑ{I} V2) →
78 ∃∃K1,V1. lpx_sn R K1 K2 & R K1 V1 V2 & L1 = K1. ⓑ{I} V1.
79 /2 width=3 by lpx_sn_inv_pair2_aux/ qed-.
81 (* Basic forward lemmas *****************************************************)
83 lemma lpx_sn_fwd_length: ∀R,L1,L2. lpx_sn R L1 L2 → |L1| = |L2|.
84 #R #L1 #L2 #H elim H -L1 -L2 normalize //
87 (* Advanced forward lemmas **************************************************)
89 lemma lpx_sn_fwd_append1: ∀R,L1,K1,L. lpx_sn R (K1 @@ L1) L →
90 ∃∃K2,L2. lpx_sn R K1 K2 & L = K2 @@ L2.
93 @(ex2_2_intro … K2 (⋆)) // (* explicit constructor, /2 width=4/ does not work *)
94 | #L1 #I #V1 #IH #K1 #X #H
95 elim (lpx_sn_inv_pair1 … H) -H #L #V2 #H1 #HV12 #H destruct
96 elim (IH … H1) -IH -H1 #K2 #L2 #HK12 #H destruct
97 @(ex2_2_intro … (L2.ⓑ{I}V2) HK12) // (* explicit constructor, /2 width=4/ does not work *)
101 lemma lpx_sn_fwd_append2: ∀R,L2,K2,L. lpx_sn R L (K2 @@ L2) →
102 ∃∃K1,L1. lpx_sn R K1 K2 & L = K1 @@ L1.
105 @(ex2_2_intro … K1 (⋆)) // (**) (* explicit constructor, /2 width=4/ does not work *)
106 | #L2 #I #V2 #IH #K2 #X #H
107 elim (lpx_sn_inv_pair2 … H) -H #L #V1 #H1 #HV12 #H destruct
108 elim (IH … H1) -IH -H1 #K1 #L1 #HK12 #H destruct
109 @(ex2_2_intro … (L1.ⓑ{I}V1) HK12) // (* explicit constructor, /2 width=4/ does not work *)
113 (* Basic properties *********************************************************)
115 lemma lpx_sn_refl: ∀R. (∀L. reflexive ? (R L)) → reflexive … (lpx_sn R).
116 #R #HR #L elim L -L // /2 width=1/
119 lemma lpx_sn_append: ∀R. l_appendable_sn R →
120 ∀K1,K2. lpx_sn R K1 K2 → ∀L1,L2. lpx_sn R L1 L2 →
121 lpx_sn R (L1 @@ K1) (L2 @@ K2).
122 #R #HR #K1 #K2 #H elim H -K1 -K2 // /3 width=1/
125 (* Advanced properties ******************************************************)
127 lemma lpx_sn_trans: ∀R. lpx_sn_transitive R R → Transitive … (lpx_sn R).
128 #R #HR #L1 #L #H elim H -L1 -L //
129 #I #L1 #L #V1 #V #HL1 #HV1 #IHL1 #X #H
130 elim (lpx_sn_inv_pair1 … H) -H #L2 #V2 #HL2 #HV2 #H destruct /3 width=5/
133 lemma lpx_sn_conf: ∀R1,R2. lpx_sn_confluent R1 R2 →
134 confluent2 … (lpx_sn R1) (lpx_sn R2).
135 #R1 #R2 #HR12 #L0 @(f_ind … length … L0) -L0 #n #IH *
136 [ #_ #X1 #H1 #X2 #H2 -n
137 >(lpx_sn_inv_atom1 … H1) -X1
138 >(lpx_sn_inv_atom1 … H2) -X2 /2 width=3/
139 | #L0 #I #V0 #Hn #X1 #H1 #X2 #H2 destruct
140 elim (lpx_sn_inv_pair1 … H1) -H1 #L1 #V1 #HL01 #HV01 #H destruct
141 elim (lpx_sn_inv_pair1 … H2) -H2 #L2 #V2 #HL02 #HV02 #H destruct
142 elim (IH … HL01 … HL02) -IH normalize // #L #HL1 #HL2
143 elim (HR12 … HV01 … HV02 … HL01 … HL02) -L0 -V0 /3 width=5/