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