]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/ground_2/relocation/rtmap_sor.ma
rtmaps with finite colength
[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 (* Main inversion lemmas ****************************************************)
76
77 corec theorem sor_mono: ∀f1,f2,x,y. f1 ⋓ f2 ≡ x → f1 ⋓ f2 ≡ y → x ≗ y.
78 #f1 #f2 #x #y * -f1 -f2 -x
79 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #H
80 [ cases (sor_inv_ppx … H … H1 H2)
81 | cases (sor_inv_npx … H … H1 H2)
82 | cases (sor_inv_pnx … H … H1 H2)
83 | cases (sor_inv_nnx … H … H1 H2)
84 ] -g1 -g2
85 /3 width=5 by eq_push, eq_next/
86 qed-.
87
88 (* Basic properties *********************************************************)
89
90 corec lemma sor_eq_repl_back1: ∀f2,f. eq_repl_back … (λf1. f1 ⋓ f2 ≡ f).
91 #f2 #f #f1 * -f1 -f2 -f
92 #f1 #f2 #f #g1 #g2 #g #Hf #H1 #H2 #H0 #x #Hx
93 try cases (eq_inv_px … Hx … H1) try cases (eq_inv_nx … Hx … H1) -g1
94 /3 width=7 by sor_pp, sor_np, sor_pn, sor_nn/
95 qed-.
96
97 lemma sor_eq_repl_fwd1: ∀f2,f. eq_repl_fwd … (λf1. f1 ⋓ f2 ≡ f).
98 #f2 #f @eq_repl_sym /2 width=3 by sor_eq_repl_back1/
99 qed-.
100
101 corec lemma sor_eq_repl_back2: ∀f1,f. eq_repl_back … (λf2. f1 ⋓ f2 ≡ f).
102 #f1 #f #f2 * -f1 -f2 -f
103 #f1 #f2 #f #g1 #g2 #g #Hf #H #H2 #H0 #x #Hx
104 try cases (eq_inv_px … Hx … H2) try cases (eq_inv_nx … Hx … H2) -g2
105 /3 width=7 by sor_pp, sor_np, sor_pn, sor_nn/
106 qed-.
107
108 lemma sor_eq_repl_fwd2: ∀f1,f. eq_repl_fwd … (λf2. f1 ⋓ f2 ≡ f).
109 #f1 #f @eq_repl_sym /2 width=3 by sor_eq_repl_back2/
110 qed-.
111
112 corec lemma sor_eq_repl_back3: ∀f1,f2. eq_repl_back … (λf. f1 ⋓ f2 ≡ f).
113 #f1 #f2 #f * -f1 -f2 -f
114 #f1 #f2 #f #g1 #g2 #g #Hf #H #H2 #H0 #x #Hx
115 try cases (eq_inv_px … Hx … H0) try cases (eq_inv_nx … Hx … H0) -g
116 /3 width=7 by sor_pp, sor_np, sor_pn, sor_nn/
117 qed-.
118
119 lemma sor_eq_repl_fwd3: ∀f1,f2. eq_repl_fwd … (λf. f1 ⋓ f2 ≡ f).
120 #f1 #f2 @eq_repl_sym /2 width=3 by sor_eq_repl_back3/
121 qed-.
122
123 corec lemma sor_refl: ∀f. f ⋓ f ≡ f.
124 #f cases (pn_split f) * #g #H
125 [ @(sor_pp … H H H) | @(sor_nn … H H H) ] -H //
126 qed.
127
128 corec lemma sor_sym: ∀f1,f2,f. f1 ⋓ f2 ≡ f → f2 ⋓ f1 ≡ f.
129 #f1 #f2 #f * -f1 -f2 -f
130 #f1 #f2 #f #g1 #g2 #g #Hf * * * -g1 -g2 -g
131 [ @sor_pp | @sor_pn | @sor_np | @sor_nn ] /2 width=7 by/
132 qed-.
133
134 (* Properies on identity ****************************************************)
135
136 corec lemma sor_isid_sn: ∀f1. 𝐈⦃f1⦄ → ∀f2. f1 ⋓ f2 ≡ f2.
137 #f1 * -f1
138 #f1 #g1 #Hf1 #H1 #f2 cases (pn_split f2) *
139 /3 width=7 by sor_pp, sor_pn/
140 qed.
141
142 corec lemma sor_isid_dx: ∀f2. 𝐈⦃f2⦄ → ∀f1. f1 ⋓ f2 ≡ f1.
143 #f2 * -f2
144 #f2 #g2 #Hf2 #H2 #f1 cases (pn_split f1) *
145 /3 width=7 by sor_pp, sor_np/
146 qed.
147
148 (* Properties on finite colength assignment *********************************)
149
150 lemma sor_fcla_ex: ∀f1,n1. 𝐂⦃f1⦄ ≡ n1 → ∀f2,n2. 𝐂⦃f2⦄ ≡ n2 →
151                    ∃∃f,n. f1 ⋓ f2 ≡ f & 𝐂⦃f⦄ ≡ n & (n1 ∨ n2) ≤ n & n ≤ n1 + n2.
152 #f1 #n1 #Hf1 elim Hf1 -f1 -n1 /3 width=6 by sor_isid_sn, ex4_2_intro/
153 #f1 #n1 #Hf1 #IH #f2 #n2 * -f2 -n2 /3 width=6 by fcla_push, fcla_next, ex4_2_intro, sor_isid_dx/
154 #f2 #n2 #Hf2 elim (IH … Hf2) -IH -Hf2 -Hf1
155 [ /3 width=7 by fcla_push, sor_pp, ex4_2_intro/
156 | /3 width=7 by fcla_next, sor_pn, max_S2_le_S, le_S_S, ex4_2_intro/
157 | /3 width=7 by fcla_next, sor_np, max_S1_le_S, le_S_S, ex4_2_intro/
158 | /4 width=7 by fcla_next, sor_nn, le_S, le_S_S, ex4_2_intro/
159 ]
160 qed-.
161
162 lemma sor_fcla: ∀f1,n1. 𝐂⦃f1⦄ ≡ n1 → ∀f2,n2. 𝐂⦃f2⦄ ≡ n2 → ∀f. f1 ⋓ f2 ≡ f →
163                 ∃∃n. 𝐂⦃f⦄ ≡ n & (n1 ∨ n2) ≤ n & n ≤ n1 + n2.
164 #f1 #n1 #Hf1 #f2 #n2 #Hf2 #f #Hf elim (sor_fcla_ex … Hf1 … Hf2) -Hf1 -Hf2
165 /4 width=6 by sor_mono, fcla_eq_repl_back, ex3_intro/
166 qed-.
167
168 (* Properties on test for finite colength ***********************************)
169
170 lemma sor_isfin_ex: ∀f1,f2. 𝐅⦃f1⦄ → 𝐅⦃f2⦄ → ∃∃f. f1 ⋓ f2 ≡ f & 𝐅⦃f⦄.
171 #f1 #f2 * #n1 #H1 * #n2 #H2 elim (sor_fcla_ex … H1 … H2) -H1 -H2
172 /3 width=4 by ex2_intro, ex_intro/
173 qed-.
174
175 lemma sor_isfin: ∀f1,f2. 𝐅⦃f1⦄ → 𝐅⦃f2⦄ → ∀f. f1 ⋓ f2 ≡ f → 𝐅⦃f⦄.
176 #f1 #f2 #Hf1 #Hf2 #f #Hf elim (sor_isfin_ex … Hf1 … Hf2) -Hf1 -Hf2
177 /3 width=6 by sor_mono, isfin_eq_repl_back/
178 qed-.