]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/grammar/lpx_sn.ma
definition of equivalence for local environments,
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / grammar / lpx_sn.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "basic_2/grammar/lenv_append.ma".
16
17 (* SN POINTWISE EXTENSION OF A CONTEXT-SENSITIVE REALTION FOR TERMS *********)
18
19 inductive lpx_sn (R:lenv→relation term): relation lenv ≝
20 | lpx_sn_atom: 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)
24 .
25
26 (* Basic inversion lemmas ***************************************************)
27
28 fact lpx_sn_inv_atom1_aux: ∀R,L1,L2. lpx_sn R L1 L2 → L1 = ⋆ → L2 = ⋆.
29 #R #L1 #L2 * -L1 -L2
30 [ //
31 | #I #K1 #K2 #V1 #V2 #_ #_ #H destruct
32 ]
33 qed-.
34
35 lemma lpx_sn_inv_atom1: ∀R,L2. lpx_sn R (⋆) L2 → L2 = ⋆.
36 /2 width=4 by lpx_sn_inv_atom1_aux/ qed-.
37
38 fact lpx_sn_inv_pair1_aux: ∀R,L1,L2. lpx_sn R L1 L2 → ∀I,K1,V1. L1 = K1. ⓑ{I} V1 →
39                            ∃∃K2,V2. lpx_sn R K1 K2 & R K1 V1 V2 & L2 = K2. ⓑ{I} V2.
40 #R #L1 #L2 * -L1 -L2
41 [ #J #K1 #V1 #H destruct
42 | #I #K1 #K2 #V1 #V2 #HK12 #HV12 #J #L #W #H destruct /2 width=5 by ex3_2_intro/
43 ]
44 qed-.
45
46 lemma lpx_sn_inv_pair1: ∀R,I,K1,V1,L2. lpx_sn R (K1. ⓑ{I} V1) L2 →
47                         ∃∃K2,V2. lpx_sn R K1 K2 & R K1 V1 V2 & L2 = K2. ⓑ{I} V2.
48 /2 width=3 by lpx_sn_inv_pair1_aux/ qed-.
49
50 fact lpx_sn_inv_atom2_aux: ∀R,L1,L2. lpx_sn R L1 L2 → L2 = ⋆ → L1 = ⋆.
51 #R #L1 #L2 * -L1 -L2
52 [ //
53 | #I #K1 #K2 #V1 #V2 #_ #_ #H destruct
54 ]
55 qed-.
56
57 lemma lpx_sn_inv_atom2: ∀R,L1. lpx_sn R L1 (⋆) → L1 = ⋆.
58 /2 width=4 by lpx_sn_inv_atom2_aux/ qed-.
59
60 fact lpx_sn_inv_pair2_aux: ∀R,L1,L2. lpx_sn R L1 L2 → ∀I,K2,V2. L2 = K2. ⓑ{I} V2 →
61                            ∃∃K1,V1. lpx_sn R K1 K2 & R K1 V1 V2 & L1 = K1. ⓑ{I} V1.
62 #R #L1 #L2 * -L1 -L2
63 [ #J #K2 #V2 #H destruct
64 | #I #K1 #K2 #V1 #V2 #HK12 #HV12 #J #K #W #H destruct /2 width=5 by ex3_2_intro/
65 ]
66 qed-.
67
68 lemma lpx_sn_inv_pair2: ∀R,I,L1,K2,V2. lpx_sn R L1 (K2. ⓑ{I} V2) →
69                         ∃∃K1,V1. lpx_sn R K1 K2 & R K1 V1 V2 & L1 = K1. ⓑ{I} V1.
70 /2 width=3 by lpx_sn_inv_pair2_aux/ qed-.
71
72 lemma lpx_sn_inv_pair: ∀R,I1,I2,L1,L2,V1,V2.
73                        lpx_sn R (L1.ⓑ{I1}V1) (L2.ⓑ{I2}V2) →
74                        ∧∧ lpx_sn R L1 L2 & R L1 V1 V2 & I1 = I2.
75 #R #I1 #I2 #L1 #L2 #V1 #V2 #H elim (lpx_sn_inv_pair1 … H) -H
76 #L0 #V0 #HL10 #HV10 #H destruct /2 width=1 by and3_intro/
77 qed-.
78
79 (* Basic forward lemmas *****************************************************)
80
81 lemma lpx_sn_fwd_length: ∀R,L1,L2. lpx_sn R L1 L2 → |L1| = |L2|.
82 #R #L1 #L2 #H elim H -L1 -L2 normalize //
83 qed-.
84
85 (* Advanced forward lemmas **************************************************)
86
87 lemma lpx_sn_fwd_append1: ∀R,L1,K1,L. lpx_sn R (K1 @@ L1) L →
88                           ∃∃K2,L2. lpx_sn R K1 K2 &  L = K2 @@ L2.
89 #R #L1 elim L1 -L1
90 [ #K1 #K2 #HK12
91   @(ex2_2_intro … K2 (⋆)) // (* explicit constructor, /2 width=4/ does not work *)
92 | #L1 #I #V1 #IH #K1 #X #H
93   elim (lpx_sn_inv_pair1 … H) -H #L #V2 #H1 #HV12 #H destruct
94   elim (IH … H1) -IH -H1 #K2 #L2 #HK12 #H destruct
95   @(ex2_2_intro … (L2.ⓑ{I}V2) HK12) // (* explicit constructor, /2 width=4/ does not work *)
96 ]
97 qed-.
98
99 lemma lpx_sn_fwd_append2: ∀R,L2,K2,L. lpx_sn R L (K2 @@ L2) →
100                           ∃∃K1,L1. lpx_sn R K1 K2 & L = K1 @@ L1.
101 #R #L2 elim L2 -L2
102 [ #K2 #K1 #HK12
103   @(ex2_2_intro … K1 (⋆)) // (**) (* explicit constructor, /2 width=4/ does not work *)
104 | #L2 #I #V2 #IH #K2 #X #H
105   elim (lpx_sn_inv_pair2 … H) -H #L #V1 #H1 #HV12 #H destruct
106   elim (IH … H1) -IH -H1 #K1 #L1 #HK12 #H destruct
107   @(ex2_2_intro … (L1.ⓑ{I}V1) HK12) // (* explicit constructor, /2 width=4/ does not work *)
108 ]
109 qed-.
110
111 (* Basic properties *********************************************************)
112
113 lemma lpx_sn_refl: ∀R. (∀L. reflexive ? (R L)) → reflexive … (lpx_sn R).
114 #R #HR #L elim L -L /2 width=1 by lpx_sn_atom, lpx_sn_pair/
115 qed-.
116
117 lemma lpx_sn_append: ∀R. l_appendable_sn R →
118                      ∀K1,K2. lpx_sn R K1 K2 → ∀L1,L2. lpx_sn R L1 L2 →
119                      lpx_sn R (L1 @@ K1) (L2 @@ K2).
120 #R #HR #K1 #K2 #H elim H -K1 -K2 /3 width=1 by lpx_sn_pair/
121 qed-.