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_length.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 (* Basic properties *********************************************************)
79 lemma lpx_refl: ∀R. reflexive ? R → reflexive … (lpx R).
80 #R #HR #L elim L -L // /2 width=1/
83 lemma lpx_trans: ∀R. Transitive ? R → Transitive … (lpx R).
84 #R #HR #L1 #L #H elim H -L //
85 #I #K1 #K #V1 #V #_ #HV1 #IHK1 #X #H
86 elim (lpx_inv_pair1 … H) -H #K2 #V2 #HK2 #HV2 #H destruct /3 width=3/
89 lemma lpx_conf: ∀R. Confluent ? R → Confluent … (lpx R).
90 #R #HR #L0 #L1 #H elim H -L1
91 [ #X #H >(lpx_inv_atom1 … H) -X /2 width=3/
92 | #I #K0 #K1 #V0 #V1 #_ #HV01 #IHK01 #X #H
93 elim (lpx_inv_pair1 … H) -H #K2 #V2 #HK02 #HV02 #H destruct
94 elim (IHK01 … HK02) -K0 #K #HK1 #HK2
95 elim (HR … HV01 … HV02) -HR -V0 /3 width=5/
99 lemma lpx_TC_inj: ∀R,L1,L2. lpx R L1 L2 → lpx (TC … R) L1 L2.
100 #R #L1 #L2 #H elim H -L1 -L2 // /3 width=1/
103 lemma lpx_TC_step: ∀R,L1,L. lpx (TC … R) L1 L →
104 ∀L2. lpx R L L2 → lpx (TC … R) L1 L2.
105 #R #L1 #L #H elim H -L /2 width=1/
106 #I #K1 #K #V1 #V #_ #HV1 #IHK1 #X #H
107 elim (lpx_inv_pair1 … H) -H #K2 #V2 #HK2 #HV2 #H destruct /3 width=3/
110 lemma TC_lpx_pair_dx: ∀R. reflexive ? R →
111 ∀I,K,V1,V2. TC … R V1 V2 →
112 TC … (lpx R) (K.ⓑ{I}V1) (K.ⓑ{I}V2).
113 #R #HR #I #K #V1 #V2 #H elim H -V2
114 /4 width=5 by lpx_refl, lpx_pair, inj, step/ (**) (* too slow without trace *)
117 lemma TC_lpx_pair_sn: ∀R. reflexive ? R →
118 ∀I,V,K1,K2. TC … (lpx R) K1 K2 →
119 TC … (lpx R) (K1.ⓑ{I}V) (K2.ⓑ{I}V).
120 #R #HR #I #V #K1 #K2 #H elim H -K2
121 /4 width=5 by lpx_refl, lpx_pair, inj, step/ (**) (* too slow without trace *)
124 lemma lpx_TC: ∀R,L1,L2. TC … (lpx R) L1 L2 → lpx (TC … R) L1 L2.
125 #R #L1 #L2 #H elim H -L2 /2 width=1/ /2 width=3/
128 lemma lpx_inv_TC: ∀R. reflexive ? R →
129 ∀L1,L2. lpx (TC … R) L1 L2 → TC … (lpx R) L1 L2.
130 #R #HR #L1 #L2 #H elim H -L1 -L2 /2 width=1/ /3 width=3/