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/relocation/ldrop.ma".
16 include "basic_2/relocation/lpx_sn.ma".
18 (* SN POINTWISE EXTENSION OF A CONTEXT-SENSITIVE REALTION FOR TERMS *********)
20 (* alternative definition of lpx_sn_alt *)
21 inductive lpx_sn_alt (R:relation3 lenv term term): relation lenv ≝
22 | lpx_sn_alt_intro: ∀L1,L2.
23 (∀I1,I2,K1,K2,V1,V2,i.
24 ⇩[i] L1 ≡ K1.ⓑ{I1}V1 → ⇩[i] L2 ≡ K2.ⓑ{I2}V2 → I1 = I2 ∧ R K1 V1 V2
26 (∀I1,I2,K1,K2,V1,V2,i.
27 ⇩[i] L1 ≡ K1.ⓑ{I1}V1 → ⇩[i] L2 ≡ K2.ⓑ{I2}V2 → lpx_sn_alt R K1 K2
28 ) → |L1| = |L2| → lpx_sn_alt R L1 L2
31 (* Basic forward lemmas ******************************************************)
33 lemma lpx_sn_alt_fwd_length: ∀R,L1,L2. lpx_sn_alt R L1 L2 → |L1| = |L2|.
34 #R #L1 #L2 * -L1 -L2 //
37 (* Basic inversion lemmas ***************************************************)
39 lemma lpx_sn_alt_inv_gen: ∀R,L1,L2. lpx_sn_alt R L1 L2 →
42 ⇩[i] L1 ≡ K1.ⓑ{I1}V1 → ⇩[i] L2 ≡ K2.ⓑ{I2}V2 →
43 ∧∧ I1 = I2 & R K1 V1 V2 & lpx_sn_alt R K1 K2.
45 #L1 #L2 #IH1 #IH2 #HL12 @conj //
46 #I1 #I2 #K1 #K2 #HLK1 #HLK2 #i #HLK1 #HLK2
47 elim (IH1 … HLK1 HLK2) -IH1 /3 width=7 by and3_intro/
50 lemma lpx_sn_alt_inv_atom1: ∀R,L2. lpx_sn_alt R (⋆) L2 → L2 = ⋆.
51 #R #L2 #H lapply (lpx_sn_alt_fwd_length … H) -H
52 normalize /2 width=1 by length_inv_zero_sn/
55 lemma lpx_sn_alt_inv_pair1: ∀R,I,L2,K1,V1. lpx_sn_alt R (K1.ⓑ{I}V1) L2 →
56 ∃∃K2,V2. lpx_sn_alt R K1 K2 & R K1 V1 V2 & L2 = K2.ⓑ{I}V2.
57 #R #I1 #L2 #K1 #V1 #H elim (lpx_sn_alt_inv_gen … H) -H
58 #H #IH elim (length_inv_pos_sn … H) -H
59 #I2 #K2 #V2 #HK12 #H destruct
60 elim (IH I1 I2 K1 K2 V1 V2 0) -IH /2 width=5 by ex3_2_intro/
63 lemma lpx_sn_alt_inv_atom2: ∀R,L1. lpx_sn_alt R L1 (⋆) → L1 = ⋆.
64 #R #L1 #H lapply (lpx_sn_alt_fwd_length … H) -H
65 normalize /2 width=1 by length_inv_zero_dx/
68 lemma lpx_sn_alt_inv_pair2: ∀R,I,L1,K2,V2. lpx_sn_alt R L1 (K2.ⓑ{I}V2) →
69 ∃∃K1,V1. lpx_sn_alt R K1 K2 & R K1 V1 V2 & L1 = K1.ⓑ{I}V1.
70 #R #I2 #L1 #K2 #V2 #H elim (lpx_sn_alt_inv_gen … H) -H
71 #H #IH elim (length_inv_pos_dx … H) -H
72 #I1 #K1 #V1 #HK12 #H destruct
73 elim (IH I1 I2 K1 K2 V1 V2 0) -IH /2 width=5 by ex3_2_intro/
76 (* Basic properties *********************************************************)
78 lemma lpx_sn_alt_intro_alt: ∀R,L1,L2. |L1| = |L2| →
79 (∀I1,I2,K1,K2,V1,V2,i.
80 ⇩[i] L1 ≡ K1.ⓑ{I1}V1 → ⇩[i] L2 ≡ K2.ⓑ{I2}V2 →
81 ∧∧ I1 = I2 & R K1 V1 V2 & lpx_sn_alt R K1 K2
82 ) → lpx_sn_alt R L1 L2.
83 #R #L1 #L2 #HL12 #IH @lpx_sn_alt_intro // -HL12
84 #I1 #I2 #K1 #K2 #V1 #V2 #i #HLK1 #HLK2
85 elim (IH … HLK1 HLK2) -IH -HLK1 -HLK2 /2 width=1 by conj/
88 lemma lpx_sn_alt_atom: ∀R. lpx_sn_alt R (⋆) (⋆).
89 #R @lpx_sn_alt_intro_alt //
90 #I1 #I2 #K1 #K2 #V1 #V2 #i #HLK1 elim (ldrop_inv_atom1 … HLK1) -HLK1
94 lemma lpx_sn_alt_pair: ∀R,I,L1,L2,V1,V2.
95 lpx_sn_alt R L1 L2 → R L1 V1 V2 →
96 lpx_sn_alt R (L1.ⓑ{I}V1) (L2.ⓑ{I}V2).
97 #R #I #L1 #L2 #V1 #V2 #H #HV12 elim (lpx_sn_alt_inv_gen … H) -H
98 #HL12 #IH @lpx_sn_alt_intro_alt normalize //
99 #I1 #I2 #K1 #K2 #W1 #W2 #i @(nat_ind_plus … i) -i
101 lapply (ldrop_inv_O2 … HLK1) -HLK1 #H destruct
102 lapply (ldrop_inv_O2 … HLK2) -HLK2 #H destruct
103 /4 width=3 by lpx_sn_alt_intro_alt, and3_intro/
104 | -HL12 -HV12 /3 width=5 by ldrop_inv_drop1/
108 (* Main properties **********************************************************)
110 theorem lpx_sn_lpx_sn_alt: ∀R,L1,L2. lpx_sn R L1 L2 → lpx_sn_alt R L1 L2.
111 #R #L1 #L2 #H elim H -L1 -L2
112 /2 width=1 by lpx_sn_alt_atom, lpx_sn_alt_pair/
115 (* Main inversion lemmas ****************************************************)
117 theorem lpx_sn_alt_inv_lpx_sn: ∀R,L1,L2. lpx_sn_alt R L1 L2 → lpx_sn R L1 L2.
119 [ #L2 #H lapply (lpx_sn_alt_inv_atom1 … H) -H //
120 | #L1 #I #V1 #IH #X #H elim (lpx_sn_alt_inv_pair1 … H) -H
121 #L2 #V2 #HL12 #HV12 #H destruct /3 width=1 by lpx_sn_pair/
125 (* Advanced properties ******************************************************)
127 lemma lpx_sn_intro_alt: ∀R,L1,L2. |L1| = |L2| →
128 (∀I1,I2,K1,K2,V1,V2,i.
129 ⇩[i] L1 ≡ K1.ⓑ{I1}V1 → ⇩[i] L2 ≡ K2.ⓑ{I2}V2 →
130 ∧∧ I1 = I2 & R K1 V1 V2 & lpx_sn R K1 K2
132 #R #L1 #L2 #HL12 #IH @lpx_sn_alt_inv_lpx_sn
133 @lpx_sn_alt_intro_alt // -HL12
134 #I1 #I2 #K1 #K2 #V1 #V2 #i #HLK1 #HLK2
135 elim (IH … HLK1 HLK2) -IH -HLK1 -HLK2 /3 width=1 by lpx_sn_lpx_sn_alt, and3_intro/
138 (* Advanced inversion lemmas ************************************************)
140 lemma lpx_sn_inv_gen: ∀R,L1,L2. lpx_sn R L1 L2 →
142 ∀I1,I2,K1,K2,V1,V2,i.
143 ⇩[i] L1 ≡ K1.ⓑ{I1}V1 → ⇩[i] L2 ≡ K2.ⓑ{I2}V2 →
144 ∧∧ I1 = I2 & R K1 V1 V2 & lpx_sn R K1 K2.
145 #R #L1 #L2 #H lapply (lpx_sn_lpx_sn_alt … H) -H
146 #H elim (lpx_sn_alt_inv_gen … H) -H
148 #I1 #I2 #K1 #K2 #V1 #V2 #i #HLK1 #HLK2
149 elim (IH … HLK1 HLK2) -IH -HLK1 -HLK2 /3 width=1 by lpx_sn_alt_inv_lpx_sn, and3_intro/