]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/static_2/relocation/lex.ma
syntactic components detached from basic_2 become 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_2/pull/pull_2.ma".
16 include "ground_2/pull/pull_4.ma".
17 include "ground_2/relocation/rtmap_uni.ma".
18 include "static_2/notation/relations/relation_3.ma".
19 include "static_2/syntax/cext2.ma".
20 include "static_2/relocation/sex.ma".
21
22 (* GENERIC EXTENSION OF A CONTEXT-SENSITIVE REALTION FOR TERMS **************)
23
24 definition lex (R): relation lenv ≝
25                     λL1,L2. ∃∃f. 𝐈⦃f⦄ & L1 ⪤[cfull, cext2 R, f] L2.
26
27 interpretation "generic extension (local environment)"
28    'Relation R L1 L2 = (lex R L1 L2).
29
30 definition lex_confluent: relation (relation3 …) ≝ λR1,R2.
31                           ∀L0,T0,T1. R1 L0 T0 T1 → ∀T2. R2 L0 T0 T2 →
32                           ∀L1. L0 ⪤[R1] L1 → ∀L2. L0 ⪤[R2] L2 →
33                           ∃∃T. R2 L1 T1 T & R1 L2 T2 T.
34
35 definition lex_transitive: relation (relation3 …) ≝ λR1,R2.
36                            ∀L1,T1,T. R1 L1 T1 T → ∀L2. L1 ⪤[R1] L2 →
37                            ∀T2. R2 L2 T T2 → R1 L1 T1 T2.
38
39 (* Basic properties *********************************************************)
40
41 (* Basic_2A1: was: lpx_sn_atom *)
42 lemma lex_atom (R): ⋆ ⪤[R] ⋆.
43 /2 width=3 by sex_atom, ex2_intro/ qed.
44
45 lemma lex_bind (R): ∀I1,I2,K1,K2. K1 ⪤[R] K2 → cext2 R K1 I1 I2 →
46                     K1.ⓘ{I1} ⪤[R] K2.ⓘ{I2}.
47 #R #I1 #I2 #K1 #K2 * #f #Hf #HK12 #HI12
48 /3 width=3 by sex_push, isid_push, ex2_intro/
49 qed.
50
51 (* Basic_2A1: was: lpx_sn_refl *)
52 lemma lex_refl (R): c_reflexive … R → reflexive … (lex R).
53 /4 width=3 by sex_refl, ext2_refl, ex2_intro/ qed.
54
55 lemma lex_co (R1) (R2): (∀L,T1,T2. R1 L T1 T2 → R2 L T1 T2) →
56                         ∀L1,L2. L1 ⪤[R1] L2 → L1 ⪤[R2] L2.
57 #R1 #R2 #HR #L1 #L2 * /5 width=7 by sex_co, cext2_co, ex2_intro/
58 qed-.
59
60 (* Advanced properties ******************************************************)
61
62 lemma lex_bind_refl_dx (R): c_reflexive … R →
63                             ∀I,K1,K2. K1 ⪤[R] K2 → K1.ⓘ{I} ⪤[R] K2.ⓘ{I}.
64 /3 width=3 by ext2_refl, lex_bind/ qed.
65
66 lemma lex_unit (R): ∀I,K1,K2. K1 ⪤[R] K2 → K1.ⓤ{I} ⪤[R] K2.ⓤ{I}.
67 /3 width=1 by lex_bind, ext2_unit/ qed.
68
69 (* Basic_2A1: was: lpx_sn_pair *)
70 lemma lex_pair (R): ∀I,K1,K2,V1,V2. K1 ⪤[R] K2 → R K1 V1 V2 →
71                     K1.ⓑ{I}V1 ⪤[R] K2.ⓑ{I}V2.
72 /3 width=1 by lex_bind, ext2_pair/ qed.
73
74 (* Basic inversion lemmas ***************************************************)
75
76 (* Basic_2A1: was: lpx_sn_inv_atom1: *)
77 lemma lex_inv_atom_sn (R): ∀L2. ⋆ ⪤[R] L2 → L2 = ⋆.
78 #R #L2 * #f #Hf #H >(sex_inv_atom1 … H) -L2 //
79 qed-.
80
81 lemma lex_inv_bind_sn (R): ∀I1,L2,K1. K1.ⓘ{I1} ⪤[R] L2 →
82                            ∃∃I2,K2. K1 ⪤[R] K2 & cext2 R K1 I1 I2 & L2 = K2.ⓘ{I2}.
83 #R #I1 #L2 #K1 * #f #Hf #H
84 lapply (sex_eq_repl_fwd … H (⫯f) ?) -H /2 width=1 by eq_push_inv_isid/ #H
85 elim (sex_inv_push1 … H) -H #I2 #K2 #HK12 #HI12 #H destruct
86 /3 width=5 by ex2_intro, ex3_2_intro/
87 qed-.
88
89 (* Basic_2A1: was: lpx_sn_inv_atom2 *)
90 lemma lex_inv_atom_dx (R): ∀L1. L1 ⪤[R] ⋆ → L1 = ⋆.
91 #R #L1 * #f #Hf #H >(sex_inv_atom2 … H) -L1 //
92 qed-.
93
94 lemma lex_inv_bind_dx (R): ∀I2,L1,K2. L1 ⪤[R] K2.ⓘ{I2} →
95                            ∃∃I1,K1. K1 ⪤[R] K2 & cext2 R K1 I1 I2 & L1 = K1.ⓘ{I1}.
96 #R #I2 #L1 #K2 * #f #Hf #H
97 lapply (sex_eq_repl_fwd … H (⫯f) ?) -H /2 width=1 by eq_push_inv_isid/ #H
98 elim (sex_inv_push2 … H) -H #I1 #K1 #HK12 #HI12 #H destruct
99 /3 width=5 by ex3_2_intro, ex2_intro/
100 qed-.
101
102 (* Advanced inversion lemmas ************************************************)
103
104 lemma lex_inv_unit_sn (R): ∀I,L2,K1. K1.ⓤ{I} ⪤[R] L2 →
105                            ∃∃K2. K1 ⪤[R] K2 & L2 = K2.ⓤ{I}.
106 #R #I #L2 #K1 #H
107 elim (lex_inv_bind_sn … H) -H #Z2 #K2 #HK12 #HZ2 #H destruct
108 elim (ext2_inv_unit_sn … HZ2) -HZ2
109 /2 width=3 by ex2_intro/
110 qed-.
111
112 (* Basic_2A1: was: lpx_sn_inv_pair1 *)
113 lemma lex_inv_pair_sn (R): ∀I,L2,K1,V1. K1.ⓑ{I}V1 ⪤[R] L2 →
114                            ∃∃K2,V2. K1 ⪤[R] K2 & R K1 V1 V2 & L2 = K2.ⓑ{I}V2.
115 #R #I #L2 #K1 #V1 #H
116 elim (lex_inv_bind_sn … H) -H #Z2 #K2 #HK12 #HZ2 #H destruct
117 elim (ext2_inv_pair_sn … HZ2) -HZ2 #V2 #HV12 #H destruct
118 /2 width=5 by ex3_2_intro/
119 qed-.
120
121 lemma lex_inv_unit_dx (R): ∀I,L1,K2. L1 ⪤[R] K2.ⓤ{I} →
122                            ∃∃K1. K1 ⪤[R] K2 & L1 = K1.ⓤ{I}.
123 #R #I #L1 #K2 #H
124 elim (lex_inv_bind_dx … H) -H #Z1 #K1 #HK12 #HZ1 #H destruct
125 elim (ext2_inv_unit_dx … HZ1) -HZ1
126 /2 width=3 by ex2_intro/
127 qed-.
128
129 (* Basic_2A1: was: lpx_sn_inv_pair2 *)
130 lemma lex_inv_pair_dx (R): ∀I,L1,K2,V2. L1 ⪤[R] K2.ⓑ{I}V2 →
131                            ∃∃K1,V1. K1 ⪤[R] K2 & R K1 V1 V2 & L1 = K1.ⓑ{I}V1.
132 #R #I #L1 #K2 #V2 #H
133 elim (lex_inv_bind_dx … H) -H #Z1 #K1 #HK12 #HZ1 #H destruct
134 elim (ext2_inv_pair_dx … HZ1) -HZ1 #V1 #HV12 #H destruct
135 /2 width=5 by ex3_2_intro/
136 qed-.
137
138 (* Basic_2A1: was: lpx_sn_inv_pair *)
139 lemma lex_inv_pair (R): ∀I1,I2,L1,L2,V1,V2.
140                         L1.ⓑ{I1}V1 ⪤[R] L2.ⓑ{I2}V2 →
141                         ∧∧ L1 ⪤[R] L2 & R L1 V1 V2 & I1 = I2.
142 #R #I1 #I2 #L1 #L2 #V1 #V2 #H elim (lex_inv_pair_sn … H) -H
143 #L0 #V0 #HL10 #HV10 #H destruct /2 width=1 by and3_intro/
144 qed-.
145
146 (* Basic eliminators ********************************************************)
147
148 lemma lex_ind (R) (Q:relation2 …):
149               Q (⋆) (⋆) →
150               (
151                  ∀I,K1,K2. K1 ⪤[R] K2 → Q K1 K2 → Q (K1.ⓤ{I}) (K2.ⓤ{I})
152               ) → (
153                  ∀I,K1,K2,V1,V2. K1 ⪤[R] K2 → Q K1 K2 → R K1 V1 V2 →Q (K1.ⓑ{I}V1) (K2.ⓑ{I}V2)
154               ) →
155               ∀L1,L2. L1 ⪤[R] L2 → Q L1 L2.
156 #R #Q #IH1 #IH2 #IH3 #L1 #L2 * #f @pull_2 #H
157 elim H -f -L1 -L2 // #f #I1 #I2 #K1 #K2 @pull_4 #H
158 [ elim (isid_inv_next … H)
159 | lapply (isid_inv_push … H ??)
160 ] -H [5:|*: // ] #Hf @pull_2 #H
161 elim H -H /3 width=3 by ex2_intro/
162 qed-.