]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/ground/relocation/rtmap_sand.ma
ground_2 released and permanently renamed as ground
[helm.git] / matita / matita / contribs / lambdadelta / ground / relocation / rtmap_sand.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/notation/relations/rintersection_3.ma".
16 include "ground/relocation/rtmap_sle.ma".
17
18 coinductive sand: relation3 rtmap rtmap rtmap ≝
19 | sand_pp: ∀f1,f2,f,g1,g2,g. sand f1 f2 f → ⫯f1 = g1 → ⫯f2 = g2 → ⫯f = g → sand g1 g2 g
20 | sand_np: ∀f1,f2,f,g1,g2,g. sand f1 f2 f → ↑f1 = g1 → ⫯f2 = g2 → ⫯f = g → sand g1 g2 g
21 | sand_pn: ∀f1,f2,f,g1,g2,g. sand f1 f2 f → ⫯f1 = g1 → ↑f2 = g2 → ⫯f = g → sand g1 g2 g
22 | sand_nn: ∀f1,f2,f,g1,g2,g. sand f1 f2 f → ↑f1 = g1 → ↑f2 = g2 → ↑f = g → sand g1 g2 g
23 .
24
25 interpretation "intersection (rtmap)"
26    'RIntersection f1 f2 f = (sand f1 f2 f).
27
28 (* Basic inversion lemmas ***************************************************)
29
30 lemma sand_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/
39 qed-.
40
41 lemma sand_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/
50 qed-.
51
52 lemma sand_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/
61 qed-.
62
63 lemma sand_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/
72 qed-.
73
74 (* Basic properties *********************************************************)
75
76 corec lemma sand_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 sand_pp, sand_np, sand_pn, sand_nn/
81 qed-.
82
83 lemma sand_eq_repl_fwd1: ∀f2,f. eq_repl_fwd … (λf1. f1 ⋒ f2 ≘ f).
84 #f2 #f @eq_repl_sym /2 width=3 by sand_eq_repl_back1/
85 qed-.
86
87 corec lemma sand_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 sand_pp, sand_np, sand_pn, sand_nn/
92 qed-.
93
94 lemma sand_eq_repl_fwd2: ∀f1,f. eq_repl_fwd … (λf2. f1 ⋒ f2 ≘ f).
95 #f1 #f @eq_repl_sym /2 width=3 by sand_eq_repl_back2/
96 qed-.
97
98 corec lemma sand_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 sand_pp, sand_np, sand_pn, sand_nn/
103 qed-.
104
105 lemma sand_eq_repl_fwd3: ∀f1,f2. eq_repl_fwd … (λf. f1 ⋒ f2 ≘ f).
106 #f1 #f2 @eq_repl_sym /2 width=3 by sand_eq_repl_back3/
107 qed-.
108
109 corec lemma sand_refl: ∀f. f ⋒ f ≘ f.
110 #f cases (pn_split f) * #g #H
111 [ @(sand_pp … H H H) | @(sand_nn … H H H) ] -H //
112 qed.
113
114 corec lemma sand_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 [ @sand_pp | @sand_pn | @sand_np | @sand_nn ] /2 width=7 by/
118 qed-.