1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "ground/notation/relations/runion_3.ma".
16 include "ground/xoa/or_3.ma".
17 include "ground/xoa/ex_3_2.ma".
18 include "ground/relocation/pr_tl.ma".
20 (* RELATIONAL UNION FOR PARTIAL RELOCATION MAPS *****************************)
23 coinductive pr_sor: relation3 pr_map pr_map pr_map ≝
25 | pr_sor_push_bi (f1) (f2) (f) (g1) (g2) (g):
26 pr_sor f1 f2 f → ⫯f1 = g1 → ⫯f2 = g2 → ⫯f = g → pr_sor g1 g2 g
28 | pr_sor_next_push (f1) (f2) (f) (g1) (g2) (g):
29 pr_sor f1 f2 f → ↑f1 = g1 → ⫯f2 = g2 → ↑f = g → pr_sor g1 g2 g
31 | pr_sor_push_next (f1) (f2) (f) (g1) (g2) (g):
32 pr_sor f1 f2 f → ⫯f1 = g1 → ↑f2 = g2 → ↑f = g → pr_sor g1 g2 g
34 | pr_sor_next_bi (f1) (f2) (f) (g1) (g2) (g):
35 pr_sor f1 f2 f → ↑f1 = g1 → ↑f2 = g2 → ↑f = g → pr_sor g1 g2 g
39 "relational union (partial relocation maps)"
40 'RUnion f1 f2 f = (pr_sor f1 f2 f).
42 (* Basic constructions ******************************************************)
45 corec lemma pr_sor_idem:
47 #f cases (pr_map_split_tl f) #H
48 [ @(pr_sor_push_bi … H H H)
49 | @(pr_sor_next_bi … H H H)
54 corec lemma pr_sor_comm:
55 ∀f1,f2,f. f1 ⋓ f2 ≘ f → f2 ⋓ f1 ≘ f.
56 #f1 #f2 #f * -f1 -f2 -f
57 #f1 #f2 #f #g1 #g2 #g #Hf * * * -g1 -g2 -g
58 [ @pr_sor_push_bi | @pr_sor_push_next | @pr_sor_next_push | @pr_sor_next_bi ] /2 width=7 by/
61 (* Basic inversions *********************************************************)
64 lemma pr_sor_inv_push_bi:
65 ∀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 (>(eq_inv_pr_push_bi … Hx1) -x1) try (>(eq_inv_pr_next_bi … Hx1) -x1)
70 try elim (eq_inv_pr_push_next … Hx1) try elim (eq_inv_pr_next_push … Hx1)
71 try (>(eq_inv_pr_push_bi … Hx2) -x2) try (>(eq_inv_pr_next_bi … Hx2) -x2)
72 try elim (eq_inv_pr_push_next … Hx2) try elim (eq_inv_pr_next_push … Hx2)
73 /2 width=3 by ex2_intro/
77 lemma pr_sor_inv_next_push:
78 ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f1,f2. ↑f1 = g1 → ⫯f2 = g2 →
79 ∃∃f. f1 ⋓ f2 ≘ f & ↑f = g.
80 #g1 #g2 #g * -g1 -g2 -g
81 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #x1 #x2 #Hx1 #Hx2 destruct
82 try (>(eq_inv_pr_push_bi … Hx1) -x1) try (>(eq_inv_pr_next_bi … Hx1) -x1)
83 try elim (eq_inv_pr_push_next … Hx1) try elim (eq_inv_pr_next_push … Hx1)
84 try (>(eq_inv_pr_push_bi … Hx2) -x2) try (>(eq_inv_pr_next_bi … Hx2) -x2)
85 try elim (eq_inv_pr_push_next … Hx2) try elim (eq_inv_pr_next_push … Hx2)
86 /2 width=3 by ex2_intro/
90 lemma pr_sor_inv_push_next:
91 ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f1,f2. ⫯f1 = g1 → ↑f2 = g2 →
92 ∃∃f. f1 ⋓ f2 ≘ f & ↑f = g.
93 #g1 #g2 #g * -g1 -g2 -g
94 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #x1 #x2 #Hx1 #Hx2 destruct
95 try (>(eq_inv_pr_push_bi … Hx1) -x1) try (>(eq_inv_pr_next_bi … Hx1) -x1)
96 try elim (eq_inv_pr_push_next … Hx1) try elim (eq_inv_pr_next_push … Hx1)
97 try (>(eq_inv_pr_push_bi … Hx2) -x2) try (>(eq_inv_pr_next_bi … Hx2) -x2)
98 try elim (eq_inv_pr_push_next … Hx2) try elim (eq_inv_pr_next_push … Hx2)
99 /2 width=3 by ex2_intro/
103 lemma pr_sor_inv_next_bi:
104 ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f1,f2. ↑f1 = g1 → ↑f2 = g2 →
105 ∃∃f. f1 ⋓ f2 ≘ f & ↑f = g.
106 #g1 #g2 #g * -g1 -g2 -g
107 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #x1 #x2 #Hx1 #Hx2 destruct
108 try (>(eq_inv_pr_push_bi … Hx1) -x1) try (>(eq_inv_pr_next_bi … Hx1) -x1)
109 try elim (eq_inv_pr_push_next … Hx1) try elim (eq_inv_pr_next_push … Hx1)
110 try (>(eq_inv_pr_push_bi … Hx2) -x2) try (>(eq_inv_pr_next_bi … Hx2) -x2)
111 try elim (eq_inv_pr_push_next … Hx2) try elim (eq_inv_pr_next_push … Hx2)
112 /2 width=3 by ex2_intro/
115 (* Advanced inversions ******************************************************)
118 lemma pr_sor_inv_push_bi_next:
119 ∀g1,g2,g. g1 ⋓ g2 ≘ g →
120 ∀f1,f2,f. ⫯f1 = g1 → ⫯f2 = g2 → ↑f = g → ⊥.
121 #g1 #g2 #g #H #f1 #f2 #f #H1 #H2 #H0
122 elim (pr_sor_inv_push_bi … H … H1 H2) -g1 -g2 #x #_ #H destruct
123 /2 width=3 by eq_inv_pr_push_next/
127 lemma pr_sor_inv_next_sn_push:
128 ∀g1,g2,g. g1 ⋓ g2 ≘ g →
129 ∀f1,f. ↑f1 = g1 → ⫯f = g → ⊥.
130 #g1 #g2 #g #H #f1 #f #H1 #H0
131 elim (pr_map_split_tl g2) #H2
132 [ elim (pr_sor_inv_next_push … H … H1 H2)
133 | elim (pr_sor_inv_next_bi … H … H1 H2)
135 /2 width=3 by eq_inv_pr_next_push/
139 lemma pr_sor_inv_next_dx_push:
140 ∀g1,g2,g. g1 ⋓ g2 ≘ g →
141 ∀f2,f. ↑f2 = g2 → ⫯f = g → ⊥.
142 #g1 #g2 #g #H #f2 #f #H2 #H0
143 elim (pr_map_split_tl g1) #H1
144 [ elim (pr_sor_inv_push_next … H … H1 H2)
145 | elim (pr_sor_inv_next_bi … H … H1 H2)
147 /2 width=3 by eq_inv_pr_next_push/
151 lemma pr_sor_inv_push_bi_push:
152 ∀g1,g2,g. g1 ⋓ g2 ≘ g →
153 ∀f1,f2,f. ⫯f1 = g1 → ⫯f2 = g2 → ⫯f = g → f1 ⋓ f2 ≘ f.
154 #g1 #g2 #g #H #f1 #f2 #f #H1 #H2 #H0
155 elim (pr_sor_inv_push_bi … H … H1 H2) -g1 -g2 #x #Hx #H destruct
156 <(eq_inv_pr_push_bi … H) -f //
160 lemma pr_sor_inv_next_push_next:
161 ∀g1,g2,g. g1 ⋓ g2 ≘ g →
162 ∀f1,f2,f. ↑f1 = g1 → ⫯f2 = g2 → ↑f = g → f1 ⋓ f2 ≘ f.
163 #g1 #g2 #g #H #f1 #f2 #f #H1 #H2 #H0
164 elim (pr_sor_inv_next_push … H … H1 H2) -g1 -g2 #x #Hx #H destruct
165 <(eq_inv_pr_next_bi … H) -f //
169 lemma pr_sor_inv_push_next_next:
170 ∀g1,g2,g. g1 ⋓ g2 ≘ g →
171 ∀f1,f2,f. ⫯f1 = g1 → ↑f2 = g2 → ↑f = g → f1 ⋓ f2 ≘ f.
172 #g1 #g2 #g #H #f1 #f2 #f #H1 #H2 #H0
173 elim (pr_sor_inv_push_next … H … H1 H2) -g1 -g2 #x #Hx #H destruct
174 <(eq_inv_pr_next_bi … H) -f //
178 lemma pr_sor_inv_next_bi_next:
179 ∀g1,g2,g. g1 ⋓ g2 ≘ g →
180 ∀f1,f2,f. ↑f1 = g1 → ↑f2 = g2 → ↑f = g → f1 ⋓ f2 ≘ f.
181 #g1 #g2 #g #H #f1 #f2 #f #H1 #H2 #H0
182 elim (pr_sor_inv_next_bi … H … H1 H2) -g1 -g2 #x #Hx #H destruct
183 <(eq_inv_pr_next_bi … H) -f //
187 lemma pr_sor_inv_push_sn_push:
188 ∀g1,g2,g. g1 ⋓ g2 ≘ g →
189 ∀f1,f. ⫯f1 = g1 → ⫯f = g →
190 ∃∃f2. f1 ⋓ f2 ≘ f & ⫯f2 = g2.
191 #g1 #g2 #g #H #f1 #f #H1 #H0
192 elim (pr_map_split_tl g2) #H2
193 [ /3 width=7 by pr_sor_inv_push_bi_push, ex2_intro/
194 | elim (pr_sor_inv_next_dx_push … H … H2 H0)
199 lemma pr_sor_inv_push_dx_push:
200 ∀g1,g2,g. g1 ⋓ g2 ≘ g →
201 ∀f2,f. ⫯f2 = g2 → ⫯f = g →
202 ∃∃f1. f1 ⋓ f2 ≘ f & ⫯f1 = g1.
203 #g1 #g2 #g #H #f2 #f #H2 #H0
204 elim (pr_map_split_tl g1) #H1
205 [ /3 width=7 by pr_sor_inv_push_bi_push, ex2_intro/
206 | elim (pr_sor_inv_next_sn_push … H … H1 H0)
211 lemma pr_sor_inv_push_sn_next:
212 ∀g1,g2,g. g1 ⋓ g2 ≘ g →
213 ∀f1,f. ⫯f1 = g1 → ↑f = g →
214 ∃∃f2. f1 ⋓ f2 ≘ f & ↑f2 = g2.
215 #g1 #g2 #g #H #f1 #f #H1 #H0
216 elim (pr_map_split_tl g2) #H2
217 [ elim (pr_sor_inv_push_bi_next … H … H1 H2 H0)
218 | /3 width=7 by pr_sor_inv_push_next_next, ex2_intro/
223 lemma pr_sor_inv_push_dx_next:
224 ∀g1,g2,g. g1 ⋓ g2 ≘ g →
225 ∀f2,f. ⫯f2 = g2 → ↑f = g →
226 ∃∃f1. f1 ⋓ f2 ≘ f & ↑f1 = g1.
227 #g1 #g2 #g #H #f2 #f #H2 #H0
228 elim (pr_map_split_tl g1) #H1
229 [ elim (pr_sor_inv_push_bi_next … H … H1 H2 H0)
230 | /3 width=7 by pr_sor_inv_next_push_next, ex2_intro/
235 lemma pr_sor_inv_push:
236 ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f. ⫯f = g →
237 ∃∃f1,f2. f1 ⋓ f2 ≘ f & ⫯f1 = g1 & ⫯f2 = g2.
239 elim (pr_map_split_tl g1) #H1
240 [ elim (pr_sor_inv_push_sn_push … H … H1 H0) -g /2 width=5 by ex3_2_intro/
241 | elim (pr_sor_inv_next_sn_push … H … H1 H0)
246 lemma pr_sor_inv_next_sn_next:
247 ∀g1,g2,g. g1 ⋓ g2 ≘ g →
248 ∀f1,f. ↑f1 = g1 → ↑f = g →
249 ∨∨ ∃∃f2. f1 ⋓ f2 ≘ f & ⫯f2 = g2
250 | ∃∃f2. f1 ⋓ f2 ≘ f & ↑f2 = g2.
251 #g1 #g2 elim (pr_map_split_tl g2)
252 /4 width=7 by pr_sor_inv_next_push_next, pr_sor_inv_next_bi_next, ex2_intro, or_intror, or_introl/
256 lemma pr_sor_inv_next_dx_next:
257 ∀g1,g2,g. g1 ⋓ g2 ≘ g →
258 ∀f2,f. ↑f2 = g2 → ↑f = g →
259 ∨∨ ∃∃f1. f1 ⋓ f2 ≘ f & ⫯f1 = g1
260 | ∃∃f1. f1 ⋓ f2 ≘ f & ↑f1 = g1.
261 #g1 elim (pr_map_split_tl g1)
262 /4 width=7 by pr_sor_inv_push_next_next, pr_sor_inv_next_bi_next, ex2_intro, or_intror, or_introl/
266 lemma pr_sor_inv_next:
267 ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f. ↑f = g →
268 ∨∨ ∃∃f1,f2. f1 ⋓ f2 ≘ f & ↑f1 = g1 & ⫯f2 = g2
269 | ∃∃f1,f2. f1 ⋓ f2 ≘ f & ⫯f1 = g1 & ↑f2 = g2
270 | ∃∃f1,f2. f1 ⋓ f2 ≘ f & ↑f1 = g1 & ↑f2 = g2.
272 elim (pr_map_split_tl g1) #H1
273 [ elim (pr_sor_inv_push_sn_next … H … H1 H0) -g
274 /3 width=5 by or3_intro1, ex3_2_intro/
275 | elim (pr_sor_inv_next_sn_next … H … H1 H0) -g *
276 /3 width=5 by or3_intro0, or3_intro2, ex3_2_intro/
280 (* Constructions with pr_tl *************************************************)
284 ∀f1,f2,f. f1 ⋓ f2 ≘ f → ⫰f1 ⋓ ⫰f2 ≘ ⫰f.
285 #f1 cases (pr_map_split_tl f1) #H1
286 #f2 cases (pr_map_split_tl f2) #H2
288 [ cases (pr_sor_inv_push_bi … Hf … H1 H2)
289 | cases (pr_sor_inv_push_next … Hf … H1 H2)
290 | cases (pr_sor_inv_next_push … Hf … H1 H2)
291 | cases (pr_sor_inv_next_bi … Hf … H1 H2)
292 ] -Hf #g #Hg #H destruct //
296 lemma pr_sor_next_tl:
297 ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f. ↑f = g →
298 (∃∃f1,f2. f1 ⋓ f2 ≘ f & ↑f1 = g1 & ⫰g2 = f2) ∨
299 (∃∃f1,f2. f1 ⋓ f2 ≘ f & ⫰g1 = f1 & ↑f2 = g2).
300 #g1 #g2 #g #H #f #H0 elim (pr_sor_inv_next … H … H0) -H -H0 *
301 /3 width=5 by ex3_2_intro, or_introl, or_intror/
305 lemma pr_sor_next_dx_tl:
306 ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f2. ↑f2 = g2 →
307 ∃∃f1,f. f1 ⋓ f2 ≘ f & ⫰g1 = f1 & ↑f = g.
308 #g1 elim (pr_map_split_tl g1) #H1 #g2 #g #H #f2 #H2
309 [ elim (pr_sor_inv_push_next … H … H1 H2)
310 | elim (pr_sor_inv_next_bi … H … H1 H2)
312 /3 width=5 by ex3_2_intro/
316 lemma pr_sor_next_sn_tl:
317 ∀g1,g2,g. g1 ⋓ g2 ≘ g → ∀f1. ↑f1 = g1 →
318 ∃∃f2,f. f1 ⋓ f2 ≘ f & ⫰g2 = f2 & ↑f = g.
319 #g1 #g2 elim (pr_map_split_tl g2) #H2 #g #H #f1 #H1
320 [ elim (pr_sor_inv_next_push … H … H1 H2)
321 | elim (pr_sor_inv_next_bi … H … H1 H2)
323 /3 width=5 by ex3_2_intro/
326 (* Inversions with pr_tl ****************************************************)
328 (*** sor_inv_tl_sn *)
329 lemma pr_sor_inv_tl_sn:
330 ∀f1,f2,f. ⫰f1 ⋓ f2 ≘ f → f1 ⋓ ↑f2 ≘ ↑f.
331 #f1 #f2 #f elim (pr_map_split_tl f1)
332 /2 width=7 by pr_sor_push_next, pr_sor_next_bi/
335 (*** sor_inv_tl_dx *)
336 lemma pr_sor_inv_tl_dx:
337 ∀f1,f2,f. f1 ⋓ ⫰f2 ≘ f → ↑f1 ⋓ f2 ≘ ↑f.
338 #f1 #f2 #f elim (pr_map_split_tl f2)
339 /2 width=7 by pr_sor_next_push, pr_sor_next_bi/