author | zhangx |
Fri, 18 Dec 2015 22:47:32 +0800 | |
changeset 61 | f8194fd6214f |
parent 60 | f98a95f3deae |
child 62 | 031d2ae9c9b8 |
permissions | -rw-r--r-- |
53
8142e80f5d58
Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents:
45
diff
changeset
|
1 |
section {* |
8142e80f5d58
Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents:
45
diff
changeset
|
2 |
This file contains lemmas used to guide the recalculation of current precedence |
8142e80f5d58
Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents:
45
diff
changeset
|
3 |
after every system call (or system operation) |
8142e80f5d58
Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents:
45
diff
changeset
|
4 |
*} |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
theory CpsG |
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
6 |
imports PrioG Max RTree |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
7 |
begin |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
8 |
|
61 | 9 |
text {* @{text "the_preced"} is also the same as @{text "preced"}, the only |
10 |
difference is the order of arguemts. *} |
|
11 |
definition "the_preced s th = preced th s" |
|
12 |
||
13 |
text {* @{term "the_thread"} extracts thread out of RAG node. *} |
|
14 |
fun the_thread :: "node \<Rightarrow> thread" where |
|
15 |
"the_thread (Th th) = th" |
|
16 |
||
17 |
text {* The following @{text "wRAG"} is the waiting sub-graph of @{text "RAG"}. *} |
|
58 | 18 |
definition "wRAG (s::state) = {(Th th, Cs cs) | th cs. waiting s th cs}" |
19 |
||
61 | 20 |
text {* The following @{text "hRAG"} is the holding sub-graph of @{text "RAG"}. *} |
58 | 21 |
definition "hRAG (s::state) = {(Cs cs, Th th) | th cs. holding s th cs}" |
22 |
||
61 | 23 |
text {* The following lemma splits @{term "RAG"} graph into the above two sub-graphs. *} |
58 | 24 |
lemma RAG_split: "RAG s = (wRAG s \<union> hRAG s)" |
25 |
by (unfold s_RAG_abv wRAG_def hRAG_def s_waiting_abv |
|
26 |
s_holding_abv cs_RAG_def, auto) |
|
27 |
||
61 | 28 |
text {* |
29 |
The following @{text "tRAG"} is the thread-graph derived from @{term "RAG"}. |
|
30 |
It characterizes the dependency between threads when calculating current |
|
31 |
precedences. It is defined as the composition of the above two sub-graphs, |
|
32 |
names @{term "wRAG"} and @{term "hRAG"}. |
|
33 |
*} |
|
34 |
definition "tRAG s = wRAG s O hRAG s" |
|
35 |
||
36 |
(* ccc *) |
|
37 |
||
38 |
definition "cp_gen s x = |
|
39 |
Max ((the_preced s \<circ> the_thread) ` subtree (tRAG s) x)" |
|
40 |
||
58 | 41 |
lemma tRAG_alt_def: |
42 |
"tRAG s = {(Th th1, Th th2) | th1 th2. |
|
43 |
\<exists> cs. (Th th1, Cs cs) \<in> RAG s \<and> (Cs cs, Th th2) \<in> RAG s}" |
|
44 |
by (auto simp:tRAG_def RAG_split wRAG_def hRAG_def) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
45 |
|
60 | 46 |
lemma tRAG_Field: |
47 |
"Field (tRAG s) \<subseteq> Field (RAG s)" |
|
48 |
by (unfold tRAG_alt_def Field_def, auto) |
|
49 |
||
50 |
lemma tRAG_ancestorsE: |
|
51 |
assumes "x \<in> ancestors (tRAG s) u" |
|
52 |
obtains th where "x = Th th" |
|
53 |
proof - |
|
54 |
from assms have "(u, x) \<in> (tRAG s)^+" |
|
55 |
by (unfold ancestors_def, auto) |
|
56 |
from tranclE[OF this] obtain c where "(c, x) \<in> tRAG s" by auto |
|
57 |
then obtain th where "x = Th th" |
|
58 |
by (unfold tRAG_alt_def, auto) |
|
59 |
from that[OF this] show ?thesis . |
|
60 |
qed |
|
61 |
||
58 | 62 |
lemma tRAG_mono: |
63 |
assumes "RAG s' \<subseteq> RAG s" |
|
64 |
shows "tRAG s' \<subseteq> tRAG s" |
|
65 |
using assms |
|
66 |
by (unfold tRAG_alt_def, auto) |
|
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
67 |
|
58 | 68 |
lemma holding_next_thI: |
69 |
assumes "holding s th cs" |
|
70 |
and "length (wq s cs) > 1" |
|
71 |
obtains th' where "next_th s th cs th'" |
|
72 |
proof - |
|
73 |
from assms(1)[folded eq_holding, unfolded cs_holding_def] |
|
74 |
have " th \<in> set (wq s cs) \<and> th = hd (wq s cs)" . |
|
75 |
then obtain rest where h1: "wq s cs = th#rest" |
|
76 |
by (cases "wq s cs", auto) |
|
77 |
with assms(2) have h2: "rest \<noteq> []" by auto |
|
78 |
let ?th' = "hd (SOME q. distinct q \<and> set q = set rest)" |
|
79 |
have "next_th s th cs ?th'" using h1(1) h2 |
|
80 |
by (unfold next_th_def, auto) |
|
81 |
from that[OF this] show ?thesis . |
|
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
82 |
qed |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
83 |
|
58 | 84 |
lemma RAG_tRAG_transfer: |
85 |
assumes "vt s'" |
|
86 |
assumes "RAG s = RAG s' \<union> {(Th th, Cs cs)}" |
|
87 |
and "(Cs cs, Th th'') \<in> RAG s'" |
|
88 |
shows "tRAG s = tRAG s' \<union> {(Th th, Th th'')}" (is "?L = ?R") |
|
89 |
proof - |
|
90 |
interpret rtree: rtree "RAG s'" |
|
91 |
proof |
|
92 |
show "single_valued (RAG s')" |
|
93 |
apply (intro_locales) |
|
94 |
by (unfold single_valued_def, |
|
95 |
auto intro:unique_RAG[OF assms(1)]) |
|
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
96 |
|
58 | 97 |
show "acyclic (RAG s')" |
98 |
by (rule acyclic_RAG[OF assms(1)]) |
|
99 |
qed |
|
100 |
{ fix n1 n2 |
|
101 |
assume "(n1, n2) \<in> ?L" |
|
102 |
from this[unfolded tRAG_alt_def] |
|
103 |
obtain th1 th2 cs' where |
|
104 |
h: "n1 = Th th1" "n2 = Th th2" |
|
105 |
"(Th th1, Cs cs') \<in> RAG s" |
|
106 |
"(Cs cs', Th th2) \<in> RAG s" by auto |
|
107 |
from h(4) and assms(2) have cs_in: "(Cs cs', Th th2) \<in> RAG s'" by auto |
|
108 |
from h(3) and assms(2) |
|
109 |
have "(Th th1, Cs cs') = (Th th, Cs cs) \<or> |
|
110 |
(Th th1, Cs cs') \<in> RAG s'" by auto |
|
111 |
hence "(n1, n2) \<in> ?R" |
|
112 |
proof |
|
113 |
assume h1: "(Th th1, Cs cs') = (Th th, Cs cs)" |
|
114 |
hence eq_th1: "th1 = th" by simp |
|
115 |
moreover have "th2 = th''" |
|
116 |
proof - |
|
117 |
from h1 have "cs' = cs" by simp |
|
118 |
from assms(3) cs_in[unfolded this] rtree.sgv |
|
119 |
show ?thesis |
|
120 |
by (unfold single_valued_def, auto) |
|
121 |
qed |
|
122 |
ultimately show ?thesis using h(1,2) by auto |
|
123 |
next |
|
124 |
assume "(Th th1, Cs cs') \<in> RAG s'" |
|
125 |
with cs_in have "(Th th1, Th th2) \<in> tRAG s'" |
|
126 |
by (unfold tRAG_alt_def, auto) |
|
127 |
from this[folded h(1, 2)] show ?thesis by auto |
|
128 |
qed |
|
129 |
} moreover { |
|
130 |
fix n1 n2 |
|
131 |
assume "(n1, n2) \<in> ?R" |
|
132 |
hence "(n1, n2) \<in>tRAG s' \<or> (n1, n2) = (Th th, Th th'')" by auto |
|
133 |
hence "(n1, n2) \<in> ?L" |
|
134 |
proof |
|
135 |
assume "(n1, n2) \<in> tRAG s'" |
|
136 |
moreover have "... \<subseteq> ?L" |
|
137 |
proof(rule tRAG_mono) |
|
138 |
show "RAG s' \<subseteq> RAG s" by (unfold assms(2), auto) |
|
139 |
qed |
|
140 |
ultimately show ?thesis by auto |
|
141 |
next |
|
142 |
assume eq_n: "(n1, n2) = (Th th, Th th'')" |
|
143 |
from assms(2, 3) have "(Cs cs, Th th'') \<in> RAG s" by auto |
|
144 |
moreover have "(Th th, Cs cs) \<in> RAG s" using assms(2) by auto |
|
145 |
ultimately show ?thesis |
|
146 |
by (unfold eq_n tRAG_alt_def, auto) |
|
147 |
qed |
|
148 |
} ultimately show ?thesis by auto |
|
149 |
qed |
|
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
150 |
|
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
151 |
lemma cp_alt_def: |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
152 |
"cp s th = |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
153 |
Max ((the_preced s) ` {th'. Th th' \<in> (subtree (RAG s) (Th th))})" |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
154 |
proof - |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
155 |
have "Max (the_preced s ` ({th} \<union> dependants (wq s) th)) = |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
156 |
Max (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)})" |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
157 |
(is "Max (_ ` ?L) = Max (_ ` ?R)") |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
158 |
proof - |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
159 |
have "?L = ?R" |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
160 |
by (auto dest:rtranclD simp:cs_dependants_def cs_RAG_def s_RAG_def subtree_def) |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
161 |
thus ?thesis by simp |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
162 |
qed |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
163 |
thus ?thesis by (unfold cp_eq_cpreced cpreced_def, fold the_preced_def, simp) |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
164 |
qed |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
165 |
|
58 | 166 |
lemma cp_gen_alt_def: |
167 |
"cp_gen s = (Max \<circ> (\<lambda>x. (the_preced s \<circ> the_thread) ` subtree (tRAG s) x))" |
|
168 |
by (auto simp:cp_gen_def) |
|
169 |
||
170 |
lemma tRAG_nodeE: |
|
171 |
assumes "(n1, n2) \<in> tRAG s" |
|
172 |
obtains th1 th2 where "n1 = Th th1" "n2 = Th th2" |
|
173 |
using assms |
|
174 |
by (auto simp: tRAG_def wRAG_def hRAG_def tRAG_def) |
|
175 |
||
176 |
lemma subtree_nodeE: |
|
177 |
assumes "n \<in> subtree (tRAG s) (Th th)" |
|
178 |
obtains th1 where "n = Th th1" |
|
179 |
proof - |
|
180 |
show ?thesis |
|
181 |
proof(rule subtreeE[OF assms]) |
|
182 |
assume "n = Th th" |
|
183 |
from that[OF this] show ?thesis . |
|
184 |
next |
|
185 |
assume "Th th \<in> ancestors (tRAG s) n" |
|
186 |
hence "(n, Th th) \<in> (tRAG s)^+" by (auto simp:ancestors_def) |
|
187 |
hence "\<exists> th1. n = Th th1" |
|
188 |
proof(induct) |
|
189 |
case (base y) |
|
190 |
from tRAG_nodeE[OF this] show ?case by metis |
|
191 |
next |
|
192 |
case (step y z) |
|
193 |
thus ?case by auto |
|
194 |
qed |
|
195 |
with that show ?thesis by auto |
|
196 |
qed |
|
197 |
qed |
|
198 |
||
60 | 199 |
lemma tRAG_star_RAG: "(tRAG s)^* \<subseteq> (RAG s)^*" |
200 |
proof - |
|
201 |
have "(wRAG s O hRAG s)^* \<subseteq> (RAG s O RAG s)^*" |
|
202 |
by (rule rtrancl_mono, auto simp:RAG_split) |
|
203 |
also have "... \<subseteq> ((RAG s)^*)^*" |
|
204 |
by (rule rtrancl_mono, auto) |
|
205 |
also have "... = (RAG s)^*" by simp |
|
206 |
finally show ?thesis by (unfold tRAG_def, simp) |
|
207 |
qed |
|
208 |
||
209 |
lemma tRAG_subtree_RAG: "subtree (tRAG s) x \<subseteq> subtree (RAG s) x" |
|
58 | 210 |
proof - |
60 | 211 |
{ fix a |
212 |
assume "a \<in> subtree (tRAG s) x" |
|
213 |
hence "(a, x) \<in> (tRAG s)^*" by (auto simp:subtree_def) |
|
214 |
with tRAG_star_RAG[of s] |
|
215 |
have "(a, x) \<in> (RAG s)^*" by auto |
|
216 |
hence "a \<in> subtree (RAG s) x" by (auto simp:subtree_def) |
|
217 |
} thus ?thesis by auto |
|
218 |
qed |
|
219 |
||
220 |
lemma tRAG_subtree_eq: |
|
221 |
"(subtree (tRAG s) (Th th)) = {Th th' | th'. Th th' \<in> (subtree (RAG s) (Th th))}" |
|
222 |
(is "?L = ?R") |
|
223 |
proof - |
|
224 |
{ fix n |
|
225 |
assume "n \<in> ?L" |
|
226 |
with subtree_nodeE[OF this] |
|
227 |
obtain th' where "n = Th th'" "Th th' \<in> subtree (tRAG s) (Th th)" by auto |
|
228 |
with tRAG_subtree_RAG[of s "Th th"] |
|
229 |
have "n \<in> ?R" by auto |
|
58 | 230 |
} moreover { |
60 | 231 |
fix n |
232 |
assume "n \<in> ?R" |
|
233 |
then obtain th' where h: "n = Th th'" "(Th th', Th th) \<in> (RAG s)^*" |
|
234 |
by (auto simp:subtree_def) |
|
235 |
from star_rpath[OF this(2)] |
|
58 | 236 |
obtain xs where "rpath (RAG s) (Th th') xs (Th th)" by auto |
237 |
hence "Th th' \<in> subtree (tRAG s) (Th th)" |
|
238 |
proof(induct xs arbitrary:th' th rule:length_induct) |
|
239 |
case (1 xs th' th) |
|
240 |
show ?case |
|
241 |
proof(cases xs) |
|
242 |
case Nil |
|
243 |
from rpath_nilE[OF 1(2)[unfolded this]] |
|
244 |
have "th' = th" by auto |
|
245 |
thus ?thesis by (auto simp:subtree_def) |
|
246 |
next |
|
247 |
case (Cons x1 xs1) note Cons1 = Cons |
|
248 |
show ?thesis |
|
249 |
proof(cases "xs1") |
|
250 |
case Nil |
|
251 |
from 1(2)[unfolded Cons[unfolded this]] |
|
252 |
have rp: "rpath (RAG s) (Th th') [x1] (Th th)" . |
|
253 |
hence "(Th th', x1) \<in> (RAG s)" by (cases, simp) |
|
254 |
then obtain cs where "x1 = Cs cs" |
|
255 |
by (unfold s_RAG_def, auto) |
|
256 |
from rpath_nnl_lastE[OF rp[unfolded this]] |
|
257 |
show ?thesis by auto |
|
258 |
next |
|
259 |
case (Cons x2 xs2) |
|
260 |
from 1(2)[unfolded Cons1[unfolded this]] |
|
261 |
have rp: "rpath (RAG s) (Th th') (x1 # x2 # xs2) (Th th)" . |
|
262 |
from rpath_edges_on[OF this] |
|
263 |
have eds: "edges_on (Th th' # x1 # x2 # xs2) \<subseteq> RAG s" . |
|
264 |
have "(Th th', x1) \<in> edges_on (Th th' # x1 # x2 # xs2)" |
|
265 |
by (simp add: edges_on_unfold) |
|
266 |
with eds have rg1: "(Th th', x1) \<in> RAG s" by auto |
|
267 |
then obtain cs1 where eq_x1: "x1 = Cs cs1" by (unfold s_RAG_def, auto) |
|
268 |
have "(x1, x2) \<in> edges_on (Th th' # x1 # x2 # xs2)" |
|
269 |
by (simp add: edges_on_unfold) |
|
270 |
from this eds |
|
271 |
have rg2: "(x1, x2) \<in> RAG s" by auto |
|
272 |
from this[unfolded eq_x1] |
|
273 |
obtain th1 where eq_x2: "x2 = Th th1" by (unfold s_RAG_def, auto) |
|
274 |
from rp have "rpath (RAG s) x2 xs2 (Th th)" |
|
275 |
by (elim rpath_ConsE, simp) |
|
276 |
from this[unfolded eq_x2] have rp': "rpath (RAG s) (Th th1) xs2 (Th th)" . |
|
277 |
from 1(1)[rule_format, OF _ this, unfolded Cons1 Cons] |
|
278 |
have "Th th1 \<in> subtree (tRAG s) (Th th)" by simp |
|
279 |
moreover have "(Th th', Th th1) \<in> (tRAG s)^*" |
|
280 |
proof - |
|
281 |
from rg1[unfolded eq_x1] rg2[unfolded eq_x1 eq_x2] |
|
282 |
show ?thesis by (unfold RAG_split tRAG_def wRAG_def hRAG_def, auto) |
|
283 |
qed |
|
284 |
ultimately show ?thesis by (auto simp:subtree_def) |
|
285 |
qed |
|
286 |
qed |
|
287 |
qed |
|
60 | 288 |
from this[folded h(1)] |
289 |
have "n \<in> ?L" . |
|
58 | 290 |
} ultimately show ?thesis by auto |
291 |
qed |
|
60 | 292 |
|
293 |
lemma threads_set_eq: |
|
294 |
"the_thread ` (subtree (tRAG s) (Th th)) = |
|
295 |
{th'. Th th' \<in> (subtree (RAG s) (Th th))}" (is "?L = ?R") |
|
296 |
by (auto intro:rev_image_eqI simp:tRAG_subtree_eq) |
|
297 |
||
58 | 298 |
lemma cp_alt_def1: |
299 |
"cp s th = Max ((the_preced s o the_thread) ` (subtree (tRAG s) (Th th)))" |
|
300 |
proof - |
|
301 |
have "(the_preced s ` the_thread ` subtree (tRAG s) (Th th)) = |
|
302 |
((the_preced s \<circ> the_thread) ` subtree (tRAG s) (Th th))" |
|
303 |
by auto |
|
304 |
thus ?thesis by (unfold cp_alt_def, fold threads_set_eq, auto) |
|
305 |
qed |
|
306 |
||
307 |
lemma cp_gen_def_cond: |
|
308 |
assumes "x = Th th" |
|
309 |
shows "cp s th = cp_gen s (Th th)" |
|
310 |
by (unfold cp_alt_def1 cp_gen_def, simp) |
|
311 |
||
312 |
lemma cp_gen_over_set: |
|
313 |
assumes "\<forall> x \<in> A. \<exists> th. x = Th th" |
|
314 |
shows "cp_gen s ` A = (cp s \<circ> the_thread) ` A" |
|
315 |
proof(rule f_image_eq) |
|
316 |
fix a |
|
317 |
assume "a \<in> A" |
|
318 |
from assms[rule_format, OF this] |
|
319 |
obtain th where eq_a: "a = Th th" by auto |
|
320 |
show "cp_gen s a = (cp s \<circ> the_thread) a" |
|
321 |
by (unfold eq_a, simp, unfold cp_gen_def_cond[OF refl[of "Th th"]], simp) |
|
322 |
qed |
|
323 |
||
324 |
locale valid_trace = |
|
325 |
fixes s |
|
326 |
assumes vt : "vt s" |
|
327 |
||
328 |
context valid_trace |
|
329 |
begin |
|
330 |
||
61 | 331 |
lemma readys_root: |
332 |
assumes "th \<in> readys s" |
|
333 |
shows "root (RAG s) (Th th)" |
|
334 |
proof - |
|
335 |
{ fix x |
|
336 |
assume "x \<in> ancestors (RAG s) (Th th)" |
|
337 |
hence h: "(Th th, x) \<in> (RAG s)^+" by (auto simp:ancestors_def) |
|
338 |
from tranclD[OF this] |
|
339 |
obtain z where "(Th th, z) \<in> RAG s" by auto |
|
340 |
with assms(1) have False |
|
341 |
apply (case_tac z, auto simp:readys_def s_RAG_def s_waiting_def cs_waiting_def) |
|
342 |
by (fold wq_def, blast) |
|
343 |
} thus ?thesis by (unfold root_def, auto) |
|
344 |
qed |
|
345 |
||
346 |
lemma readys_in_no_subtree: |
|
347 |
assumes "th \<in> readys s" |
|
348 |
and "th' \<noteq> th" |
|
349 |
shows "Th th \<notin> subtree (RAG s) (Th th')" |
|
350 |
proof |
|
351 |
assume "Th th \<in> subtree (RAG s) (Th th')" |
|
352 |
thus False |
|
353 |
proof(cases rule:subtreeE) |
|
354 |
case 1 |
|
355 |
with assms show ?thesis by auto |
|
356 |
next |
|
357 |
case 2 |
|
358 |
with readys_root[OF assms(1)] |
|
359 |
show ?thesis by (auto simp:root_def) |
|
360 |
qed |
|
361 |
qed |
|
362 |
||
60 | 363 |
lemma not_in_thread_isolated: |
364 |
assumes "th \<notin> threads s" |
|
365 |
shows "(Th th) \<notin> Field (RAG s)" |
|
366 |
proof |
|
367 |
assume "(Th th) \<in> Field (RAG s)" |
|
368 |
with dm_RAG_threads[OF vt] and range_in[OF vt] assms |
|
369 |
show False by (unfold Field_def, blast) |
|
370 |
qed |
|
371 |
||
58 | 372 |
lemma wf_RAG: "wf (RAG s)" |
373 |
proof(rule finite_acyclic_wf) |
|
374 |
from finite_RAG[OF vt] show "finite (RAG s)" . |
|
375 |
next |
|
376 |
from acyclic_RAG[OF vt] show "acyclic (RAG s)" . |
|
377 |
qed |
|
378 |
||
379 |
lemma sgv_wRAG: "single_valued (wRAG s)" |
|
380 |
using waiting_unique[OF vt] |
|
381 |
by (unfold single_valued_def wRAG_def, auto) |
|
382 |
||
383 |
lemma sgv_hRAG: "single_valued (hRAG s)" |
|
384 |
using holding_unique |
|
385 |
by (unfold single_valued_def hRAG_def, auto) |
|
386 |
||
387 |
lemma sgv_tRAG: "single_valued (tRAG s)" |
|
388 |
by (unfold tRAG_def, rule single_valued_relcomp, |
|
389 |
insert sgv_wRAG sgv_hRAG, auto) |
|
390 |
||
391 |
lemma acyclic_tRAG: "acyclic (tRAG s)" |
|
392 |
proof(unfold tRAG_def, rule acyclic_compose) |
|
393 |
show "acyclic (RAG s)" using acyclic_RAG[OF vt] . |
|
394 |
next |
|
395 |
show "wRAG s \<subseteq> RAG s" unfolding RAG_split by auto |
|
396 |
next |
|
397 |
show "hRAG s \<subseteq> RAG s" unfolding RAG_split by auto |
|
398 |
qed |
|
399 |
||
400 |
lemma sgv_RAG: "single_valued (RAG s)" |
|
401 |
using unique_RAG[OF vt] by (auto simp:single_valued_def) |
|
402 |
||
403 |
lemma rtree_RAG: "rtree (RAG s)" |
|
404 |
using sgv_RAG acyclic_RAG[OF vt] |
|
405 |
by (unfold rtree_def rtree_axioms_def sgv_def, auto) |
|
61 | 406 |
end |
58 | 407 |
|
61 | 408 |
|
409 |
sublocale valid_trace < rtree_RAG: rtree "RAG s" |
|
410 |
proof |
|
411 |
show "single_valued (RAG s)" |
|
412 |
apply (intro_locales) |
|
413 |
by (unfold single_valued_def, |
|
414 |
auto intro:unique_RAG[OF vt]) |
|
415 |
||
416 |
show "acyclic (RAG s)" |
|
417 |
by (rule acyclic_RAG[OF vt]) |
|
418 |
qed |
|
58 | 419 |
|
420 |
sublocale valid_trace < rtree_s: rtree "tRAG s" |
|
421 |
proof(unfold_locales) |
|
422 |
from sgv_tRAG show "single_valued (tRAG s)" . |
|
423 |
next |
|
424 |
from acyclic_tRAG show "acyclic (tRAG s)" . |
|
425 |
qed |
|
426 |
||
427 |
sublocale valid_trace < fsbtRAGs : fsubtree "RAG s" |
|
428 |
proof - |
|
429 |
show "fsubtree (RAG s)" |
|
430 |
proof(intro_locales) |
|
431 |
show "fbranch (RAG s)" using finite_fbranchI[OF finite_RAG[OF vt]] . |
|
432 |
next |
|
433 |
show "fsubtree_axioms (RAG s)" |
|
434 |
proof(unfold fsubtree_axioms_def) |
|
435 |
find_theorems wf RAG |
|
436 |
from wf_RAG show "wf (RAG s)" . |
|
437 |
qed |
|
438 |
qed |
|
439 |
qed |
|
440 |
||
441 |
sublocale valid_trace < fsbttRAGs: fsubtree "tRAG s" |
|
442 |
proof - |
|
443 |
have "fsubtree (tRAG s)" |
|
444 |
proof - |
|
445 |
have "fbranch (tRAG s)" |
|
446 |
proof(unfold tRAG_def, rule fbranch_compose) |
|
447 |
show "fbranch (wRAG s)" |
|
448 |
proof(rule finite_fbranchI) |
|
449 |
from finite_RAG[OF vt] show "finite (wRAG s)" |
|
450 |
by (unfold RAG_split, auto) |
|
451 |
qed |
|
452 |
next |
|
453 |
show "fbranch (hRAG s)" |
|
454 |
proof(rule finite_fbranchI) |
|
455 |
from finite_RAG[OF vt] |
|
456 |
show "finite (hRAG s)" by (unfold RAG_split, auto) |
|
457 |
qed |
|
458 |
qed |
|
459 |
moreover have "wf (tRAG s)" |
|
460 |
proof(rule wf_subset) |
|
461 |
show "wf (RAG s O RAG s)" using wf_RAG |
|
462 |
by (fold wf_comp_self, simp) |
|
463 |
next |
|
464 |
show "tRAG s \<subseteq> (RAG s O RAG s)" |
|
465 |
by (unfold tRAG_alt_def, auto) |
|
466 |
qed |
|
467 |
ultimately show ?thesis |
|
468 |
by (unfold fsubtree_def fsubtree_axioms_def,auto) |
|
469 |
qed |
|
470 |
from this[folded tRAG_def] show "fsubtree (tRAG s)" . |
|
471 |
qed |
|
472 |
||
473 |
lemma Max_UNION: |
|
474 |
assumes "finite A" |
|
475 |
and "A \<noteq> {}" |
|
476 |
and "\<forall> M \<in> f ` A. finite M" |
|
477 |
and "\<forall> M \<in> f ` A. M \<noteq> {}" |
|
478 |
shows "Max (\<Union>x\<in> A. f x) = Max (Max ` f ` A)" (is "?L = ?R") |
|
479 |
using assms[simp] |
|
480 |
proof - |
|
481 |
have "?L = Max (\<Union>(f ` A))" |
|
482 |
by (fold Union_image_eq, simp) |
|
483 |
also have "... = ?R" |
|
484 |
by (subst Max_Union, simp+) |
|
485 |
finally show ?thesis . |
|
486 |
qed |
|
487 |
||
488 |
lemma max_Max_eq: |
|
489 |
assumes "finite A" |
|
490 |
and "A \<noteq> {}" |
|
491 |
and "x = y" |
|
492 |
shows "max x (Max A) = Max ({y} \<union> A)" (is "?L = ?R") |
|
493 |
proof - |
|
494 |
have "?R = Max (insert y A)" by simp |
|
495 |
also from assms have "... = ?L" |
|
496 |
by (subst Max.insert, simp+) |
|
497 |
finally show ?thesis by simp |
|
498 |
qed |
|
499 |
||
500 |
context valid_trace |
|
501 |
begin |
|
502 |
||
503 |
(* ddd *) |
|
504 |
lemma cp_gen_rec: |
|
505 |
assumes "x = Th th" |
|
506 |
shows "cp_gen s x = Max ({the_preced s th} \<union> (cp_gen s) ` children (tRAG s) x)" |
|
507 |
proof(cases "children (tRAG s) x = {}") |
|
508 |
case True |
|
509 |
show ?thesis |
|
510 |
by (unfold True cp_gen_def subtree_children, simp add:assms) |
|
511 |
next |
|
512 |
case False |
|
513 |
hence [simp]: "children (tRAG s) x \<noteq> {}" by auto |
|
514 |
note fsbttRAGs.finite_subtree[simp] |
|
515 |
have [simp]: "finite (children (tRAG s) x)" |
|
516 |
by (intro rev_finite_subset[OF fsbttRAGs.finite_subtree], |
|
517 |
rule children_subtree) |
|
518 |
{ fix r x |
|
519 |
have "subtree r x \<noteq> {}" by (auto simp:subtree_def) |
|
520 |
} note this[simp] |
|
521 |
have [simp]: "\<exists>x\<in>children (tRAG s) x. subtree (tRAG s) x \<noteq> {}" |
|
522 |
proof - |
|
523 |
from False obtain q where "q \<in> children (tRAG s) x" by blast |
|
524 |
moreover have "subtree (tRAG s) q \<noteq> {}" by simp |
|
525 |
ultimately show ?thesis by blast |
|
526 |
qed |
|
527 |
have h: "Max ((the_preced s \<circ> the_thread) ` |
|
528 |
({x} \<union> \<Union>(subtree (tRAG s) ` children (tRAG s) x))) = |
|
529 |
Max ({the_preced s th} \<union> cp_gen s ` children (tRAG s) x)" |
|
530 |
(is "?L = ?R") |
|
531 |
proof - |
|
532 |
let "Max (?f ` (?A \<union> \<Union> (?g ` ?B)))" = ?L |
|
533 |
let "Max (_ \<union> (?h ` ?B))" = ?R |
|
534 |
let ?L1 = "?f ` \<Union>(?g ` ?B)" |
|
535 |
have eq_Max_L1: "Max ?L1 = Max (?h ` ?B)" |
|
536 |
proof - |
|
537 |
have "?L1 = ?f ` (\<Union> x \<in> ?B.(?g x))" by simp |
|
538 |
also have "... = (\<Union> x \<in> ?B. ?f ` (?g x))" by auto |
|
539 |
finally have "Max ?L1 = Max ..." by simp |
|
540 |
also have "... = Max (Max ` (\<lambda>x. ?f ` subtree (tRAG s) x) ` ?B)" |
|
541 |
by (subst Max_UNION, simp+) |
|
542 |
also have "... = Max (cp_gen s ` children (tRAG s) x)" |
|
543 |
by (unfold image_comp cp_gen_alt_def, simp) |
|
544 |
finally show ?thesis . |
|
545 |
qed |
|
546 |
show ?thesis |
|
547 |
proof - |
|
548 |
have "?L = Max (?f ` ?A \<union> ?L1)" by simp |
|
549 |
also have "... = max (the_preced s (the_thread x)) (Max ?L1)" |
|
550 |
by (subst Max_Un, simp+) |
|
551 |
also have "... = max (?f x) (Max (?h ` ?B))" |
|
552 |
by (unfold eq_Max_L1, simp) |
|
553 |
also have "... =?R" |
|
554 |
by (rule max_Max_eq, (simp)+, unfold assms, simp) |
|
555 |
finally show ?thesis . |
|
556 |
qed |
|
557 |
qed thus ?thesis |
|
558 |
by (fold h subtree_children, unfold cp_gen_def, simp) |
|
559 |
qed |
|
560 |
||
561 |
lemma cp_rec: |
|
562 |
"cp s th = Max ({the_preced s th} \<union> |
|
563 |
(cp s o the_thread) ` children (tRAG s) (Th th))" |
|
564 |
proof - |
|
565 |
have "Th th = Th th" by simp |
|
566 |
note h = cp_gen_def_cond[OF this] cp_gen_rec[OF this] |
|
567 |
show ?thesis |
|
568 |
proof - |
|
569 |
have "cp_gen s ` children (tRAG s) (Th th) = |
|
570 |
(cp s \<circ> the_thread) ` children (tRAG s) (Th th)" |
|
571 |
proof(rule cp_gen_over_set) |
|
572 |
show " \<forall>x\<in>children (tRAG s) (Th th). \<exists>th. x = Th th" |
|
573 |
by (unfold tRAG_alt_def, auto simp:children_def) |
|
574 |
qed |
|
575 |
thus ?thesis by (subst (1) h(1), unfold h(2), simp) |
|
576 |
qed |
|
577 |
qed |
|
578 |
||
579 |
end |
|
580 |
||
61 | 581 |
(* keep *) |
58 | 582 |
lemma next_th_holding: |
583 |
assumes vt: "vt s" |
|
584 |
and nxt: "next_th s th cs th'" |
|
585 |
shows "holding (wq s) th cs" |
|
586 |
proof - |
|
587 |
from nxt[unfolded next_th_def] |
|
588 |
obtain rest where h: "wq s cs = th # rest" |
|
589 |
"rest \<noteq> []" |
|
590 |
"th' = hd (SOME q. distinct q \<and> set q = set rest)" by auto |
|
591 |
thus ?thesis |
|
592 |
by (unfold cs_holding_def, auto) |
|
593 |
qed |
|
594 |
||
595 |
lemma next_th_waiting: |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
596 |
assumes vt: "vt s" |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
597 |
and nxt: "next_th s th cs th'" |
58 | 598 |
shows "waiting (wq s) th' cs" |
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
599 |
proof - |
58 | 600 |
from nxt[unfolded next_th_def] |
601 |
obtain rest where h: "wq s cs = th # rest" |
|
602 |
"rest \<noteq> []" |
|
603 |
"th' = hd (SOME q. distinct q \<and> set q = set rest)" by auto |
|
604 |
from wq_distinct[OF vt, of cs, unfolded h] |
|
605 |
have dst: "distinct (th # rest)" . |
|
606 |
have in_rest: "th' \<in> set rest" |
|
607 |
proof(unfold h, rule someI2) |
|
608 |
show "distinct rest \<and> set rest = set rest" using dst by auto |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
609 |
next |
58 | 610 |
fix x assume "distinct x \<and> set x = set rest" |
611 |
with h(2) |
|
612 |
show "hd x \<in> set (rest)" by (cases x, auto) |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
613 |
qed |
58 | 614 |
hence "th' \<in> set (wq s cs)" by (unfold h(1), auto) |
615 |
moreover have "th' \<noteq> hd (wq s cs)" |
|
616 |
by (unfold h(1), insert in_rest dst, auto) |
|
617 |
ultimately show ?thesis by (auto simp:cs_waiting_def) |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
618 |
qed |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
619 |
|
58 | 620 |
lemma next_th_RAG: |
621 |
assumes vt: "vt s" |
|
622 |
and nxt: "next_th s th cs th'" |
|
623 |
shows "{(Cs cs, Th th), (Th th', Cs cs)} \<subseteq> RAG s" |
|
624 |
using assms next_th_holding next_th_waiting |
|
625 |
by (unfold s_RAG_def, simp) |
|
626 |
||
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
627 |
-- {* A useless definition *} |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
628 |
definition cps:: "state \<Rightarrow> (thread \<times> precedence) set" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
629 |
where "cps s = {(th, cp s th) | th . th \<in> threads s}" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
630 |
|
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
631 |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
632 |
text {* (* ddd *) |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
633 |
One beauty of our modelling is that we follow the definitional extension tradition of HOL. |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
634 |
The benefit of such a concise and miniature model is that large number of intuitively |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
635 |
obvious facts are derived as lemmas, rather than asserted as axioms. |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
636 |
*} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
637 |
|
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
638 |
text {* |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
639 |
However, the lemmas in the forthcoming several locales are no longer |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
640 |
obvious. These lemmas show how the current precedences should be recalculated |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
641 |
after every execution step (in our model, every step is represented by an event, |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
642 |
which in turn, represents a system call, or operation). Each operation is |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
643 |
treated in a separate locale. |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
644 |
|
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
645 |
The complication of current precedence recalculation comes |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
646 |
because the changing of RAG needs to be taken into account, |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
647 |
in addition to the changing of precedence. |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
648 |
The reason RAG changing affects current precedence is that, |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
649 |
according to the definition, current precedence |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
650 |
of a thread is the maximum of the precedences of its dependants, |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
651 |
where the dependants are defined in terms of RAG. |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
652 |
|
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
653 |
Therefore, each operation, lemmas concerning the change of the precedences |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
654 |
and RAG are derived first, so that the lemmas about |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
655 |
current precedence recalculation can be based on. |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
656 |
*} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
657 |
|
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
658 |
text {* (* ddd *) |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
659 |
The following locale @{text "step_set_cps"} investigates the recalculation |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
660 |
after the @{text "Set"} operation. |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
661 |
*} |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
662 |
locale step_set_cps = |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
663 |
fixes s' th prio s |
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
664 |
-- {* @{text "s'"} is the system state before the operation *} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
665 |
-- {* @{text "s"} is the system state after the operation *} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
666 |
defines s_def : "s \<equiv> (Set th prio#s')" |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
667 |
-- {* @{text "s"} is assumed to be a legitimate state, from which |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
668 |
the legitimacy of @{text "s"} can be derived. *} |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
669 |
assumes vt_s: "vt s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
670 |
|
61 | 671 |
sublocale step_set_cps < vat_s : valid_trace "s" |
672 |
proof |
|
673 |
from vt_s show "vt s" . |
|
674 |
qed |
|
675 |
||
676 |
sublocale step_set_cps < vat_s' : valid_trace "s'" |
|
677 |
proof |
|
678 |
from step_back_vt[OF vt_s[unfolded s_def]] show "vt s'" . |
|
679 |
qed |
|
680 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
681 |
context step_set_cps |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
682 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
683 |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
684 |
text {* (* ddd *) |
58 | 685 |
The following two lemmas confirm that @{text "Set"}-operating only changes the precedence |
686 |
of the initiating thread. |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
687 |
*} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
688 |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
689 |
lemma eq_preced: |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
690 |
assumes "th' \<noteq> th" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
691 |
shows "preced th' s = preced th' s'" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
692 |
proof - |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
693 |
from assms show ?thesis |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
694 |
by (unfold s_def, auto simp:preced_def) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
695 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
696 |
|
58 | 697 |
lemma eq_the_preced: |
698 |
fixes th' |
|
699 |
assumes "th' \<noteq> th" |
|
700 |
shows "the_preced s th' = the_preced s' th'" |
|
701 |
using assms |
|
702 |
by (unfold the_preced_def, intro eq_preced, simp) |
|
703 |
||
704 |
text {* |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
705 |
The following lemma assures that the resetting of priority does not change the RAG. |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
706 |
*} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
707 |
|
35
92f61f6a0fe7
added a bit more text to the paper and separated a theory about Max
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
708 |
lemma eq_dep: "RAG s = RAG s'" |
92f61f6a0fe7
added a bit more text to the paper and separated a theory about Max
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
709 |
by (unfold s_def RAG_set_unchanged, auto) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
710 |
|
58 | 711 |
text {* (* ddd *) |
712 |
Th following lemma @{text "eq_cp_pre"} says the priority change of @{text "th"} |
|
713 |
only affects those threads, which as @{text "Th th"} in their sub-trees. |
|
714 |
||
715 |
The proof of this lemma is simplified by using the alternative definition of @{text "cp"}. |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
716 |
*} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
717 |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
718 |
lemma eq_cp_pre: |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
719 |
fixes th' |
58 | 720 |
assumes nd: "Th th \<notin> subtree (RAG s') (Th th')" |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
721 |
shows "cp s th' = cp s' th'" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
722 |
proof - |
58 | 723 |
-- {* After unfolding using the alternative definition, elements |
724 |
affecting the @{term "cp"}-value of threads become explicit. |
|
725 |
We only need to prove the following: *} |
|
726 |
have "Max (the_preced s ` {th'a. Th th'a \<in> subtree (RAG s) (Th th')}) = |
|
727 |
Max (the_preced s' ` {th'a. Th th'a \<in> subtree (RAG s') (Th th')})" |
|
728 |
(is "Max (?f ` ?S1) = Max (?g ` ?S2)") |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
729 |
proof - |
58 | 730 |
-- {* The base sets are equal. *} |
731 |
have "?S1 = ?S2" using eq_dep by simp |
|
732 |
-- {* The function values on the base set are equal as well. *} |
|
733 |
moreover have "\<forall> e \<in> ?S2. ?f e = ?g e" |
|
734 |
proof |
|
735 |
fix th1 |
|
736 |
assume "th1 \<in> ?S2" |
|
737 |
with nd have "th1 \<noteq> th" by (auto) |
|
738 |
from eq_the_preced[OF this] |
|
739 |
show "the_preced s th1 = the_preced s' th1" . |
|
740 |
qed |
|
741 |
-- {* Therefore, the image of the functions are equal. *} |
|
742 |
ultimately have "(?f ` ?S1) = (?g ` ?S2)" by (auto intro!:f_image_eq) |
|
743 |
thus ?thesis by simp |
|
744 |
qed |
|
745 |
thus ?thesis by (simp add:cp_alt_def) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
746 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
747 |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
748 |
text {* |
58 | 749 |
The following lemma shows that @{term "th"} is not in the |
750 |
sub-tree of any other thread. |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
751 |
*} |
58 | 752 |
lemma th_in_no_subtree: |
753 |
assumes "th' \<noteq> th" |
|
754 |
shows "Th th \<notin> subtree (RAG s') (Th th')" |
|
755 |
proof - |
|
756 |
have "th \<in> readys s'" |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
757 |
proof - |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
758 |
from step_back_step [OF vt_s[unfolded s_def]] |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
759 |
have "step s' (Set th prio)" . |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
760 |
hence "th \<in> runing s'" by (cases, simp) |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
761 |
thus ?thesis by (simp add:readys_def runing_def) |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
762 |
qed |
61 | 763 |
find_theorems readys subtree |
764 |
from vat_s'.readys_in_no_subtree[OF this assms(1)] |
|
58 | 765 |
show ?thesis by blast |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
766 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
767 |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
768 |
text {* |
58 | 769 |
By combining @{thm "eq_cp_pre"} and @{thm "th_in_no_subtree"}, |
770 |
it is obvious that the change of priority only affects the @{text "cp"}-value |
|
771 |
of the initiating thread @{text "th"}. |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
772 |
*} |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
773 |
lemma eq_cp: |
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
774 |
fixes th' |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
775 |
assumes "th' \<noteq> th" |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
776 |
shows "cp s th' = cp s' th'" |
58 | 777 |
by (rule eq_cp_pre[OF th_in_no_subtree[OF assms]]) |
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
778 |
|
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
779 |
end |
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
780 |
|
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
781 |
text {* |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
782 |
The following @{text "step_v_cps"} is the locale for @{text "V"}-operation. |
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
783 |
*} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
784 |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
785 |
locale step_v_cps = |
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
786 |
-- {* @{text "th"} is the initiating thread *} |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
787 |
-- {* @{text "cs"} is the critical resource release by the @{text "V"}-operation *} |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
788 |
fixes s' th cs s -- {* @{text "s'"} is the state before operation*} |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
789 |
defines s_def : "s \<equiv> (V th cs#s')" -- {* @{text "s"} is the state after operation*} |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
790 |
-- {* @{text "s"} is assumed to be valid, which implies the validity of @{text "s'"} *} |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
791 |
assumes vt_s: "vt s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
792 |
|
61 | 793 |
sublocale step_v_cps < vat_s : valid_trace "s" |
58 | 794 |
proof |
61 | 795 |
from vt_s show "vt s" . |
58 | 796 |
qed |
797 |
||
61 | 798 |
sublocale step_v_cps < vat_s' : valid_trace "s'" |
58 | 799 |
proof |
61 | 800 |
from step_back_vt[OF vt_s[unfolded s_def]] show "vt s'" . |
58 | 801 |
qed |
802 |
||
61 | 803 |
context step_v_cps |
804 |
begin |
|
58 | 805 |
|
806 |
lemma ready_th_s': "th \<in> readys s'" |
|
807 |
using step_back_step[OF vt_s[unfolded s_def]] |
|
808 |
by (cases, simp add:runing_def) |
|
809 |
||
810 |
lemma ancestors_th: "ancestors (RAG s') (Th th) = {}" |
|
811 |
proof - |
|
61 | 812 |
from vat_s'.readys_root[OF ready_th_s'] |
58 | 813 |
show ?thesis |
814 |
by (unfold root_def, simp) |
|
815 |
qed |
|
816 |
||
817 |
lemma holding_th: "holding s' th cs" |
|
818 |
proof - |
|
819 |
from vt_s[unfolded s_def] |
|
820 |
have " PIP s' (V th cs)" by (cases, simp) |
|
821 |
thus ?thesis by (cases, auto) |
|
822 |
qed |
|
823 |
||
824 |
lemma edge_of_th: |
|
825 |
"(Cs cs, Th th) \<in> RAG s'" |
|
826 |
proof - |
|
827 |
from holding_th |
|
828 |
show ?thesis |
|
829 |
by (unfold s_RAG_def holding_eq, auto) |
|
830 |
qed |
|
831 |
||
832 |
lemma ancestors_cs: |
|
833 |
"ancestors (RAG s') (Cs cs) = {Th th}" |
|
834 |
proof - |
|
835 |
have "ancestors (RAG s') (Cs cs) = ancestors (RAG s') (Th th) \<union> {Th th}" |
|
61 | 836 |
proof(rule vat_s'.rtree_RAG.ancestors_accum) |
58 | 837 |
from vt_s[unfolded s_def] |
838 |
have " PIP s' (V th cs)" by (cases, simp) |
|
839 |
thus "(Cs cs, Th th) \<in> RAG s'" |
|
840 |
proof(cases) |
|
841 |
assume "holding s' th cs" |
|
842 |
from this[unfolded holding_eq] |
|
843 |
show ?thesis by (unfold s_RAG_def, auto) |
|
844 |
qed |
|
845 |
qed |
|
846 |
from this[unfolded ancestors_th] show ?thesis by simp |
|
847 |
qed |
|
848 |
||
849 |
lemma preced_kept: "the_preced s = the_preced s'" |
|
850 |
by (auto simp: s_def the_preced_def preced_def) |
|
851 |
||
852 |
end |
|
853 |
||
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
854 |
text {* |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
855 |
The following @{text "step_v_cps_nt"} is the sub-locale for @{text "V"}-operation, |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
856 |
which represents the case when there is another thread @{text "th'"} |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
857 |
to take over the critical resource released by the initiating thread @{text "th"}. |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
858 |
*} |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
859 |
locale step_v_cps_nt = step_v_cps + |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
860 |
fixes th' |
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
861 |
-- {* @{text "th'"} is assumed to take over @{text "cs"} *} |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
862 |
assumes nt: "next_th s' th cs th'" |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
863 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
864 |
context step_v_cps_nt |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
865 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
866 |
|
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
867 |
text {* |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
868 |
Lemma @{text "RAG_s"} confirms the change of RAG: |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
869 |
two edges removed and one added, as shown by the following diagram. |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
870 |
*} |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
871 |
|
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
872 |
(* |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
873 |
RAG before the V-operation |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
874 |
th1 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
875 |
| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
876 |
th' ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
877 |
|----> cs -----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
878 |
th2 ----| | |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
879 |
| | |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
880 |
th3 ----| | |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
881 |
|------> th |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
882 |
th4 ----| | |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
883 |
| | |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
884 |
th5 ----| | |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
885 |
|----> cs'-----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
886 |
th6 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
887 |
| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
888 |
th7 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
889 |
|
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
890 |
RAG after the V-operation |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
891 |
th1 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
892 |
| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
893 |
|----> cs ----> th' |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
894 |
th2 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
895 |
| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
896 |
th3 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
897 |
|
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
898 |
th4 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
899 |
| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
900 |
th5 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
901 |
|----> cs'----> th |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
902 |
th6 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
903 |
| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
904 |
th7 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
905 |
*) |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
906 |
|
58 | 907 |
lemma sub_RAGs': "{(Cs cs, Th th), (Th th', Cs cs)} \<subseteq> RAG s'" |
61 | 908 |
using next_th_RAG[OF vat_s'.vt nt] . |
58 | 909 |
|
910 |
lemma ancestors_th': |
|
911 |
"ancestors (RAG s') (Th th') = {Th th, Cs cs}" |
|
912 |
proof - |
|
913 |
have "ancestors (RAG s') (Th th') = ancestors (RAG s') (Cs cs) \<union> {Cs cs}" |
|
61 | 914 |
proof(rule vat_s'.rtree_RAG.ancestors_accum) |
58 | 915 |
from sub_RAGs' show "(Th th', Cs cs) \<in> RAG s'" by auto |
916 |
qed |
|
917 |
thus ?thesis using ancestors_th ancestors_cs by auto |
|
918 |
qed |
|
919 |
||
35
92f61f6a0fe7
added a bit more text to the paper and separated a theory about Max
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
920 |
lemma RAG_s: |
92f61f6a0fe7
added a bit more text to the paper and separated a theory about Max
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
921 |
"RAG s = (RAG s' - {(Cs cs, Th th), (Th th', Cs cs)}) \<union> |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
922 |
{(Cs cs, Th th')}" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
923 |
proof - |
35
92f61f6a0fe7
added a bit more text to the paper and separated a theory about Max
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
924 |
from step_RAG_v[OF vt_s[unfolded s_def], folded s_def] |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
925 |
and nt show ?thesis by (auto intro:next_th_unique) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
926 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
927 |
|
58 | 928 |
lemma subtree_kept: |
929 |
assumes "th1 \<notin> {th, th'}" |
|
930 |
shows "subtree (RAG s) (Th th1) = subtree (RAG s') (Th th1)" (is "_ = ?R") |
|
931 |
proof - |
|
932 |
let ?RAG' = "(RAG s' - {(Cs cs, Th th), (Th th', Cs cs)})" |
|
933 |
let ?RAG'' = "?RAG' \<union> {(Cs cs, Th th')}" |
|
934 |
have "subtree ?RAG' (Th th1) = ?R" |
|
935 |
proof(rule subset_del_subtree_outside) |
|
936 |
show "Range {(Cs cs, Th th), (Th th', Cs cs)} \<inter> subtree (RAG s') (Th th1) = {}" |
|
937 |
proof - |
|
938 |
have "(Th th) \<notin> subtree (RAG s') (Th th1)" |
|
939 |
proof(rule subtree_refute) |
|
940 |
show "Th th1 \<notin> ancestors (RAG s') (Th th)" |
|
941 |
by (unfold ancestors_th, simp) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
942 |
next |
58 | 943 |
from assms show "Th th1 \<noteq> Th th" by simp |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
944 |
qed |
58 | 945 |
moreover have "(Cs cs) \<notin> subtree (RAG s') (Th th1)" |
946 |
proof(rule subtree_refute) |
|
947 |
show "Th th1 \<notin> ancestors (RAG s') (Cs cs)" |
|
948 |
by (unfold ancestors_cs, insert assms, auto) |
|
949 |
qed simp |
|
950 |
ultimately have "{Th th, Cs cs} \<inter> subtree (RAG s') (Th th1) = {}" by auto |
|
951 |
thus ?thesis by simp |
|
952 |
qed |
|
953 |
qed |
|
954 |
moreover have "subtree ?RAG'' (Th th1) = subtree ?RAG' (Th th1)" |
|
955 |
proof(rule subtree_insert_next) |
|
956 |
show "Th th' \<notin> subtree (RAG s' - {(Cs cs, Th th), (Th th', Cs cs)}) (Th th1)" |
|
957 |
proof(rule subtree_refute) |
|
958 |
show "Th th1 \<notin> ancestors (RAG s' - {(Cs cs, Th th), (Th th', Cs cs)}) (Th th')" |
|
959 |
(is "_ \<notin> ?R") |
|
960 |
proof - |
|
961 |
have "?R \<subseteq> ancestors (RAG s') (Th th')" by (rule ancestors_mono, auto) |
|
962 |
moreover have "Th th1 \<notin> ..." using ancestors_th' assms by simp |
|
963 |
ultimately show ?thesis by auto |
|
964 |
qed |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
965 |
next |
58 | 966 |
from assms show "Th th1 \<noteq> Th th'" by simp |
967 |
qed |
|
968 |
qed |
|
969 |
ultimately show ?thesis by (unfold RAG_s, simp) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
970 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
971 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
972 |
lemma cp_kept: |
58 | 973 |
assumes "th1 \<notin> {th, th'}" |
974 |
shows "cp s th1 = cp s' th1" |
|
975 |
by (unfold cp_alt_def preced_kept subtree_kept[OF assms], simp) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
976 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
977 |
end |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
978 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
979 |
locale step_v_cps_nnt = step_v_cps + |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
980 |
assumes nnt: "\<And> th'. (\<not> next_th s' th cs th')" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
981 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
982 |
context step_v_cps_nnt |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
983 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
984 |
|
35
92f61f6a0fe7
added a bit more text to the paper and separated a theory about Max
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
985 |
lemma RAG_s: "RAG s = RAG s' - {(Cs cs, Th th)}" |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
986 |
proof - |
35
92f61f6a0fe7
added a bit more text to the paper and separated a theory about Max
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
987 |
from nnt and step_RAG_v[OF vt_s[unfolded s_def], folded s_def] |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
988 |
show ?thesis by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
989 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
990 |
|
58 | 991 |
lemma subtree_kept: |
992 |
assumes "th1 \<noteq> th" |
|
993 |
shows "subtree (RAG s) (Th th1) = subtree (RAG s') (Th th1)" |
|
994 |
proof(unfold RAG_s, rule subset_del_subtree_outside) |
|
995 |
show "Range {(Cs cs, Th th)} \<inter> subtree (RAG s') (Th th1) = {}" |
|
996 |
proof - |
|
997 |
have "(Th th) \<notin> subtree (RAG s') (Th th1)" |
|
998 |
proof(rule subtree_refute) |
|
999 |
show "Th th1 \<notin> ancestors (RAG s') (Th th)" |
|
1000 |
by (unfold ancestors_th, simp) |
|
1001 |
next |
|
1002 |
from assms show "Th th1 \<noteq> Th th" by simp |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1003 |
qed |
58 | 1004 |
thus ?thesis by auto |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1005 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1006 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1007 |
|
58 | 1008 |
lemma cp_kept_1: |
1009 |
assumes "th1 \<noteq> th" |
|
1010 |
shows "cp s th1 = cp s' th1" |
|
1011 |
by (unfold cp_alt_def preced_kept subtree_kept[OF assms], simp) |
|
1012 |
||
1013 |
lemma subtree_cs: "subtree (RAG s') (Cs cs) = {Cs cs}" |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1014 |
proof - |
58 | 1015 |
{ fix n |
1016 |
have "(Cs cs) \<notin> ancestors (RAG s') n" |
|
1017 |
proof |
|
1018 |
assume "Cs cs \<in> ancestors (RAG s') n" |
|
1019 |
hence "(n, Cs cs) \<in> (RAG s')^+" by (auto simp:ancestors_def) |
|
1020 |
from tranclE[OF this] obtain nn where h: "(nn, Cs cs) \<in> RAG s'" by auto |
|
1021 |
then obtain th' where "nn = Th th'" |
|
1022 |
by (unfold s_RAG_def, auto) |
|
1023 |
from h[unfolded this] have "(Th th', Cs cs) \<in> RAG s'" . |
|
1024 |
from this[unfolded s_RAG_def] |
|
1025 |
have "waiting (wq s') th' cs" by auto |
|
1026 |
from this[unfolded cs_waiting_def] |
|
1027 |
have "1 < length (wq s' cs)" |
|
1028 |
by (cases "wq s' cs", auto) |
|
1029 |
from holding_next_thI[OF holding_th this] |
|
1030 |
obtain th' where "next_th s' th cs th'" by auto |
|
1031 |
with nnt show False by auto |
|
1032 |
qed |
|
1033 |
} note h = this |
|
1034 |
{ fix n |
|
1035 |
assume "n \<in> subtree (RAG s') (Cs cs)" |
|
1036 |
hence "n = (Cs cs)" |
|
1037 |
by (elim subtreeE, insert h, auto) |
|
1038 |
} moreover have "(Cs cs) \<in> subtree (RAG s') (Cs cs)" |
|
1039 |
by (auto simp:subtree_def) |
|
1040 |
ultimately show ?thesis by auto |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1041 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1042 |
|
58 | 1043 |
lemma subtree_th: |
1044 |
"subtree (RAG s) (Th th) = subtree (RAG s') (Th th) - {Cs cs}" |
|
61 | 1045 |
find_theorems "subtree" "_ - _" RAG |
1046 |
proof(unfold RAG_s, fold subtree_cs, rule vat_s'.rtree_RAG.subtree_del_inside) |
|
58 | 1047 |
from edge_of_th |
1048 |
show "(Cs cs, Th th) \<in> edges_in (RAG s') (Th th)" |
|
1049 |
by (unfold edges_in_def, auto simp:subtree_def) |
|
1050 |
qed |
|
1051 |
||
1052 |
lemma cp_kept_2: |
|
1053 |
shows "cp s th = cp s' th" |
|
1054 |
by (unfold cp_alt_def subtree_th preced_kept, auto) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1055 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1056 |
lemma eq_cp: |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1057 |
fixes th' |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1058 |
shows "cp s th' = cp s' th'" |
58 | 1059 |
using cp_kept_1 cp_kept_2 |
1060 |
by (cases "th' = th", auto) |
|
1061 |
end |
|
1062 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1063 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1064 |
locale step_P_cps = |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1065 |
fixes s' th cs s |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1066 |
defines s_def : "s \<equiv> (P th cs#s')" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1067 |
assumes vt_s: "vt s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1068 |
|
58 | 1069 |
sublocale step_P_cps < vat_s : valid_trace "s" |
1070 |
proof |
|
1071 |
from vt_s show "vt s" . |
|
1072 |
qed |
|
1073 |
||
1074 |
sublocale step_P_cps < vat_s' : valid_trace "s'" |
|
1075 |
proof |
|
1076 |
from step_back_vt[OF vt_s[unfolded s_def]] show "vt s'" . |
|
1077 |
qed |
|
1078 |
||
1079 |
context step_P_cps |
|
1080 |
begin |
|
1081 |
||
60 | 1082 |
lemma readys_th: "th \<in> readys s'" |
1083 |
proof - |
|
1084 |
from step_back_step [OF vt_s[unfolded s_def]] |
|
1085 |
have "PIP s' (P th cs)" . |
|
1086 |
hence "th \<in> runing s'" by (cases, simp) |
|
1087 |
thus ?thesis by (simp add:readys_def runing_def) |
|
58 | 1088 |
qed |
1089 |
||
60 | 1090 |
lemma root_th: "root (RAG s') (Th th)" |
61 | 1091 |
using readys_root[OF readys_th] . |
60 | 1092 |
|
1093 |
lemma in_no_others_subtree: |
|
1094 |
assumes "th' \<noteq> th" |
|
1095 |
shows "Th th \<notin> subtree (RAG s') (Th th')" |
|
58 | 1096 |
proof |
60 | 1097 |
assume "Th th \<in> subtree (RAG s') (Th th')" |
1098 |
thus False |
|
1099 |
proof(cases rule:subtreeE) |
|
1100 |
case 1 |
|
1101 |
with assms show ?thesis by auto |
|
1102 |
next |
|
1103 |
case 2 |
|
1104 |
with root_th show ?thesis by (auto simp:root_def) |
|
1105 |
qed |
|
58 | 1106 |
qed |
1107 |
||
1108 |
lemma preced_kept: "the_preced s = the_preced s'" |
|
1109 |
by (auto simp: s_def the_preced_def preced_def) |
|
1110 |
||
1111 |
end |
|
1112 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1113 |
locale step_P_cps_ne =step_P_cps + |
58 | 1114 |
fixes th' |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1115 |
assumes ne: "wq s' cs \<noteq> []" |
58 | 1116 |
defines th'_def: "th' \<equiv> hd (wq s' cs)" |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1117 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1118 |
locale step_P_cps_e =step_P_cps + |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1119 |
assumes ee: "wq s' cs = []" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1120 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1121 |
context step_P_cps_e |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1122 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1123 |
|
35
92f61f6a0fe7
added a bit more text to the paper and separated a theory about Max
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
1124 |
lemma RAG_s: "RAG s = RAG s' \<union> {(Cs cs, Th th)}" |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1125 |
proof - |
35
92f61f6a0fe7
added a bit more text to the paper and separated a theory about Max
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
1126 |
from ee and step_RAG_p[OF vt_s[unfolded s_def], folded s_def] |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1127 |
show ?thesis by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1128 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1129 |
|
60 | 1130 |
lemma subtree_kept: |
1131 |
assumes "th' \<noteq> th" |
|
1132 |
shows "subtree (RAG s) (Th th') = subtree (RAG s') (Th th')" |
|
1133 |
proof(unfold RAG_s, rule subtree_insert_next) |
|
1134 |
from in_no_others_subtree[OF assms] |
|
1135 |
show "Th th \<notin> subtree (RAG s') (Th th')" . |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1136 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1137 |
|
60 | 1138 |
lemma cp_kept: |
1139 |
assumes "th' \<noteq> th" |
|
1140 |
shows "cp s th' = cp s' th'" |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1141 |
proof - |
60 | 1142 |
have "(the_preced s ` {th'a. Th th'a \<in> subtree (RAG s) (Th th')}) = |
1143 |
(the_preced s' ` {th'a. Th th'a \<in> subtree (RAG s') (Th th')})" |
|
1144 |
by (unfold preced_kept subtree_kept[OF assms], simp) |
|
1145 |
thus ?thesis by (unfold cp_alt_def, simp) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1146 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1147 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1148 |
end |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1149 |
|
58 | 1150 |
context step_P_cps_ne |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1151 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1152 |
|
35
92f61f6a0fe7
added a bit more text to the paper and separated a theory about Max
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
1153 |
lemma RAG_s: "RAG s = RAG s' \<union> {(Th th, Cs cs)}" |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1154 |
proof - |
35
92f61f6a0fe7
added a bit more text to the paper and separated a theory about Max
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
1155 |
from step_RAG_p[OF vt_s[unfolded s_def]] and ne |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1156 |
show ?thesis by (simp add:s_def) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1157 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1158 |
|
58 | 1159 |
lemma cs_held: "(Cs cs, Th th') \<in> RAG s'" |
1160 |
proof - |
|
1161 |
have "(Cs cs, Th th') \<in> hRAG s'" |
|
1162 |
proof - |
|
1163 |
from ne |
|
1164 |
have " holding s' th' cs" |
|
1165 |
by (unfold th'_def holding_eq cs_holding_def, auto) |
|
1166 |
thus ?thesis |
|
1167 |
by (unfold hRAG_def, auto) |
|
1168 |
qed |
|
1169 |
thus ?thesis by (unfold RAG_split, auto) |
|
1170 |
qed |
|
1171 |
||
1172 |
lemma tRAG_s: |
|
1173 |
"tRAG s = tRAG s' \<union> {(Th th, Th th')}" |
|
1174 |
using RAG_tRAG_transfer[OF step_back_vt[OF vt_s[unfolded s_def]] RAG_s cs_held] . |
|
1175 |
||
1176 |
lemma cp_kept: |
|
1177 |
assumes "Th th'' \<notin> ancestors (tRAG s) (Th th)" |
|
1178 |
shows "cp s th'' = cp s' th''" |
|
1179 |
proof - |
|
1180 |
have h: "subtree (tRAG s) (Th th'') = subtree (tRAG s') (Th th'')" |
|
1181 |
proof - |
|
1182 |
have "Th th' \<notin> subtree (tRAG s') (Th th'')" |
|
1183 |
proof |
|
1184 |
assume "Th th' \<in> subtree (tRAG s') (Th th'')" |
|
1185 |
thus False |
|
1186 |
proof(rule subtreeE) |
|
1187 |
assume "Th th' = Th th''" |
|
1188 |
from assms[unfolded tRAG_s ancestors_def, folded this] |
|
1189 |
show ?thesis by auto |
|
1190 |
next |
|
1191 |
assume "Th th'' \<in> ancestors (tRAG s') (Th th')" |
|
1192 |
moreover have "... \<subseteq> ancestors (tRAG s) (Th th')" |
|
1193 |
proof(rule ancestors_mono) |
|
1194 |
show "tRAG s' \<subseteq> tRAG s" by (unfold tRAG_s, auto) |
|
1195 |
qed |
|
1196 |
ultimately have "Th th'' \<in> ancestors (tRAG s) (Th th')" by auto |
|
1197 |
moreover have "Th th' \<in> ancestors (tRAG s) (Th th)" |
|
1198 |
by (unfold tRAG_s, auto simp:ancestors_def) |
|
1199 |
ultimately have "Th th'' \<in> ancestors (tRAG s) (Th th)" |
|
1200 |
by (auto simp:ancestors_def) |
|
1201 |
with assms show ?thesis by auto |
|
1202 |
qed |
|
1203 |
qed |
|
1204 |
from subtree_insert_next[OF this] |
|
1205 |
have "subtree (tRAG s' \<union> {(Th th, Th th')}) (Th th'') = subtree (tRAG s') (Th th'')" . |
|
1206 |
from this[folded tRAG_s] show ?thesis . |
|
1207 |
qed |
|
1208 |
show ?thesis by (unfold cp_alt_def1 h preced_kept, simp) |
|
1209 |
qed |
|
1210 |
||
60 | 1211 |
lemma cp_gen_update_stop: (* ddd *) |
58 | 1212 |
assumes "u \<in> ancestors (tRAG s) (Th th)" |
1213 |
and "cp_gen s u = cp_gen s' u" |
|
1214 |
and "y \<in> ancestors (tRAG s) u" |
|
1215 |
shows "cp_gen s y = cp_gen s' y" |
|
1216 |
using assms(3) |
|
1217 |
proof(induct rule:wf_induct[OF vat_s.fsbttRAGs.wf]) |
|
1218 |
case (1 x) |
|
1219 |
show ?case (is "?L = ?R") |
|
1220 |
proof - |
|
1221 |
from tRAG_ancestorsE[OF 1(2)] |
|
1222 |
obtain th2 where eq_x: "x = Th th2" by blast |
|
1223 |
from vat_s.cp_gen_rec[OF this] |
|
1224 |
have "?L = |
|
1225 |
Max ({the_preced s th2} \<union> cp_gen s ` RTree.children (tRAG s) x)" . |
|
1226 |
also have "... = |
|
1227 |
Max ({the_preced s' th2} \<union> cp_gen s' ` RTree.children (tRAG s') x)" |
|
59
0a069a667301
removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
58
diff
changeset
|
1228 |
|
58 | 1229 |
proof - |
1230 |
from preced_kept have "the_preced s th2 = the_preced s' th2" by simp |
|
1231 |
moreover have "cp_gen s ` RTree.children (tRAG s) x = |
|
1232 |
cp_gen s' ` RTree.children (tRAG s') x" |
|
1233 |
proof - |
|
1234 |
have "RTree.children (tRAG s) x = RTree.children (tRAG s') x" |
|
1235 |
proof(unfold tRAG_s, rule children_union_kept) |
|
1236 |
have start: "(Th th, Th th') \<in> tRAG s" |
|
1237 |
by (unfold tRAG_s, auto) |
|
1238 |
note x_u = 1(2) |
|
1239 |
show "x \<notin> Range {(Th th, Th th')}" |
|
1240 |
proof |
|
1241 |
assume "x \<in> Range {(Th th, Th th')}" |
|
1242 |
hence eq_x: "x = Th th'" using RangeE by auto |
|
1243 |
show False |
|
1244 |
proof(cases rule:vat_s.rtree_s.ancestors_headE[OF assms(1) start]) |
|
1245 |
case 1 |
|
1246 |
from x_u[folded this, unfolded eq_x] vat_s.acyclic_tRAG |
|
1247 |
show ?thesis by (auto simp:ancestors_def acyclic_def) |
|
1248 |
next |
|
1249 |
case 2 |
|
1250 |
with x_u[unfolded eq_x] |
|
1251 |
have "(Th th', Th th') \<in> (tRAG s)^+" by (auto simp:ancestors_def) |
|
1252 |
with vat_s.acyclic_tRAG show ?thesis by (auto simp:acyclic_def) |
|
1253 |
qed |
|
1254 |
qed |
|
1255 |
qed |
|
1256 |
moreover have "cp_gen s ` RTree.children (tRAG s) x = |
|
1257 |
cp_gen s' ` RTree.children (tRAG s) x" (is "?f ` ?A = ?g ` ?A") |
|
1258 |
proof(rule f_image_eq) |
|
1259 |
fix a |
|
1260 |
assume a_in: "a \<in> ?A" |
|
1261 |
from 1(2) |
|
1262 |
show "?f a = ?g a" |
|
1263 |
proof(cases rule:vat_s.rtree_s.ancestors_childrenE[case_names in_ch out_ch]) |
|
1264 |
case in_ch |
|
1265 |
show ?thesis |
|
1266 |
proof(cases "a = u") |
|
1267 |
case True |
|
1268 |
from assms(2)[folded this] show ?thesis . |
|
1269 |
next |
|
1270 |
case False |
|
1271 |
have a_not_in: "a \<notin> ancestors (tRAG s) (Th th)" |
|
1272 |
proof |
|
1273 |
assume a_in': "a \<in> ancestors (tRAG s) (Th th)" |
|
1274 |
have "a = u" |
|
1275 |
proof(rule vat_s.rtree_s.ancestors_children_unique) |
|
1276 |
from a_in' a_in show "a \<in> ancestors (tRAG s) (Th th) \<inter> |
|
1277 |
RTree.children (tRAG s) x" by auto |
|
1278 |
next |
|
1279 |
from assms(1) in_ch show "u \<in> ancestors (tRAG s) (Th th) \<inter> |
|
1280 |
RTree.children (tRAG s) x" by auto |
|
1281 |
qed |
|
1282 |
with False show False by simp |
|
1283 |
qed |
|
1284 |
from a_in obtain th_a where eq_a: "a = Th th_a" |
|
1285 |
by (unfold RTree.children_def tRAG_alt_def, auto) |
|
1286 |
from cp_kept[OF a_not_in[unfolded eq_a]] |
|
1287 |
have "cp s th_a = cp s' th_a" . |
|
1288 |
from this [unfolded cp_gen_def_cond[OF eq_a], folded eq_a] |
|
1289 |
show ?thesis . |
|
1290 |
qed |
|
1291 |
next |
|
1292 |
case (out_ch z) |
|
1293 |
hence h: "z \<in> ancestors (tRAG s) u" "z \<in> RTree.children (tRAG s) x" by auto |
|
1294 |
show ?thesis |
|
1295 |
proof(cases "a = z") |
|
1296 |
case True |
|
1297 |
from h(2) have zx_in: "(z, x) \<in> (tRAG s)" by (auto simp:RTree.children_def) |
|
1298 |
from 1(1)[rule_format, OF this h(1)] |
|
1299 |
have eq_cp_gen: "cp_gen s z = cp_gen s' z" . |
|
1300 |
with True show ?thesis by metis |
|
1301 |
next |
|
1302 |
case False |
|
1303 |
from a_in obtain th_a where eq_a: "a = Th th_a" |
|
1304 |
by (auto simp:RTree.children_def tRAG_alt_def) |
|
60 | 1305 |
have "a \<notin> ancestors (tRAG s) (Th th)" |
1306 |
proof |
|
1307 |
assume a_in': "a \<in> ancestors (tRAG s) (Th th)" |
|
1308 |
have "a = z" |
|
1309 |
proof(rule vat_s.rtree_s.ancestors_children_unique) |
|
1310 |
from assms(1) h(1) have "z \<in> ancestors (tRAG s) (Th th)" |
|
1311 |
by (auto simp:ancestors_def) |
|
1312 |
with h(2) show " z \<in> ancestors (tRAG s) (Th th) \<inter> |
|
1313 |
RTree.children (tRAG s) x" by auto |
|
1314 |
next |
|
1315 |
from a_in a_in' |
|
1316 |
show "a \<in> ancestors (tRAG s) (Th th) \<inter> RTree.children (tRAG s) x" |
|
1317 |
by auto |
|
1318 |
qed |
|
1319 |
with False show False by auto |
|
1320 |
qed |
|
58 | 1321 |
from cp_kept[OF this[unfolded eq_a]] |
1322 |
have "cp s th_a = cp s' th_a" . |
|
1323 |
from this[unfolded cp_gen_def_cond[OF eq_a], folded eq_a] |
|
1324 |
show ?thesis . |
|
1325 |
qed |
|
1326 |
qed |
|
1327 |
qed |
|
1328 |
ultimately show ?thesis by metis |
|
1329 |
qed |
|
1330 |
ultimately show ?thesis by simp |
|
1331 |
qed |
|
1332 |
also have "... = ?R" |
|
1333 |
by (fold vat_s'.cp_gen_rec[OF eq_x], simp) |
|
1334 |
finally show ?thesis . |
|
1335 |
qed |
|
1336 |
qed |
|
1337 |
||
60 | 1338 |
lemma cp_up: |
1339 |
assumes "(Th th') \<in> ancestors (tRAG s) (Th th)" |
|
1340 |
and "cp s th' = cp s' th'" |
|
1341 |
and "(Th th'') \<in> ancestors (tRAG s) (Th th')" |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1342 |
shows "cp s th'' = cp s' th''" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1343 |
proof - |
60 | 1344 |
have "cp_gen s (Th th'') = cp_gen s' (Th th'')" |
1345 |
proof(rule cp_gen_update_stop[OF assms(1) _ assms(3)]) |
|
1346 |
from assms(2) cp_gen_def_cond[OF refl[of "Th th'"]] |
|
1347 |
show "cp_gen s (Th th') = cp_gen s' (Th th')" by metis |
|
1348 |
qed |
|
1349 |
with cp_gen_def_cond[OF refl[of "Th th''"]] |
|
1350 |
show ?thesis by metis |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1351 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1352 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1353 |
end |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1354 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1355 |
locale step_create_cps = |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1356 |
fixes s' th prio s |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1357 |
defines s_def : "s \<equiv> (Create th prio#s')" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1358 |
assumes vt_s: "vt s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1359 |
|
60 | 1360 |
sublocale step_create_cps < vat_s: valid_trace "s" |
1361 |
by (unfold_locales, insert vt_s, simp) |
|
1362 |
||
1363 |
sublocale step_create_cps < vat_s': valid_trace "s'" |
|
1364 |
by (unfold_locales, insert step_back_vt[OF vt_s[unfolded s_def]], simp) |
|
1365 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1366 |
context step_create_cps |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1367 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1368 |
|
60 | 1369 |
lemma RAG_kept: "RAG s = RAG s'" |
35
92f61f6a0fe7
added a bit more text to the paper and separated a theory about Max
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
1370 |
by (unfold s_def RAG_create_unchanged, auto) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1371 |
|
60 | 1372 |
lemma tRAG_kept: "tRAG s = tRAG s'" |
1373 |
by (unfold tRAG_alt_def RAG_kept, auto) |
|
1374 |
||
1375 |
lemma preced_kept: |
|
1376 |
assumes "th' \<noteq> th" |
|
1377 |
shows "the_preced s th' = the_preced s' th'" |
|
1378 |
by (unfold s_def the_preced_def preced_def, insert assms, auto) |
|
1379 |
||
1380 |
lemma th_not_in: "Th th \<notin> Field (tRAG s')" |
|
1381 |
proof - |
|
1382 |
from vt_s[unfolded s_def] |
|
1383 |
have "PIP s' (Create th prio)" by (cases, simp) |
|
1384 |
hence "th \<notin> threads s'" by(cases, simp) |
|
1385 |
from vat_s'.not_in_thread_isolated[OF this] |
|
1386 |
have "Th th \<notin> Field (RAG s')" . |
|
1387 |
with tRAG_Field show ?thesis by auto |
|
1388 |
qed |
|
1389 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1390 |
lemma eq_cp: |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1391 |
assumes neq_th: "th' \<noteq> th" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1392 |
shows "cp s th' = cp s' th'" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1393 |
proof - |
60 | 1394 |
have "(the_preced s \<circ> the_thread) ` subtree (tRAG s) (Th th') = |
1395 |
(the_preced s' \<circ> the_thread) ` subtree (tRAG s') (Th th')" |
|
1396 |
proof(unfold tRAG_kept, rule f_image_eq) |
|
1397 |
fix a |
|
1398 |
assume a_in: "a \<in> subtree (tRAG s') (Th th')" |
|
1399 |
then obtain th_a where eq_a: "a = Th th_a" |
|
1400 |
proof(cases rule:subtreeE) |
|
1401 |
case 2 |
|
1402 |
from ancestors_Field[OF 2(2)] |
|
1403 |
and that show ?thesis by (unfold tRAG_alt_def, auto) |
|
1404 |
qed auto |
|
1405 |
have neq_th_a: "th_a \<noteq> th" |
|
1406 |
proof - |
|
1407 |
have "(Th th) \<notin> subtree (tRAG s') (Th th')" |
|
1408 |
proof |
|
1409 |
assume "Th th \<in> subtree (tRAG s') (Th th')" |
|
1410 |
thus False |
|
1411 |
proof(cases rule:subtreeE) |
|
1412 |
case 2 |
|
1413 |
from ancestors_Field[OF this(2)] |
|
1414 |
and th_not_in[unfolded Field_def] |
|
1415 |
show ?thesis by auto |
|
1416 |
qed (insert assms, auto) |
|
1417 |
qed |
|
1418 |
with a_in[unfolded eq_a] show ?thesis by auto |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1419 |
qed |
60 | 1420 |
from preced_kept[OF this] |
1421 |
show "(the_preced s \<circ> the_thread) a = (the_preced s' \<circ> the_thread) a" |
|
1422 |
by (unfold eq_a, simp) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1423 |
qed |
60 | 1424 |
thus ?thesis by (unfold cp_alt_def1, simp) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1425 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1426 |
|
60 | 1427 |
lemma children_of_th: "RTree.children (tRAG s) (Th th) = {}" |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1428 |
proof - |
60 | 1429 |
{ fix a |
1430 |
assume "a \<in> RTree.children (tRAG s) (Th th)" |
|
1431 |
hence "(a, Th th) \<in> tRAG s" by (auto simp:RTree.children_def) |
|
1432 |
with th_not_in have False |
|
1433 |
by (unfold Field_def tRAG_kept, auto) |
|
1434 |
} thus ?thesis by auto |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1435 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1436 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1437 |
lemma eq_cp_th: "cp s th = preced th s" |
60 | 1438 |
by (unfold vat_s.cp_rec children_of_th, simp add:the_preced_def) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1439 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1440 |
end |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1441 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1442 |
locale step_exit_cps = |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1443 |
fixes s' th prio s |
33
9b9f2117561f
simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
1444 |
defines s_def : "s \<equiv> Exit th # s'" |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1445 |
assumes vt_s: "vt s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1446 |
|
60 | 1447 |
sublocale step_exit_cps < vat_s: valid_trace "s" |
1448 |
by (unfold_locales, insert vt_s, simp) |
|
1449 |
||
1450 |
sublocale step_exit_cps < vat_s': valid_trace "s'" |
|
1451 |
by (unfold_locales, insert step_back_vt[OF vt_s[unfolded s_def]], simp) |
|
1452 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1453 |
context step_exit_cps |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1454 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1455 |
|
60 | 1456 |
lemma preced_kept: |
1457 |
assumes "th' \<noteq> th" |
|
1458 |
shows "the_preced s th' = the_preced s' th'" |
|
1459 |
by (unfold s_def the_preced_def preced_def, insert assms, auto) |
|
1460 |
||
1461 |
lemma RAG_kept: "RAG s = RAG s'" |
|
35
92f61f6a0fe7
added a bit more text to the paper and separated a theory about Max
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
1462 |
by (unfold s_def RAG_exit_unchanged, auto) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1463 |
|
60 | 1464 |
lemma tRAG_kept: "tRAG s = tRAG s'" |
1465 |
by (unfold tRAG_alt_def RAG_kept, auto) |
|
1466 |
||
1467 |
lemma th_ready: "th \<in> readys s'" |
|
1468 |
proof - |
|
1469 |
from vt_s[unfolded s_def] |
|
1470 |
have "PIP s' (Exit th)" by (cases, simp) |
|
1471 |
hence h: "th \<in> runing s' \<and> holdents s' th = {}" by (cases, metis) |
|
1472 |
thus ?thesis by (unfold runing_def, auto) |
|
1473 |
qed |
|
1474 |
||
1475 |
lemma th_holdents: "holdents s' th = {}" |
|
1476 |
proof - |
|
1477 |
from vt_s[unfolded s_def] |
|
1478 |
have "PIP s' (Exit th)" by (cases, simp) |
|
1479 |
thus ?thesis by (cases, metis) |
|
1480 |
qed |
|
1481 |
||
1482 |
lemma th_RAG: "Th th \<notin> Field (RAG s')" |
|
1483 |
proof - |
|
1484 |
have "Th th \<notin> Range (RAG s')" |
|
1485 |
proof |
|
1486 |
assume "Th th \<in> Range (RAG s')" |
|
1487 |
then obtain cs where "holding (wq s') th cs" |
|
1488 |
by (unfold Range_iff s_RAG_def, auto) |
|
1489 |
with th_holdents[unfolded holdents_def] |
|
1490 |
show False by (unfold eq_holding, auto) |
|
1491 |
qed |
|
1492 |
moreover have "Th th \<notin> Domain (RAG s')" |
|
1493 |
proof |
|
1494 |
assume "Th th \<in> Domain (RAG s')" |
|
1495 |
then obtain cs where "waiting (wq s') th cs" |
|
1496 |
by (unfold Domain_iff s_RAG_def, auto) |
|
1497 |
with th_ready show False by (unfold readys_def eq_waiting, auto) |
|
1498 |
qed |
|
1499 |
ultimately show ?thesis by (auto simp:Field_def) |
|
1500 |
qed |
|
1501 |
||
1502 |
lemma th_tRAG: "(Th th) \<notin> Field (tRAG s')" |
|
1503 |
using th_RAG tRAG_Field[of s'] by auto |
|
1504 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1505 |
lemma eq_cp: |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1506 |
assumes neq_th: "th' \<noteq> th" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1507 |
shows "cp s th' = cp s' th'" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1508 |
proof - |
60 | 1509 |
have "(the_preced s \<circ> the_thread) ` subtree (tRAG s) (Th th') = |
1510 |
(the_preced s' \<circ> the_thread) ` subtree (tRAG s') (Th th')" |
|
1511 |
proof(unfold tRAG_kept, rule f_image_eq) |
|
1512 |
fix a |
|
1513 |
assume a_in: "a \<in> subtree (tRAG s') (Th th')" |
|
1514 |
then obtain th_a where eq_a: "a = Th th_a" |
|
1515 |
proof(cases rule:subtreeE) |
|
1516 |
case 2 |
|
1517 |
from ancestors_Field[OF 2(2)] |
|
1518 |
and that show ?thesis by (unfold tRAG_alt_def, auto) |
|
1519 |
qed auto |
|
1520 |
have neq_th_a: "th_a \<noteq> th" |
|
1521 |
proof - |
|
61 | 1522 |
find_theorems readys subtree s' |
1523 |
from vat_s'.readys_in_no_subtree[OF th_ready assms] |
|
60 | 1524 |
have "(Th th) \<notin> subtree (RAG s') (Th th')" . |
1525 |
with tRAG_subtree_RAG[of s' "Th th'"] |
|
1526 |
have "(Th th) \<notin> subtree (tRAG s') (Th th')" by auto |
|
1527 |
with a_in[unfolded eq_a] show ?thesis by auto |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1528 |
qed |
60 | 1529 |
from preced_kept[OF this] |
1530 |
show "(the_preced s \<circ> the_thread) a = (the_preced s' \<circ> the_thread) a" |
|
1531 |
by (unfold eq_a, simp) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1532 |
qed |
60 | 1533 |
thus ?thesis by (unfold cp_alt_def1, simp) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1534 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1535 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1536 |
end |
60 | 1537 |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1538 |
end |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1539 |