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 "ground/pull/pull_4.ma".
16 include "ground/relocation/rtmap_uni.ma".
17 include "static_2/notation/relations/relation_3.ma".
18 include "static_2/syntax/cext2.ma".
19 include "static_2/relocation/sex.ma".
21 (* GENERIC EXTENSION OF A CONTEXT-SENSITIVE REALTION FOR TERMS **************)
23 definition lex (R): relation lenv ≝
24 λL1,L2. ∃∃f. 𝐈❨f❩ & L1 ⪤[cfull,cext2 R,f] L2.
26 interpretation "generic extension (local environment)"
27 'Relation R L1 L2 = (lex R L1 L2).
29 definition lex_confluent: relation (relation3 …) ≝ λR1,R2.
30 ∀L0,T0,T1. R1 L0 T0 T1 → ∀T2. R2 L0 T0 T2 →
31 ∀L1. L0 ⪤[R1] L1 → ∀L2. L0 ⪤[R2] L2 →
32 ∃∃T. R2 L1 T1 T & R1 L2 T2 T.
34 definition lex_transitive: relation (relation3 …) ≝ λR1,R2.
35 ∀L1,T1,T. R1 L1 T1 T → ∀L2. L1 ⪤[R1] L2 →
36 ∀T2. R2 L2 T T2 → R1 L1 T1 T2.
38 (* Basic properties *********************************************************)
40 (* Basic_2A1: was: lpx_sn_atom *)
41 lemma lex_atom (R): ⋆ ⪤[R] ⋆.
42 /2 width=3 by sex_atom, ex2_intro/ qed.
44 lemma lex_bind (R): ∀I1,I2,K1,K2. K1 ⪤[R] K2 → cext2 R K1 I1 I2 →
45 K1.ⓘ[I1] ⪤[R] K2.ⓘ[I2].
46 #R #I1 #I2 #K1 #K2 * #f #Hf #HK12 #HI12
47 /3 width=3 by sex_push, pr_isi_push, ex2_intro/
50 (* Basic_2A1: was: lpx_sn_refl *)
51 lemma lex_refl (R): c_reflexive … R → reflexive … (lex R).
52 /4 width=3 by sex_refl, ext2_refl, ex2_intro/ qed.
54 lemma lex_co (R1) (R2): (∀L,T1,T2. R1 L T1 T2 → R2 L T1 T2) →
55 ∀L1,L2. L1 ⪤[R1] L2 → L1 ⪤[R2] L2.
56 #R1 #R2 #HR #L1 #L2 * /5 width=7 by sex_co, cext2_co, ex2_intro/
59 (* Advanced properties ******************************************************)
61 lemma lex_bind_refl_dx (R): c_reflexive … R →
62 ∀I,K1,K2. K1 ⪤[R] K2 → K1.ⓘ[I] ⪤[R] K2.ⓘ[I].
63 /3 width=3 by ext2_refl, lex_bind/ qed.
65 lemma lex_unit (R): ∀I,K1,K2. K1 ⪤[R] K2 → K1.ⓤ[I] ⪤[R] K2.ⓤ[I].
66 /3 width=1 by lex_bind, ext2_unit/ qed.
68 (* Basic_2A1: was: lpx_sn_pair *)
69 lemma lex_pair (R): ∀I,K1,K2,V1,V2. K1 ⪤[R] K2 → R K1 V1 V2 →
70 K1.ⓑ[I]V1 ⪤[R] K2.ⓑ[I]V2.
71 /3 width=1 by lex_bind, ext2_pair/ qed.
73 (* Basic inversion lemmas ***************************************************)
75 (* Basic_2A1: was: lpx_sn_inv_atom1: *)
76 lemma lex_inv_atom_sn (R): ∀L2. ⋆ ⪤[R] L2 → L2 = ⋆.
77 #R #L2 * #f #Hf #H >(sex_inv_atom1 … H) -L2 //
80 lemma lex_inv_bind_sn (R): ∀I1,L2,K1. K1.ⓘ[I1] ⪤[R] L2 →
81 ∃∃I2,K2. K1 ⪤[R] K2 & cext2 R K1 I1 I2 & L2 = K2.ⓘ[I2].
82 #R #I1 #L2 #K1 * #f #Hf #H
83 lapply (sex_eq_repl_fwd … H (⫯f) ?) -H /2 width=1 by pr_isi_inv_eq_push/ #H
84 elim (sex_inv_push1 … H) -H #I2 #K2 #HK12 #HI12 #H destruct
85 /3 width=5 by ex2_intro, ex3_2_intro/
88 (* Basic_2A1: was: lpx_sn_inv_atom2 *)
89 lemma lex_inv_atom_dx (R): ∀L1. L1 ⪤[R] ⋆ → L1 = ⋆.
90 #R #L1 * #f #Hf #H >(sex_inv_atom2 … H) -L1 //
93 lemma lex_inv_bind_dx (R): ∀I2,L1,K2. L1 ⪤[R] K2.ⓘ[I2] →
94 ∃∃I1,K1. K1 ⪤[R] K2 & cext2 R K1 I1 I2 & L1 = K1.ⓘ[I1].
95 #R #I2 #L1 #K2 * #f #Hf #H
96 lapply (sex_eq_repl_fwd … H (⫯f) ?) -H /2 width=1 by pr_isi_inv_eq_push/ #H
97 elim (sex_inv_push2 … H) -H #I1 #K1 #HK12 #HI12 #H destruct
98 /3 width=5 by ex3_2_intro, ex2_intro/
101 (* Advanced inversion lemmas ************************************************)
103 lemma lex_inv_unit_sn (R): ∀I,L2,K1. K1.ⓤ[I] ⪤[R] L2 →
104 ∃∃K2. K1 ⪤[R] K2 & L2 = K2.ⓤ[I].
106 elim (lex_inv_bind_sn … H) -H #Z2 #K2 #HK12 #HZ2 #H destruct
107 elim (ext2_inv_unit_sn … HZ2) -HZ2
108 /2 width=3 by ex2_intro/
111 (* Basic_2A1: was: lpx_sn_inv_pair1 *)
112 lemma lex_inv_pair_sn (R): ∀I,L2,K1,V1. K1.ⓑ[I]V1 ⪤[R] L2 →
113 ∃∃K2,V2. K1 ⪤[R] K2 & R K1 V1 V2 & L2 = K2.ⓑ[I]V2.
115 elim (lex_inv_bind_sn … H) -H #Z2 #K2 #HK12 #HZ2 #H destruct
116 elim (ext2_inv_pair_sn … HZ2) -HZ2 #V2 #HV12 #H destruct
117 /2 width=5 by ex3_2_intro/
120 lemma lex_inv_unit_dx (R): ∀I,L1,K2. L1 ⪤[R] K2.ⓤ[I] →
121 ∃∃K1. K1 ⪤[R] K2 & L1 = K1.ⓤ[I].
123 elim (lex_inv_bind_dx … H) -H #Z1 #K1 #HK12 #HZ1 #H destruct
124 elim (ext2_inv_unit_dx … HZ1) -HZ1
125 /2 width=3 by ex2_intro/
128 (* Basic_2A1: was: lpx_sn_inv_pair2 *)
129 lemma lex_inv_pair_dx (R): ∀I,L1,K2,V2. L1 ⪤[R] K2.ⓑ[I]V2 →
130 ∃∃K1,V1. K1 ⪤[R] K2 & R K1 V1 V2 & L1 = K1.ⓑ[I]V1.
132 elim (lex_inv_bind_dx … H) -H #Z1 #K1 #HK12 #HZ1 #H destruct
133 elim (ext2_inv_pair_dx … HZ1) -HZ1 #V1 #HV12 #H destruct
134 /2 width=5 by ex3_2_intro/
137 (* Basic_2A1: was: lpx_sn_inv_pair *)
138 lemma lex_inv_pair (R): ∀I1,I2,L1,L2,V1,V2.
139 L1.ⓑ[I1]V1 ⪤[R] L2.ⓑ[I2]V2 →
140 ∧∧ L1 ⪤[R] L2 & R L1 V1 V2 & I1 = I2.
141 #R #I1 #I2 #L1 #L2 #V1 #V2 #H elim (lex_inv_pair_sn … H) -H
142 #L0 #V0 #HL10 #HV10 #H destruct /2 width=1 by and3_intro/
145 (* Basic eliminators ********************************************************)
147 lemma lex_ind (R) (Q:relation2 …):
150 ∀I,K1,K2. K1 ⪤[R] K2 → Q K1 K2 → Q (K1.ⓤ[I]) (K2.ⓤ[I])
152 ∀I,K1,K2,V1,V2. K1 ⪤[R] K2 → Q K1 K2 → R K1 V1 V2 →Q (K1.ⓑ[I]V1) (K2.ⓑ[I]V2)
154 ∀L1,L2. L1 ⪤[R] L2 → Q L1 L2.
155 #R #Q #IH1 #IH2 #IH3 #L1 #L2 * #f @pull_2 #H
156 elim H -f -L1 -L2 // #f #I1 #I2 #K1 #K2 @pull_4 #H
157 [ elim (pr_isi_inv_next … H)
158 | lapply (pr_isi_inv_push … H ??)
159 ] -H [5:|*: // ] #Hf @pull_2 #H
160 elim H -H /3 width=3 by ex2_intro/