]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/ground_2/relocation/rtmap_sor.ma
update in ground_2, static_2, basic_2, apps_2, alpha_1
[helm.git] / matita / matita / contribs / lambdadelta / ground_2 / relocation / rtmap_sor.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/xoa/ex_4_2.ma".
16 include "ground_2/notation/relations/runion_3.ma".
17 include "ground_2/relocation/rtmap_isfin.ma".
18 include "ground_2/relocation/rtmap_sle.ma".
19
20 coinductive sor: relation3 rtmap rtmap rtmap ≝
21 | sor_pp: ∀f1,f2,f,g1,g2,g. sor f1 f2 f → ⫯f1 = g1 → ⫯f2 = g2 → ⫯f = g → sor g1 g2 g
22 | sor_np: ∀f1,f2,f,g1,g2,g. sor f1 f2 f → ↑f1 = g1 → ⫯f2 = g2 → ↑f = g → sor g1 g2 g
23 | sor_pn: ∀f1,f2,f,g1,g2,g. sor f1 f2 f → ⫯f1 = g1 → ↑f2 = g2 → ↑f = g → sor g1 g2 g
24 | sor_nn: ∀f1,f2,f,g1,g2,g. sor f1 f2 f → ↑f1 = g1 → ↑f2 = g2 → ↑f = g → sor g1 g2 g
25 .
26
27 interpretation "union (rtmap)"
28    'RUnion f1 f2 f = (sor f1 f2 f).
29
30 (* Basic inversion lemmas ***************************************************)
31
32 lemma sor_inv_ppx: ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f1,f2. ⫯f1 = g1 → ⫯f2 = g2 →
33                    ∃∃f. f1 ⋓ f2 ≘ f & ⫯f = g.
34 #g1 #g2 #g * -g1 -g2 -g
35 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #x1 #x2 #Hx1 #Hx2 destruct
36 try (>(injective_push … Hx1) -x1) try (>(injective_next … Hx1) -x1)
37 try elim (discr_push_next … Hx1) try elim (discr_next_push … Hx1)
38 try (>(injective_push … Hx2) -x2) try (>(injective_next … Hx2) -x2)
39 try elim (discr_push_next … Hx2) try elim (discr_next_push … Hx2)
40 /2 width=3 by ex2_intro/
41 qed-.
42
43 lemma sor_inv_npx: ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f1,f2. ↑f1 = g1 → ⫯f2 = g2 →
44                    ∃∃f. f1 ⋓ f2 ≘ f & ↑f = g.
45 #g1 #g2 #g * -g1 -g2 -g
46 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #x1 #x2 #Hx1 #Hx2 destruct
47 try (>(injective_push … Hx1) -x1) try (>(injective_next … Hx1) -x1)
48 try elim (discr_push_next … Hx1) try elim (discr_next_push … Hx1)
49 try (>(injective_push … Hx2) -x2) try (>(injective_next … Hx2) -x2)
50 try elim (discr_push_next … Hx2) try elim (discr_next_push … Hx2)
51 /2 width=3 by ex2_intro/
52 qed-.
53
54 lemma sor_inv_pnx: ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f1,f2. ⫯f1 = g1 → ↑f2 = g2 →
55                    ∃∃f. f1 ⋓ f2 ≘ f & ↑f = g.
56 #g1 #g2 #g * -g1 -g2 -g
57 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #x1 #x2 #Hx1 #Hx2 destruct
58 try (>(injective_push … Hx1) -x1) try (>(injective_next … Hx1) -x1)
59 try elim (discr_push_next … Hx1) try elim (discr_next_push … Hx1)
60 try (>(injective_push … Hx2) -x2) try (>(injective_next … Hx2) -x2)
61 try elim (discr_push_next … Hx2) try elim (discr_next_push … Hx2)
62 /2 width=3 by ex2_intro/
63 qed-.
64
65 lemma sor_inv_nnx: ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f1,f2. ↑f1 = g1 → ↑f2 = g2 →
66                    ∃∃f. f1 ⋓ f2 ≘ f & ↑f = g.
67 #g1 #g2 #g * -g1 -g2 -g
68 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #x1 #x2 #Hx1 #Hx2 destruct
69 try (>(injective_push … Hx1) -x1) try (>(injective_next … Hx1) -x1)
70 try elim (discr_push_next … Hx1) try elim (discr_next_push … Hx1)
71 try (>(injective_push … Hx2) -x2) try (>(injective_next … Hx2) -x2)
72 try elim (discr_push_next … Hx2) try elim (discr_next_push … Hx2)
73 /2 width=3 by ex2_intro/
74 qed-.
75
76 (* Advanced inversion lemmas ************************************************)
77
78 lemma sor_inv_ppn: ∀g1,g2,g. g1 ⋓ g2 ≘ g →
79                    ∀f1,f2,f. ⫯f1 = g1 → ⫯f2 = g2 → ↑f = g → ⊥.
80 #g1 #g2 #g #H #f1 #f2 #f #H1 #H2 #H0
81 elim (sor_inv_ppx … H … H1 H2) -g1 -g2 #x #_ #H destruct
82 /2 width=3 by discr_push_next/
83 qed-.
84
85 lemma sor_inv_nxp: ∀g1,g2,g. g1 ⋓ g2 ≘ g →
86                    ∀f1,f. ↑f1 = g1 → ⫯f = g → ⊥.
87 #g1 #g2 #g #H #f1 #f #H1 #H0
88 elim (pn_split g2) * #f2 #H2
89 [ elim (sor_inv_npx … H … H1 H2)
90 | elim (sor_inv_nnx … H … H1 H2)
91 ] -g1 -g2 #x #_ #H destruct
92 /2 width=3 by discr_next_push/
93 qed-.
94
95 lemma sor_inv_xnp: ∀g1,g2,g. g1 ⋓ g2 ≘ g →
96                    ∀f2,f. ↑f2 = g2 → ⫯f = g → ⊥.
97 #g1 #g2 #g #H #f2 #f #H2 #H0
98 elim (pn_split g1) * #f1 #H1
99 [ elim (sor_inv_pnx … H … H1 H2)
100 | elim (sor_inv_nnx … H … H1 H2)
101 ] -g1 -g2 #x #_ #H destruct
102 /2 width=3 by discr_next_push/
103 qed-.
104
105 lemma sor_inv_ppp: ∀g1,g2,g. g1 ⋓ g2 ≘ g →
106                    ∀f1,f2,f. ⫯f1 = g1 → ⫯f2 = g2 → ⫯f = g → f1 ⋓ f2 ≘ f.
107 #g1 #g2 #g #H #f1 #f2 #f #H1 #H2 #H0
108 elim (sor_inv_ppx … H … H1 H2) -g1 -g2 #x #Hx #H destruct
109 <(injective_push … H) -f //
110 qed-.
111
112 lemma sor_inv_npn: ∀g1,g2,g. g1 ⋓ g2 ≘ g →
113                    ∀f1,f2,f. ↑f1 = g1 → ⫯f2 = g2 → ↑f = g → f1 ⋓ f2 ≘ f.
114 #g1 #g2 #g #H #f1 #f2 #f #H1 #H2 #H0
115 elim (sor_inv_npx … H … H1 H2) -g1 -g2 #x #Hx #H destruct
116 <(injective_next … H) -f //
117 qed-.
118
119 lemma sor_inv_pnn: ∀g1,g2,g. g1 ⋓ g2 ≘ g →
120                    ∀f1,f2,f. ⫯f1 = g1 → ↑f2 = g2 → ↑f = g → f1 ⋓ f2 ≘ f.
121 #g1 #g2 #g #H #f1 #f2 #f #H1 #H2 #H0
122 elim (sor_inv_pnx … H … H1 H2) -g1 -g2 #x #Hx #H destruct
123 <(injective_next … H) -f //
124 qed-.
125
126 lemma sor_inv_nnn: ∀g1,g2,g. g1 ⋓ g2 ≘ g →
127                    ∀f1,f2,f. ↑f1 = g1 → ↑f2 = g2 → ↑f = g → f1 ⋓ f2 ≘ f.
128 #g1 #g2 #g #H #f1 #f2 #f #H1 #H2 #H0
129 elim (sor_inv_nnx … H … H1 H2) -g1 -g2 #x #Hx #H destruct
130 <(injective_next … H) -f //
131 qed-.
132
133 lemma sor_inv_pxp: ∀g1,g2,g. g1 ⋓ g2 ≘ g →
134                    ∀f1,f. ⫯f1 = g1 → ⫯f = g →
135                    ∃∃f2. f1 ⋓ f2 ≘ f & ⫯f2 = g2.
136 #g1 #g2 #g #H #f1 #f #H1 #H0
137 elim (pn_split g2) * #f2 #H2
138 [ /3 width=7 by sor_inv_ppp, ex2_intro/
139 | elim (sor_inv_xnp … H … H2 H0)
140 ]
141 qed-.
142
143 lemma sor_inv_xpp: ∀g1,g2,g. g1 ⋓ g2 ≘ g →
144                    ∀f2,f. ⫯f2 = g2 → ⫯f = g →
145                    ∃∃f1. f1 ⋓ f2 ≘ f & ⫯f1 = g1.
146 #g1 #g2 #g #H #f2 #f #H2 #H0
147 elim (pn_split g1) * #f1 #H1
148 [ /3 width=7 by sor_inv_ppp, ex2_intro/
149 | elim (sor_inv_nxp … H … H1 H0)
150 ]
151 qed-.
152
153 lemma sor_inv_pxn: ∀g1,g2,g. g1 ⋓ g2 ≘ g →
154                    ∀f1,f. ⫯f1 = g1 → ↑f = g →
155                    ∃∃f2. f1 ⋓ f2 ≘ f & ↑f2 = g2.
156 #g1 #g2 #g #H #f1 #f #H1 #H0
157 elim (pn_split g2) * #f2 #H2
158 [ elim (sor_inv_ppn … H … H1 H2 H0)
159 | /3 width=7 by sor_inv_pnn, ex2_intro/
160 ]
161 qed-.
162
163 lemma sor_inv_xpn: ∀g1,g2,g. g1 ⋓ g2 ≘ g →
164                    ∀f2,f. ⫯f2 = g2 → ↑f = g →
165                    ∃∃f1. f1 ⋓ f2 ≘ f & ↑f1 = g1.
166 #g1 #g2 #g #H #f2 #f #H2 #H0
167 elim (pn_split g1) * #f1 #H1
168 [ elim (sor_inv_ppn … H … H1 H2 H0)
169 | /3 width=7 by sor_inv_npn, ex2_intro/
170 ]
171 qed-.
172
173 lemma sor_inv_xxp: ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f. ⫯f = g →
174                    ∃∃f1,f2. f1 ⋓ f2 ≘ f & ⫯f1 = g1 & ⫯f2 = g2.
175 #g1 #g2 #g #H #f #H0
176 elim (pn_split g1) * #f1 #H1
177 [ elim (sor_inv_pxp … H … H1 H0) -g /2 width=5 by ex3_2_intro/
178 | elim (sor_inv_nxp … H … H1 H0)
179 ]
180 qed-.
181
182 lemma sor_inv_nxn: ∀g1,g2,g. g1 ⋓ g2 ≘ g →
183                    ∀f1,f. ↑f1 = g1 → ↑f = g →
184                    (∃∃f2. f1 ⋓ f2 ≘ f & ⫯f2 = g2) ∨
185                    ∃∃f2. f1 ⋓ f2 ≘ f & ↑f2 = g2.
186 #g1 #g2 elim (pn_split g2) *
187 /4 width=7 by sor_inv_npn, sor_inv_nnn, ex2_intro, or_intror, or_introl/
188 qed-.
189
190 lemma sor_inv_xnn: ∀g1,g2,g. g1 ⋓ g2 ≘ g →
191                    ∀f2,f. ↑f2 = g2 → ↑f = g →
192                    (∃∃f1. f1 ⋓ f2 ≘ f & ⫯f1 = g1) ∨
193                    ∃∃f1. f1 ⋓ f2 ≘ f & ↑f1 = g1.
194 #g1 elim (pn_split g1) *
195 /4 width=7 by sor_inv_pnn, sor_inv_nnn, ex2_intro, or_intror, or_introl/
196 qed-.
197
198 lemma sor_inv_xxn: ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f. ↑f = g →
199                    ∨∨ ∃∃f1,f2. f1 ⋓ f2 ≘ f & ↑f1 = g1 & ⫯f2 = g2
200                     | ∃∃f1,f2. f1 ⋓ f2 ≘ f & ⫯f1 = g1 & ↑f2 = g2
201                     | ∃∃f1,f2. f1 ⋓ f2 ≘ f & ↑f1 = g1 & ↑f2 = g2.
202 #g1 #g2 #g #H #f #H0
203 elim (pn_split g1) * #f1 #H1
204 [ elim (sor_inv_pxn … H … H1 H0) -g
205   /3 width=5 by or3_intro1, ex3_2_intro/
206 | elim (sor_inv_nxn … H … H1 H0) -g *
207   /3 width=5 by or3_intro0, or3_intro2, ex3_2_intro/
208 ]
209 qed-.
210
211 (* Main inversion lemmas ****************************************************)
212
213 corec theorem sor_mono: ∀f1,f2,x,y. f1 ⋓ f2 ≘ x → f1 ⋓ f2 ≘ y → x ≡ y.
214 #f1 #f2 #x #y * -f1 -f2 -x
215 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #H
216 [ cases (sor_inv_ppx … H … H1 H2)
217 | cases (sor_inv_npx … H … H1 H2)
218 | cases (sor_inv_pnx … H … H1 H2)
219 | cases (sor_inv_nnx … H … H1 H2)
220 ] -g1 -g2
221 /3 width=5 by eq_push, eq_next/
222 qed-.
223
224 (* Basic properties *********************************************************)
225
226 corec lemma sor_eq_repl_back1: ∀f2,f. eq_repl_back … (λf1. f1 ⋓ f2 ≘ f).
227 #f2 #f #f1 * -f1 -f2 -f
228 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #x #Hx
229 try cases (eq_inv_px … Hx … H1) try cases (eq_inv_nx … Hx … H1) -g1
230 /3 width=7 by sor_pp, sor_np, sor_pn, sor_nn/
231 qed-.
232
233 lemma sor_eq_repl_fwd1: ∀f2,f. eq_repl_fwd … (λf1. f1 ⋓ f2 ≘ f).
234 #f2 #f @eq_repl_sym /2 width=3 by sor_eq_repl_back1/
235 qed-.
236
237 corec lemma sor_eq_repl_back2: ∀f1,f. eq_repl_back … (λf2. f1 ⋓ f2 ≘ f).
238 #f1 #f #f2 * -f1 -f2 -f
239 #f1 #f2 #f #g1 #g2 #g #Hf #H #H2 #H0 #x #Hx
240 try cases (eq_inv_px … Hx … H2) try cases (eq_inv_nx … Hx … H2) -g2
241 /3 width=7 by sor_pp, sor_np, sor_pn, sor_nn/
242 qed-.
243
244 lemma sor_eq_repl_fwd2: ∀f1,f. eq_repl_fwd … (λf2. f1 ⋓ f2 ≘ f).
245 #f1 #f @eq_repl_sym /2 width=3 by sor_eq_repl_back2/
246 qed-.
247
248 corec lemma sor_eq_repl_back3: ∀f1,f2. eq_repl_back … (λf. f1 ⋓ f2 ≘ f).
249 #f1 #f2 #f * -f1 -f2 -f
250 #f1 #f2 #f #g1 #g2 #g #Hf #H #H2 #H0 #x #Hx
251 try cases (eq_inv_px … Hx … H0) try cases (eq_inv_nx … Hx … H0) -g
252 /3 width=7 by sor_pp, sor_np, sor_pn, sor_nn/
253 qed-.
254
255 lemma sor_eq_repl_fwd3: ∀f1,f2. eq_repl_fwd … (λf. f1 ⋓ f2 ≘ f).
256 #f1 #f2 @eq_repl_sym /2 width=3 by sor_eq_repl_back3/
257 qed-.
258
259 corec lemma sor_idem: ∀f. f ⋓ f ≘ f.
260 #f cases (pn_split f) * #g #H
261 [ @(sor_pp … H H H) | @(sor_nn … H H H) ] -H //
262 qed.
263
264 corec lemma sor_comm: ∀f1,f2,f. f1 ⋓ f2 ≘ f → f2 ⋓ f1 ≘ f.
265 #f1 #f2 #f * -f1 -f2 -f
266 #f1 #f2 #f #g1 #g2 #g #Hf * * * -g1 -g2 -g
267 [ @sor_pp | @sor_pn | @sor_np | @sor_nn ] /2 width=7 by/
268 qed-.
269
270 (* Properties with tail *****************************************************)
271
272 lemma sor_tl: ∀f1,f2,f. f1 ⋓ f2 ≘ f → ⫱f1 ⋓ ⫱f2 ≘ ⫱f.
273 #f1 cases (pn_split f1) * #g1 #H1
274 #f2 cases (pn_split f2) * #g2 #H2
275 #f #Hf
276 [ cases (sor_inv_ppx … Hf … H1 H2)
277 | cases (sor_inv_pnx … Hf … H1 H2)
278 | cases (sor_inv_npx … Hf … H1 H2)
279 | cases (sor_inv_nnx … Hf … H1 H2)
280 ] -Hf #g #Hg #H destruct //
281 qed.
282
283 lemma sor_xxn_tl: ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f. ↑f = g →
284                   (∃∃f1,f2. f1 ⋓ f2 ≘ f & ↑f1 = g1 & ⫱g2 = f2) ∨
285                   (∃∃f1,f2. f1 ⋓ f2 ≘ f & ⫱g1 = f1 & ↑f2 = g2).
286 #g1 #g2 #g #H #f #H0 elim (sor_inv_xxn … H … H0) -H -H0 *
287 /3 width=5 by ex3_2_intro, or_introl, or_intror/
288 qed-.
289
290 lemma sor_xnx_tl: ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f2. ↑f2 = g2 →
291                   ∃∃f1,f. f1 ⋓ f2 ≘ f & ⫱g1 = f1 & ↑f = g.
292 #g1 elim (pn_split g1) * #f1 #H1 #g2 #g #H #f2 #H2
293 [ elim (sor_inv_pnx … H … H1 H2) | elim (sor_inv_nnx … H … H1 H2) ] -g2
294 /3 width=5 by ex3_2_intro/
295 qed-.
296
297 lemma sor_nxx_tl: ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f1. ↑f1 = g1 →
298                   ∃∃f2,f. f1 ⋓ f2 ≘ f & ⫱g2 = f2 & ↑f = g.
299 #g1 #g2 elim (pn_split g2) * #f2 #H2 #g #H #f1 #H1
300 [ elim (sor_inv_npx … H … H1 H2) | elim (sor_inv_nnx … H … H1 H2) ] -g1
301 /3 width=5 by ex3_2_intro/
302 qed-.
303
304 (* Properties with iterated tail ********************************************)
305
306 lemma sor_tls: ∀f1,f2,f. f1 ⋓ f2 ≘ f →
307                ∀n. ⫱*[n]f1 ⋓ ⫱*[n]f2 ≘ ⫱*[n]f.
308 #f1 #f2 #f #Hf #n elim n -n /2 width=1 by sor_tl/
309 qed.
310
311 (* Properies with test for identity *****************************************)
312
313 corec lemma sor_isid_sn: ∀f1. 𝐈❪f1❫ → ∀f2. f1 ⋓ f2 ≘ f2.
314 #f1 * -f1
315 #f1 #g1 #Hf1 #H1 #f2 cases (pn_split f2) *
316 /3 width=7 by sor_pp, sor_pn/
317 qed.
318
319 corec lemma sor_isid_dx: ∀f2. 𝐈❪f2❫ → ∀f1. f1 ⋓ f2 ≘ f1.
320 #f2 * -f2
321 #f2 #g2 #Hf2 #H2 #f1 cases (pn_split f1) *
322 /3 width=7 by sor_pp, sor_np/
323 qed.
324
325 lemma sor_isid: ∀f1,f2,f. 𝐈❪f1❫ → 𝐈❪f2❫ → 𝐈❪f❫ → f1 ⋓ f2 ≘ f.
326 /4 width=3 by sor_eq_repl_back2, sor_eq_repl_back1, isid_inv_eq_repl/ qed.
327
328 (* Inversion lemmas with tail ***********************************************)
329
330 lemma sor_inv_tl_sn: ∀f1,f2,f. ⫱f1 ⋓ f2 ≘ f → f1 ⋓ ↑f2 ≘ ↑f.
331 #f1 #f2 #f elim (pn_split f1) *
332 #g1 #H destruct /2 width=7 by sor_pn, sor_nn/
333 qed-.
334
335 lemma sor_inv_tl_dx: ∀f1,f2,f. f1 ⋓ ⫱f2 ≘ f → ↑f1 ⋓ f2 ≘ ↑f.
336 #f1 #f2 #f elim (pn_split f2) *
337 #g2 #H destruct /2 width=7 by sor_np, sor_nn/
338 qed-.
339
340 (* Inversion lemmas with test for identity **********************************)
341
342 lemma sor_isid_inv_sn: ∀f1,f2,f. f1 ⋓ f2 ≘ f → 𝐈❪f1❫ → f2 ≡ f.
343 /3 width=4 by sor_isid_sn, sor_mono/
344 qed-.
345
346 lemma sor_isid_inv_dx: ∀f1,f2,f. f1 ⋓ f2 ≘ f → 𝐈❪f2❫ → f1 ≡ f.
347 /3 width=4 by sor_isid_dx, sor_mono/
348 qed-.
349
350 corec lemma sor_fwd_isid1: ∀f1,f2,f. f1 ⋓ f2 ≘ f → 𝐈❪f❫ → 𝐈❪f1❫.
351 #f1 #f2 #f * -f1 -f2 -f
352 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H #Hg
353 [ /4 width=6 by isid_inv_push, isid_push/ ]
354 cases (isid_inv_next … Hg … H)
355 qed-.
356
357 corec lemma sor_fwd_isid2: ∀f1,f2,f. f1 ⋓ f2 ≘ f → 𝐈❪f❫ → 𝐈❪f2❫.
358 #f1 #f2 #f * -f1 -f2 -f
359 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H #Hg
360 [ /4 width=6 by isid_inv_push, isid_push/ ]
361 cases (isid_inv_next … Hg … H)
362 qed-.
363
364 lemma sor_inv_isid3: ∀f1,f2,f. f1 ⋓ f2 ≘ f → 𝐈❪f❫ → 𝐈❪f1❫ ∧ 𝐈❪f2❫.
365 /3 width=4 by sor_fwd_isid2, sor_fwd_isid1, conj/ qed-.
366
367 (* Properties with finite colength assignment *******************************)
368
369 lemma sor_fcla_ex: ∀f1,n1. 𝐂❪f1❫ ≘ n1 → ∀f2,n2. 𝐂❪f2❫ ≘ n2 →
370                    ∃∃f,n. f1 ⋓ f2 ≘ f & 𝐂❪f❫ ≘ n & (n1 ∨ n2) ≤ n & n ≤ n1 + n2.
371 #f1 #n1 #Hf1 elim Hf1 -f1 -n1 /3 width=6 by sor_isid_sn, ex4_2_intro/
372 #f1 #n1 #Hf1 #IH #f2 #n2 * -f2 -n2 /3 width=6 by fcla_push, fcla_next, ex4_2_intro, sor_isid_dx/
373 #f2 #n2 #Hf2 elim (IH … Hf2) -IH -Hf2 -Hf1 [2,4: #f #n <plus_n_Sm ] (**) (* full auto fails *)
374 [ /3 width=7 by fcla_next, sor_pn, max_S2_le_S, le_S_S, ex4_2_intro/
375 | /4 width=7 by fcla_next, sor_nn, le_S, le_S_S, ex4_2_intro/
376 | /3 width=7 by fcla_push, sor_pp, ex4_2_intro/
377 | /3 width=7 by fcla_next, sor_np, max_S1_le_S, le_S_S, ex4_2_intro/
378 ]
379 qed-.
380
381 lemma sor_fcla: ∀f1,n1. 𝐂❪f1❫ ≘ n1 → ∀f2,n2. 𝐂❪f2❫ ≘ n2 → ∀f. f1 ⋓ f2 ≘ f →
382                 ∃∃n. 𝐂❪f❫ ≘ n & (n1 ∨ n2) ≤ n & n ≤ n1 + n2.
383 #f1 #n1 #Hf1 #f2 #n2 #Hf2 #f #Hf elim (sor_fcla_ex … Hf1 … Hf2) -Hf1 -Hf2
384 /4 width=6 by sor_mono, fcla_eq_repl_back, ex3_intro/
385 qed-.
386
387 (* Forward lemmas with finite colength **************************************)
388
389 lemma sor_fwd_fcla_sn_ex: ∀f,n. 𝐂❪f❫ ≘ n → ∀f1,f2. f1 ⋓ f2 ≘ f →
390                           ∃∃n1.  𝐂❪f1❫ ≘ n1 & n1 ≤ n.
391 #f #n #H elim H -f -n
392 [ /4 width=4 by sor_fwd_isid1, fcla_isid, ex2_intro/
393 | #f #n #_ #IH #f1 #f2 #H
394   elim (sor_inv_xxp … H) -H [ |*: // ] #g1 #g2 #Hf #H1 #H2 destruct
395   elim (IH … Hf) -f /3 width=3 by fcla_push, ex2_intro/
396 | #f #n #_ #IH #f1 #f2 #H
397   elim (sor_inv_xxn … H) -H [1,3,4: * |*: // ] #g1 #g2 #Hf #H1 #H2 destruct
398   elim (IH … Hf) -f /3 width=3 by fcla_push, fcla_next, le_S_S, le_S, ex2_intro/
399 ]
400 qed-.
401
402 lemma sor_fwd_fcla_dx_ex: ∀f,n. 𝐂❪f❫ ≘ n → ∀f1,f2. f1 ⋓ f2 ≘ f →
403                           ∃∃n2.  𝐂❪f2❫ ≘ n2 & n2 ≤ n.
404 /3 width=4 by sor_fwd_fcla_sn_ex, sor_comm/ qed-.
405
406 (* Properties with test for finite colength *********************************)
407
408 lemma sor_isfin_ex: ∀f1,f2. 𝐅❪f1❫ → 𝐅❪f2❫ → ∃∃f. f1 ⋓ f2 ≘ f & 𝐅❪f❫.
409 #f1 #f2 * #n1 #H1 * #n2 #H2 elim (sor_fcla_ex … H1 … H2) -H1 -H2
410 /3 width=4 by ex2_intro, ex_intro/
411 qed-.
412
413 lemma sor_isfin: ∀f1,f2. 𝐅❪f1❫ → 𝐅❪f2❫ → ∀f. f1 ⋓ f2 ≘ f → 𝐅❪f❫.
414 #f1 #f2 #Hf1 #Hf2 #f #Hf elim (sor_isfin_ex … Hf1 … Hf2) -Hf1 -Hf2
415 /3 width=6 by sor_mono, isfin_eq_repl_back/
416 qed-.
417
418 (* Forward lemmas with test for finite colength *****************************)
419
420 lemma sor_fwd_isfin_sn: ∀f. 𝐅❪f❫ → ∀f1,f2. f1 ⋓ f2 ≘ f → 𝐅❪f1❫.
421 #f * #n #Hf #f1 #f2 #H
422 elim (sor_fwd_fcla_sn_ex … Hf … H) -f -f2 /2 width=2 by ex_intro/
423 qed-.
424
425 lemma sor_fwd_isfin_dx: ∀f. 𝐅❪f❫ → ∀f1,f2. f1 ⋓ f2 ≘ f → 𝐅❪f2❫.
426 #f * #n #Hf #f1 #f2 #H
427 elim (sor_fwd_fcla_dx_ex … Hf … H) -f -f1 /2 width=2 by ex_intro/
428 qed-.
429
430 (* Inversion lemmas with test for finite colength ***************************)
431
432 lemma sor_inv_isfin3: ∀f1,f2,f. f1 ⋓ f2 ≘ f → 𝐅❪f❫ → 𝐅❪f1❫ ∧ 𝐅❪f2❫.
433 /3 width=4 by sor_fwd_isfin_dx, sor_fwd_isfin_sn, conj/ qed-.
434
435 (* Inversion lemmas with inclusion ******************************************)
436
437 corec lemma sor_inv_sle_sn: ∀f1,f2,f. f1 ⋓ f2 ≘ f → f1 ⊆ f.
438 #f1 #f2 #f * -f1 -f2 -f
439 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0
440 /3 width=5 by sle_push, sle_next, sle_weak/
441 qed-.
442
443 corec lemma sor_inv_sle_dx: ∀f1,f2,f. f1 ⋓ f2 ≘ f → f2 ⊆ f.
444 #f1 #f2 #f * -f1 -f2 -f
445 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0
446 /3 width=5 by sle_push, sle_next, sle_weak/
447 qed-.
448
449 lemma sor_inv_sle_sn_trans: ∀f1,f2,f. f1 ⋓ f2 ≘ f → ∀g. g ⊆ f1 → g ⊆ f.
450 /3 width=4 by sor_inv_sle_sn, sle_trans/ qed-.
451
452 lemma sor_inv_sle_dx_trans: ∀f1,f2,f. f1 ⋓ f2 ≘ f → ∀g. g ⊆ f2 → g ⊆ f.
453 /3 width=4 by sor_inv_sle_dx, sle_trans/ qed-.
454
455 axiom sor_inv_sle: ∀f1,f2,f. f1 ⋓ f2 ≘ f → ∀g. f1 ⊆ g → f2 ⊆ g → f ⊆ g.
456
457 (* Properties with inclusion ************************************************)
458
459 corec lemma sor_sle_dx: ∀f1,f2. f1 ⊆ f2 → f1 ⋓ f2 ≘ f2.
460 #f1 #f2 * -f1 -f2 /3 width=7 by sor_pp, sor_nn, sor_pn/
461 qed.
462
463 corec lemma sor_sle_sn: ∀f1,f2. f1 ⊆ f2 → f2 ⋓ f1 ≘ f2.
464 #f1 #f2 * -f1 -f2 /3 width=7 by sor_pp, sor_nn, sor_np/
465 qed.
466
467 (* Main properties **********************************************************)
468
469 axiom monotonic_sle_sor: ∀f1,g1. f1 ⊆ g1 → ∀f2,g2. f2 ⊆ g2 →
470                          ∀f. f1 ⋓ f2 ≘ f → ∀g. g1 ⋓ g2 ≘ g → f ⊆ g.
471
472 axiom sor_assoc_dx: ∀f0,f3,f4. f0 ⋓ f3 ≘ f4 →
473                     ∀f1,f2. f1 ⋓ f2 ≘ f0 →
474                     ∀f. f2 ⋓ f3 ≘ f → f1 ⋓ f ≘ f4.
475
476 axiom sor_assoc_sn: ∀f1,f0,f4. f1 ⋓ f0 ≘ f4 →
477                     ∀f2, f3. f2 ⋓ f3 ≘ f0 →
478                     ∀f. f1 ⋓ f2 ≘ f → f ⋓ f3 ≘ f4.
479
480 lemma sor_comm_23: ∀f0,f1,f2,f3,f4,f.
481                    f0⋓f4 ≘ f1 → f1⋓f2 ≘ f → f0⋓f2 ≘ f3 → f3⋓f4 ≘ f.
482 /4 width=6 by sor_comm, sor_assoc_dx/ qed-.
483
484 corec theorem sor_comm_23_idem: ∀f0,f1,f2. f0 ⋓ f1 ≘ f2 →
485                                 ∀f. f1 ⋓ f2 ≘ f → f1 ⋓ f0 ≘ f.
486 #f0 #f1 #f2 * -f0 -f1 -f2
487 #f0 #f1 #f2 #g0 #g1 #g2 #Hf2 #H0 #H1 #H2 #g #Hg
488 [ cases (sor_inv_ppx … Hg … H1 H2)
489 | cases (sor_inv_pnx … Hg … H1 H2)
490 | cases (sor_inv_nnx … Hg … H1 H2)
491 | cases (sor_inv_nnx … Hg … H1 H2)
492 ] -g2 #f #Hf #H
493 /3 width=7 by sor_nn, sor_np, sor_pn, sor_pp/
494 qed-.
495
496 corec theorem sor_coll_dx: ∀f1,f2,f. f1 ⋓ f2 ≘ f → ∀g1,g2,g. g1 ⋓ g2 ≘ g →
497                            ∀g0. g1 ⋓ g0 ≘ f1 → g2 ⋓ g0 ≘ f2 → g ⋓ g0 ≘ f.
498 #f1 #f2 #f cases (pn_split f) * #x #Hx #Hf #g1 #g2 #g #Hg #g0 #Hf1 #Hf2
499 [ cases (sor_inv_xxp … Hf … Hx) -Hf #x1 #x2 #Hf #Hx1 #Hx2
500   cases (sor_inv_xxp … Hf1 … Hx1) -f1 #y1 #y0 #Hf1 #Hy1 #Hy0
501   cases (sor_inv_xpp … Hf2 … Hy0 … Hx2) -f2 #y2 #Hf2 #Hy2
502   cases (sor_inv_ppx … Hg … Hy1 Hy2) -g1 -g2 #y #Hg #Hy
503   @(sor_pp … Hy Hy0 Hx) -g -g0 -f /2 width=8 by/
504 | cases (pn_split g) * #y #Hy
505   [ cases (sor_inv_xxp … Hg … Hy) -Hg #y1 #y2 #Hg #Hy1 #Hy2
506     cases (sor_xxn_tl … Hf … Hx) * #x1 #x2 #_ #Hx1 #Hx2
507     [ cases (sor_inv_pxn … Hf1 … Hy1 Hx1) -g1 #y0 #Hf1 #Hy0
508       cases (sor_inv_pnx … Hf2 … Hy2 Hy0) -g2 -x2 #x2 #Hf2 #Hx2
509     | cases (sor_inv_pxn … Hf2 … Hy2 Hx2) -g2 #y0 #Hf2 #Hy0
510       cases (sor_inv_pnx … Hf1 … Hy1 Hy0) -g1 -x1 #x1 #Hf1 #Hx1
511     ]
512     lapply (sor_inv_nnn … Hf … Hx1 Hx2 Hx) -f1 -f2 #Hf
513     @(sor_pn … Hy Hy0 Hx) -g -g0 -f /2 width=8 by/
514   | lapply (sor_tl … Hf) -Hf #Hf
515     lapply (sor_tl … Hg) -Hg #Hg
516     lapply (sor_tl … Hf1) -Hf1 #Hf1
517     lapply (sor_tl … Hf2) -Hf2 #Hf2
518     cases (pn_split g0) * #y0 #Hy0
519     [ @(sor_np … Hy Hy0 Hx) /2 width=8 by/
520     | @(sor_nn … Hy Hy0 Hx) /2 width=8 by/
521     ]
522   ]
523 ]
524 qed-.
525
526 corec theorem sor_distr_dx: ∀g0,g1,g2,g. g1 ⋓ g2 ≘ g →
527                             ∀f1,f2,f. g1 ⋓ g0 ≘ f1 → g2 ⋓ g0 ≘ f2 → g ⋓ g0 ≘ f →
528                             f1 ⋓ f2 ≘ f.
529 #g0 cases (pn_split g0) * #y0 #H0 #g1 #g2 #g
530 [ * -g1 -g2 -g #y1 #y2 #y #g1 #g2 #g #Hy #Hy1 #Hy2 #Hy #f1 #f2 #f #Hf1 #Hf2 #Hf
531   [ cases (sor_inv_ppx … Hf1 … Hy1 H0) -g1
532     cases (sor_inv_ppx … Hf2 … Hy2 H0) -g2
533     cases (sor_inv_ppx … Hf … Hy H0) -g
534   | cases (sor_inv_npx … Hf1 … Hy1 H0) -g1
535     cases (sor_inv_ppx … Hf2 … Hy2 H0) -g2
536     cases (sor_inv_npx … Hf … Hy H0) -g
537   | cases (sor_inv_ppx … Hf1 … Hy1 H0) -g1
538     cases (sor_inv_npx … Hf2 … Hy2 H0) -g2
539     cases (sor_inv_npx … Hf … Hy H0) -g
540   | cases (sor_inv_npx … Hf1 … Hy1 H0) -g1
541     cases (sor_inv_npx … Hf2 … Hy2 H0) -g2
542     cases (sor_inv_npx … Hf … Hy H0) -g
543   ] -g0 #y #Hy #H #y2 #Hy2 #H2 #y1 #Hy1 #H1
544   /3 width=8 by sor_nn, sor_np, sor_pn, sor_pp/
545 | #H #f1 #f2 #f #Hf1 #Hf2 #Hf
546   cases (sor_xnx_tl … Hf1 … H0) -Hf1
547   cases (sor_xnx_tl … Hf2 … H0) -Hf2
548   cases (sor_xnx_tl … Hf … H0) -Hf
549   -g0 #y #x #Hx #Hy #H #y2 #x2 #Hx2 #Hy2 #H2 #y1 #x1 #Hx1 #Hy1 #H1
550   /4 width=8 by sor_tl, sor_nn/
551 ]
552 qed-.