author | zhangx |
Fri, 18 Dec 2015 19:13:19 +0800 | |
changeset 60 | f98a95f3deae |
parent 59 | 0a069a667301 |
child 61 | f8194fd6214f |
permissions | -rw-r--r-- |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1 |
section {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
2 |
This file contains lemmas used to guide the recalculation of current precedence |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
3 |
after every system call (or system operation) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
4 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
5 |
theory CpsG |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
6 |
imports PrioG Max RTree |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
7 |
begin |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
8 |
|
58 | 9 |
definition "wRAG (s::state) = {(Th th, Cs cs) | th cs. waiting s th cs}" |
10 |
||
11 |
definition "hRAG (s::state) = {(Cs cs, Th th) | th cs. holding s th cs}" |
|
12 |
||
13 |
definition "tRAG s = wRAG s O hRAG s" |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
14 |
|
58 | 15 |
lemma RAG_split: "RAG s = (wRAG s \<union> hRAG s)" |
16 |
by (unfold s_RAG_abv wRAG_def hRAG_def s_waiting_abv |
|
17 |
s_holding_abv cs_RAG_def, auto) |
|
18 |
||
19 |
lemma tRAG_alt_def: |
|
20 |
"tRAG s = {(Th th1, Th th2) | th1 th2. |
|
21 |
\<exists> cs. (Th th1, Cs cs) \<in> RAG s \<and> (Cs cs, Th th2) \<in> RAG s}" |
|
22 |
by (auto simp:tRAG_def RAG_split wRAG_def hRAG_def) |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
23 |
|
60 | 24 |
lemma tRAG_Field: |
25 |
"Field (tRAG s) \<subseteq> Field (RAG s)" |
|
26 |
by (unfold tRAG_alt_def Field_def, auto) |
|
27 |
||
28 |
lemma tRAG_ancestorsE: |
|
29 |
assumes "x \<in> ancestors (tRAG s) u" |
|
30 |
obtains th where "x = Th th" |
|
31 |
proof - |
|
32 |
from assms have "(u, x) \<in> (tRAG s)^+" |
|
33 |
by (unfold ancestors_def, auto) |
|
34 |
from tranclE[OF this] obtain c where "(c, x) \<in> tRAG s" by auto |
|
35 |
then obtain th where "x = Th th" |
|
36 |
by (unfold tRAG_alt_def, auto) |
|
37 |
from that[OF this] show ?thesis . |
|
38 |
qed |
|
39 |
||
58 | 40 |
lemma tRAG_mono: |
41 |
assumes "RAG s' \<subseteq> RAG s" |
|
42 |
shows "tRAG s' \<subseteq> tRAG s" |
|
43 |
using assms |
|
44 |
by (unfold tRAG_alt_def, auto) |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
45 |
|
58 | 46 |
lemma holding_next_thI: |
47 |
assumes "holding s th cs" |
|
48 |
and "length (wq s cs) > 1" |
|
49 |
obtains th' where "next_th s th cs th'" |
|
50 |
proof - |
|
51 |
from assms(1)[folded eq_holding, unfolded cs_holding_def] |
|
52 |
have " th \<in> set (wq s cs) \<and> th = hd (wq s cs)" . |
|
53 |
then obtain rest where h1: "wq s cs = th#rest" |
|
54 |
by (cases "wq s cs", auto) |
|
55 |
with assms(2) have h2: "rest \<noteq> []" by auto |
|
56 |
let ?th' = "hd (SOME q. distinct q \<and> set q = set rest)" |
|
57 |
have "next_th s th cs ?th'" using h1(1) h2 |
|
58 |
by (unfold next_th_def, auto) |
|
59 |
from that[OF this] show ?thesis . |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
60 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
61 |
|
58 | 62 |
lemma RAG_tRAG_transfer: |
63 |
assumes "vt s'" |
|
64 |
assumes "RAG s = RAG s' \<union> {(Th th, Cs cs)}" |
|
65 |
and "(Cs cs, Th th'') \<in> RAG s'" |
|
66 |
shows "tRAG s = tRAG s' \<union> {(Th th, Th th'')}" (is "?L = ?R") |
|
67 |
proof - |
|
68 |
interpret rtree: rtree "RAG s'" |
|
69 |
proof |
|
70 |
show "single_valued (RAG s')" |
|
71 |
apply (intro_locales) |
|
72 |
by (unfold single_valued_def, |
|
73 |
auto intro:unique_RAG[OF assms(1)]) |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
74 |
|
58 | 75 |
show "acyclic (RAG s')" |
76 |
by (rule acyclic_RAG[OF assms(1)]) |
|
77 |
qed |
|
78 |
{ fix n1 n2 |
|
79 |
assume "(n1, n2) \<in> ?L" |
|
80 |
from this[unfolded tRAG_alt_def] |
|
81 |
obtain th1 th2 cs' where |
|
82 |
h: "n1 = Th th1" "n2 = Th th2" |
|
83 |
"(Th th1, Cs cs') \<in> RAG s" |
|
84 |
"(Cs cs', Th th2) \<in> RAG s" by auto |
|
85 |
from h(4) and assms(2) have cs_in: "(Cs cs', Th th2) \<in> RAG s'" by auto |
|
86 |
from h(3) and assms(2) |
|
87 |
have "(Th th1, Cs cs') = (Th th, Cs cs) \<or> |
|
88 |
(Th th1, Cs cs') \<in> RAG s'" by auto |
|
89 |
hence "(n1, n2) \<in> ?R" |
|
90 |
proof |
|
91 |
assume h1: "(Th th1, Cs cs') = (Th th, Cs cs)" |
|
92 |
hence eq_th1: "th1 = th" by simp |
|
93 |
moreover have "th2 = th''" |
|
94 |
proof - |
|
95 |
from h1 have "cs' = cs" by simp |
|
96 |
from assms(3) cs_in[unfolded this] rtree.sgv |
|
97 |
show ?thesis |
|
98 |
by (unfold single_valued_def, auto) |
|
99 |
qed |
|
100 |
ultimately show ?thesis using h(1,2) by auto |
|
101 |
next |
|
102 |
assume "(Th th1, Cs cs') \<in> RAG s'" |
|
103 |
with cs_in have "(Th th1, Th th2) \<in> tRAG s'" |
|
104 |
by (unfold tRAG_alt_def, auto) |
|
105 |
from this[folded h(1, 2)] show ?thesis by auto |
|
106 |
qed |
|
107 |
} moreover { |
|
108 |
fix n1 n2 |
|
109 |
assume "(n1, n2) \<in> ?R" |
|
110 |
hence "(n1, n2) \<in>tRAG s' \<or> (n1, n2) = (Th th, Th th'')" by auto |
|
111 |
hence "(n1, n2) \<in> ?L" |
|
112 |
proof |
|
113 |
assume "(n1, n2) \<in> tRAG s'" |
|
114 |
moreover have "... \<subseteq> ?L" |
|
115 |
proof(rule tRAG_mono) |
|
116 |
show "RAG s' \<subseteq> RAG s" by (unfold assms(2), auto) |
|
117 |
qed |
|
118 |
ultimately show ?thesis by auto |
|
119 |
next |
|
120 |
assume eq_n: "(n1, n2) = (Th th, Th th'')" |
|
121 |
from assms(2, 3) have "(Cs cs, Th th'') \<in> RAG s" by auto |
|
122 |
moreover have "(Th th, Cs cs) \<in> RAG s" using assms(2) by auto |
|
123 |
ultimately show ?thesis |
|
124 |
by (unfold eq_n tRAG_alt_def, auto) |
|
125 |
qed |
|
126 |
} ultimately show ?thesis by auto |
|
127 |
qed |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
128 |
|
58 | 129 |
lemma readys_root: |
130 |
assumes "vt s" |
|
131 |
and "th \<in> readys s" |
|
132 |
shows "root (RAG s) (Th th)" |
|
133 |
proof - |
|
134 |
{ fix x |
|
135 |
assume "x \<in> ancestors (RAG s) (Th th)" |
|
136 |
hence h: "(Th th, x) \<in> (RAG s)^+" by (auto simp:ancestors_def) |
|
137 |
from tranclD[OF this] |
|
138 |
obtain z where "(Th th, z) \<in> RAG s" by auto |
|
139 |
with assms(2) have False |
|
140 |
apply (case_tac z, auto simp:readys_def s_RAG_def s_waiting_def cs_waiting_def) |
|
141 |
by (fold wq_def, blast) |
|
142 |
} thus ?thesis by (unfold root_def, auto) |
|
143 |
qed |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
144 |
|
58 | 145 |
lemma readys_in_no_subtree: |
146 |
assumes "vt s" |
|
147 |
and "th \<in> readys s" |
|
148 |
and "th' \<noteq> th" |
|
149 |
shows "Th th \<notin> subtree (RAG s) (Th th')" |
|
150 |
proof |
|
151 |
assume "Th th \<in> subtree (RAG s) (Th th')" |
|
152 |
thus False |
|
153 |
proof(cases rule:subtreeE) |
|
154 |
case 1 |
|
155 |
with assms show ?thesis by auto |
|
156 |
next |
|
157 |
case 2 |
|
158 |
with readys_root[OF assms(1,2)] |
|
159 |
show ?thesis by (auto simp:root_def) |
|
160 |
qed |
|
161 |
qed |
|
162 |
||
163 |
lemma image_id: |
|
164 |
assumes "\<And> x. x \<in> A \<Longrightarrow> f x = x" |
|
165 |
shows "f ` A = A" |
|
166 |
using assms by (auto simp:image_def) |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
167 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
168 |
definition "the_preced s th = preced th s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
169 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
170 |
lemma cp_alt_def: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
171 |
"cp s th = |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
172 |
Max ((the_preced s) ` {th'. Th th' \<in> (subtree (RAG s) (Th th))})" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
173 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
174 |
have "Max (the_preced s ` ({th} \<union> dependants (wq s) th)) = |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
175 |
Max (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)})" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
176 |
(is "Max (_ ` ?L) = Max (_ ` ?R)") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
177 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
178 |
have "?L = ?R" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
179 |
by (auto dest:rtranclD simp:cs_dependants_def cs_RAG_def s_RAG_def subtree_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
180 |
thus ?thesis by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
181 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
182 |
thus ?thesis by (unfold cp_eq_cpreced cpreced_def, fold the_preced_def, simp) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
183 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
184 |
|
58 | 185 |
fun the_thread :: "node \<Rightarrow> thread" where |
186 |
"the_thread (Th th) = th" |
|
187 |
||
188 |
definition "cp_gen s x = |
|
189 |
Max ((the_preced s \<circ> the_thread) ` subtree (tRAG s) x)" |
|
190 |
||
191 |
lemma cp_gen_alt_def: |
|
192 |
"cp_gen s = (Max \<circ> (\<lambda>x. (the_preced s \<circ> the_thread) ` subtree (tRAG s) x))" |
|
193 |
by (auto simp:cp_gen_def) |
|
194 |
||
195 |
lemma tRAG_nodeE: |
|
196 |
assumes "(n1, n2) \<in> tRAG s" |
|
197 |
obtains th1 th2 where "n1 = Th th1" "n2 = Th th2" |
|
198 |
using assms |
|
199 |
by (auto simp: tRAG_def wRAG_def hRAG_def tRAG_def) |
|
200 |
||
201 |
lemma subtree_nodeE: |
|
202 |
assumes "n \<in> subtree (tRAG s) (Th th)" |
|
203 |
obtains th1 where "n = Th th1" |
|
204 |
proof - |
|
205 |
show ?thesis |
|
206 |
proof(rule subtreeE[OF assms]) |
|
207 |
assume "n = Th th" |
|
208 |
from that[OF this] show ?thesis . |
|
209 |
next |
|
210 |
assume "Th th \<in> ancestors (tRAG s) n" |
|
211 |
hence "(n, Th th) \<in> (tRAG s)^+" by (auto simp:ancestors_def) |
|
212 |
hence "\<exists> th1. n = Th th1" |
|
213 |
proof(induct) |
|
214 |
case (base y) |
|
215 |
from tRAG_nodeE[OF this] show ?case by metis |
|
216 |
next |
|
217 |
case (step y z) |
|
218 |
thus ?case by auto |
|
219 |
qed |
|
220 |
with that show ?thesis by auto |
|
221 |
qed |
|
222 |
qed |
|
223 |
||
224 |
lemma threads_set_eq: |
|
225 |
"the_thread ` (subtree (tRAG s) (Th th)) = |
|
226 |
{th'. Th th' \<in> (subtree (RAG s) (Th th))}" (is "?L = ?R") |
|
227 |
proof - |
|
228 |
{ fix th' |
|
229 |
assume "th' \<in> ?L" |
|
230 |
then obtain n where h: "th' = the_thread n" "n \<in> subtree (tRAG s) (Th th)" by auto |
|
231 |
from subtree_nodeE[OF this(2)] |
|
232 |
obtain th1 where "n = Th th1" by auto |
|
233 |
with h have "Th th' \<in> subtree (tRAG s) (Th th)" by auto |
|
234 |
hence "Th th' \<in> subtree (RAG s) (Th th)" |
|
235 |
proof(cases rule:subtreeE[consumes 1]) |
|
236 |
case 1 |
|
237 |
thus ?thesis by (auto simp:subtree_def) |
|
238 |
next |
|
239 |
case 2 |
|
240 |
hence "(Th th', Th th) \<in> (tRAG s)^+" by (auto simp:ancestors_def) |
|
241 |
thus ?thesis |
|
242 |
proof(induct) |
|
243 |
case (step y z) |
|
244 |
from this(2)[unfolded tRAG_alt_def] |
|
245 |
obtain u where |
|
246 |
h: "(y, u) \<in> RAG s" "(u, z) \<in> RAG s" |
|
247 |
by auto |
|
248 |
hence "y \<in> subtree (RAG s) z" by (auto simp:subtree_def) |
|
249 |
with step(3) |
|
250 |
show ?case by (auto simp:subtree_def) |
|
251 |
next |
|
252 |
case (base y) |
|
253 |
from this[unfolded tRAG_alt_def] |
|
254 |
show ?case by (auto simp:subtree_def) |
|
255 |
qed |
|
256 |
qed |
|
257 |
hence "th' \<in> ?R" by auto |
|
258 |
} moreover { |
|
259 |
fix th' |
|
260 |
assume "th' \<in> ?R" |
|
261 |
hence "(Th th', Th th) \<in> (RAG s)^*" by (auto simp:subtree_def) |
|
262 |
from star_rpath[OF this] |
|
263 |
obtain xs where "rpath (RAG s) (Th th') xs (Th th)" by auto |
|
264 |
hence "Th th' \<in> subtree (tRAG s) (Th th)" |
|
265 |
proof(induct xs arbitrary:th' th rule:length_induct) |
|
266 |
case (1 xs th' th) |
|
267 |
show ?case |
|
268 |
proof(cases xs) |
|
269 |
case Nil |
|
270 |
from rpath_nilE[OF 1(2)[unfolded this]] |
|
271 |
have "th' = th" by auto |
|
272 |
thus ?thesis by (auto simp:subtree_def) |
|
273 |
next |
|
274 |
case (Cons x1 xs1) note Cons1 = Cons |
|
275 |
show ?thesis |
|
276 |
proof(cases "xs1") |
|
277 |
case Nil |
|
278 |
from 1(2)[unfolded Cons[unfolded this]] |
|
279 |
have rp: "rpath (RAG s) (Th th') [x1] (Th th)" . |
|
280 |
hence "(Th th', x1) \<in> (RAG s)" by (cases, simp) |
|
281 |
then obtain cs where "x1 = Cs cs" |
|
282 |
by (unfold s_RAG_def, auto) |
|
283 |
find_theorems rpath "_ = _@[_]" |
|
284 |
from rpath_nnl_lastE[OF rp[unfolded this]] |
|
285 |
show ?thesis by auto |
|
286 |
next |
|
287 |
case (Cons x2 xs2) |
|
288 |
from 1(2)[unfolded Cons1[unfolded this]] |
|
289 |
have rp: "rpath (RAG s) (Th th') (x1 # x2 # xs2) (Th th)" . |
|
290 |
from rpath_edges_on[OF this] |
|
291 |
have eds: "edges_on (Th th' # x1 # x2 # xs2) \<subseteq> RAG s" . |
|
292 |
have "(Th th', x1) \<in> edges_on (Th th' # x1 # x2 # xs2)" |
|
293 |
by (simp add: edges_on_unfold) |
|
294 |
with eds have rg1: "(Th th', x1) \<in> RAG s" by auto |
|
295 |
then obtain cs1 where eq_x1: "x1 = Cs cs1" by (unfold s_RAG_def, auto) |
|
296 |
have "(x1, x2) \<in> edges_on (Th th' # x1 # x2 # xs2)" |
|
297 |
by (simp add: edges_on_unfold) |
|
298 |
from this eds |
|
299 |
have rg2: "(x1, x2) \<in> RAG s" by auto |
|
300 |
from this[unfolded eq_x1] |
|
301 |
obtain th1 where eq_x2: "x2 = Th th1" by (unfold s_RAG_def, auto) |
|
302 |
from rp have "rpath (RAG s) x2 xs2 (Th th)" |
|
303 |
by (elim rpath_ConsE, simp) |
|
304 |
from this[unfolded eq_x2] have rp': "rpath (RAG s) (Th th1) xs2 (Th th)" . |
|
305 |
from 1(1)[rule_format, OF _ this, unfolded Cons1 Cons] |
|
306 |
have "Th th1 \<in> subtree (tRAG s) (Th th)" by simp |
|
307 |
moreover have "(Th th', Th th1) \<in> (tRAG s)^*" |
|
308 |
proof - |
|
309 |
from rg1[unfolded eq_x1] rg2[unfolded eq_x1 eq_x2] |
|
310 |
show ?thesis by (unfold RAG_split tRAG_def wRAG_def hRAG_def, auto) |
|
311 |
qed |
|
312 |
ultimately show ?thesis by (auto simp:subtree_def) |
|
313 |
qed |
|
314 |
qed |
|
315 |
qed |
|
316 |
from imageI[OF this, of the_thread] |
|
317 |
have "th' \<in> ?L" by simp |
|
318 |
} ultimately show ?thesis by auto |
|
319 |
qed |
|
320 |
||
321 |
lemma cp_alt_def1: |
|
322 |
"cp s th = Max ((the_preced s o the_thread) ` (subtree (tRAG s) (Th th)))" |
|
323 |
proof - |
|
324 |
have "(the_preced s ` the_thread ` subtree (tRAG s) (Th th)) = |
|
325 |
((the_preced s \<circ> the_thread) ` subtree (tRAG s) (Th th))" |
|
326 |
by auto |
|
327 |
thus ?thesis by (unfold cp_alt_def, fold threads_set_eq, auto) |
|
328 |
qed |
|
329 |
||
330 |
lemma cp_gen_def_cond: |
|
331 |
assumes "x = Th th" |
|
332 |
shows "cp s th = cp_gen s (Th th)" |
|
333 |
by (unfold cp_alt_def1 cp_gen_def, simp) |
|
334 |
||
335 |
lemma cp_gen_over_set: |
|
336 |
assumes "\<forall> x \<in> A. \<exists> th. x = Th th" |
|
337 |
shows "cp_gen s ` A = (cp s \<circ> the_thread) ` A" |
|
338 |
proof(rule f_image_eq) |
|
339 |
fix a |
|
340 |
assume "a \<in> A" |
|
341 |
from assms[rule_format, OF this] |
|
342 |
obtain th where eq_a: "a = Th th" by auto |
|
343 |
show "cp_gen s a = (cp s \<circ> the_thread) a" |
|
344 |
by (unfold eq_a, simp, unfold cp_gen_def_cond[OF refl[of "Th th"]], simp) |
|
345 |
qed |
|
346 |
||
347 |
||
348 |
||
349 |
locale valid_trace = |
|
350 |
fixes s |
|
351 |
assumes vt : "vt s" |
|
352 |
||
353 |
context valid_trace |
|
354 |
begin |
|
355 |
||
60 | 356 |
lemma not_in_thread_isolated: |
357 |
assumes "th \<notin> threads s" |
|
358 |
shows "(Th th) \<notin> Field (RAG s)" |
|
359 |
proof |
|
360 |
assume "(Th th) \<in> Field (RAG s)" |
|
361 |
with dm_RAG_threads[OF vt] and range_in[OF vt] assms |
|
362 |
show False by (unfold Field_def, blast) |
|
363 |
qed |
|
364 |
||
58 | 365 |
lemma wf_RAG: "wf (RAG s)" |
366 |
proof(rule finite_acyclic_wf) |
|
367 |
from finite_RAG[OF vt] show "finite (RAG s)" . |
|
368 |
next |
|
369 |
from acyclic_RAG[OF vt] show "acyclic (RAG s)" . |
|
370 |
qed |
|
371 |
||
372 |
end |
|
373 |
||
374 |
context valid_trace |
|
375 |
begin |
|
376 |
||
377 |
lemma sgv_wRAG: "single_valued (wRAG s)" |
|
378 |
using waiting_unique[OF vt] |
|
379 |
by (unfold single_valued_def wRAG_def, auto) |
|
380 |
||
381 |
lemma sgv_hRAG: "single_valued (hRAG s)" |
|
382 |
using holding_unique |
|
383 |
by (unfold single_valued_def hRAG_def, auto) |
|
384 |
||
385 |
lemma sgv_tRAG: "single_valued (tRAG s)" |
|
386 |
by (unfold tRAG_def, rule single_valued_relcomp, |
|
387 |
insert sgv_wRAG sgv_hRAG, auto) |
|
388 |
||
389 |
lemma acyclic_tRAG: "acyclic (tRAG s)" |
|
390 |
proof(unfold tRAG_def, rule acyclic_compose) |
|
391 |
show "acyclic (RAG s)" using acyclic_RAG[OF vt] . |
|
392 |
next |
|
393 |
show "wRAG s \<subseteq> RAG s" unfolding RAG_split by auto |
|
394 |
next |
|
395 |
show "hRAG s \<subseteq> RAG s" unfolding RAG_split by auto |
|
396 |
qed |
|
397 |
||
398 |
lemma sgv_RAG: "single_valued (RAG s)" |
|
399 |
using unique_RAG[OF vt] by (auto simp:single_valued_def) |
|
400 |
||
401 |
lemma rtree_RAG: "rtree (RAG s)" |
|
402 |
using sgv_RAG acyclic_RAG[OF vt] |
|
403 |
by (unfold rtree_def rtree_axioms_def sgv_def, auto) |
|
404 |
||
405 |
end |
|
406 |
||
407 |
sublocale valid_trace < rtree_s: rtree "tRAG s" |
|
408 |
proof(unfold_locales) |
|
409 |
from sgv_tRAG show "single_valued (tRAG s)" . |
|
410 |
next |
|
411 |
from acyclic_tRAG show "acyclic (tRAG s)" . |
|
412 |
qed |
|
413 |
||
414 |
sublocale valid_trace < fsbtRAGs : fsubtree "RAG s" |
|
415 |
proof - |
|
416 |
show "fsubtree (RAG s)" |
|
417 |
proof(intro_locales) |
|
418 |
show "fbranch (RAG s)" using finite_fbranchI[OF finite_RAG[OF vt]] . |
|
419 |
next |
|
420 |
show "fsubtree_axioms (RAG s)" |
|
421 |
proof(unfold fsubtree_axioms_def) |
|
422 |
find_theorems wf RAG |
|
423 |
from wf_RAG show "wf (RAG s)" . |
|
424 |
qed |
|
425 |
qed |
|
426 |
qed |
|
427 |
||
428 |
sublocale valid_trace < fsbttRAGs: fsubtree "tRAG s" |
|
429 |
proof - |
|
430 |
have "fsubtree (tRAG s)" |
|
431 |
proof - |
|
432 |
have "fbranch (tRAG s)" |
|
433 |
proof(unfold tRAG_def, rule fbranch_compose) |
|
434 |
show "fbranch (wRAG s)" |
|
435 |
proof(rule finite_fbranchI) |
|
436 |
from finite_RAG[OF vt] show "finite (wRAG s)" |
|
437 |
by (unfold RAG_split, auto) |
|
438 |
qed |
|
439 |
next |
|
440 |
show "fbranch (hRAG s)" |
|
441 |
proof(rule finite_fbranchI) |
|
442 |
from finite_RAG[OF vt] |
|
443 |
show "finite (hRAG s)" by (unfold RAG_split, auto) |
|
444 |
qed |
|
445 |
qed |
|
446 |
moreover have "wf (tRAG s)" |
|
447 |
proof(rule wf_subset) |
|
448 |
show "wf (RAG s O RAG s)" using wf_RAG |
|
449 |
by (fold wf_comp_self, simp) |
|
450 |
next |
|
451 |
show "tRAG s \<subseteq> (RAG s O RAG s)" |
|
452 |
by (unfold tRAG_alt_def, auto) |
|
453 |
qed |
|
454 |
ultimately show ?thesis |
|
455 |
by (unfold fsubtree_def fsubtree_axioms_def,auto) |
|
456 |
qed |
|
457 |
from this[folded tRAG_def] show "fsubtree (tRAG s)" . |
|
458 |
qed |
|
459 |
||
460 |
lemma Max_UNION: |
|
461 |
assumes "finite A" |
|
462 |
and "A \<noteq> {}" |
|
463 |
and "\<forall> M \<in> f ` A. finite M" |
|
464 |
and "\<forall> M \<in> f ` A. M \<noteq> {}" |
|
465 |
shows "Max (\<Union>x\<in> A. f x) = Max (Max ` f ` A)" (is "?L = ?R") |
|
466 |
using assms[simp] |
|
467 |
proof - |
|
468 |
have "?L = Max (\<Union>(f ` A))" |
|
469 |
by (fold Union_image_eq, simp) |
|
470 |
also have "... = ?R" |
|
471 |
by (subst Max_Union, simp+) |
|
472 |
finally show ?thesis . |
|
473 |
qed |
|
474 |
||
475 |
lemma max_Max_eq: |
|
476 |
assumes "finite A" |
|
477 |
and "A \<noteq> {}" |
|
478 |
and "x = y" |
|
479 |
shows "max x (Max A) = Max ({y} \<union> A)" (is "?L = ?R") |
|
480 |
proof - |
|
481 |
have "?R = Max (insert y A)" by simp |
|
482 |
also from assms have "... = ?L" |
|
483 |
by (subst Max.insert, simp+) |
|
484 |
finally show ?thesis by simp |
|
485 |
qed |
|
486 |
||
487 |
||
488 |
context valid_trace |
|
489 |
begin |
|
490 |
||
491 |
(* ddd *) |
|
492 |
lemma cp_gen_rec: |
|
493 |
assumes "x = Th th" |
|
494 |
shows "cp_gen s x = Max ({the_preced s th} \<union> (cp_gen s) ` children (tRAG s) x)" |
|
495 |
proof(cases "children (tRAG s) x = {}") |
|
496 |
case True |
|
497 |
show ?thesis |
|
498 |
by (unfold True cp_gen_def subtree_children, simp add:assms) |
|
499 |
next |
|
500 |
case False |
|
501 |
hence [simp]: "children (tRAG s) x \<noteq> {}" by auto |
|
502 |
note fsbttRAGs.finite_subtree[simp] |
|
503 |
have [simp]: "finite (children (tRAG s) x)" |
|
504 |
by (intro rev_finite_subset[OF fsbttRAGs.finite_subtree], |
|
505 |
rule children_subtree) |
|
506 |
{ fix r x |
|
507 |
have "subtree r x \<noteq> {}" by (auto simp:subtree_def) |
|
508 |
} note this[simp] |
|
509 |
have [simp]: "\<exists>x\<in>children (tRAG s) x. subtree (tRAG s) x \<noteq> {}" |
|
510 |
proof - |
|
511 |
from False obtain q where "q \<in> children (tRAG s) x" by blast |
|
512 |
moreover have "subtree (tRAG s) q \<noteq> {}" by simp |
|
513 |
ultimately show ?thesis by blast |
|
514 |
qed |
|
515 |
have h: "Max ((the_preced s \<circ> the_thread) ` |
|
516 |
({x} \<union> \<Union>(subtree (tRAG s) ` children (tRAG s) x))) = |
|
517 |
Max ({the_preced s th} \<union> cp_gen s ` children (tRAG s) x)" |
|
518 |
(is "?L = ?R") |
|
519 |
proof - |
|
520 |
let "Max (?f ` (?A \<union> \<Union> (?g ` ?B)))" = ?L |
|
521 |
let "Max (_ \<union> (?h ` ?B))" = ?R |
|
522 |
let ?L1 = "?f ` \<Union>(?g ` ?B)" |
|
523 |
have eq_Max_L1: "Max ?L1 = Max (?h ` ?B)" |
|
524 |
proof - |
|
525 |
have "?L1 = ?f ` (\<Union> x \<in> ?B.(?g x))" by simp |
|
526 |
also have "... = (\<Union> x \<in> ?B. ?f ` (?g x))" by auto |
|
527 |
finally have "Max ?L1 = Max ..." by simp |
|
528 |
also have "... = Max (Max ` (\<lambda>x. ?f ` subtree (tRAG s) x) ` ?B)" |
|
529 |
by (subst Max_UNION, simp+) |
|
530 |
also have "... = Max (cp_gen s ` children (tRAG s) x)" |
|
531 |
by (unfold image_comp cp_gen_alt_def, simp) |
|
532 |
finally show ?thesis . |
|
533 |
qed |
|
534 |
show ?thesis |
|
535 |
proof - |
|
536 |
have "?L = Max (?f ` ?A \<union> ?L1)" by simp |
|
537 |
also have "... = max (the_preced s (the_thread x)) (Max ?L1)" |
|
538 |
by (subst Max_Un, simp+) |
|
539 |
also have "... = max (?f x) (Max (?h ` ?B))" |
|
540 |
by (unfold eq_Max_L1, simp) |
|
541 |
also have "... =?R" |
|
542 |
by (rule max_Max_eq, (simp)+, unfold assms, simp) |
|
543 |
finally show ?thesis . |
|
544 |
qed |
|
545 |
qed thus ?thesis |
|
546 |
by (fold h subtree_children, unfold cp_gen_def, simp) |
|
547 |
qed |
|
548 |
||
549 |
lemma cp_rec: |
|
550 |
"cp s th = Max ({the_preced s th} \<union> |
|
551 |
(cp s o the_thread) ` children (tRAG s) (Th th))" |
|
552 |
proof - |
|
553 |
have "Th th = Th th" by simp |
|
554 |
note h = cp_gen_def_cond[OF this] cp_gen_rec[OF this] |
|
555 |
show ?thesis |
|
556 |
proof - |
|
557 |
have "cp_gen s ` children (tRAG s) (Th th) = |
|
558 |
(cp s \<circ> the_thread) ` children (tRAG s) (Th th)" |
|
559 |
proof(rule cp_gen_over_set) |
|
560 |
show " \<forall>x\<in>children (tRAG s) (Th th). \<exists>th. x = Th th" |
|
561 |
by (unfold tRAG_alt_def, auto simp:children_def) |
|
562 |
qed |
|
563 |
thus ?thesis by (subst (1) h(1), unfold h(2), simp) |
|
564 |
qed |
|
565 |
qed |
|
566 |
||
567 |
end |
|
568 |
||
569 |
||
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
570 |
lemma eq_dependants: "dependants (wq s) = dependants s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
571 |
by (simp add: s_dependants_abv wq_def) |
58 | 572 |
|
573 |
||
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
574 |
(* obvious lemma *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
575 |
lemma not_thread_holdents: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
576 |
fixes th s |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
577 |
assumes vt: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
578 |
and not_in: "th \<notin> threads s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
579 |
shows "holdents s th = {}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
580 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
581 |
from vt not_in show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
582 |
proof(induct arbitrary:th) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
583 |
case (vt_cons s e th) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
584 |
assume vt: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
585 |
and ih: "\<And>th. th \<notin> threads s \<Longrightarrow> holdents s th = {}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
586 |
and stp: "step s e" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
587 |
and not_in: "th \<notin> threads (e # s)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
588 |
from stp show ?case |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
589 |
proof(cases) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
590 |
case (thread_create thread prio) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
591 |
assume eq_e: "e = Create thread prio" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
592 |
and not_in': "thread \<notin> threads s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
593 |
have "holdents (e # s) th = holdents s th" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
594 |
apply (unfold eq_e holdents_test) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
595 |
by (simp add:RAG_create_unchanged) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
596 |
moreover have "th \<notin> threads s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
597 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
598 |
from not_in eq_e show ?thesis by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
599 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
600 |
moreover note ih ultimately show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
601 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
602 |
case (thread_exit thread) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
603 |
assume eq_e: "e = Exit thread" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
604 |
and nh: "holdents s thread = {}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
605 |
show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
606 |
proof(cases "th = thread") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
607 |
case True |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
608 |
with nh eq_e |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
609 |
show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
610 |
by (auto simp:holdents_test RAG_exit_unchanged) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
611 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
612 |
case False |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
613 |
with not_in and eq_e |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
614 |
have "th \<notin> threads s" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
615 |
from ih[OF this] False eq_e show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
616 |
by (auto simp:holdents_test RAG_exit_unchanged) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
617 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
618 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
619 |
case (thread_P thread cs) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
620 |
assume eq_e: "e = P thread cs" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
621 |
and is_runing: "thread \<in> runing s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
622 |
from assms thread_exit ih stp not_in vt eq_e have vtp: "vt (P thread cs#s)" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
623 |
have neq_th: "th \<noteq> thread" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
624 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
625 |
from not_in eq_e have "th \<notin> threads s" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
626 |
moreover from is_runing have "thread \<in> threads s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
627 |
by (simp add:runing_def readys_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
628 |
ultimately show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
629 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
630 |
hence "holdents (e # s) th = holdents s th " |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
631 |
apply (unfold cntCS_def holdents_test eq_e) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
632 |
by (unfold step_RAG_p[OF vtp], auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
633 |
moreover have "holdents s th = {}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
634 |
proof(rule ih) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
635 |
from not_in eq_e show "th \<notin> threads s" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
636 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
637 |
ultimately show ?thesis by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
638 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
639 |
case (thread_V thread cs) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
640 |
assume eq_e: "e = V thread cs" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
641 |
and is_runing: "thread \<in> runing s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
642 |
and hold: "holding s thread cs" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
643 |
have neq_th: "th \<noteq> thread" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
644 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
645 |
from not_in eq_e have "th \<notin> threads s" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
646 |
moreover from is_runing have "thread \<in> threads s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
647 |
by (simp add:runing_def readys_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
648 |
ultimately show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
649 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
650 |
from assms thread_V eq_e ih stp not_in vt have vtv: "vt (V thread cs#s)" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
651 |
from hold obtain rest |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
652 |
where eq_wq: "wq s cs = thread # rest" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
653 |
by (case_tac "wq s cs", auto simp: wq_def s_holding_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
654 |
from not_in eq_e eq_wq |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
655 |
have "\<not> next_th s thread cs th" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
656 |
apply (auto simp:next_th_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
657 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
658 |
assume ne: "rest \<noteq> []" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
659 |
and ni: "hd (SOME q. distinct q \<and> set q = set rest) \<notin> threads s" (is "?t \<notin> threads s") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
660 |
have "?t \<in> set rest" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
661 |
proof(rule someI2) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
662 |
from wq_distinct[OF step_back_vt[OF vtv], of cs] and eq_wq |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
663 |
show "distinct rest \<and> set rest = set rest" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
664 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
665 |
fix x assume "distinct x \<and> set x = set rest" with ne |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
666 |
show "hd x \<in> set rest" by (cases x, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
667 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
668 |
with eq_wq have "?t \<in> set (wq s cs)" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
669 |
from wq_threads[OF step_back_vt[OF vtv], OF this] and ni |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
670 |
show False by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
671 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
672 |
moreover note neq_th eq_wq |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
673 |
ultimately have "holdents (e # s) th = holdents s th" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
674 |
by (unfold eq_e cntCS_def holdents_test step_RAG_v[OF vtv], auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
675 |
moreover have "holdents s th = {}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
676 |
proof(rule ih) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
677 |
from not_in eq_e show "th \<notin> threads s" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
678 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
679 |
ultimately show ?thesis by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
680 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
681 |
case (thread_set thread prio) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
682 |
print_facts |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
683 |
assume eq_e: "e = Set thread prio" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
684 |
and is_runing: "thread \<in> runing s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
685 |
from not_in and eq_e have "th \<notin> threads s" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
686 |
from ih [OF this] and eq_e |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
687 |
show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
688 |
apply (unfold eq_e cntCS_def holdents_test) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
689 |
by (simp add:RAG_set_unchanged) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
690 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
691 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
692 |
case vt_nil |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
693 |
show ?case |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
694 |
by (auto simp:count_def holdents_test s_RAG_def wq_def cs_holding_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
695 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
696 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
697 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
698 |
(* obvious lemma *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
699 |
lemma next_th_neq: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
700 |
assumes vt: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
701 |
and nt: "next_th s th cs th'" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
702 |
shows "th' \<noteq> th" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
703 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
704 |
from nt show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
705 |
apply (auto simp:next_th_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
706 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
707 |
fix rest |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
708 |
assume eq_wq: "wq s cs = hd (SOME q. distinct q \<and> set q = set rest) # rest" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
709 |
and ne: "rest \<noteq> []" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
710 |
have "hd (SOME q. distinct q \<and> set q = set rest) \<in> set rest" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
711 |
proof(rule someI2) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
712 |
from wq_distinct[OF vt, of cs] eq_wq |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
713 |
show "distinct rest \<and> set rest = set rest" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
714 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
715 |
fix x |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
716 |
assume "distinct x \<and> set x = set rest" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
717 |
hence eq_set: "set x = set rest" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
718 |
with ne have "x \<noteq> []" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
719 |
hence "hd x \<in> set x" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
720 |
with eq_set show "hd x \<in> set rest" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
721 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
722 |
with wq_distinct[OF vt, of cs] eq_wq show False by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
723 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
724 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
725 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
726 |
(* obvious lemma *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
727 |
lemma next_th_unique: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
728 |
assumes nt1: "next_th s th cs th1" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
729 |
and nt2: "next_th s th cs th2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
730 |
shows "th1 = th2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
731 |
using assms by (unfold next_th_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
732 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
733 |
lemma wf_RAG: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
734 |
assumes vt: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
735 |
shows "wf (RAG s)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
736 |
proof(rule finite_acyclic_wf) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
737 |
from finite_RAG[OF vt] show "finite (RAG s)" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
738 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
739 |
from acyclic_RAG[OF vt] show "acyclic (RAG s)" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
740 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
741 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
742 |
definition child :: "state \<Rightarrow> (node \<times> node) set" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
743 |
where "child s \<equiv> |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
744 |
{(Th th', Th th) | th th'. \<exists>cs. (Th th', Cs cs) \<in> RAG s \<and> (Cs cs, Th th) \<in> RAG s}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
745 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
746 |
definition children :: "state \<Rightarrow> thread \<Rightarrow> thread set" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
747 |
where "children s th \<equiv> {th'. (Th th', Th th) \<in> child s}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
748 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
749 |
lemma children_def2: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
750 |
"children s th \<equiv> {th'. \<exists> cs. (Th th', Cs cs) \<in> RAG s \<and> (Cs cs, Th th) \<in> RAG s}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
751 |
unfolding child_def children_def by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
752 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
753 |
lemma children_dependants: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
754 |
"children s th \<subseteq> dependants (wq s) th" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
755 |
unfolding children_def2 |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
756 |
unfolding cs_dependants_def |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
757 |
by (auto simp add: eq_RAG) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
758 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
759 |
lemma child_unique: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
760 |
assumes vt: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
761 |
and ch1: "(Th th, Th th1) \<in> child s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
762 |
and ch2: "(Th th, Th th2) \<in> child s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
763 |
shows "th1 = th2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
764 |
using ch1 ch2 |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
765 |
proof(unfold child_def, clarsimp) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
766 |
fix cs csa |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
767 |
assume h1: "(Th th, Cs cs) \<in> RAG s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
768 |
and h2: "(Cs cs, Th th1) \<in> RAG s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
769 |
and h3: "(Th th, Cs csa) \<in> RAG s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
770 |
and h4: "(Cs csa, Th th2) \<in> RAG s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
771 |
from unique_RAG[OF vt h1 h3] have "cs = csa" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
772 |
with h4 have "(Cs cs, Th th2) \<in> RAG s" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
773 |
from unique_RAG[OF vt h2 this] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
774 |
show "th1 = th2" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
775 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
776 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
777 |
lemma RAG_children: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
778 |
assumes h: "(Th th1, Th th2) \<in> (RAG s)^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
779 |
shows "th1 \<in> children s th2 \<or> (\<exists> th3. th3 \<in> children s th2 \<and> (Th th1, Th th3) \<in> (RAG s)^+)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
780 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
781 |
from h show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
782 |
proof(induct rule: tranclE) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
783 |
fix c th2 |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
784 |
assume h1: "(Th th1, c) \<in> (RAG s)\<^sup>+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
785 |
and h2: "(c, Th th2) \<in> RAG s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
786 |
from h2 obtain cs where eq_c: "c = Cs cs" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
787 |
by (case_tac c, auto simp:s_RAG_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
788 |
show "th1 \<in> children s th2 \<or> (\<exists>th3. th3 \<in> children s th2 \<and> (Th th1, Th th3) \<in> (RAG s)\<^sup>+)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
789 |
proof(rule tranclE[OF h1]) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
790 |
fix ca |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
791 |
assume h3: "(Th th1, ca) \<in> (RAG s)\<^sup>+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
792 |
and h4: "(ca, c) \<in> RAG s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
793 |
show "th1 \<in> children s th2 \<or> (\<exists>th3. th3 \<in> children s th2 \<and> (Th th1, Th th3) \<in> (RAG s)\<^sup>+)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
794 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
795 |
from eq_c and h4 obtain th3 where eq_ca: "ca = Th th3" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
796 |
by (case_tac ca, auto simp:s_RAG_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
797 |
from eq_ca h4 h2 eq_c |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
798 |
have "th3 \<in> children s th2" by (auto simp:children_def child_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
799 |
moreover from h3 eq_ca have "(Th th1, Th th3) \<in> (RAG s)\<^sup>+" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
800 |
ultimately show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
801 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
802 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
803 |
assume "(Th th1, c) \<in> RAG s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
804 |
with h2 eq_c |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
805 |
have "th1 \<in> children s th2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
806 |
by (auto simp:children_def child_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
807 |
thus ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
808 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
809 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
810 |
assume "(Th th1, Th th2) \<in> RAG s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
811 |
thus ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
812 |
by (auto simp:s_RAG_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
813 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
814 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
815 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
816 |
lemma sub_child: "child s \<subseteq> (RAG s)^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
817 |
by (unfold child_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
818 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
819 |
lemma wf_child: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
820 |
assumes vt: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
821 |
shows "wf (child s)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
822 |
apply(rule wf_subset) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
823 |
apply(rule wf_trancl[OF wf_RAG[OF vt]]) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
824 |
apply(rule sub_child) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
825 |
done |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
826 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
827 |
lemma RAG_child_pre: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
828 |
assumes vt: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
829 |
shows |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
830 |
"(Th th, n) \<in> (RAG s)^+ \<longrightarrow> (\<forall> th'. n = (Th th') \<longrightarrow> (Th th, Th th') \<in> (child s)^+)" (is "?P n") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
831 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
832 |
from wf_trancl[OF wf_RAG[OF vt]] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
833 |
have wf: "wf ((RAG s)^+)" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
834 |
show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
835 |
proof(rule wf_induct[OF wf, of ?P], clarsimp) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
836 |
fix th' |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
837 |
assume ih[rule_format]: "\<forall>y. (y, Th th') \<in> (RAG s)\<^sup>+ \<longrightarrow> |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
838 |
(Th th, y) \<in> (RAG s)\<^sup>+ \<longrightarrow> (\<forall>th'. y = Th th' \<longrightarrow> (Th th, Th th') \<in> (child s)\<^sup>+)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
839 |
and h: "(Th th, Th th') \<in> (RAG s)\<^sup>+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
840 |
show "(Th th, Th th') \<in> (child s)\<^sup>+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
841 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
842 |
from RAG_children[OF h] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
843 |
have "th \<in> children s th' \<or> (\<exists>th3. th3 \<in> children s th' \<and> (Th th, Th th3) \<in> (RAG s)\<^sup>+)" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
844 |
thus ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
845 |
proof |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
846 |
assume "th \<in> children s th'" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
847 |
thus "(Th th, Th th') \<in> (child s)\<^sup>+" by (auto simp:children_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
848 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
849 |
assume "\<exists>th3. th3 \<in> children s th' \<and> (Th th, Th th3) \<in> (RAG s)\<^sup>+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
850 |
then obtain th3 where th3_in: "th3 \<in> children s th'" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
851 |
and th_dp: "(Th th, Th th3) \<in> (RAG s)\<^sup>+" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
852 |
from th3_in have "(Th th3, Th th') \<in> (RAG s)^+" by (auto simp:children_def child_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
853 |
from ih[OF this th_dp, of th3] have "(Th th, Th th3) \<in> (child s)\<^sup>+" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
854 |
with th3_in show "(Th th, Th th') \<in> (child s)\<^sup>+" by (auto simp:children_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
855 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
856 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
857 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
858 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
859 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
860 |
lemma RAG_child: "\<lbrakk>vt s; (Th th, Th th') \<in> (RAG s)^+\<rbrakk> \<Longrightarrow> (Th th, Th th') \<in> (child s)^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
861 |
by (insert RAG_child_pre, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
862 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
863 |
lemma child_RAG_p: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
864 |
assumes "(n1, n2) \<in> (child s)^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
865 |
shows "(n1, n2) \<in> (RAG s)^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
866 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
867 |
from assms show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
868 |
proof(induct) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
869 |
case (base y) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
870 |
with sub_child show ?case by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
871 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
872 |
case (step y z) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
873 |
assume "(y, z) \<in> child s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
874 |
with sub_child have "(y, z) \<in> (RAG s)^+" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
875 |
moreover have "(n1, y) \<in> (RAG s)^+" by fact |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
876 |
ultimately show ?case by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
877 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
878 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
879 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
880 |
text {* (* ddd *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
881 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
882 |
lemma child_RAG_eq: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
883 |
assumes vt: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
884 |
shows "(Th th1, Th th2) \<in> (child s)^+ \<longleftrightarrow> (Th th1, Th th2) \<in> (RAG s)^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
885 |
by (auto intro: RAG_child[OF vt] child_RAG_p) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
886 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
887 |
text {* (* ddd *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
888 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
889 |
lemma children_no_dep: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
890 |
fixes s th th1 th2 th3 |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
891 |
assumes vt: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
892 |
and ch1: "(Th th1, Th th) \<in> child s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
893 |
and ch2: "(Th th2, Th th) \<in> child s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
894 |
and ch3: "(Th th1, Th th2) \<in> (RAG s)^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
895 |
shows "False" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
896 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
897 |
from RAG_child[OF vt ch3] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
898 |
have "(Th th1, Th th2) \<in> (child s)\<^sup>+" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
899 |
thus ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
900 |
proof(rule converse_tranclE) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
901 |
assume "(Th th1, Th th2) \<in> child s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
902 |
from child_unique[OF vt ch1 this] have "th = th2" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
903 |
with ch2 have "(Th th2, Th th2) \<in> child s" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
904 |
with wf_child[OF vt] show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
905 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
906 |
fix c |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
907 |
assume h1: "(Th th1, c) \<in> child s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
908 |
and h2: "(c, Th th2) \<in> (child s)\<^sup>+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
909 |
from h1 obtain th3 where eq_c: "c = Th th3" by (unfold child_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
910 |
with h1 have "(Th th1, Th th3) \<in> child s" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
911 |
from child_unique[OF vt ch1 this] have eq_th3: "th3 = th" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
912 |
with eq_c and h2 have "(Th th, Th th2) \<in> (child s)\<^sup>+" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
913 |
with ch2 have "(Th th, Th th) \<in> (child s)\<^sup>+" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
914 |
moreover have "wf ((child s)\<^sup>+)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
915 |
proof(rule wf_trancl) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
916 |
from wf_child[OF vt] show "wf (child s)" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
917 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
918 |
ultimately show False by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
919 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
920 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
921 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
922 |
text {* (* ddd *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
923 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
924 |
lemma unique_RAG_p: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
925 |
assumes vt: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
926 |
and dp1: "(n, n1) \<in> (RAG s)^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
927 |
and dp2: "(n, n2) \<in> (RAG s)^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
928 |
and neq: "n1 \<noteq> n2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
929 |
shows "(n1, n2) \<in> (RAG s)^+ \<or> (n2, n1) \<in> (RAG s)^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
930 |
proof(rule unique_chain [OF _ dp1 dp2 neq]) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
931 |
from unique_RAG[OF vt] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
932 |
show "\<And>a b c. \<lbrakk>(a, b) \<in> RAG s; (a, c) \<in> RAG s\<rbrakk> \<Longrightarrow> b = c" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
933 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
934 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
935 |
text {* (* ddd *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
936 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
937 |
lemma dependants_child_unique: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
938 |
fixes s th th1 th2 th3 |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
939 |
assumes vt: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
940 |
and ch1: "(Th th1, Th th) \<in> child s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
941 |
and ch2: "(Th th2, Th th) \<in> child s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
942 |
and dp1: "th3 \<in> dependants s th1" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
943 |
and dp2: "th3 \<in> dependants s th2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
944 |
shows "th1 = th2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
945 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
946 |
{ assume neq: "th1 \<noteq> th2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
947 |
from dp1 have dp1: "(Th th3, Th th1) \<in> (RAG s)^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
948 |
by (simp add:s_dependants_def eq_RAG) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
949 |
from dp2 have dp2: "(Th th3, Th th2) \<in> (RAG s)^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
950 |
by (simp add:s_dependants_def eq_RAG) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
951 |
from unique_RAG_p[OF vt dp1 dp2] and neq |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
952 |
have "(Th th1, Th th2) \<in> (RAG s)\<^sup>+ \<or> (Th th2, Th th1) \<in> (RAG s)\<^sup>+" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
953 |
hence False |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
954 |
proof |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
955 |
assume "(Th th1, Th th2) \<in> (RAG s)\<^sup>+ " |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
956 |
from children_no_dep[OF vt ch1 ch2 this] show ?thesis . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
957 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
958 |
assume " (Th th2, Th th1) \<in> (RAG s)\<^sup>+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
959 |
from children_no_dep[OF vt ch2 ch1 this] show ?thesis . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
960 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
961 |
} thus ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
962 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
963 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
964 |
lemma RAG_plus_elim: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
965 |
assumes "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
966 |
fixes x |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
967 |
assumes "(Th x, Th th) \<in> (RAG (wq s))\<^sup>+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
968 |
shows "\<exists>th'\<in>children s th. x = th' \<or> (Th x, Th th') \<in> (RAG (wq s))\<^sup>+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
969 |
using assms(2)[unfolded eq_RAG, folded child_RAG_eq[OF `vt s`]] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
970 |
apply (unfold children_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
971 |
by (metis assms(2) children_def RAG_children eq_RAG) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
972 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
973 |
text {* (* ddd *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
974 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
975 |
lemma dependants_expand: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
976 |
assumes "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
977 |
shows "dependants (wq s) th = (children s th) \<union> (\<Union>((dependants (wq s)) ` children s th))" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
978 |
apply(simp add: image_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
979 |
unfolding cs_dependants_def |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
980 |
apply(auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
981 |
apply (metis assms RAG_plus_elim mem_Collect_eq) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
982 |
apply (metis child_RAG_p children_def eq_RAG mem_Collect_eq r_into_trancl') |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
983 |
by (metis assms child_RAG_eq children_def eq_RAG mem_Collect_eq trancl.trancl_into_trancl) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
984 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
985 |
lemma finite_children: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
986 |
assumes "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
987 |
shows "finite (children s th)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
988 |
using children_dependants dependants_threads[OF assms] finite_threads[OF assms] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
989 |
by (metis rev_finite_subset) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
990 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
991 |
lemma finite_dependants: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
992 |
assumes "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
993 |
shows "finite (dependants (wq s) th')" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
994 |
using dependants_threads[OF assms] finite_threads[OF assms] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
995 |
by (metis rev_finite_subset) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
996 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
997 |
abbreviation |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
998 |
"preceds s ths \<equiv> {preced th s| th. th \<in> ths}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
999 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1000 |
abbreviation |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1001 |
"cpreceds s ths \<equiv> (cp s) ` ths" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1002 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1003 |
lemma Un_compr: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1004 |
"{f th | th. R th \<or> Q th} = ({f th | th. R th} \<union> {f th' | th'. Q th'})" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1005 |
by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1006 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1007 |
lemma in_disj: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1008 |
shows "x \<in> A \<or> (\<exists>y \<in> A. x \<in> Q y) \<longleftrightarrow> (\<exists>y \<in> A. x = y \<or> x \<in> Q y)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1009 |
by metis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1010 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1011 |
lemma UN_exists: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1012 |
shows "(\<Union>x \<in> A. {f y | y. Q y x}) = ({f y | y. (\<exists>x \<in> A. Q y x)})" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1013 |
by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1014 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1015 |
text {* (* ddd *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1016 |
This is the recursive equation used to compute the current precedence of |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1017 |
a thread (the @{text "th"}) here. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1018 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1019 |
lemma cp_rec: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1020 |
fixes s th |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1021 |
assumes vt: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1022 |
shows "cp s th = Max ({preced th s} \<union> (cp s ` children s th))" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1023 |
proof(cases "children s th = {}") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1024 |
case True |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1025 |
show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1026 |
unfolding cp_eq_cpreced cpreced_def |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1027 |
by (subst dependants_expand[OF `vt s`]) (simp add: True) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1028 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1029 |
case False |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1030 |
show ?thesis (is "?LHS = ?RHS") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1031 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1032 |
have eq_cp: "cp s = (\<lambda>th. Max (preceds s ({th} \<union> dependants (wq s) th)))" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1033 |
by (simp add: fun_eq_iff cp_eq_cpreced cpreced_def Un_compr image_Collect[symmetric]) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1034 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1035 |
have not_emptyness_facts[simp]: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1036 |
"dependants (wq s) th \<noteq> {}" "children s th \<noteq> {}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1037 |
using False dependants_expand[OF assms] by(auto simp only: Un_empty) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1038 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1039 |
have finiteness_facts[simp]: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1040 |
"\<And>th. finite (dependants (wq s) th)" "\<And>th. finite (children s th)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1041 |
by (simp_all add: finite_dependants[OF `vt s`] finite_children[OF `vt s`]) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1042 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1043 |
(* expanding definition *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1044 |
have "?LHS = Max ({preced th s} \<union> preceds s (dependants (wq s) th))" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1045 |
unfolding eq_cp by (simp add: Un_compr) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1046 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1047 |
(* moving Max in *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1048 |
also have "\<dots> = max (Max {preced th s}) (Max (preceds s (dependants (wq s) th)))" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1049 |
by (simp add: Max_Un) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1050 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1051 |
(* expanding dependants *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1052 |
also have "\<dots> = max (Max {preced th s}) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1053 |
(Max (preceds s (children s th \<union> \<Union>(dependants (wq s) ` children s th))))" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1054 |
by (subst dependants_expand[OF `vt s`]) (simp) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1055 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1056 |
(* moving out big Union *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1057 |
also have "\<dots> = max (Max {preced th s}) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1058 |
(Max (preceds s (\<Union> ({children s th} \<union> (dependants (wq s) ` children s th)))))" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1059 |
by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1060 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1061 |
(* moving in small union *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1062 |
also have "\<dots> = max (Max {preced th s}) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1063 |
(Max (preceds s (\<Union> ((\<lambda>th. {th} \<union> (dependants (wq s) th)) ` children s th))))" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1064 |
by (simp add: in_disj) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1065 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1066 |
(* moving in preceds *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1067 |
also have "\<dots> = max (Max {preced th s}) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1068 |
(Max (\<Union> ((\<lambda>th. preceds s ({th} \<union> (dependants (wq s) th))) ` children s th)))" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1069 |
by (simp add: UN_exists) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1070 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1071 |
(* moving in Max *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1072 |
also have "\<dots> = max (Max {preced th s}) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1073 |
(Max ((\<lambda>th. Max (preceds s ({th} \<union> (dependants (wq s) th)))) ` children s th))" |
58 | 1074 |
by (subst Max_Union) (auto simp add: image_image) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1075 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1076 |
(* folding cp + moving out Max *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1077 |
also have "\<dots> = ?RHS" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1078 |
unfolding eq_cp by (simp add: Max_insert) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1079 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1080 |
finally show "?LHS = ?RHS" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1081 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1082 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1083 |
|
58 | 1084 |
lemma next_th_holding: |
1085 |
assumes vt: "vt s" |
|
1086 |
and nxt: "next_th s th cs th'" |
|
1087 |
shows "holding (wq s) th cs" |
|
1088 |
proof - |
|
1089 |
from nxt[unfolded next_th_def] |
|
1090 |
obtain rest where h: "wq s cs = th # rest" |
|
1091 |
"rest \<noteq> []" |
|
1092 |
"th' = hd (SOME q. distinct q \<and> set q = set rest)" by auto |
|
1093 |
thus ?thesis |
|
1094 |
by (unfold cs_holding_def, auto) |
|
1095 |
qed |
|
1096 |
||
1097 |
lemma next_th_waiting: |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1098 |
assumes vt: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1099 |
and nxt: "next_th s th cs th'" |
58 | 1100 |
shows "waiting (wq s) th' cs" |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1101 |
proof - |
58 | 1102 |
from nxt[unfolded next_th_def] |
1103 |
obtain rest where h: "wq s cs = th # rest" |
|
1104 |
"rest \<noteq> []" |
|
1105 |
"th' = hd (SOME q. distinct q \<and> set q = set rest)" by auto |
|
1106 |
from wq_distinct[OF vt, of cs, unfolded h] |
|
1107 |
have dst: "distinct (th # rest)" . |
|
1108 |
have in_rest: "th' \<in> set rest" |
|
1109 |
proof(unfold h, rule someI2) |
|
1110 |
show "distinct rest \<and> set rest = set rest" using dst by auto |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1111 |
next |
58 | 1112 |
fix x assume "distinct x \<and> set x = set rest" |
1113 |
with h(2) |
|
1114 |
show "hd x \<in> set (rest)" by (cases x, auto) |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1115 |
qed |
58 | 1116 |
hence "th' \<in> set (wq s cs)" by (unfold h(1), auto) |
1117 |
moreover have "th' \<noteq> hd (wq s cs)" |
|
1118 |
by (unfold h(1), insert in_rest dst, auto) |
|
1119 |
ultimately show ?thesis by (auto simp:cs_waiting_def) |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1120 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1121 |
|
58 | 1122 |
lemma next_th_RAG: |
1123 |
assumes vt: "vt s" |
|
1124 |
and nxt: "next_th s th cs th'" |
|
1125 |
shows "{(Cs cs, Th th), (Th th', Cs cs)} \<subseteq> RAG s" |
|
1126 |
using assms next_th_holding next_th_waiting |
|
1127 |
by (unfold s_RAG_def, simp) |
|
1128 |
||
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1129 |
-- {* A useless definition *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1130 |
definition cps:: "state \<Rightarrow> (thread \<times> precedence) set" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1131 |
where "cps s = {(th, cp s th) | th . th \<in> threads s}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1132 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1133 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1134 |
text {* (* ddd *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1135 |
One beauty of our modelling is that we follow the definitional extension tradition of HOL. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1136 |
The benefit of such a concise and miniature model is that large number of intuitively |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1137 |
obvious facts are derived as lemmas, rather than asserted as axioms. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1138 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1139 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1140 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1141 |
However, the lemmas in the forthcoming several locales are no longer |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1142 |
obvious. These lemmas show how the current precedences should be recalculated |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1143 |
after every execution step (in our model, every step is represented by an event, |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1144 |
which in turn, represents a system call, or operation). Each operation is |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1145 |
treated in a separate locale. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1146 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1147 |
The complication of current precedence recalculation comes |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1148 |
because the changing of RAG needs to be taken into account, |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1149 |
in addition to the changing of precedence. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1150 |
The reason RAG changing affects current precedence is that, |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1151 |
according to the definition, current precedence |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1152 |
of a thread is the maximum of the precedences of its dependants, |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1153 |
where the dependants are defined in terms of RAG. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1154 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1155 |
Therefore, each operation, lemmas concerning the change of the precedences |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1156 |
and RAG are derived first, so that the lemmas about |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1157 |
current precedence recalculation can be based on. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1158 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1159 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1160 |
text {* (* ddd *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1161 |
The following locale @{text "step_set_cps"} investigates the recalculation |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1162 |
after the @{text "Set"} operation. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1163 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1164 |
locale step_set_cps = |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1165 |
fixes s' th prio s |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1166 |
-- {* @{text "s'"} is the system state before the operation *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1167 |
-- {* @{text "s"} is the system state after the operation *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1168 |
defines s_def : "s \<equiv> (Set th prio#s')" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1169 |
-- {* @{text "s"} is assumed to be a legitimate state, from which |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1170 |
the legitimacy of @{text "s"} can be derived. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1171 |
assumes vt_s: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1172 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1173 |
context step_set_cps |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1174 |
begin |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1175 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1176 |
text {* (* ddd *) |
58 | 1177 |
The following two lemmas confirm that @{text "Set"}-operating only changes the precedence |
1178 |
of the initiating thread. |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1179 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1180 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1181 |
lemma eq_preced: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1182 |
fixes th' |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1183 |
assumes "th' \<noteq> th" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1184 |
shows "preced th' s = preced th' s'" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1185 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1186 |
from assms show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1187 |
by (unfold s_def, auto simp:preced_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1188 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1189 |
|
58 | 1190 |
lemma eq_the_preced: |
1191 |
fixes th' |
|
1192 |
assumes "th' \<noteq> th" |
|
1193 |
shows "the_preced s th' = the_preced s' th'" |
|
1194 |
using assms |
|
1195 |
by (unfold the_preced_def, intro eq_preced, simp) |
|
1196 |
||
1197 |
text {* |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1198 |
The following lemma assures that the resetting of priority does not change the RAG. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1199 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1200 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1201 |
lemma eq_dep: "RAG s = RAG s'" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1202 |
by (unfold s_def RAG_set_unchanged, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1203 |
|
58 | 1204 |
text {* (* ddd *) |
1205 |
Th following lemma @{text "eq_cp_pre"} says the priority change of @{text "th"} |
|
1206 |
only affects those threads, which as @{text "Th th"} in their sub-trees. |
|
1207 |
||
1208 |
The proof of this lemma is simplified by using the alternative definition of @{text "cp"}. |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1209 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1210 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1211 |
lemma eq_cp_pre: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1212 |
fixes th' |
58 | 1213 |
assumes nd: "Th th \<notin> subtree (RAG s') (Th th')" |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1214 |
shows "cp s th' = cp s' th'" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1215 |
proof - |
58 | 1216 |
-- {* After unfolding using the alternative definition, elements |
1217 |
affecting the @{term "cp"}-value of threads become explicit. |
|
1218 |
We only need to prove the following: *} |
|
1219 |
have "Max (the_preced s ` {th'a. Th th'a \<in> subtree (RAG s) (Th th')}) = |
|
1220 |
Max (the_preced s' ` {th'a. Th th'a \<in> subtree (RAG s') (Th th')})" |
|
1221 |
(is "Max (?f ` ?S1) = Max (?g ` ?S2)") |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1222 |
proof - |
58 | 1223 |
-- {* The base sets are equal. *} |
1224 |
have "?S1 = ?S2" using eq_dep by simp |
|
1225 |
-- {* The function values on the base set are equal as well. *} |
|
1226 |
moreover have "\<forall> e \<in> ?S2. ?f e = ?g e" |
|
1227 |
proof |
|
1228 |
fix th1 |
|
1229 |
assume "th1 \<in> ?S2" |
|
1230 |
with nd have "th1 \<noteq> th" by (auto) |
|
1231 |
from eq_the_preced[OF this] |
|
1232 |
show "the_preced s th1 = the_preced s' th1" . |
|
1233 |
qed |
|
1234 |
-- {* Therefore, the image of the functions are equal. *} |
|
1235 |
ultimately have "(?f ` ?S1) = (?g ` ?S2)" by (auto intro!:f_image_eq) |
|
1236 |
thus ?thesis by simp |
|
1237 |
qed |
|
1238 |
thus ?thesis by (simp add:cp_alt_def) |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1239 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1240 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1241 |
text {* |
58 | 1242 |
The following lemma shows that @{term "th"} is not in the |
1243 |
sub-tree of any other thread. |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1244 |
*} |
58 | 1245 |
lemma th_in_no_subtree: |
1246 |
assumes "th' \<noteq> th" |
|
1247 |
shows "Th th \<notin> subtree (RAG s') (Th th')" |
|
1248 |
proof - |
|
1249 |
have "th \<in> readys s'" |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1250 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1251 |
from step_back_step [OF vt_s[unfolded s_def]] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1252 |
have "step s' (Set th prio)" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1253 |
hence "th \<in> runing s'" by (cases, simp) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1254 |
thus ?thesis by (simp add:readys_def runing_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1255 |
qed |
58 | 1256 |
from readys_in_no_subtree[OF step_back_vt[OF vt_s[unfolded s_def]] this assms(1)] |
1257 |
show ?thesis by blast |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1258 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1259 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1260 |
text {* |
58 | 1261 |
By combining @{thm "eq_cp_pre"} and @{thm "th_in_no_subtree"}, |
1262 |
it is obvious that the change of priority only affects the @{text "cp"}-value |
|
1263 |
of the initiating thread @{text "th"}. |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1264 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1265 |
lemma eq_cp: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1266 |
fixes th' |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1267 |
assumes "th' \<noteq> th" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1268 |
shows "cp s th' = cp s' th'" |
58 | 1269 |
by (rule eq_cp_pre[OF th_in_no_subtree[OF assms]]) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1270 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1271 |
end |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1272 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1273 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1274 |
The following @{text "step_v_cps"} is the locale for @{text "V"}-operation. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1275 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1276 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1277 |
locale step_v_cps = |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1278 |
-- {* @{text "th"} is the initiating thread *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1279 |
-- {* @{text "cs"} is the critical resource release by the @{text "V"}-operation *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1280 |
fixes s' th cs s -- {* @{text "s'"} is the state before operation*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1281 |
defines s_def : "s \<equiv> (V th cs#s')" -- {* @{text "s"} is the state after operation*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1282 |
-- {* @{text "s"} is assumed to be valid, which implies the validity of @{text "s'"} *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1283 |
assumes vt_s: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1284 |
|
58 | 1285 |
context step_v_cps |
1286 |
begin |
|
1287 |
||
1288 |
lemma rtree_RAGs: "rtree (RAG s)" |
|
1289 |
proof |
|
1290 |
show "single_valued (RAG s)" |
|
1291 |
apply (intro_locales) |
|
1292 |
by (unfold single_valued_def, auto intro: unique_RAG[OF vt_s]) |
|
1293 |
||
1294 |
show "acyclic (RAG s)" |
|
1295 |
by (rule acyclic_RAG[OF vt_s]) |
|
1296 |
qed |
|
1297 |
||
1298 |
lemma rtree_RAGs': "rtree (RAG s')" |
|
1299 |
proof |
|
1300 |
show "single_valued (RAG s')" |
|
1301 |
apply (intro_locales) |
|
1302 |
by (unfold single_valued_def, |
|
1303 |
auto intro:unique_RAG[OF step_back_vt[OF vt_s[unfolded s_def]]]) |
|
1304 |
||
1305 |
show "acyclic (RAG s')" |
|
1306 |
by (rule acyclic_RAG[OF step_back_vt[OF vt_s[unfolded s_def]]]) |
|
1307 |
qed |
|
1308 |
||
1309 |
lemmas vt_s' = step_back_vt[OF vt_s[unfolded s_def]] |
|
1310 |
||
1311 |
lemma ready_th_s': "th \<in> readys s'" |
|
1312 |
using step_back_step[OF vt_s[unfolded s_def]] |
|
1313 |
by (cases, simp add:runing_def) |
|
1314 |
||
1315 |
||
1316 |
lemma ancestors_th: "ancestors (RAG s') (Th th) = {}" |
|
1317 |
proof - |
|
1318 |
from readys_root[OF vt_s' ready_th_s'] |
|
1319 |
show ?thesis |
|
1320 |
by (unfold root_def, simp) |
|
1321 |
qed |
|
1322 |
||
1323 |
lemma holding_th: "holding s' th cs" |
|
1324 |
proof - |
|
1325 |
from vt_s[unfolded s_def] |
|
1326 |
have " PIP s' (V th cs)" by (cases, simp) |
|
1327 |
thus ?thesis by (cases, auto) |
|
1328 |
qed |
|
1329 |
||
1330 |
lemma edge_of_th: |
|
1331 |
"(Cs cs, Th th) \<in> RAG s'" |
|
1332 |
proof - |
|
1333 |
from holding_th |
|
1334 |
show ?thesis |
|
1335 |
by (unfold s_RAG_def holding_eq, auto) |
|
1336 |
qed |
|
1337 |
||
1338 |
lemma ancestors_cs: |
|
1339 |
"ancestors (RAG s') (Cs cs) = {Th th}" |
|
1340 |
proof - |
|
1341 |
find_theorems ancestors |
|
1342 |
have "ancestors (RAG s') (Cs cs) = ancestors (RAG s') (Th th) \<union> {Th th}" |
|
1343 |
proof(rule RTree.rtree.ancestors_accum[OF rtree_RAGs']) |
|
1344 |
from vt_s[unfolded s_def] |
|
1345 |
have " PIP s' (V th cs)" by (cases, simp) |
|
1346 |
thus "(Cs cs, Th th) \<in> RAG s'" |
|
1347 |
proof(cases) |
|
1348 |
assume "holding s' th cs" |
|
1349 |
from this[unfolded holding_eq] |
|
1350 |
show ?thesis by (unfold s_RAG_def, auto) |
|
1351 |
qed |
|
1352 |
qed |
|
1353 |
from this[unfolded ancestors_th] show ?thesis by simp |
|
1354 |
qed |
|
1355 |
||
1356 |
lemma preced_kept: "the_preced s = the_preced s'" |
|
1357 |
by (auto simp: s_def the_preced_def preced_def) |
|
1358 |
||
1359 |
end |
|
1360 |
||
1361 |
||
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1362 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1363 |
The following @{text "step_v_cps_nt"} is the sub-locale for @{text "V"}-operation, |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1364 |
which represents the case when there is another thread @{text "th'"} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1365 |
to take over the critical resource released by the initiating thread @{text "th"}. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1366 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1367 |
locale step_v_cps_nt = step_v_cps + |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1368 |
fixes th' |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1369 |
-- {* @{text "th'"} is assumed to take over @{text "cs"} *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1370 |
assumes nt: "next_th s' th cs th'" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1371 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1372 |
context step_v_cps_nt |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1373 |
begin |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1374 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1375 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1376 |
Lemma @{text "RAG_s"} confirms the change of RAG: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1377 |
two edges removed and one added, as shown by the following diagram. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1378 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1379 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1380 |
(* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1381 |
RAG before the V-operation |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1382 |
th1 ----| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1383 |
| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1384 |
th' ----| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1385 |
|----> cs -----| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1386 |
th2 ----| | |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1387 |
| | |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1388 |
th3 ----| | |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1389 |
|------> th |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1390 |
th4 ----| | |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1391 |
| | |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1392 |
th5 ----| | |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1393 |
|----> cs'-----| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1394 |
th6 ----| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1395 |
| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1396 |
th7 ----| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1397 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1398 |
RAG after the V-operation |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1399 |
th1 ----| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1400 |
| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1401 |
|----> cs ----> th' |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1402 |
th2 ----| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1403 |
| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1404 |
th3 ----| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1405 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1406 |
th4 ----| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1407 |
| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1408 |
th5 ----| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1409 |
|----> cs'----> th |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1410 |
th6 ----| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1411 |
| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1412 |
th7 ----| |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1413 |
*) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1414 |
|
58 | 1415 |
lemma sub_RAGs': "{(Cs cs, Th th), (Th th', Cs cs)} \<subseteq> RAG s'" |
1416 |
using next_th_RAG[OF vt_s' nt] . |
|
1417 |
||
1418 |
lemma ancestors_th': |
|
1419 |
"ancestors (RAG s') (Th th') = {Th th, Cs cs}" |
|
1420 |
proof - |
|
1421 |
have "ancestors (RAG s') (Th th') = ancestors (RAG s') (Cs cs) \<union> {Cs cs}" |
|
1422 |
proof(rule RTree.rtree.ancestors_accum[OF rtree_RAGs']) |
|
1423 |
from sub_RAGs' show "(Th th', Cs cs) \<in> RAG s'" by auto |
|
1424 |
qed |
|
1425 |
thus ?thesis using ancestors_th ancestors_cs by auto |
|
1426 |
qed |
|
1427 |
||
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1428 |
lemma RAG_s: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1429 |
"RAG s = (RAG s' - {(Cs cs, Th th), (Th th', Cs cs)}) \<union> |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1430 |
{(Cs cs, Th th')}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1431 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1432 |
from step_RAG_v[OF vt_s[unfolded s_def], folded s_def] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1433 |
and nt show ?thesis by (auto intro:next_th_unique) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1434 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1435 |
|
58 | 1436 |
lemma subtree_kept: |
1437 |
assumes "th1 \<notin> {th, th'}" |
|
1438 |
shows "subtree (RAG s) (Th th1) = subtree (RAG s') (Th th1)" (is "_ = ?R") |
|
1439 |
proof - |
|
1440 |
let ?RAG' = "(RAG s' - {(Cs cs, Th th), (Th th', Cs cs)})" |
|
1441 |
let ?RAG'' = "?RAG' \<union> {(Cs cs, Th th')}" |
|
1442 |
have "subtree ?RAG' (Th th1) = ?R" |
|
1443 |
proof(rule subset_del_subtree_outside) |
|
1444 |
show "Range {(Cs cs, Th th), (Th th', Cs cs)} \<inter> subtree (RAG s') (Th th1) = {}" |
|
1445 |
proof - |
|
1446 |
have "(Th th) \<notin> subtree (RAG s') (Th th1)" |
|
1447 |
proof(rule subtree_refute) |
|
1448 |
show "Th th1 \<notin> ancestors (RAG s') (Th th)" |
|
1449 |
by (unfold ancestors_th, simp) |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1450 |
next |
58 | 1451 |
from assms show "Th th1 \<noteq> Th th" by simp |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1452 |
qed |
58 | 1453 |
moreover have "(Cs cs) \<notin> subtree (RAG s') (Th th1)" |
1454 |
proof(rule subtree_refute) |
|
1455 |
show "Th th1 \<notin> ancestors (RAG s') (Cs cs)" |
|
1456 |
by (unfold ancestors_cs, insert assms, auto) |
|
1457 |
qed simp |
|
1458 |
ultimately have "{Th th, Cs cs} \<inter> subtree (RAG s') (Th th1) = {}" by auto |
|
1459 |
thus ?thesis by simp |
|
1460 |
qed |
|
1461 |
qed |
|
1462 |
moreover have "subtree ?RAG'' (Th th1) = subtree ?RAG' (Th th1)" |
|
1463 |
proof(rule subtree_insert_next) |
|
1464 |
show "Th th' \<notin> subtree (RAG s' - {(Cs cs, Th th), (Th th', Cs cs)}) (Th th1)" |
|
1465 |
proof(rule subtree_refute) |
|
1466 |
show "Th th1 \<notin> ancestors (RAG s' - {(Cs cs, Th th), (Th th', Cs cs)}) (Th th')" |
|
1467 |
(is "_ \<notin> ?R") |
|
1468 |
proof - |
|
1469 |
have "?R \<subseteq> ancestors (RAG s') (Th th')" by (rule ancestors_mono, auto) |
|
1470 |
moreover have "Th th1 \<notin> ..." using ancestors_th' assms by simp |
|
1471 |
ultimately show ?thesis by auto |
|
1472 |
qed |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1473 |
next |
58 | 1474 |
from assms show "Th th1 \<noteq> Th th'" by simp |
1475 |
qed |
|
1476 |
qed |
|
1477 |
ultimately show ?thesis by (unfold RAG_s, simp) |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1478 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1479 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1480 |
lemma cp_kept: |
58 | 1481 |
assumes "th1 \<notin> {th, th'}" |
1482 |
shows "cp s th1 = cp s' th1" |
|
1483 |
by (unfold cp_alt_def preced_kept subtree_kept[OF assms], simp) |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1484 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1485 |
end |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1486 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1487 |
locale step_v_cps_nnt = step_v_cps + |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1488 |
assumes nnt: "\<And> th'. (\<not> next_th s' th cs th')" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1489 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1490 |
context step_v_cps_nnt |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1491 |
begin |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1492 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1493 |
lemma RAG_s: "RAG s = RAG s' - {(Cs cs, Th th)}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1494 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1495 |
from nnt and step_RAG_v[OF vt_s[unfolded s_def], folded s_def] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1496 |
show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1497 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1498 |
|
58 | 1499 |
lemma subtree_kept: |
1500 |
assumes "th1 \<noteq> th" |
|
1501 |
shows "subtree (RAG s) (Th th1) = subtree (RAG s') (Th th1)" |
|
1502 |
proof(unfold RAG_s, rule subset_del_subtree_outside) |
|
1503 |
show "Range {(Cs cs, Th th)} \<inter> subtree (RAG s') (Th th1) = {}" |
|
1504 |
proof - |
|
1505 |
have "(Th th) \<notin> subtree (RAG s') (Th th1)" |
|
1506 |
proof(rule subtree_refute) |
|
1507 |
show "Th th1 \<notin> ancestors (RAG s') (Th th)" |
|
1508 |
by (unfold ancestors_th, simp) |
|
1509 |
next |
|
1510 |
from assms show "Th th1 \<noteq> Th th" by simp |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1511 |
qed |
58 | 1512 |
thus ?thesis by auto |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1513 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1514 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1515 |
|
58 | 1516 |
lemma cp_kept_1: |
1517 |
assumes "th1 \<noteq> th" |
|
1518 |
shows "cp s th1 = cp s' th1" |
|
1519 |
by (unfold cp_alt_def preced_kept subtree_kept[OF assms], simp) |
|
1520 |
||
1521 |
lemma subtree_cs: "subtree (RAG s') (Cs cs) = {Cs cs}" |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1522 |
proof - |
58 | 1523 |
{ fix n |
1524 |
have "(Cs cs) \<notin> ancestors (RAG s') n" |
|
1525 |
proof |
|
1526 |
assume "Cs cs \<in> ancestors (RAG s') n" |
|
1527 |
hence "(n, Cs cs) \<in> (RAG s')^+" by (auto simp:ancestors_def) |
|
1528 |
from tranclE[OF this] obtain nn where h: "(nn, Cs cs) \<in> RAG s'" by auto |
|
1529 |
then obtain th' where "nn = Th th'" |
|
1530 |
by (unfold s_RAG_def, auto) |
|
1531 |
from h[unfolded this] have "(Th th', Cs cs) \<in> RAG s'" . |
|
1532 |
from this[unfolded s_RAG_def] |
|
1533 |
have "waiting (wq s') th' cs" by auto |
|
1534 |
from this[unfolded cs_waiting_def] |
|
1535 |
have "1 < length (wq s' cs)" |
|
1536 |
by (cases "wq s' cs", auto) |
|
1537 |
from holding_next_thI[OF holding_th this] |
|
1538 |
obtain th' where "next_th s' th cs th'" by auto |
|
1539 |
with nnt show False by auto |
|
1540 |
qed |
|
1541 |
} note h = this |
|
1542 |
{ fix n |
|
1543 |
assume "n \<in> subtree (RAG s') (Cs cs)" |
|
1544 |
hence "n = (Cs cs)" |
|
1545 |
by (elim subtreeE, insert h, auto) |
|
1546 |
} moreover have "(Cs cs) \<in> subtree (RAG s') (Cs cs)" |
|
1547 |
by (auto simp:subtree_def) |
|
1548 |
ultimately show ?thesis by auto |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1549 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1550 |
|
58 | 1551 |
lemma subtree_th: |
1552 |
"subtree (RAG s) (Th th) = subtree (RAG s') (Th th) - {Cs cs}" |
|
1553 |
proof(unfold RAG_s, fold subtree_cs, rule RTree.rtree.subtree_del_inside[OF rtree_RAGs']) |
|
1554 |
from edge_of_th |
|
1555 |
show "(Cs cs, Th th) \<in> edges_in (RAG s') (Th th)" |
|
1556 |
by (unfold edges_in_def, auto simp:subtree_def) |
|
1557 |
qed |
|
1558 |
||
1559 |
lemma cp_kept_2: |
|
1560 |
shows "cp s th = cp s' th" |
|
1561 |
by (unfold cp_alt_def subtree_th preced_kept, auto) |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1562 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1563 |
lemma eq_cp: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1564 |
fixes th' |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1565 |
shows "cp s th' = cp s' th'" |
58 | 1566 |
using cp_kept_1 cp_kept_2 |
1567 |
by (cases "th' = th", auto) |
|
1568 |
||
1569 |
end |
|
1570 |
||
1571 |
find_theorems "_`_" "\<Union> _" |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1572 |
|
58 | 1573 |
find_theorems "Max" "\<Union> _" |
1574 |
||
1575 |
find_theorems wf RAG |
|
1576 |
||
1577 |
thm wf_def |
|
1578 |
||
1579 |
thm image_Union |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1580 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1581 |
locale step_P_cps = |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1582 |
fixes s' th cs s |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1583 |
defines s_def : "s \<equiv> (P th cs#s')" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1584 |
assumes vt_s: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1585 |
|
58 | 1586 |
sublocale step_P_cps < vat_s : valid_trace "s" |
1587 |
proof |
|
1588 |
from vt_s show "vt s" . |
|
1589 |
qed |
|
1590 |
||
1591 |
sublocale step_P_cps < vat_s' : valid_trace "s'" |
|
1592 |
proof |
|
1593 |
from step_back_vt[OF vt_s[unfolded s_def]] show "vt s'" . |
|
1594 |
qed |
|
1595 |
||
1596 |
||
1597 |
context step_P_cps |
|
1598 |
begin |
|
1599 |
||
60 | 1600 |
lemma readys_th: "th \<in> readys s'" |
1601 |
proof - |
|
1602 |
from step_back_step [OF vt_s[unfolded s_def]] |
|
1603 |
have "PIP s' (P th cs)" . |
|
1604 |
hence "th \<in> runing s'" by (cases, simp) |
|
1605 |
thus ?thesis by (simp add:readys_def runing_def) |
|
58 | 1606 |
qed |
1607 |
||
60 | 1608 |
lemma root_th: "root (RAG s') (Th th)" |
1609 |
using readys_root[OF vat_s'.vt readys_th] . |
|
1610 |
||
1611 |
lemma in_no_others_subtree: |
|
1612 |
assumes "th' \<noteq> th" |
|
1613 |
shows "Th th \<notin> subtree (RAG s') (Th th')" |
|
58 | 1614 |
proof |
60 | 1615 |
assume "Th th \<in> subtree (RAG s') (Th th')" |
1616 |
thus False |
|
1617 |
proof(cases rule:subtreeE) |
|
1618 |
case 1 |
|
1619 |
with assms show ?thesis by auto |
|
1620 |
next |
|
1621 |
case 2 |
|
1622 |
with root_th show ?thesis by (auto simp:root_def) |
|
1623 |
qed |
|
58 | 1624 |
qed |
1625 |
||
1626 |
lemma preced_kept: "the_preced s = the_preced s'" |
|
1627 |
by (auto simp: s_def the_preced_def preced_def) |
|
1628 |
||
1629 |
end |
|
1630 |
||
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1631 |
locale step_P_cps_ne =step_P_cps + |
58 | 1632 |
fixes th' |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1633 |
assumes ne: "wq s' cs \<noteq> []" |
58 | 1634 |
defines th'_def: "th' \<equiv> hd (wq s' cs)" |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1635 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1636 |
locale step_P_cps_e =step_P_cps + |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1637 |
assumes ee: "wq s' cs = []" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1638 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1639 |
context step_P_cps_e |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1640 |
begin |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1641 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1642 |
lemma RAG_s: "RAG s = RAG s' \<union> {(Cs cs, Th th)}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1643 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1644 |
from ee and step_RAG_p[OF vt_s[unfolded s_def], folded s_def] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1645 |
show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1646 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1647 |
|
60 | 1648 |
lemma subtree_kept: |
1649 |
assumes "th' \<noteq> th" |
|
1650 |
shows "subtree (RAG s) (Th th') = subtree (RAG s') (Th th')" |
|
1651 |
proof(unfold RAG_s, rule subtree_insert_next) |
|
1652 |
from in_no_others_subtree[OF assms] |
|
1653 |
show "Th th \<notin> subtree (RAG s') (Th th')" . |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1654 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1655 |
|
60 | 1656 |
lemma cp_kept: |
1657 |
assumes "th' \<noteq> th" |
|
1658 |
shows "cp s th' = cp s' th'" |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1659 |
proof - |
60 | 1660 |
have "(the_preced s ` {th'a. Th th'a \<in> subtree (RAG s) (Th th')}) = |
1661 |
(the_preced s' ` {th'a. Th th'a \<in> subtree (RAG s') (Th th')})" |
|
1662 |
by (unfold preced_kept subtree_kept[OF assms], simp) |
|
1663 |
thus ?thesis by (unfold cp_alt_def, simp) |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1664 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1665 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1666 |
end |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1667 |
|
58 | 1668 |
context step_P_cps_ne |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1669 |
begin |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1670 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1671 |
lemma RAG_s: "RAG s = RAG s' \<union> {(Th th, Cs cs)}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1672 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1673 |
from step_RAG_p[OF vt_s[unfolded s_def]] and ne |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1674 |
show ?thesis by (simp add:s_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1675 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1676 |
|
58 | 1677 |
lemma cs_held: "(Cs cs, Th th') \<in> RAG s'" |
1678 |
proof - |
|
1679 |
have "(Cs cs, Th th') \<in> hRAG s'" |
|
1680 |
proof - |
|
1681 |
from ne |
|
1682 |
have " holding s' th' cs" |
|
1683 |
by (unfold th'_def holding_eq cs_holding_def, auto) |
|
1684 |
thus ?thesis |
|
1685 |
by (unfold hRAG_def, auto) |
|
1686 |
qed |
|
1687 |
thus ?thesis by (unfold RAG_split, auto) |
|
1688 |
qed |
|
1689 |
||
1690 |
lemma tRAG_s: |
|
1691 |
"tRAG s = tRAG s' \<union> {(Th th, Th th')}" |
|
1692 |
using RAG_tRAG_transfer[OF step_back_vt[OF vt_s[unfolded s_def]] RAG_s cs_held] . |
|
1693 |
||
1694 |
lemma cp_kept: |
|
1695 |
assumes "Th th'' \<notin> ancestors (tRAG s) (Th th)" |
|
1696 |
shows "cp s th'' = cp s' th''" |
|
1697 |
proof - |
|
1698 |
have h: "subtree (tRAG s) (Th th'') = subtree (tRAG s') (Th th'')" |
|
1699 |
proof - |
|
1700 |
have "Th th' \<notin> subtree (tRAG s') (Th th'')" |
|
1701 |
proof |
|
1702 |
assume "Th th' \<in> subtree (tRAG s') (Th th'')" |
|
1703 |
thus False |
|
1704 |
proof(rule subtreeE) |
|
1705 |
assume "Th th' = Th th''" |
|
1706 |
from assms[unfolded tRAG_s ancestors_def, folded this] |
|
1707 |
show ?thesis by auto |
|
1708 |
next |
|
1709 |
assume "Th th'' \<in> ancestors (tRAG s') (Th th')" |
|
1710 |
moreover have "... \<subseteq> ancestors (tRAG s) (Th th')" |
|
1711 |
proof(rule ancestors_mono) |
|
1712 |
show "tRAG s' \<subseteq> tRAG s" by (unfold tRAG_s, auto) |
|
1713 |
qed |
|
1714 |
ultimately have "Th th'' \<in> ancestors (tRAG s) (Th th')" by auto |
|
1715 |
moreover have "Th th' \<in> ancestors (tRAG s) (Th th)" |
|
1716 |
by (unfold tRAG_s, auto simp:ancestors_def) |
|
1717 |
ultimately have "Th th'' \<in> ancestors (tRAG s) (Th th)" |
|
1718 |
by (auto simp:ancestors_def) |
|
1719 |
with assms show ?thesis by auto |
|
1720 |
qed |
|
1721 |
qed |
|
1722 |
from subtree_insert_next[OF this] |
|
1723 |
have "subtree (tRAG s' \<union> {(Th th, Th th')}) (Th th'') = subtree (tRAG s') (Th th'')" . |
|
1724 |
from this[folded tRAG_s] show ?thesis . |
|
1725 |
qed |
|
1726 |
show ?thesis by (unfold cp_alt_def1 h preced_kept, simp) |
|
1727 |
qed |
|
1728 |
||
60 | 1729 |
lemma cp_gen_update_stop: (* ddd *) |
58 | 1730 |
assumes "u \<in> ancestors (tRAG s) (Th th)" |
1731 |
and "cp_gen s u = cp_gen s' u" |
|
1732 |
and "y \<in> ancestors (tRAG s) u" |
|
1733 |
shows "cp_gen s y = cp_gen s' y" |
|
1734 |
using assms(3) |
|
1735 |
proof(induct rule:wf_induct[OF vat_s.fsbttRAGs.wf]) |
|
1736 |
case (1 x) |
|
1737 |
show ?case (is "?L = ?R") |
|
1738 |
proof - |
|
1739 |
from tRAG_ancestorsE[OF 1(2)] |
|
1740 |
obtain th2 where eq_x: "x = Th th2" by blast |
|
1741 |
from vat_s.cp_gen_rec[OF this] |
|
1742 |
have "?L = |
|
1743 |
Max ({the_preced s th2} \<union> cp_gen s ` RTree.children (tRAG s) x)" . |
|
1744 |
also have "... = |
|
1745 |
Max ({the_preced s' th2} \<union> cp_gen s' ` RTree.children (tRAG s') x)" |
|
60 | 1746 |
|
58 | 1747 |
proof - |
59
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1748 |
from preced_kept have "the_preced s th2 = the_preced s' th2" by simp |
58 | 1749 |
moreover have "cp_gen s ` RTree.children (tRAG s) x = |
1750 |
cp_gen s' ` RTree.children (tRAG s') x" |
|
1751 |
proof - |
|
1752 |
have "RTree.children (tRAG s) x = RTree.children (tRAG s') x" |
|
1753 |
proof(unfold tRAG_s, rule children_union_kept) |
|
1754 |
have start: "(Th th, Th th') \<in> tRAG s" |
|
1755 |
by (unfold tRAG_s, auto) |
|
1756 |
note x_u = 1(2) |
|
1757 |
show "x \<notin> Range {(Th th, Th th')}" |
|
1758 |
proof |
|
1759 |
assume "x \<in> Range {(Th th, Th th')}" |
|
1760 |
hence eq_x: "x = Th th'" using RangeE by auto |
|
1761 |
show False |
|
1762 |
proof(cases rule:vat_s.rtree_s.ancestors_headE[OF assms(1) start]) |
|
1763 |
case 1 |
|
1764 |
from x_u[folded this, unfolded eq_x] vat_s.acyclic_tRAG |
|
1765 |
show ?thesis by (auto simp:ancestors_def acyclic_def) |
|
1766 |
next |
|
1767 |
case 2 |
|
1768 |
with x_u[unfolded eq_x] |
|
1769 |
have "(Th th', Th th') \<in> (tRAG s)^+" by (auto simp:ancestors_def) |
|
1770 |
with vat_s.acyclic_tRAG show ?thesis by (auto simp:acyclic_def) |
|
1771 |
qed |
|
1772 |
qed |
|
1773 |
qed |
|
1774 |
moreover have "cp_gen s ` RTree.children (tRAG s) x = |
|
1775 |
cp_gen s' ` RTree.children (tRAG s) x" (is "?f ` ?A = ?g ` ?A") |
|
59
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1776 |
proof(rule f_image_eq) |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1777 |
fix a |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1778 |
assume a_in: "a \<in> ?A" |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1779 |
from 1(2) |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1780 |
show "?f a = ?g a" |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1781 |
proof(cases rule:vat_s.rtree_s.ancestors_childrenE[case_names in_ch out_ch]) |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1782 |
case in_ch |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1783 |
show ?thesis |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1784 |
proof(cases "a = u") |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1785 |
case True |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1786 |
from assms(2)[folded this] show ?thesis . |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1787 |
next |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1788 |
case False |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1789 |
have a_not_in: "a \<notin> ancestors (tRAG s) (Th th)" |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1790 |
proof |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1791 |
assume a_in': "a \<in> ancestors (tRAG s) (Th th)" |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1792 |
have "a = u" |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1793 |
proof(rule vat_s.rtree_s.ancestors_children_unique) |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1794 |
from a_in' a_in show "a \<in> ancestors (tRAG s) (Th th) \<inter> |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1795 |
RTree.children (tRAG s) x" by auto |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1796 |
next |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1797 |
from assms(1) in_ch show "u \<in> ancestors (tRAG s) (Th th) \<inter> |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1798 |
RTree.children (tRAG s) x" by auto |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1799 |
qed |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1800 |
with False show False by simp |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1801 |
qed |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1802 |
from a_in obtain th_a where eq_a: "a = Th th_a" |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1803 |
by (unfold RTree.children_def tRAG_alt_def, auto) |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1804 |
from cp_kept[OF a_not_in[unfolded eq_a]] |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1805 |
have "cp s th_a = cp s' th_a" . |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1806 |
from this [unfolded cp_gen_def_cond[OF eq_a], folded eq_a] |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1807 |
show ?thesis . |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1808 |
qed |
58 | 1809 |
next |
59
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1810 |
case (out_ch z) |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1811 |
hence h: "z \<in> ancestors (tRAG s) u" "z \<in> RTree.children (tRAG s) x" by auto |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1812 |
show ?thesis |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1813 |
proof(cases "a = z") |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1814 |
case True |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1815 |
from h(2) have zx_in: "(z, x) \<in> (tRAG s)" by (auto simp:RTree.children_def) |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1816 |
from 1(1)[rule_format, OF this h(1)] |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1817 |
have eq_cp_gen: "cp_gen s z = cp_gen s' z" . |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1818 |
with True show ?thesis by metis |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1819 |
next |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1820 |
case False |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1821 |
from a_in obtain th_a where eq_a: "a = Th th_a" |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1822 |
by (auto simp:RTree.children_def tRAG_alt_def) |
60 | 1823 |
have "a \<notin> ancestors (tRAG s) (Th th)" |
1824 |
proof |
|
1825 |
assume a_in': "a \<in> ancestors (tRAG s) (Th th)" |
|
1826 |
have "a = z" |
|
1827 |
proof(rule vat_s.rtree_s.ancestors_children_unique) |
|
1828 |
from assms(1) h(1) have "z \<in> ancestors (tRAG s) (Th th)" |
|
1829 |
by (auto simp:ancestors_def) |
|
1830 |
with h(2) show " z \<in> ancestors (tRAG s) (Th th) \<inter> |
|
1831 |
RTree.children (tRAG s) x" by auto |
|
1832 |
next |
|
1833 |
from a_in a_in' |
|
1834 |
show "a \<in> ancestors (tRAG s) (Th th) \<inter> RTree.children (tRAG s) x" |
|
1835 |
by auto |
|
1836 |
qed |
|
1837 |
with False show False by auto |
|
1838 |
qed |
|
59
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1839 |
from cp_kept[OF this[unfolded eq_a]] |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1840 |
have "cp s th_a = cp s' th_a" . |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1841 |
from this[unfolded cp_gen_def_cond[OF eq_a], folded eq_a] |
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1842 |
show ?thesis . |
58 | 1843 |
qed |
1844 |
qed |
|
1845 |
qed |
|
1846 |
ultimately show ?thesis by metis |
|
1847 |
qed |
|
1848 |
ultimately show ?thesis by simp |
|
1849 |
qed |
|
1850 |
also have "... = ?R" |
|
1851 |
by (fold vat_s'.cp_gen_rec[OF eq_x], simp) |
|
1852 |
finally show ?thesis . |
|
1853 |
qed |
|
1854 |
qed |
|
1855 |
||
60 | 1856 |
lemma cp_up: |
1857 |
assumes "(Th th') \<in> ancestors (tRAG s) (Th th)" |
|
1858 |
and "cp s th' = cp s' th'" |
|
1859 |
and "(Th th'') \<in> ancestors (tRAG s) (Th th')" |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1860 |
shows "cp s th'' = cp s' th''" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1861 |
proof - |
60 | 1862 |
have "cp_gen s (Th th'') = cp_gen s' (Th th'')" |
1863 |
proof(rule cp_gen_update_stop[OF assms(1) _ assms(3)]) |
|
1864 |
from assms(2) cp_gen_def_cond[OF refl[of "Th th'"]] |
|
1865 |
show "cp_gen s (Th th') = cp_gen s' (Th th')" by metis |
|
1866 |
qed |
|
1867 |
with cp_gen_def_cond[OF refl[of "Th th''"]] |
|
1868 |
show ?thesis by metis |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1869 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1870 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1871 |
end |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1872 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1873 |
locale step_create_cps = |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1874 |
fixes s' th prio s |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1875 |
defines s_def : "s \<equiv> (Create th prio#s')" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1876 |
assumes vt_s: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1877 |
|
60 | 1878 |
sublocale step_create_cps < vat_s: valid_trace "s" |
1879 |
by (unfold_locales, insert vt_s, simp) |
|
1880 |
||
1881 |
sublocale step_create_cps < vat_s': valid_trace "s'" |
|
1882 |
by (unfold_locales, insert step_back_vt[OF vt_s[unfolded s_def]], simp) |
|
1883 |
||
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1884 |
context step_create_cps |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1885 |
begin |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1886 |
|
60 | 1887 |
lemma RAG_kept: "RAG s = RAG s'" |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1888 |
by (unfold s_def RAG_create_unchanged, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1889 |
|
60 | 1890 |
lemma tRAG_kept: "tRAG s = tRAG s'" |
1891 |
by (unfold tRAG_alt_def RAG_kept, auto) |
|
1892 |
||
1893 |
lemma preced_kept: |
|
1894 |
assumes "th' \<noteq> th" |
|
1895 |
shows "the_preced s th' = the_preced s' th'" |
|
1896 |
by (unfold s_def the_preced_def preced_def, insert assms, auto) |
|
1897 |
||
1898 |
lemma th_not_in: "Th th \<notin> Field (tRAG s')" |
|
1899 |
proof - |
|
1900 |
from vt_s[unfolded s_def] |
|
1901 |
have "PIP s' (Create th prio)" by (cases, simp) |
|
1902 |
hence "th \<notin> threads s'" by(cases, simp) |
|
1903 |
from vat_s'.not_in_thread_isolated[OF this] |
|
1904 |
have "Th th \<notin> Field (RAG s')" . |
|
1905 |
with tRAG_Field show ?thesis by auto |
|
1906 |
qed |
|
1907 |
||
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1908 |
lemma eq_cp: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1909 |
assumes neq_th: "th' \<noteq> th" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1910 |
shows "cp s th' = cp s' th'" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1911 |
proof - |
60 | 1912 |
have "(the_preced s \<circ> the_thread) ` subtree (tRAG s) (Th th') = |
1913 |
(the_preced s' \<circ> the_thread) ` subtree (tRAG s') (Th th')" |
|
1914 |
proof(unfold tRAG_kept, rule f_image_eq) |
|
1915 |
fix a |
|
1916 |
assume a_in: "a \<in> subtree (tRAG s') (Th th')" |
|
1917 |
then obtain th_a where eq_a: "a = Th th_a" |
|
1918 |
proof(cases rule:subtreeE) |
|
1919 |
case 2 |
|
1920 |
from ancestors_Field[OF 2(2)] |
|
1921 |
and that show ?thesis by (unfold tRAG_alt_def, auto) |
|
1922 |
qed auto |
|
1923 |
have neq_th_a: "th_a \<noteq> th" |
|
1924 |
proof - |
|
1925 |
have "(Th th) \<notin> subtree (tRAG s') (Th th')" |
|
1926 |
proof |
|
1927 |
assume "Th th \<in> subtree (tRAG s') (Th th')" |
|
1928 |
thus False |
|
1929 |
proof(cases rule:subtreeE) |
|
1930 |
case 2 |
|
1931 |
from ancestors_Field[OF this(2)] |
|
1932 |
and th_not_in[unfolded Field_def] |
|
1933 |
show ?thesis by auto |
|
1934 |
qed (insert assms, auto) |
|
1935 |
qed |
|
1936 |
with a_in[unfolded eq_a] show ?thesis by auto |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1937 |
qed |
60 | 1938 |
from preced_kept[OF this] |
1939 |
show "(the_preced s \<circ> the_thread) a = (the_preced s' \<circ> the_thread) a" |
|
1940 |
by (unfold eq_a, simp) |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1941 |
qed |
60 | 1942 |
thus ?thesis by (unfold cp_alt_def1, simp) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1943 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1944 |
|
60 | 1945 |
lemma children_of_th: "RTree.children (tRAG s) (Th th) = {}" |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1946 |
proof - |
60 | 1947 |
{ fix a |
1948 |
assume "a \<in> RTree.children (tRAG s) (Th th)" |
|
1949 |
hence "(a, Th th) \<in> tRAG s" by (auto simp:RTree.children_def) |
|
1950 |
with th_not_in have False |
|
1951 |
by (unfold Field_def tRAG_kept, auto) |
|
1952 |
} thus ?thesis by auto |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1953 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1954 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1955 |
lemma eq_cp_th: "cp s th = preced th s" |
60 | 1956 |
by (unfold vat_s.cp_rec children_of_th, simp add:the_preced_def) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1957 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1958 |
end |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1959 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1960 |
locale step_exit_cps = |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1961 |
fixes s' th prio s |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1962 |
defines s_def : "s \<equiv> Exit th # s'" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1963 |
assumes vt_s: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1964 |
|
60 | 1965 |
sublocale step_exit_cps < vat_s: valid_trace "s" |
1966 |
by (unfold_locales, insert vt_s, simp) |
|
1967 |
||
1968 |
sublocale step_exit_cps < vat_s': valid_trace "s'" |
|
1969 |
by (unfold_locales, insert step_back_vt[OF vt_s[unfolded s_def]], simp) |
|
1970 |
||
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1971 |
context step_exit_cps |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1972 |
begin |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1973 |
|
60 | 1974 |
lemma preced_kept: |
1975 |
assumes "th' \<noteq> th" |
|
1976 |
shows "the_preced s th' = the_preced s' th'" |
|
1977 |
by (unfold s_def the_preced_def preced_def, insert assms, auto) |
|
1978 |
||
1979 |
lemma RAG_kept: "RAG s = RAG s'" |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1980 |
by (unfold s_def RAG_exit_unchanged, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1981 |
|
60 | 1982 |
lemma tRAG_kept: "tRAG s = tRAG s'" |
1983 |
by (unfold tRAG_alt_def RAG_kept, auto) |
|
1984 |
||
1985 |
lemma th_ready: "th \<in> readys s'" |
|
1986 |
proof - |
|
1987 |
from vt_s[unfolded s_def] |
|
1988 |
have "PIP s' (Exit th)" by (cases, simp) |
|
1989 |
hence h: "th \<in> runing s' \<and> holdents s' th = {}" by (cases, metis) |
|
1990 |
thus ?thesis by (unfold runing_def, auto) |
|
1991 |
qed |
|
1992 |
||
1993 |
lemma th_holdents: "holdents s' th = {}" |
|
1994 |
proof - |
|
1995 |
from vt_s[unfolded s_def] |
|
1996 |
have "PIP s' (Exit th)" by (cases, simp) |
|
1997 |
thus ?thesis by (cases, metis) |
|
1998 |
qed |
|
1999 |
||
2000 |
lemma th_RAG: "Th th \<notin> Field (RAG s')" |
|
2001 |
proof - |
|
2002 |
have "Th th \<notin> Range (RAG s')" |
|
2003 |
proof |
|
2004 |
assume "Th th \<in> Range (RAG s')" |
|
2005 |
then obtain cs where "holding (wq s') th cs" |
|
2006 |
by (unfold Range_iff s_RAG_def, auto) |
|
2007 |
with th_holdents[unfolded holdents_def] |
|
2008 |
show False by (unfold eq_holding, auto) |
|
2009 |
qed |
|
2010 |
moreover have "Th th \<notin> Domain (RAG s')" |
|
2011 |
proof |
|
2012 |
assume "Th th \<in> Domain (RAG s')" |
|
2013 |
then obtain cs where "waiting (wq s') th cs" |
|
2014 |
by (unfold Domain_iff s_RAG_def, auto) |
|
2015 |
with th_ready show False by (unfold readys_def eq_waiting, auto) |
|
2016 |
qed |
|
2017 |
ultimately show ?thesis by (auto simp:Field_def) |
|
2018 |
qed |
|
2019 |
||
2020 |
lemma th_tRAG: "(Th th) \<notin> Field (tRAG s')" |
|
2021 |
using th_RAG tRAG_Field[of s'] by auto |
|
2022 |
||
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
2023 |
lemma eq_cp: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
2024 |
assumes neq_th: "th' \<noteq> th" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
2025 |
shows "cp s th' = cp s' th'" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
2026 |
proof - |
60 | 2027 |
have "(the_preced s \<circ> the_thread) ` subtree (tRAG s) (Th th') = |
2028 |
(the_preced s' \<circ> the_thread) ` subtree (tRAG s') (Th th')" |
|
2029 |
proof(unfold tRAG_kept, rule f_image_eq) |
|
2030 |
fix a |
|
2031 |
assume a_in: "a \<in> subtree (tRAG s') (Th th')" |
|
2032 |
then obtain th_a where eq_a: "a = Th th_a" |
|
2033 |
proof(cases rule:subtreeE) |
|
2034 |
case 2 |
|
2035 |
from ancestors_Field[OF 2(2)] |
|
2036 |
and that show ?thesis by (unfold tRAG_alt_def, auto) |
|
2037 |
qed auto |
|
2038 |
have neq_th_a: "th_a \<noteq> th" |
|
2039 |
proof - |
|
2040 |
from readys_in_no_subtree[OF vat_s'.vt th_ready assms] |
|
2041 |
have "(Th th) \<notin> subtree (RAG s') (Th th')" . |
|
2042 |
find_theorems subtree tRAG RAG (* ccc *) |
|
2043 |
proof |
|
2044 |
assume "Th th \<in> subtree (tRAG s') (Th th')" |
|
2045 |
thus False |
|
2046 |
proof(cases rule:subtreeE) |
|
2047 |
case 2 |
|
2048 |
from ancestors_Field[OF this(2)] |
|
2049 |
and th_tRAG[unfolded Field_def] |
|
2050 |
show ?thesis by auto |
|
2051 |
qed (insert assms, auto) |
|
2052 |
qed |
|
2053 |
with a_in[unfolded eq_a] show ?thesis by auto |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
2054 |
qed |
60 | 2055 |
from preced_kept[OF this] |
2056 |
show "(the_preced s \<circ> the_thread) a = (the_preced s' \<circ> the_thread) a" |
|
2057 |
by (unfold eq_a, simp) |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
2058 |
qed |
60 | 2059 |
thus ?thesis by (unfold cp_alt_def1, simp) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
2060 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
2061 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
2062 |
end |
60 | 2063 |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
2064 |
end |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
2065 |