]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/delayed_updating/unwind1/unwind.ma
update in delayed_updating
[helm.git] / matita / matita / contribs / lambdadelta / delayed_updating / unwind1 / unwind.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/relocation/tr_uni_pap.ma".
16 include "delayed_updating/syntax/path.ma".
17 include "delayed_updating/notation/functions/black_downtriangle_4.ma".
18 include "delayed_updating/notation/functions/black_downtriangle_2.ma".
19
20 (* UNWIND FOR PATH **********************************************************)
21
22 definition unwind_continuation (A:Type[0]) ≝
23            tr_map → path → A.
24
25 rec definition unwind_gen (A:Type[0]) (k:unwind_continuation A) (f) (p) on p ≝
26 match p with
27 [ list_empty     ⇒ k f (𝐞)
28 | list_lcons l q ⇒
29   match l with
30   [ label_d n ⇒
31     match q with
32     [ list_empty     ⇒ unwind_gen (A) (λg,p. k g (𝗱(f@❨n❩)◗p)) (𝐮❨f@❨n❩❩) q
33     | list_lcons _ _ ⇒ unwind_gen (A) k (𝐮❨f@❨n❩❩) q
34     ]
35   | label_m   ⇒ unwind_gen (A) k f q
36   | label_L   ⇒ unwind_gen (A) (λg,p. k g (𝗟◗p)) (⫯f) q
37   | label_A   ⇒ unwind_gen (A) (λg,p. k g (𝗔◗p)) f q
38   | label_S   ⇒ unwind_gen (A) (λg,p. k g (𝗦◗p)) f q
39   ]
40 ].
41
42 interpretation
43   "unwind (gneric)"
44   'BlackDownTriangle A k f p = (unwind_gen A k f p).
45
46 definition proj_path: unwind_continuation … ≝
47            λf,p.p.
48
49 definition proj_rmap: unwind_continuation … ≝
50            λf,p.f.
51
52 interpretation
53   "unwind (path)"
54   'BlackDownTriangle f p = (unwind_gen ? proj_path f p).
55
56 interpretation
57   "unwind (relocation map)"
58   'BlackDownTriangle p f = (unwind_gen ? proj_rmap f p).
59
60 (* Basic constructions ******************************************************)
61
62 lemma unwind_empty (A) (k) (f):
63       k f (𝐞) = ▼{A}❨k, f, 𝐞❩.
64 // qed.
65
66 lemma unwind_d_empty (A) (k) (n) (f):
67       ▼❨(λg,p. k g (𝗱(f@❨n❩)◗p)), 𝐮❨f@❨n❩❩, 𝐞❩ = ▼{A}❨k, f, 𝗱n◗𝐞❩.
68 // qed.
69
70 lemma unwind_d_lcons (A) (k) (p) (l) (n) (f):
71       ▼❨k, 𝐮❨f@❨n❩❩, l◗p❩ = ▼{A}❨k, f, 𝗱n◗l◗p❩.
72 // qed.
73
74 lemma unwind_m_sn (A) (k) (p) (f):
75       ▼❨k, f, p❩ = ▼{A}❨k, f, 𝗺◗p❩.
76 // qed.
77
78 lemma unwind_L_sn (A) (k) (p) (f):
79       ▼❨(λg,p. k g (𝗟◗p)), ⫯f, p❩ = ▼{A}❨k, f, 𝗟◗p❩.
80 // qed.
81
82 lemma unwind_A_sn (A) (k) (p) (f):
83       ▼❨(λg,p. k g (𝗔◗p)), f, p❩ = ▼{A}❨k, f, 𝗔◗p❩.
84 // qed.
85
86 lemma unwind_S_sn (A) (k) (p) (f):
87       ▼❨(λg,p. k g (𝗦◗p)), f, p❩ = ▼{A}❨k, f, 𝗦◗p❩.
88 // qed.
89
90 (* Basic constructions with proj_path ***************************************)
91
92 lemma unwind_path_empty (f):
93       (𝐞) = ▼[f]𝐞.
94 // qed.
95
96 lemma unwind_path_d_empty (f) (n):
97       𝗱(f@❨n❩)◗𝐞 = ▼[f](𝗱n◗𝐞).
98 // qed.
99
100 lemma unwind_path_d_lcons (f) (p) (l) (n):
101       ▼[𝐮❨f@❨n❩❩](l◗p) = ▼[f](𝗱n◗l◗p).
102 // qed.
103
104 lemma unwind_path_m_sn (f) (p):
105       ▼[f]p = ▼[f](𝗺◗p).
106 // qed.
107
108 (* Basic constructions with proj_rmap ***************************************)
109
110 lemma unwind_rmap_empty (f):
111       f = ▼[𝐞]f.
112 // qed.
113
114 lemma unwind_rmap_d_sn (f) (p) (n):
115       ▼[p](𝐮❨f@❨n❩❩) = ▼[𝗱n◗p]f.
116 #f * // qed.
117
118 lemma unwind_rmap_m_sn (f) (p):
119       ▼[p]f = ▼[𝗺◗p]f.
120 // qed.
121
122 lemma unwind_rmap_L_sn (f) (p):
123       ▼[p](⫯f) = ▼[𝗟◗p]f.
124 // qed.
125
126 lemma unwind_rmap_A_sn (f) (p):
127       ▼[p]f = ▼[𝗔◗p]f.
128 // qed.
129
130 lemma unwind_rmap_S_sn (f) (p):
131       ▼[p]f = ▼[𝗦◗p]f.
132 // qed.
133
134 (* Advanced constructions with proj_rmap and path_append ********************)
135
136 lemma unwind_rmap_append (p2) (p1) (f):
137       ▼[p2]▼[p1]f = ▼[p1●p2]f.
138 #p2 #p1 elim p1 -p1 // * [ #n ] #p1 #IH #f //
139 [ <unwind_rmap_m_sn <unwind_rmap_m_sn //
140 | <unwind_rmap_A_sn <unwind_rmap_A_sn //
141 | <unwind_rmap_S_sn <unwind_rmap_S_sn //
142 ]
143 qed.
144
145 (* Advanced constructions with proj_rmap and path_rcons *********************)
146
147 lemma unwind_rmap_d_dx (f) (p) (n):
148       (𝐮❨(▼[p]f)@❨n❩❩) = ▼[p◖𝗱n]f.
149 // qed.
150
151 lemma unwind_rmap_m_dx (f) (p):
152       ▼[p]f = ▼[p◖𝗺]f.
153 // qed.
154
155 lemma unwind_rmap_L_dx (f) (p):
156       (⫯▼[p]f) = ▼[p◖𝗟]f.
157 // qed.
158
159 lemma unwind_rmap_A_dx (f) (p):
160       ▼[p]f = ▼[p◖𝗔]f.
161 // qed.
162
163 lemma unwind_rmap_S_dx (f) (p):
164       ▼[p]f = ▼[p◖𝗦]f.
165 // qed.
166
167 lemma unwind_rmap_pap_d_dx (f) (p) (n) (m):
168       ▼[p]f@❨n❩+m = ▼[p◖𝗱n]f@❨m❩.
169 #f #p #n #m
170 <unwind_rmap_d_dx <tr_uni_pap <pplus_comm //
171 qed.
172
173 (* Advanced eliminations with path ******************************************)
174
175 lemma path_ind_unwind (Q:predicate …):
176       Q (𝐞) →
177       (∀n. Q (𝐞) → Q (𝗱n◗𝐞)) →
178       (∀n,l,p. Q (l◗p) → Q (𝗱n◗l◗p)) →
179       (∀p. Q p → Q (𝗺◗p)) →
180       (∀p. Q p → Q (𝗟◗p)) →
181       (∀p. Q p → Q (𝗔◗p)) →
182       (∀p. Q p → Q (𝗦◗p)) →
183       ∀p. Q p.
184 #Q #IH1 #IH2 #IH3 #IH4 #IH5 #IH6 #IH7 #p
185 elim p -p [| * [ #n * ] ]
186 /2 width=1 by/
187 qed-.