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 (* POINTWISE EXTENSION OF A CONTEXT-FREE REALTION FOR TERMS *****************)
19 inductive lpx (R:relation term): relation lenv ≝
20 | lpx_stom: lpx R (⋆) (⋆)
21 | lpx_pair: ∀I,K1,K2,V1,V2.
22 lpx R K1 K2 → R V1 V2 → lpx R (K1. ⓑ{I} V1) (K2. ⓑ{I} V2)
25 (* Basic inversion lemmas ***************************************************)
27 fact lpx_inv_atom1_aux: ∀R,L1,L2. lpx R L1 L2 → L1 = ⋆ → L2 = ⋆.
30 | #I #K1 #K2 #V1 #V2 #_ #_ #H destruct
34 lemma lpx_inv_atom1: ∀R,L2. lpx R (⋆) L2 → L2 = ⋆.
35 /2 width=4 by lpx_inv_atom1_aux/ qed-.
37 fact lpx_inv_pair1_aux: ∀R,L1,L2. lpx R L1 L2 → ∀I,K1,V1. L1 = K1. ⓑ{I} V1 →
38 ∃∃K2,V2. lpx R K1 K2 & R V1 V2 & L2 = K2. ⓑ{I} V2.
40 [ #J #K1 #V1 #H destruct
41 | #I #K1 #K2 #V1 #V2 #HK12 #HV12 #J #L #W #H destruct /2 width=5/
45 lemma lpx_inv_pair1: ∀R,I,K1,V1,L2. lpx R (K1. ⓑ{I} V1) L2 →
46 ∃∃K2,V2. lpx R K1 K2 & R V1 V2 & L2 = K2. ⓑ{I} V2.
47 /2 width=3 by lpx_inv_pair1_aux/ qed-.
49 fact lpx_inv_atom2_aux: ∀R,L1,L2. lpx R L1 L2 → L2 = ⋆ → L1 = ⋆.
52 | #I #K1 #K2 #V1 #V2 #_ #_ #H destruct
56 lemma lpx_inv_atom2: ∀R,L1. lpx R L1 (⋆) → L1 = ⋆.
57 /2 width=4 by lpx_inv_atom2_aux/ qed-.
59 fact lpx_inv_pair2_aux: ∀R,L1,L2. lpx R L1 L2 → ∀I,K2,V2. L2 = K2. ⓑ{I} V2 →
60 ∃∃K1,V1. lpx R K1 K2 & R V1 V2 & L1 = K1. ⓑ{I} V1.
62 [ #J #K2 #V2 #H destruct
63 | #I #K1 #K2 #V1 #V2 #HK12 #HV12 #J #K #W #H destruct /2 width=5/
67 lemma lpx_inv_pair2: ∀R,I,L1,K2,V2. lpx R L1 (K2. ⓑ{I} V2) →
68 ∃∃K1,V1. lpx R K1 K2 & R V1 V2 & L1 = K1. ⓑ{I} V1.
69 /2 width=3 by lpx_inv_pair2_aux/ qed-.
71 (* Basic forward lemmas *****************************************************)
73 lemma lpx_fwd_length: ∀R,L1,L2. lpx R L1 L2 → |L1| = |L2|.
74 #R #L1 #L2 #H elim H -L1 -L2 normalize //
77 (* Advanced inversion lemmas ************************************************)
79 lemma lpx_inv_append1: ∀R,L1,K1,L. lpx R (K1 @@ L1) L →
80 ∃∃K2,L2. lpx R K1 K2 & lpx R L1 L2 & L = K2 @@ L2.
81 #R #L1 elim L1 -L1 normalize
83 @(ex3_2_intro … K2 (⋆)) // (**) (* explicit constructor, /2 width=5/ does not work *)
84 | #L1 #I #V1 #IH #K1 #X #H
85 elim (lpx_inv_pair1 … H) -H #L #V2 #H1 #HV12 #H destruct
86 elim (IH … H1) -IH -H1 #K2 #L2 #HK12 #HL12 #H destruct
87 @(ex3_2_intro … HK12) [2: /2 width=2/ | skip | // ] (* explicit constructor, /3 width=5/ does not work *)
91 lemma lpx_inv_append2: ∀R,L2,K2,L. lpx R L (K2 @@ L2) →
92 ∃∃K1,L1. lpx R K1 K2 & lpx R L1 L2 & L = K1 @@ L1.
93 #R #L2 elim L2 -L2 normalize
95 @(ex3_2_intro … K1 (⋆)) // (**) (* explicit constructor, /2 width=5/ does not work *)
96 | #L2 #I #V2 #IH #K2 #X #H
97 elim (lpx_inv_pair2 … H) -H #L #V1 #H1 #HV12 #H destruct
98 elim (IH … H1) -IH -H1 #K1 #L1 #HK12 #HL12 #H destruct
99 @(ex3_2_intro … HK12) [2: /2 width=2/ | skip | // ] (* explicit constructor, /3 width=5/ does not work *)
103 (* Basic properties *********************************************************)
105 lemma lpx_refl: ∀R. reflexive ? R → reflexive … (lpx R).
106 #R #HR #L elim L -L // /2 width=1/
109 lemma lpx_sym: ∀R. symmetric ? R → symmetric … (lpx R).
110 #R #HR #L1 #L2 #H elim H -H // /3 width=1/
113 lemma lpx_trans: ∀R. Transitive ? R → Transitive … (lpx R).
114 #R #HR #L1 #L #H elim H -L //
115 #I #K1 #K #V1 #V #_ #HV1 #IHK1 #X #H
116 elim (lpx_inv_pair1 … H) -H #K2 #V2 #HK2 #HV2 #H destruct /3 width=3/
119 lemma lpx_conf: ∀R. confluent ? R → confluent … (lpx R).
120 #R #HR #L0 #L1 #H elim H -L1
121 [ #X #H >(lpx_inv_atom1 … H) -X /2 width=3/
122 | #I #K0 #K1 #V0 #V1 #_ #HV01 #IHK01 #X #H
123 elim (lpx_inv_pair1 … H) -H #K2 #V2 #HK02 #HV02 #H destruct
124 elim (IHK01 … HK02) -K0 #K #HK1 #HK2
125 elim (HR … HV01 … HV02) -HR -V0 /3 width=5/
129 lemma lpx_TC_inj: ∀R,L1,L2. lpx R L1 L2 → lpx (TC … R) L1 L2.
130 #R #L1 #L2 #H elim H -L1 -L2 // /3 width=1/
133 lemma lpx_TC_step: ∀R,L1,L. lpx (TC … R) L1 L →
134 ∀L2. lpx R L L2 → lpx (TC … R) L1 L2.
135 #R #L1 #L #H elim H -L /2 width=1/
136 #I #K1 #K #V1 #V #_ #HV1 #IHK1 #X #H
137 elim (lpx_inv_pair1 … H) -H #K2 #V2 #HK2 #HV2 #H destruct /3 width=3/
140 lemma TC_lpx_pair_dx: ∀R. reflexive ? R →
141 ∀I,K,V1,V2. TC … R V1 V2 →
142 TC … (lpx R) (K.ⓑ{I}V1) (K.ⓑ{I}V2).
143 #R #HR #I #K #V1 #V2 #H elim H -V2
144 /4 width=5 by lpx_refl, lpx_pair, inj, step/ (**) (* too slow without trace *)
147 lemma TC_lpx_pair_sn: ∀R. reflexive ? R →
148 ∀I,V,K1,K2. TC … (lpx R) K1 K2 →
149 TC … (lpx R) (K1.ⓑ{I}V) (K2.ⓑ{I}V).
150 #R #HR #I #V #K1 #K2 #H elim H -K2
151 /4 width=5 by lpx_refl, lpx_pair, inj, step/ (**) (* too slow without trace *)
154 lemma lpx_TC: ∀R,L1,L2. TC … (lpx R) L1 L2 → lpx (TC … R) L1 L2.
155 #R #L1 #L2 #H elim H -L2 /2 width=1/ /2 width=3/
158 lemma lpx_inv_TC: ∀R. reflexive ? R →
159 ∀L1,L2. lpx (TC … R) L1 L2 → TC … (lpx R) L1 L2.
160 #R #HR #L1 #L2 #H elim H -L1 -L2 /3 width=1/ /3 width=3/
163 lemma lpx_append: ∀R,K1,K2. lpx R K1 K2 → ∀L1,L2. lpx R L1 L2 →
164 lpx R (L1 @@ K1) (L2 @@ K2).
165 #R #K1 #K2 #H elim H -K1 -K2 // /3 width=1/