]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/static_2/relocation/lex.ma
partial commit in static_2
[helm.git] / matita / matita / contribs / lambdadelta / static_2 / relocation / lex.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 "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".
20
21 (* GENERIC EXTENSION OF A CONTEXT-SENSITIVE REALTION FOR TERMS **************)
22
23 definition lex (R): relation lenv ≝
24                     λL1,L2. ∃∃f. 𝐈❪f❫ & L1 ⪤[cfull,cext2 R,f] L2.
25
26 interpretation "generic extension (local environment)"
27    'Relation R L1 L2 = (lex R L1 L2).
28
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.
33
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.
37
38 (* Basic properties *********************************************************)
39
40 (* Basic_2A1: was: lpx_sn_atom *)
41 lemma lex_atom (R): ⋆ ⪤[R] ⋆.
42 /2 width=3 by sex_atom, ex2_intro/ qed.
43
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/
48 qed.
49
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.
53
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/
57 qed-.
58
59 (* Advanced properties ******************************************************)
60
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.
64
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.
67
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.
72
73 (* Basic inversion lemmas ***************************************************)
74
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 //
78 qed-.
79
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/
86 qed-.
87
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 //
91 qed-.
92
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/
99 qed-.
100
101 (* Advanced inversion lemmas ************************************************)
102
103 lemma lex_inv_unit_sn (R): ∀I,L2,K1. K1.ⓤ[I] ⪤[R] L2 →
104                            ∃∃K2. K1 ⪤[R] K2 & L2 = K2.ⓤ[I].
105 #R #I #L2 #K1 #H
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/
109 qed-.
110
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.
114 #R #I #L2 #K1 #V1 #H
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/
118 qed-.
119
120 lemma lex_inv_unit_dx (R): ∀I,L1,K2. L1 ⪤[R] K2.ⓤ[I] →
121                            ∃∃K1. K1 ⪤[R] K2 & L1 = K1.ⓤ[I].
122 #R #I #L1 #K2 #H
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/
126 qed-.
127
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.
131 #R #I #L1 #K2 #V2 #H
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/
135 qed-.
136
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/
143 qed-.
144
145 (* Basic eliminators ********************************************************)
146
147 lemma lex_ind (R) (Q:relation2 …):
148               Q (⋆) (⋆) →
149               (
150                  ∀I,K1,K2. K1 ⪤[R] K2 → Q K1 K2 → Q (K1.ⓤ[I]) (K2.ⓤ[I])
151               ) → (
152                  ∀I,K1,K2,V1,V2. K1 ⪤[R] K2 → Q K1 K2 → R K1 V1 V2 →Q (K1.ⓑ[I]V1) (K2.ⓑ[I]V2)
153               ) →
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/
161 qed-.