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_2/notation/relations/runion_3.ma".
16 include "ground_2/relocation/rtmap_sle.ma".
18 coinductive sor: relation3 rtmap rtmap rtmap ≝
19 | sor_pp: ∀f1,f2,f,g1,g2,g. sor f1 f2 f → ↑f1 = g1 → ↑f2 = g2 → ↑f = g → sor g1 g2 g
20 | sor_np: ∀f1,f2,f,g1,g2,g. sor f1 f2 f → ⫯f1 = g1 → ↑f2 = g2 → ⫯f = g → sor g1 g2 g
21 | sor_pn: ∀f1,f2,f,g1,g2,g. sor f1 f2 f → ↑f1 = g1 → ⫯f2 = g2 → ⫯f = g → sor g1 g2 g
22 | sor_nn: ∀f1,f2,f,g1,g2,g. sor f1 f2 f → ⫯f1 = g1 → ⫯f2 = g2 → ⫯f = g → sor g1 g2 g
25 interpretation "union (rtmap)"
26 'RUnion f1 f2 f = (sor f1 f2 f).
28 (* Basic inversion lemmas ***************************************************)
30 lemma sor_inv_ppx: ∀g1,g2,g. g1 ⋓ g2 ≡ g → ∀f1,f2. ↑f1 = g1 → ↑f2 = g2 →
31 ∃∃f. f1 ⋓ f2 ≡ f & ↑f = g.
32 #g1 #g2 #g * -g1 -g2 -g
33 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #x1 #x2 #Hx1 #Hx2 destruct
34 try (>(injective_push … Hx1) -x1) try (>(injective_next … Hx1) -x1)
35 try elim (discr_push_next … Hx1) try elim (discr_next_push … Hx1)
36 try (>(injective_push … Hx2) -x2) try (>(injective_next … Hx2) -x2)
37 try elim (discr_push_next … Hx2) try elim (discr_next_push … Hx2)
38 /2 width=3 by ex2_intro/
41 lemma sor_inv_npx: ∀g1,g2,g. g1 ⋓ g2 ≡ g → ∀f1,f2. ⫯f1 = g1 → ↑f2 = g2 →
42 ∃∃f. f1 ⋓ f2 ≡ f & ⫯f = g.
43 #g1 #g2 #g * -g1 -g2 -g
44 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #x1 #x2 #Hx1 #Hx2 destruct
45 try (>(injective_push … Hx1) -x1) try (>(injective_next … Hx1) -x1)
46 try elim (discr_push_next … Hx1) try elim (discr_next_push … Hx1)
47 try (>(injective_push … Hx2) -x2) try (>(injective_next … Hx2) -x2)
48 try elim (discr_push_next … Hx2) try elim (discr_next_push … Hx2)
49 /2 width=3 by ex2_intro/
52 lemma sor_inv_pnx: ∀g1,g2,g. g1 ⋓ g2 ≡ g → ∀f1,f2. ↑f1 = g1 → ⫯f2 = g2 →
53 ∃∃f. f1 ⋓ f2 ≡ f & ⫯f = g.
54 #g1 #g2 #g * -g1 -g2 -g
55 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #x1 #x2 #Hx1 #Hx2 destruct
56 try (>(injective_push … Hx1) -x1) try (>(injective_next … Hx1) -x1)
57 try elim (discr_push_next … Hx1) try elim (discr_next_push … Hx1)
58 try (>(injective_push … Hx2) -x2) try (>(injective_next … Hx2) -x2)
59 try elim (discr_push_next … Hx2) try elim (discr_next_push … Hx2)
60 /2 width=3 by ex2_intro/
63 lemma sor_inv_nnx: ∀g1,g2,g. g1 ⋓ g2 ≡ g → ∀f1,f2. ⫯f1 = g1 → ⫯f2 = g2 →
64 ∃∃f. f1 ⋓ f2 ≡ f & ⫯f = g.
65 #g1 #g2 #g * -g1 -g2 -g
66 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #x1 #x2 #Hx1 #Hx2 destruct
67 try (>(injective_push … Hx1) -x1) try (>(injective_next … Hx1) -x1)
68 try elim (discr_push_next … Hx1) try elim (discr_next_push … Hx1)
69 try (>(injective_push … Hx2) -x2) try (>(injective_next … Hx2) -x2)
70 try elim (discr_push_next … Hx2) try elim (discr_next_push … Hx2)
71 /2 width=3 by ex2_intro/
74 (* Basic properties *********************************************************)
76 corec lemma sor_eq_repl_back1: ∀f2,f. eq_repl_back … (λf1. f1 ⋓ f2 ≡ f).
77 #f2 #f #f1 * -f1 -f2 -f
78 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #x #Hx
79 try cases (eq_inv_px … Hx … H1) try cases (eq_inv_nx … Hx … H1) -g1
80 /3 width=7 by sor_pp, sor_np, sor_pn, sor_nn/
83 lemma sor_eq_repl_fwd1: ∀f2,f. eq_repl_fwd … (λf1. f1 ⋓ f2 ≡ f).
84 #f2 #f @eq_repl_sym /2 width=3 by sor_eq_repl_back1/
87 corec lemma sor_eq_repl_back2: ∀f1,f. eq_repl_back … (λf2. f1 ⋓ f2 ≡ f).
88 #f1 #f #f2 * -f1 -f2 -f
89 #f1 #f2 #f #g1 #g2 #g #Hf #H #H2 #H0 #x #Hx
90 try cases (eq_inv_px … Hx … H2) try cases (eq_inv_nx … Hx … H2) -g2
91 /3 width=7 by sor_pp, sor_np, sor_pn, sor_nn/
94 lemma sor_eq_repl_fwd2: ∀f1,f. eq_repl_fwd … (λf2. f1 ⋓ f2 ≡ f).
95 #f1 #f @eq_repl_sym /2 width=3 by sor_eq_repl_back2/
98 corec lemma sor_eq_repl_back3: ∀f1,f2. eq_repl_back … (λf. f1 ⋓ f2 ≡ f).
99 #f1 #f2 #f * -f1 -f2 -f
100 #f1 #f2 #f #g1 #g2 #g #Hf #H #H2 #H0 #x #Hx
101 try cases (eq_inv_px … Hx … H0) try cases (eq_inv_nx … Hx … H0) -g
102 /3 width=7 by sor_pp, sor_np, sor_pn, sor_nn/
105 lemma sor_eq_repl_fwd3: ∀f1,f2. eq_repl_fwd … (λf. f1 ⋓ f2 ≡ f).
106 #f1 #f2 @eq_repl_sym /2 width=3 by sor_eq_repl_back3/
109 corec lemma sor_refl: ∀f. f ⋓ f ≡ f.
110 #f cases (pn_split f) * #g #H
111 [ @(sor_pp … H H H) | @(sor_nn … H H H) ] -H //
114 corec lemma sor_sym: ∀f1,f2,f. f1 ⋓ f2 ≡ f → f2 ⋓ f1 ≡ f.
115 #f1 #f2 #f * -f1 -f2 -f
116 #f1 #f2 #f #g1 #g2 #g #Hf * * * -g1 -g2 -g
117 [ @sor_pp | @sor_pn | @sor_np | @sor_nn ] /2 width=7 by/