]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/static/lfdeq.ma
advances on lfsx ...
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / static / lfdeq.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/notation/relations/lazyeq_5.ma".
16 include "basic_2/syntax/tdeq.ma".
17 include "basic_2/static/lfxs.ma".
18
19 (* DEGREE-BASED EQUIVALENCE FOR LOCAL ENVIRONMENTS ON REFERRED ENTRIES ******)
20
21 definition lfdeq: ∀h. sd h → relation3 term lenv lenv ≝
22                   λh,o. lfxs (cdeq h o).
23
24 interpretation
25    "degree-based equivalence on referred entries (local environment)"
26    'LazyEq h o T L1 L2 = (lfdeq h o T L1 L2).
27
28 interpretation
29    "degree-based ranged equivalence (local environment)"
30    'LazyEq h o f L1 L2 = (lexs (cdeq h o) cfull f L1 L2).
31 (*
32 definition lfdeq_transitive: predicate (relation3 lenv term term) ≝
33            λR. ∀L2,T1,T2. R L2 T1 T2 → ∀L1. L1 ≡[h, o, T1] L2 → R L1 T1 T2.
34 *)
35 (* Basic properties ***********************************************************)
36
37 lemma frees_tdeq_conf_lexs: ∀h,o,f,L1,T1. L1 ⊢ 𝐅*⦃T1⦄ ≡ f → ∀T2. T1 ≡[h, o] T2 →
38                             ∀L2. L1 ≡[h, o, f] L2 → L2 ⊢ 𝐅*⦃T2⦄ ≡ f.
39 #h #o #f #L1 #T1 #H elim H -f -L1 -T1
40 [ #f #I1 #Hf #X #H1 elim (tdeq_fwd_atom1 … H1) -H1
41   #I2 #H1 #Y #H2 lapply (lexs_inv_atom1 … H2) -H2
42   #H2 destruct /2 width=1 by frees_atom/
43 | #f #I #L1 #V1 #s1 #_ #IH #X #H1 elim (tdeq_inv_sort1 … H1) -H1
44   #s2 #d #Hs1 #Hs2 #H1 #Y #H2 elim (lexs_inv_push1 … H2) -H2
45   #L2 #V2 #HL12 #_ #H2 destruct /4 width=3 by frees_sort, tdeq_sort/
46 | #f #I #L1 #V1 #_ #IH #X #H1 >(tdeq_inv_lref1 … H1) -H1
47   #Y #H2 elim (lexs_inv_next1 … H2) -H2
48   #L2 #V2 #HL12 #HV12 #H2 destruct /3 width=1 by frees_zero/
49 | #f #I #L1 #V1 #i #_ #IH #X #H1 >(tdeq_inv_lref1 … H1) -H1
50   #Y #H2 elim (lexs_inv_push1 … H2) -H2
51   #L2 #V2 #HL12 #_ #H2 destruct /3 width=1 by frees_lref/
52 | #f #I #L1 #V1 #l #_ #IH #X #H1 >(tdeq_inv_gref1 … H1) -H1
53   #Y #H2 elim (lexs_inv_push1 … H2) -H2
54   #L2 #V2 #HL12 #_ #H2 destruct /3 width=1 by frees_gref/
55 | #f1V #f1T #f1 #p #I #L1 #V1 #T1 #_ #_ #Hf1 #IHV #IHT #X #H1 elim (tdeq_inv_pair1 … H1) -H1
56   #V2 #T2 #HV12 #HT12 #H1 #L2 #HL12 destruct
57   /6 width=5 by frees_bind, lexs_inv_tl, sle_lexs_trans, sor_inv_sle_dx, sor_inv_sle_sn/
58 | #f1V #f1T #f1 #I #L1 #V1 #T1 #_ #_ #Hf1 #IHV #IHT #X #H1 elim (tdeq_inv_pair1 … H1) -H1
59   #V2 #T2 #HV12 #HT12 #H1 #L2 #HL12 destruct
60   /5 width=5 by frees_flat, sle_lexs_trans, sor_inv_sle_dx, sor_inv_sle_sn/
61 ]
62 qed-.
63
64 lemma frees_tdeq_conf: ∀h,o,f,L,T1. L ⊢ 𝐅*⦃T1⦄ ≡ f →
65                        ∀T2. T1 ≡[h, o] T2 → L ⊢ 𝐅*⦃T2⦄ ≡ f.
66 /3 width=7 by frees_tdeq_conf_lexs, lexs_refl/ qed-.
67
68 lemma frees_lfdeq_conf_lexs: ∀h,o. lexs_frees_confluent (cdeq h o) cfull.
69 /3 width=7 by frees_tdeq_conf_lexs, ex2_intro/ qed-.
70
71 lemma tdeq_lfdeq_conf_sn: ∀h,o. s_r_confluent1 … (cdeq h o) (lfdeq h o).
72 #h #o #L1 #T1 #T2 #HT12 #L2 *
73 /3 width=5 by frees_tdeq_conf, ex2_intro/
74 qed-.
75
76 lemma lfdeq_sym: ∀h,o,T. symmetric … (lfdeq h o T).
77 #h #o #T #L1 #L2 *
78 /4 width=7 by frees_tdeq_conf_lexs, lfxs_sym, tdeq_sym, ex2_intro/
79 qed-.
80
81 lemma lfdeq_atom: ∀h,o,I. ⋆ ≡[h, o, ⓪{I}] ⋆.
82 /2 width=1 by lfxs_atom/ qed.
83
84 lemma lfdeq_sort: ∀h,o,I,L1,L2,V1,V2,s.
85                   L1 ≡[h, o, ⋆s] L2 → L1.ⓑ{I}V1 ≡[h, o, ⋆s] L2.ⓑ{I}V2.
86 /2 width=1 by lfxs_sort/ qed.
87
88 lemma lfdeq_zero: ∀h,o,I,L1,L2,V.
89                   L1 ≡[h, o, V] L2 → L1.ⓑ{I}V ≡[h, o, #0] L2.ⓑ{I}V.
90 /2 width=1 by lfxs_zero/ qed.
91
92 lemma lfdeq_lref: ∀h,o,I,L1,L2,V1,V2,i.
93                   L1 ≡[h, o, #i] L2 → L1.ⓑ{I}V1 ≡[h, o, #⫯i] L2.ⓑ{I}V2.
94 /2 width=1 by lfxs_lref/ qed.
95
96 lemma lfdeq_gref: ∀h,o,I,L1,L2,V1,V2,l.
97                   L1 ≡[h, o, §l] L2 → L1.ⓑ{I}V1 ≡[h, o, §l] L2.ⓑ{I}V2.
98 /2 width=1 by lfxs_gref/ qed.
99
100 lemma lfdeq_pair_repl_dx: ∀h,o,I,L1,L2.∀T:term.∀V,V1.
101                           L1.ⓑ{I}V ≡[h, o, T] L2.ⓑ{I}V1 →
102                           ∀V2. V ≡[h, o] V2 →
103                           L1.ⓑ{I}V ≡[h, o, T] L2.ⓑ{I}V2.
104 /2 width=2 by lfxs_pair_repl_dx/ qed-.
105
106 (* Basic inversion lemmas ***************************************************)
107
108 lemma lfdeq_inv_atom_sn: ∀h,o,Y2. ∀T:term. ⋆ ≡[h, o, T] Y2 → Y2 = ⋆.
109 /2 width=3 by lfxs_inv_atom_sn/ qed-.
110
111 lemma lfdeq_inv_atom_dx: ∀h,o,Y1. ∀T:term. Y1 ≡[h, o, T] ⋆ → Y1 = ⋆.
112 /2 width=3 by lfxs_inv_atom_dx/ qed-.
113
114 lemma lfdeq_inv_zero: ∀h,o,Y1,Y2. Y1 ≡[h, o, #0] Y2 →
115                       (Y1 = ⋆ ∧ Y2 = ⋆) ∨
116                       ∃∃I,L1,L2,V1,V2. L1 ≡[h, o, V1] L2 & V1 ≡[h, o] V2 &
117                                        Y1 = L1.ⓑ{I}V1 & Y2 = L2.ⓑ{I}V2.
118 #h #o #Y1 #Y2 #H elim (lfxs_inv_zero … H) -H *
119 /3 width=9 by ex4_5_intro, or_introl, or_intror, conj/
120 qed-.
121
122 lemma lfdeq_inv_lref: ∀h,o,Y1,Y2,i. Y1 ≡[h, o, #⫯i] Y2 →
123                       (Y1 = ⋆ ∧ Y2 = ⋆) ∨ 
124                       ∃∃I,L1,L2,V1,V2. L1 ≡[h, o, #i] L2 &
125                                        Y1 = L1.ⓑ{I}V1 & Y2 = L2.ⓑ{I}V2.
126 /2 width=1 by lfxs_inv_lref/ qed-.
127
128 lemma lfdeq_inv_bind: ∀h,o,p,I,L1,L2,V,T. L1 ≡[h, o, ⓑ{p,I}V.T] L2 →
129                       L1 ≡[h, o, V] L2 ∧ L1.ⓑ{I}V ≡[h, o, T] L2.ⓑ{I}V.
130 /2 width=2 by lfxs_inv_bind/ qed-.
131
132 lemma lfdeq_inv_flat: ∀h,o,I,L1,L2,V,T. L1 ≡[h, o, ⓕ{I}V.T] L2 →
133                       L1 ≡[h, o, V] L2 ∧ L1 ≡[h, o, T] L2.
134 /2 width=2 by lfxs_inv_flat/ qed-.
135
136 (* Advanced inversion lemmas ************************************************)
137
138 lemma lfdeq_inv_zero_pair_sn: ∀h,o,I,Y2,L1,V1. L1.ⓑ{I}V1 ≡[h, o, #0] Y2 →
139                               ∃∃L2,V2. L1 ≡[h, o, V1] L2 & V1 ≡[h, o] V2 & Y2 = L2.ⓑ{I}V2.
140 #h #o #I #Y2 #L1 #V1 #H elim (lfxs_inv_zero_pair_sn … H) -H /2 width=5 by ex3_2_intro/
141 qed-.
142
143 lemma lfdeq_inv_zero_pair_dx: ∀h,o,I,Y1,L2,V2. Y1 ≡[h, o, #0] L2.ⓑ{I}V2 →
144                               ∃∃L1,V1. L1 ≡[h, o, V1] L2 & V1 ≡[h, o] V2 & Y1 = L1.ⓑ{I}V1.
145 #h #o #I #Y1 #L2 #V2 #H elim (lfxs_inv_zero_pair_dx … H) -H
146 #L1 #V1 #HL12 #HV12 #H destruct /2 width=5 by ex3_2_intro/
147 qed-.
148
149 lemma lfdeq_inv_lref_pair_sn: ∀h,o,I,Y2,L1,V1,i. L1.ⓑ{I}V1 ≡[h, o, #⫯i] Y2 →
150                               ∃∃L2,V2. L1 ≡[h, o, #i] L2 & Y2 = L2.ⓑ{I}V2.
151 /2 width=2 by lfxs_inv_lref_pair_sn/ qed-.
152
153 lemma lfdeq_inv_lref_pair_dx: ∀h,o,I,Y1,L2,V2,i. Y1 ≡[h, o, #⫯i] L2.ⓑ{I}V2 →
154                               ∃∃L1,V1. L1 ≡[h, o, #i] L2 & Y1 = L1.ⓑ{I}V1.
155 /2 width=2 by lfxs_inv_lref_pair_dx/ qed-.
156
157 (* Basic forward lemmas *****************************************************)
158
159 lemma lfdeq_fwd_bind_sn: ∀h,o,p,I,L1,L2,V,T. L1 ≡[h, o, ⓑ{p,I}V.T] L2 → L1 ≡[h, o, V] L2.
160 /2 width=4 by lfxs_fwd_bind_sn/ qed-.
161
162 lemma lfdeq_fwd_bind_dx: ∀h,o,p,I,L1,L2,V,T.
163                          L1 ≡[h, o, ⓑ{p,I}V.T] L2 → L1.ⓑ{I}V ≡[h, o, T] L2.ⓑ{I}V.
164 /2 width=2 by lfxs_fwd_bind_dx/ qed-.
165
166 lemma lfdeq_fwd_flat_sn: ∀h,o,I,L1,L2,V,T. L1 ≡[h, o, ⓕ{I}V.T] L2 → L1 ≡[h, o, V] L2.
167 /2 width=3 by lfxs_fwd_flat_sn/ qed-.
168
169 lemma lfdeq_fwd_flat_dx: ∀h,o,I,L1,L2,V,T. L1 ≡[h, o, ⓕ{I}V.T] L2 → L1 ≡[h, o, T] L2.
170 /2 width=3 by lfxs_fwd_flat_dx/ qed-.
171
172 lemma lfdeq_fwd_pair_sn: ∀h,o,I,L1,L2,V,T. L1 ≡[h, o, ②{I}V.T] L2 → L1 ≡[h, o, V] L2.
173 /2 width=3 by lfxs_fwd_pair_sn/ qed-.
174
175 lemma lfdeq_fwd_dx: ∀h,o,I,L1,K2,V2. ∀T:term. L1 ≡[h, o, T] K2.ⓑ{I}V2 →
176                     ∃∃K1,V1. L1 = K1.ⓑ{I}V1.
177 /2 width=5 by lfxs_fwd_dx/ qed-.
178
179 (* Basic_2A1: removed theorems 31: 
180               lleq_ind lleq_inv_bind lleq_inv_flat lleq_fwd_length lleq_fwd_lref
181               lleq_fwd_drop_sn lleq_fwd_drop_dx
182               lleq_fwd_bind_sn lleq_fwd_bind_dx lleq_fwd_flat_sn lleq_fwd_flat_dx
183               lleq_sort lleq_skip lleq_lref lleq_free lleq_gref lleq_bind lleq_flat
184               lleq_refl lleq_Y lleq_sym lleq_ge_up lleq_ge lleq_bind_O llpx_sn_lrefl
185               lleq_trans lleq_canc_sn lleq_canc_dx lleq_nlleq_trans nlleq_lleq_div
186               lleq_dec 
187 *)