author | zhangx |
Thu, 07 Jan 2016 08:33:13 +0800 | |
changeset 65 | 633b1fc8631b |
parent 64 | b4bcd1edbb6d |
child 68 | db196b066b97 |
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 |
*} |
64
b4bcd1edbb6d
renamed files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
63
diff
changeset
|
5 |
theory Implementation |
65
633b1fc8631b
Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents:
64
diff
changeset
|
6 |
imports PIPBasics |
63 | 7 |
begin |
8 |
||
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
9 |
text {* (* ddd *) |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
10 |
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
|
11 |
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
|
12 |
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
|
13 |
*} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
14 |
|
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
15 |
text {* |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
16 |
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
|
17 |
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
|
18 |
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
|
19 |
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
|
20 |
treated in a separate locale. |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
21 |
|
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
22 |
The complication of current precedence recalculation comes |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
23 |
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
|
24 |
in addition to the changing of precedence. |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
25 |
The reason RAG changing affects current precedence is that, |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
26 |
according to the definition, current precedence |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
27 |
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
|
28 |
where the dependants are defined in terms of RAG. |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
29 |
|
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
30 |
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
|
31 |
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
|
32 |
current precedence recalculation can be based on. |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
33 |
*} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
34 |
|
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
35 |
text {* (* ddd *) |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
36 |
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
|
37 |
after the @{text "Set"} operation. |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
38 |
*} |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
39 |
locale step_set_cps = |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
40 |
fixes s' th prio s |
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
41 |
-- {* @{text "s'"} is the system state before the operation *} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
42 |
-- {* @{text "s"} is the system state after the operation *} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
43 |
defines s_def : "s \<equiv> (Set th prio#s')" |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
44 |
-- {* @{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
|
45 |
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
|
46 |
assumes vt_s: "vt s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
47 |
|
61 | 48 |
sublocale step_set_cps < vat_s : valid_trace "s" |
49 |
proof |
|
50 |
from vt_s show "vt s" . |
|
51 |
qed |
|
52 |
||
53 |
sublocale step_set_cps < vat_s' : valid_trace "s'" |
|
54 |
proof |
|
55 |
from step_back_vt[OF vt_s[unfolded s_def]] show "vt s'" . |
|
56 |
qed |
|
57 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
58 |
context step_set_cps |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
59 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
60 |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
61 |
text {* (* ddd *) |
58 | 62 |
The following two lemmas confirm that @{text "Set"}-operating only changes the precedence |
63 |
of the initiating thread. |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
64 |
*} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
65 |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
66 |
lemma eq_preced: |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
67 |
assumes "th' \<noteq> th" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
68 |
shows "preced th' s = preced th' s'" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
69 |
proof - |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
70 |
from assms show ?thesis |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
71 |
by (unfold s_def, auto simp:preced_def) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
72 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
73 |
|
58 | 74 |
lemma eq_the_preced: |
75 |
fixes th' |
|
76 |
assumes "th' \<noteq> th" |
|
77 |
shows "the_preced s th' = the_preced s' th'" |
|
78 |
using assms |
|
79 |
by (unfold the_preced_def, intro eq_preced, simp) |
|
80 |
||
81 |
text {* |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
82 |
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
|
83 |
*} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
84 |
|
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
|
85 |
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
|
86 |
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
|
87 |
|
58 | 88 |
text {* (* ddd *) |
89 |
Th following lemma @{text "eq_cp_pre"} says the priority change of @{text "th"} |
|
90 |
only affects those threads, which as @{text "Th th"} in their sub-trees. |
|
91 |
||
92 |
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
|
93 |
*} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
94 |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
95 |
lemma eq_cp_pre: |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
96 |
fixes th' |
58 | 97 |
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
|
98 |
shows "cp s th' = cp s' th'" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
99 |
proof - |
58 | 100 |
-- {* After unfolding using the alternative definition, elements |
101 |
affecting the @{term "cp"}-value of threads become explicit. |
|
102 |
We only need to prove the following: *} |
|
103 |
have "Max (the_preced s ` {th'a. Th th'a \<in> subtree (RAG s) (Th th')}) = |
|
104 |
Max (the_preced s' ` {th'a. Th th'a \<in> subtree (RAG s') (Th th')})" |
|
105 |
(is "Max (?f ` ?S1) = Max (?g ` ?S2)") |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
106 |
proof - |
58 | 107 |
-- {* The base sets are equal. *} |
108 |
have "?S1 = ?S2" using eq_dep by simp |
|
109 |
-- {* The function values on the base set are equal as well. *} |
|
110 |
moreover have "\<forall> e \<in> ?S2. ?f e = ?g e" |
|
111 |
proof |
|
112 |
fix th1 |
|
113 |
assume "th1 \<in> ?S2" |
|
114 |
with nd have "th1 \<noteq> th" by (auto) |
|
115 |
from eq_the_preced[OF this] |
|
116 |
show "the_preced s th1 = the_preced s' th1" . |
|
117 |
qed |
|
118 |
-- {* Therefore, the image of the functions are equal. *} |
|
119 |
ultimately have "(?f ` ?S1) = (?g ` ?S2)" by (auto intro!:f_image_eq) |
|
120 |
thus ?thesis by simp |
|
121 |
qed |
|
122 |
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
|
123 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
124 |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
125 |
text {* |
58 | 126 |
The following lemma shows that @{term "th"} is not in the |
127 |
sub-tree of any other thread. |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
128 |
*} |
58 | 129 |
lemma th_in_no_subtree: |
130 |
assumes "th' \<noteq> th" |
|
131 |
shows "Th th \<notin> subtree (RAG s') (Th th')" |
|
132 |
proof - |
|
133 |
have "th \<in> readys s'" |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
134 |
proof - |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
135 |
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
|
136 |
have "step s' (Set th prio)" . |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
137 |
hence "th \<in> runing s'" by (cases, simp) |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
138 |
thus ?thesis by (simp add:readys_def runing_def) |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
139 |
qed |
61 | 140 |
from vat_s'.readys_in_no_subtree[OF this assms(1)] |
58 | 141 |
show ?thesis by blast |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
142 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
143 |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
144 |
text {* |
58 | 145 |
By combining @{thm "eq_cp_pre"} and @{thm "th_in_no_subtree"}, |
146 |
it is obvious that the change of priority only affects the @{text "cp"}-value |
|
147 |
of the initiating thread @{text "th"}. |
|
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
148 |
*} |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
149 |
lemma eq_cp: |
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
150 |
fixes th' |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
151 |
assumes "th' \<noteq> th" |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
152 |
shows "cp s th' = cp s' th'" |
58 | 153 |
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
|
154 |
|
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
155 |
end |
55
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
156 |
|
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
157 |
text {* |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
158 |
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
|
159 |
*} |
b85cfbd58f59
Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents:
53
diff
changeset
|
160 |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
161 |
locale step_v_cps = |
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
162 |
-- {* @{text "th"} is the initiating thread *} |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
163 |
-- {* @{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
|
164 |
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
|
165 |
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
|
166 |
-- {* @{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
|
167 |
assumes vt_s: "vt s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
168 |
|
61 | 169 |
sublocale step_v_cps < vat_s : valid_trace "s" |
58 | 170 |
proof |
61 | 171 |
from vt_s show "vt s" . |
58 | 172 |
qed |
173 |
||
61 | 174 |
sublocale step_v_cps < vat_s' : valid_trace "s'" |
58 | 175 |
proof |
61 | 176 |
from step_back_vt[OF vt_s[unfolded s_def]] show "vt s'" . |
58 | 177 |
qed |
178 |
||
61 | 179 |
context step_v_cps |
180 |
begin |
|
58 | 181 |
|
182 |
lemma ready_th_s': "th \<in> readys s'" |
|
183 |
using step_back_step[OF vt_s[unfolded s_def]] |
|
184 |
by (cases, simp add:runing_def) |
|
185 |
||
186 |
lemma ancestors_th: "ancestors (RAG s') (Th th) = {}" |
|
187 |
proof - |
|
61 | 188 |
from vat_s'.readys_root[OF ready_th_s'] |
58 | 189 |
show ?thesis |
190 |
by (unfold root_def, simp) |
|
191 |
qed |
|
192 |
||
193 |
lemma holding_th: "holding s' th cs" |
|
194 |
proof - |
|
195 |
from vt_s[unfolded s_def] |
|
196 |
have " PIP s' (V th cs)" by (cases, simp) |
|
197 |
thus ?thesis by (cases, auto) |
|
198 |
qed |
|
199 |
||
200 |
lemma edge_of_th: |
|
201 |
"(Cs cs, Th th) \<in> RAG s'" |
|
202 |
proof - |
|
203 |
from holding_th |
|
204 |
show ?thesis |
|
205 |
by (unfold s_RAG_def holding_eq, auto) |
|
206 |
qed |
|
207 |
||
208 |
lemma ancestors_cs: |
|
209 |
"ancestors (RAG s') (Cs cs) = {Th th}" |
|
210 |
proof - |
|
211 |
have "ancestors (RAG s') (Cs cs) = ancestors (RAG s') (Th th) \<union> {Th th}" |
|
61 | 212 |
proof(rule vat_s'.rtree_RAG.ancestors_accum) |
58 | 213 |
from vt_s[unfolded s_def] |
214 |
have " PIP s' (V th cs)" by (cases, simp) |
|
215 |
thus "(Cs cs, Th th) \<in> RAG s'" |
|
216 |
proof(cases) |
|
217 |
assume "holding s' th cs" |
|
218 |
from this[unfolded holding_eq] |
|
219 |
show ?thesis by (unfold s_RAG_def, auto) |
|
220 |
qed |
|
221 |
qed |
|
222 |
from this[unfolded ancestors_th] show ?thesis by simp |
|
223 |
qed |
|
224 |
||
225 |
lemma preced_kept: "the_preced s = the_preced s'" |
|
226 |
by (auto simp: s_def the_preced_def preced_def) |
|
227 |
||
228 |
end |
|
229 |
||
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
230 |
text {* |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
231 |
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
|
232 |
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
|
233 |
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
|
234 |
*} |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
235 |
locale step_v_cps_nt = step_v_cps + |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
236 |
fixes th' |
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
237 |
-- {* @{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
|
238 |
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
|
239 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
240 |
context step_v_cps_nt |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
241 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
242 |
|
56
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
243 |
text {* |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
244 |
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
|
245 |
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
|
246 |
*} |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
247 |
|
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
248 |
(* |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
249 |
RAG before the V-operation |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
250 |
th1 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
251 |
| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
252 |
th' ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
253 |
|----> cs -----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
254 |
th2 ----| | |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
255 |
| | |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
256 |
th3 ----| | |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
257 |
|------> th |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
258 |
th4 ----| | |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
259 |
| | |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
260 |
th5 ----| | |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
261 |
|----> cs'-----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
262 |
th6 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
263 |
| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
264 |
th7 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
265 |
|
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
266 |
RAG after the V-operation |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
267 |
th1 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
268 |
| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
269 |
|----> cs ----> th' |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
270 |
th2 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
271 |
| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
272 |
th3 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
273 |
|
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
274 |
th4 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
275 |
| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
276 |
th5 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
277 |
|----> cs'----> th |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
278 |
th6 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
279 |
| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
280 |
th7 ----| |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
281 |
*) |
0fd478e14e87
Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents:
55
diff
changeset
|
282 |
|
58 | 283 |
lemma sub_RAGs': "{(Cs cs, Th th), (Th th', Cs cs)} \<subseteq> RAG s'" |
63 | 284 |
using next_th_RAG[OF nt] . |
58 | 285 |
|
286 |
lemma ancestors_th': |
|
287 |
"ancestors (RAG s') (Th th') = {Th th, Cs cs}" |
|
288 |
proof - |
|
289 |
have "ancestors (RAG s') (Th th') = ancestors (RAG s') (Cs cs) \<union> {Cs cs}" |
|
61 | 290 |
proof(rule vat_s'.rtree_RAG.ancestors_accum) |
58 | 291 |
from sub_RAGs' show "(Th th', Cs cs) \<in> RAG s'" by auto |
292 |
qed |
|
293 |
thus ?thesis using ancestors_th ancestors_cs by auto |
|
294 |
qed |
|
295 |
||
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
|
296 |
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
|
297 |
"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
|
298 |
{(Cs cs, Th th')}" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
299 |
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
|
300 |
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
|
301 |
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
|
302 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
303 |
|
58 | 304 |
lemma subtree_kept: |
305 |
assumes "th1 \<notin> {th, th'}" |
|
306 |
shows "subtree (RAG s) (Th th1) = subtree (RAG s') (Th th1)" (is "_ = ?R") |
|
307 |
proof - |
|
308 |
let ?RAG' = "(RAG s' - {(Cs cs, Th th), (Th th', Cs cs)})" |
|
309 |
let ?RAG'' = "?RAG' \<union> {(Cs cs, Th th')}" |
|
310 |
have "subtree ?RAG' (Th th1) = ?R" |
|
311 |
proof(rule subset_del_subtree_outside) |
|
312 |
show "Range {(Cs cs, Th th), (Th th', Cs cs)} \<inter> subtree (RAG s') (Th th1) = {}" |
|
313 |
proof - |
|
314 |
have "(Th th) \<notin> subtree (RAG s') (Th th1)" |
|
315 |
proof(rule subtree_refute) |
|
316 |
show "Th th1 \<notin> ancestors (RAG s') (Th th)" |
|
317 |
by (unfold ancestors_th, simp) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
318 |
next |
58 | 319 |
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
|
320 |
qed |
58 | 321 |
moreover have "(Cs cs) \<notin> subtree (RAG s') (Th th1)" |
322 |
proof(rule subtree_refute) |
|
323 |
show "Th th1 \<notin> ancestors (RAG s') (Cs cs)" |
|
324 |
by (unfold ancestors_cs, insert assms, auto) |
|
325 |
qed simp |
|
326 |
ultimately have "{Th th, Cs cs} \<inter> subtree (RAG s') (Th th1) = {}" by auto |
|
327 |
thus ?thesis by simp |
|
328 |
qed |
|
329 |
qed |
|
330 |
moreover have "subtree ?RAG'' (Th th1) = subtree ?RAG' (Th th1)" |
|
331 |
proof(rule subtree_insert_next) |
|
332 |
show "Th th' \<notin> subtree (RAG s' - {(Cs cs, Th th), (Th th', Cs cs)}) (Th th1)" |
|
333 |
proof(rule subtree_refute) |
|
334 |
show "Th th1 \<notin> ancestors (RAG s' - {(Cs cs, Th th), (Th th', Cs cs)}) (Th th')" |
|
335 |
(is "_ \<notin> ?R") |
|
336 |
proof - |
|
337 |
have "?R \<subseteq> ancestors (RAG s') (Th th')" by (rule ancestors_mono, auto) |
|
338 |
moreover have "Th th1 \<notin> ..." using ancestors_th' assms by simp |
|
339 |
ultimately show ?thesis by auto |
|
340 |
qed |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
341 |
next |
58 | 342 |
from assms show "Th th1 \<noteq> Th th'" by simp |
343 |
qed |
|
344 |
qed |
|
345 |
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
|
346 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
347 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
348 |
lemma cp_kept: |
58 | 349 |
assumes "th1 \<notin> {th, th'}" |
350 |
shows "cp s th1 = cp s' th1" |
|
351 |
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
|
352 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
353 |
end |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
354 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
355 |
locale step_v_cps_nnt = step_v_cps + |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
356 |
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
|
357 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
358 |
context step_v_cps_nnt |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
359 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
360 |
|
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
|
361 |
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
|
362 |
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
|
363 |
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
|
364 |
show ?thesis by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
365 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
366 |
|
58 | 367 |
lemma subtree_kept: |
368 |
assumes "th1 \<noteq> th" |
|
369 |
shows "subtree (RAG s) (Th th1) = subtree (RAG s') (Th th1)" |
|
370 |
proof(unfold RAG_s, rule subset_del_subtree_outside) |
|
371 |
show "Range {(Cs cs, Th th)} \<inter> subtree (RAG s') (Th th1) = {}" |
|
372 |
proof - |
|
373 |
have "(Th th) \<notin> subtree (RAG s') (Th th1)" |
|
374 |
proof(rule subtree_refute) |
|
375 |
show "Th th1 \<notin> ancestors (RAG s') (Th th)" |
|
376 |
by (unfold ancestors_th, simp) |
|
377 |
next |
|
378 |
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
|
379 |
qed |
58 | 380 |
thus ?thesis by auto |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
381 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
382 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
383 |
|
58 | 384 |
lemma cp_kept_1: |
385 |
assumes "th1 \<noteq> th" |
|
386 |
shows "cp s th1 = cp s' th1" |
|
387 |
by (unfold cp_alt_def preced_kept subtree_kept[OF assms], simp) |
|
388 |
||
389 |
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
|
390 |
proof - |
58 | 391 |
{ fix n |
392 |
have "(Cs cs) \<notin> ancestors (RAG s') n" |
|
393 |
proof |
|
394 |
assume "Cs cs \<in> ancestors (RAG s') n" |
|
395 |
hence "(n, Cs cs) \<in> (RAG s')^+" by (auto simp:ancestors_def) |
|
396 |
from tranclE[OF this] obtain nn where h: "(nn, Cs cs) \<in> RAG s'" by auto |
|
397 |
then obtain th' where "nn = Th th'" |
|
398 |
by (unfold s_RAG_def, auto) |
|
399 |
from h[unfolded this] have "(Th th', Cs cs) \<in> RAG s'" . |
|
400 |
from this[unfolded s_RAG_def] |
|
401 |
have "waiting (wq s') th' cs" by auto |
|
402 |
from this[unfolded cs_waiting_def] |
|
403 |
have "1 < length (wq s' cs)" |
|
404 |
by (cases "wq s' cs", auto) |
|
405 |
from holding_next_thI[OF holding_th this] |
|
406 |
obtain th' where "next_th s' th cs th'" by auto |
|
407 |
with nnt show False by auto |
|
408 |
qed |
|
409 |
} note h = this |
|
410 |
{ fix n |
|
411 |
assume "n \<in> subtree (RAG s') (Cs cs)" |
|
412 |
hence "n = (Cs cs)" |
|
413 |
by (elim subtreeE, insert h, auto) |
|
414 |
} moreover have "(Cs cs) \<in> subtree (RAG s') (Cs cs)" |
|
415 |
by (auto simp:subtree_def) |
|
416 |
ultimately show ?thesis by auto |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
417 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
418 |
|
58 | 419 |
lemma subtree_th: |
420 |
"subtree (RAG s) (Th th) = subtree (RAG s') (Th th) - {Cs cs}" |
|
61 | 421 |
proof(unfold RAG_s, fold subtree_cs, rule vat_s'.rtree_RAG.subtree_del_inside) |
58 | 422 |
from edge_of_th |
423 |
show "(Cs cs, Th th) \<in> edges_in (RAG s') (Th th)" |
|
424 |
by (unfold edges_in_def, auto simp:subtree_def) |
|
425 |
qed |
|
426 |
||
427 |
lemma cp_kept_2: |
|
428 |
shows "cp s th = cp s' th" |
|
429 |
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
|
430 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
431 |
lemma eq_cp: |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
432 |
fixes th' |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
433 |
shows "cp s th' = cp s' th'" |
58 | 434 |
using cp_kept_1 cp_kept_2 |
435 |
by (cases "th' = th", auto) |
|
436 |
end |
|
437 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
438 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
439 |
locale step_P_cps = |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
440 |
fixes s' th cs s |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
441 |
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
|
442 |
assumes vt_s: "vt s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
443 |
|
58 | 444 |
sublocale step_P_cps < vat_s : valid_trace "s" |
445 |
proof |
|
446 |
from vt_s show "vt s" . |
|
447 |
qed |
|
448 |
||
449 |
sublocale step_P_cps < vat_s' : valid_trace "s'" |
|
450 |
proof |
|
451 |
from step_back_vt[OF vt_s[unfolded s_def]] show "vt s'" . |
|
452 |
qed |
|
453 |
||
454 |
context step_P_cps |
|
455 |
begin |
|
456 |
||
60 | 457 |
lemma readys_th: "th \<in> readys s'" |
458 |
proof - |
|
459 |
from step_back_step [OF vt_s[unfolded s_def]] |
|
460 |
have "PIP s' (P th cs)" . |
|
461 |
hence "th \<in> runing s'" by (cases, simp) |
|
462 |
thus ?thesis by (simp add:readys_def runing_def) |
|
58 | 463 |
qed |
464 |
||
60 | 465 |
lemma root_th: "root (RAG s') (Th th)" |
61 | 466 |
using readys_root[OF readys_th] . |
60 | 467 |
|
468 |
lemma in_no_others_subtree: |
|
469 |
assumes "th' \<noteq> th" |
|
470 |
shows "Th th \<notin> subtree (RAG s') (Th th')" |
|
58 | 471 |
proof |
60 | 472 |
assume "Th th \<in> subtree (RAG s') (Th th')" |
473 |
thus False |
|
474 |
proof(cases rule:subtreeE) |
|
475 |
case 1 |
|
476 |
with assms show ?thesis by auto |
|
477 |
next |
|
478 |
case 2 |
|
479 |
with root_th show ?thesis by (auto simp:root_def) |
|
480 |
qed |
|
58 | 481 |
qed |
482 |
||
483 |
lemma preced_kept: "the_preced s = the_preced s'" |
|
484 |
by (auto simp: s_def the_preced_def preced_def) |
|
485 |
||
486 |
end |
|
487 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
488 |
locale step_P_cps_ne =step_P_cps + |
58 | 489 |
fixes th' |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
490 |
assumes ne: "wq s' cs \<noteq> []" |
58 | 491 |
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
|
492 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
493 |
locale step_P_cps_e =step_P_cps + |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
494 |
assumes ee: "wq s' cs = []" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
495 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
496 |
context step_P_cps_e |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
497 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
498 |
|
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
|
499 |
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
|
500 |
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
|
501 |
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
|
502 |
show ?thesis by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
503 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
504 |
|
60 | 505 |
lemma subtree_kept: |
506 |
assumes "th' \<noteq> th" |
|
507 |
shows "subtree (RAG s) (Th th') = subtree (RAG s') (Th th')" |
|
508 |
proof(unfold RAG_s, rule subtree_insert_next) |
|
509 |
from in_no_others_subtree[OF assms] |
|
510 |
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
|
511 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
512 |
|
60 | 513 |
lemma cp_kept: |
514 |
assumes "th' \<noteq> th" |
|
515 |
shows "cp s th' = cp s' th'" |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
516 |
proof - |
60 | 517 |
have "(the_preced s ` {th'a. Th th'a \<in> subtree (RAG s) (Th th')}) = |
518 |
(the_preced s' ` {th'a. Th th'a \<in> subtree (RAG s') (Th th')})" |
|
519 |
by (unfold preced_kept subtree_kept[OF assms], simp) |
|
520 |
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
|
521 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
522 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
523 |
end |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
524 |
|
58 | 525 |
context step_P_cps_ne |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
526 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
527 |
|
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
|
528 |
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
|
529 |
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
|
530 |
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
|
531 |
show ?thesis by (simp add:s_def) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
532 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
533 |
|
58 | 534 |
lemma cs_held: "(Cs cs, Th th') \<in> RAG s'" |
535 |
proof - |
|
536 |
have "(Cs cs, Th th') \<in> hRAG s'" |
|
537 |
proof - |
|
538 |
from ne |
|
539 |
have " holding s' th' cs" |
|
540 |
by (unfold th'_def holding_eq cs_holding_def, auto) |
|
541 |
thus ?thesis |
|
542 |
by (unfold hRAG_def, auto) |
|
543 |
qed |
|
544 |
thus ?thesis by (unfold RAG_split, auto) |
|
545 |
qed |
|
546 |
||
547 |
lemma tRAG_s: |
|
548 |
"tRAG s = tRAG s' \<union> {(Th th, Th th')}" |
|
63 | 549 |
using RAG_tRAG_transfer[OF RAG_s cs_held] . |
58 | 550 |
|
551 |
lemma cp_kept: |
|
552 |
assumes "Th th'' \<notin> ancestors (tRAG s) (Th th)" |
|
553 |
shows "cp s th'' = cp s' th''" |
|
554 |
proof - |
|
555 |
have h: "subtree (tRAG s) (Th th'') = subtree (tRAG s') (Th th'')" |
|
556 |
proof - |
|
557 |
have "Th th' \<notin> subtree (tRAG s') (Th th'')" |
|
558 |
proof |
|
559 |
assume "Th th' \<in> subtree (tRAG s') (Th th'')" |
|
560 |
thus False |
|
561 |
proof(rule subtreeE) |
|
562 |
assume "Th th' = Th th''" |
|
563 |
from assms[unfolded tRAG_s ancestors_def, folded this] |
|
564 |
show ?thesis by auto |
|
565 |
next |
|
566 |
assume "Th th'' \<in> ancestors (tRAG s') (Th th')" |
|
567 |
moreover have "... \<subseteq> ancestors (tRAG s) (Th th')" |
|
568 |
proof(rule ancestors_mono) |
|
569 |
show "tRAG s' \<subseteq> tRAG s" by (unfold tRAG_s, auto) |
|
570 |
qed |
|
571 |
ultimately have "Th th'' \<in> ancestors (tRAG s) (Th th')" by auto |
|
572 |
moreover have "Th th' \<in> ancestors (tRAG s) (Th th)" |
|
573 |
by (unfold tRAG_s, auto simp:ancestors_def) |
|
574 |
ultimately have "Th th'' \<in> ancestors (tRAG s) (Th th)" |
|
575 |
by (auto simp:ancestors_def) |
|
576 |
with assms show ?thesis by auto |
|
577 |
qed |
|
578 |
qed |
|
579 |
from subtree_insert_next[OF this] |
|
580 |
have "subtree (tRAG s' \<union> {(Th th, Th th')}) (Th th'') = subtree (tRAG s') (Th th'')" . |
|
581 |
from this[folded tRAG_s] show ?thesis . |
|
582 |
qed |
|
583 |
show ?thesis by (unfold cp_alt_def1 h preced_kept, simp) |
|
584 |
qed |
|
585 |
||
60 | 586 |
lemma cp_gen_update_stop: (* ddd *) |
58 | 587 |
assumes "u \<in> ancestors (tRAG s) (Th th)" |
588 |
and "cp_gen s u = cp_gen s' u" |
|
589 |
and "y \<in> ancestors (tRAG s) u" |
|
590 |
shows "cp_gen s y = cp_gen s' y" |
|
591 |
using assms(3) |
|
592 |
proof(induct rule:wf_induct[OF vat_s.fsbttRAGs.wf]) |
|
593 |
case (1 x) |
|
594 |
show ?case (is "?L = ?R") |
|
595 |
proof - |
|
596 |
from tRAG_ancestorsE[OF 1(2)] |
|
597 |
obtain th2 where eq_x: "x = Th th2" by blast |
|
598 |
from vat_s.cp_gen_rec[OF this] |
|
599 |
have "?L = |
|
600 |
Max ({the_preced s th2} \<union> cp_gen s ` RTree.children (tRAG s) x)" . |
|
601 |
also have "... = |
|
602 |
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
|
603 |
|
58 | 604 |
proof - |
605 |
from preced_kept have "the_preced s th2 = the_preced s' th2" by simp |
|
606 |
moreover have "cp_gen s ` RTree.children (tRAG s) x = |
|
607 |
cp_gen s' ` RTree.children (tRAG s') x" |
|
608 |
proof - |
|
609 |
have "RTree.children (tRAG s) x = RTree.children (tRAG s') x" |
|
610 |
proof(unfold tRAG_s, rule children_union_kept) |
|
611 |
have start: "(Th th, Th th') \<in> tRAG s" |
|
612 |
by (unfold tRAG_s, auto) |
|
613 |
note x_u = 1(2) |
|
614 |
show "x \<notin> Range {(Th th, Th th')}" |
|
615 |
proof |
|
616 |
assume "x \<in> Range {(Th th, Th th')}" |
|
617 |
hence eq_x: "x = Th th'" using RangeE by auto |
|
618 |
show False |
|
619 |
proof(cases rule:vat_s.rtree_s.ancestors_headE[OF assms(1) start]) |
|
620 |
case 1 |
|
621 |
from x_u[folded this, unfolded eq_x] vat_s.acyclic_tRAG |
|
622 |
show ?thesis by (auto simp:ancestors_def acyclic_def) |
|
623 |
next |
|
624 |
case 2 |
|
625 |
with x_u[unfolded eq_x] |
|
626 |
have "(Th th', Th th') \<in> (tRAG s)^+" by (auto simp:ancestors_def) |
|
627 |
with vat_s.acyclic_tRAG show ?thesis by (auto simp:acyclic_def) |
|
628 |
qed |
|
629 |
qed |
|
630 |
qed |
|
631 |
moreover have "cp_gen s ` RTree.children (tRAG s) x = |
|
632 |
cp_gen s' ` RTree.children (tRAG s) x" (is "?f ` ?A = ?g ` ?A") |
|
633 |
proof(rule f_image_eq) |
|
634 |
fix a |
|
635 |
assume a_in: "a \<in> ?A" |
|
636 |
from 1(2) |
|
637 |
show "?f a = ?g a" |
|
638 |
proof(cases rule:vat_s.rtree_s.ancestors_childrenE[case_names in_ch out_ch]) |
|
639 |
case in_ch |
|
640 |
show ?thesis |
|
641 |
proof(cases "a = u") |
|
642 |
case True |
|
643 |
from assms(2)[folded this] show ?thesis . |
|
644 |
next |
|
645 |
case False |
|
646 |
have a_not_in: "a \<notin> ancestors (tRAG s) (Th th)" |
|
647 |
proof |
|
648 |
assume a_in': "a \<in> ancestors (tRAG s) (Th th)" |
|
649 |
have "a = u" |
|
650 |
proof(rule vat_s.rtree_s.ancestors_children_unique) |
|
651 |
from a_in' a_in show "a \<in> ancestors (tRAG s) (Th th) \<inter> |
|
652 |
RTree.children (tRAG s) x" by auto |
|
653 |
next |
|
654 |
from assms(1) in_ch show "u \<in> ancestors (tRAG s) (Th th) \<inter> |
|
655 |
RTree.children (tRAG s) x" by auto |
|
656 |
qed |
|
657 |
with False show False by simp |
|
658 |
qed |
|
659 |
from a_in obtain th_a where eq_a: "a = Th th_a" |
|
660 |
by (unfold RTree.children_def tRAG_alt_def, auto) |
|
661 |
from cp_kept[OF a_not_in[unfolded eq_a]] |
|
662 |
have "cp s th_a = cp s' th_a" . |
|
663 |
from this [unfolded cp_gen_def_cond[OF eq_a], folded eq_a] |
|
664 |
show ?thesis . |
|
665 |
qed |
|
666 |
next |
|
667 |
case (out_ch z) |
|
668 |
hence h: "z \<in> ancestors (tRAG s) u" "z \<in> RTree.children (tRAG s) x" by auto |
|
669 |
show ?thesis |
|
670 |
proof(cases "a = z") |
|
671 |
case True |
|
672 |
from h(2) have zx_in: "(z, x) \<in> (tRAG s)" by (auto simp:RTree.children_def) |
|
673 |
from 1(1)[rule_format, OF this h(1)] |
|
674 |
have eq_cp_gen: "cp_gen s z = cp_gen s' z" . |
|
675 |
with True show ?thesis by metis |
|
676 |
next |
|
677 |
case False |
|
678 |
from a_in obtain th_a where eq_a: "a = Th th_a" |
|
679 |
by (auto simp:RTree.children_def tRAG_alt_def) |
|
60 | 680 |
have "a \<notin> ancestors (tRAG s) (Th th)" |
681 |
proof |
|
682 |
assume a_in': "a \<in> ancestors (tRAG s) (Th th)" |
|
683 |
have "a = z" |
|
684 |
proof(rule vat_s.rtree_s.ancestors_children_unique) |
|
685 |
from assms(1) h(1) have "z \<in> ancestors (tRAG s) (Th th)" |
|
686 |
by (auto simp:ancestors_def) |
|
687 |
with h(2) show " z \<in> ancestors (tRAG s) (Th th) \<inter> |
|
688 |
RTree.children (tRAG s) x" by auto |
|
689 |
next |
|
690 |
from a_in a_in' |
|
691 |
show "a \<in> ancestors (tRAG s) (Th th) \<inter> RTree.children (tRAG s) x" |
|
692 |
by auto |
|
693 |
qed |
|
694 |
with False show False by auto |
|
695 |
qed |
|
58 | 696 |
from cp_kept[OF this[unfolded eq_a]] |
697 |
have "cp s th_a = cp s' th_a" . |
|
698 |
from this[unfolded cp_gen_def_cond[OF eq_a], folded eq_a] |
|
699 |
show ?thesis . |
|
700 |
qed |
|
701 |
qed |
|
702 |
qed |
|
703 |
ultimately show ?thesis by metis |
|
704 |
qed |
|
705 |
ultimately show ?thesis by simp |
|
706 |
qed |
|
707 |
also have "... = ?R" |
|
708 |
by (fold vat_s'.cp_gen_rec[OF eq_x], simp) |
|
709 |
finally show ?thesis . |
|
710 |
qed |
|
711 |
qed |
|
712 |
||
60 | 713 |
lemma cp_up: |
714 |
assumes "(Th th') \<in> ancestors (tRAG s) (Th th)" |
|
715 |
and "cp s th' = cp s' th'" |
|
716 |
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
|
717 |
shows "cp s th'' = cp s' th''" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
718 |
proof - |
60 | 719 |
have "cp_gen s (Th th'') = cp_gen s' (Th th'')" |
720 |
proof(rule cp_gen_update_stop[OF assms(1) _ assms(3)]) |
|
721 |
from assms(2) cp_gen_def_cond[OF refl[of "Th th'"]] |
|
722 |
show "cp_gen s (Th th') = cp_gen s' (Th th')" by metis |
|
723 |
qed |
|
724 |
with cp_gen_def_cond[OF refl[of "Th th''"]] |
|
725 |
show ?thesis by metis |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
726 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
727 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
728 |
end |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
729 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
730 |
locale step_create_cps = |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
731 |
fixes s' th prio s |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
732 |
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
|
733 |
assumes vt_s: "vt s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
734 |
|
60 | 735 |
sublocale step_create_cps < vat_s: valid_trace "s" |
736 |
by (unfold_locales, insert vt_s, simp) |
|
737 |
||
738 |
sublocale step_create_cps < vat_s': valid_trace "s'" |
|
739 |
by (unfold_locales, insert step_back_vt[OF vt_s[unfolded s_def]], simp) |
|
740 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
741 |
context step_create_cps |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
742 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
743 |
|
60 | 744 |
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
|
745 |
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
|
746 |
|
60 | 747 |
lemma tRAG_kept: "tRAG s = tRAG s'" |
748 |
by (unfold tRAG_alt_def RAG_kept, auto) |
|
749 |
||
750 |
lemma preced_kept: |
|
751 |
assumes "th' \<noteq> th" |
|
752 |
shows "the_preced s th' = the_preced s' th'" |
|
753 |
by (unfold s_def the_preced_def preced_def, insert assms, auto) |
|
754 |
||
755 |
lemma th_not_in: "Th th \<notin> Field (tRAG s')" |
|
756 |
proof - |
|
757 |
from vt_s[unfolded s_def] |
|
758 |
have "PIP s' (Create th prio)" by (cases, simp) |
|
759 |
hence "th \<notin> threads s'" by(cases, simp) |
|
760 |
from vat_s'.not_in_thread_isolated[OF this] |
|
761 |
have "Th th \<notin> Field (RAG s')" . |
|
762 |
with tRAG_Field show ?thesis by auto |
|
763 |
qed |
|
764 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
765 |
lemma eq_cp: |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
766 |
assumes neq_th: "th' \<noteq> th" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
767 |
shows "cp s th' = cp s' th'" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
768 |
proof - |
60 | 769 |
have "(the_preced s \<circ> the_thread) ` subtree (tRAG s) (Th th') = |
770 |
(the_preced s' \<circ> the_thread) ` subtree (tRAG s') (Th th')" |
|
771 |
proof(unfold tRAG_kept, rule f_image_eq) |
|
772 |
fix a |
|
773 |
assume a_in: "a \<in> subtree (tRAG s') (Th th')" |
|
774 |
then obtain th_a where eq_a: "a = Th th_a" |
|
775 |
proof(cases rule:subtreeE) |
|
776 |
case 2 |
|
777 |
from ancestors_Field[OF 2(2)] |
|
778 |
and that show ?thesis by (unfold tRAG_alt_def, auto) |
|
779 |
qed auto |
|
780 |
have neq_th_a: "th_a \<noteq> th" |
|
781 |
proof - |
|
782 |
have "(Th th) \<notin> subtree (tRAG s') (Th th')" |
|
783 |
proof |
|
784 |
assume "Th th \<in> subtree (tRAG s') (Th th')" |
|
785 |
thus False |
|
786 |
proof(cases rule:subtreeE) |
|
787 |
case 2 |
|
788 |
from ancestors_Field[OF this(2)] |
|
789 |
and th_not_in[unfolded Field_def] |
|
790 |
show ?thesis by auto |
|
791 |
qed (insert assms, auto) |
|
792 |
qed |
|
793 |
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
|
794 |
qed |
60 | 795 |
from preced_kept[OF this] |
796 |
show "(the_preced s \<circ> the_thread) a = (the_preced s' \<circ> the_thread) a" |
|
797 |
by (unfold eq_a, simp) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
798 |
qed |
60 | 799 |
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
|
800 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
801 |
|
60 | 802 |
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
|
803 |
proof - |
60 | 804 |
{ fix a |
805 |
assume "a \<in> RTree.children (tRAG s) (Th th)" |
|
806 |
hence "(a, Th th) \<in> tRAG s" by (auto simp:RTree.children_def) |
|
807 |
with th_not_in have False |
|
808 |
by (unfold Field_def tRAG_kept, auto) |
|
809 |
} thus ?thesis by auto |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
810 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
811 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
812 |
lemma eq_cp_th: "cp s th = preced th s" |
60 | 813 |
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
|
814 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
815 |
end |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
816 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
817 |
locale step_exit_cps = |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
818 |
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
|
819 |
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
|
820 |
assumes vt_s: "vt s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
821 |
|
60 | 822 |
sublocale step_exit_cps < vat_s: valid_trace "s" |
823 |
by (unfold_locales, insert vt_s, simp) |
|
824 |
||
825 |
sublocale step_exit_cps < vat_s': valid_trace "s'" |
|
826 |
by (unfold_locales, insert step_back_vt[OF vt_s[unfolded s_def]], simp) |
|
827 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
828 |
context step_exit_cps |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
829 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
830 |
|
60 | 831 |
lemma preced_kept: |
832 |
assumes "th' \<noteq> th" |
|
833 |
shows "the_preced s th' = the_preced s' th'" |
|
834 |
by (unfold s_def the_preced_def preced_def, insert assms, auto) |
|
835 |
||
836 |
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
|
837 |
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
|
838 |
|
60 | 839 |
lemma tRAG_kept: "tRAG s = tRAG s'" |
840 |
by (unfold tRAG_alt_def RAG_kept, auto) |
|
841 |
||
842 |
lemma th_ready: "th \<in> readys s'" |
|
843 |
proof - |
|
844 |
from vt_s[unfolded s_def] |
|
845 |
have "PIP s' (Exit th)" by (cases, simp) |
|
846 |
hence h: "th \<in> runing s' \<and> holdents s' th = {}" by (cases, metis) |
|
847 |
thus ?thesis by (unfold runing_def, auto) |
|
848 |
qed |
|
849 |
||
850 |
lemma th_holdents: "holdents s' th = {}" |
|
851 |
proof - |
|
852 |
from vt_s[unfolded s_def] |
|
853 |
have "PIP s' (Exit th)" by (cases, simp) |
|
854 |
thus ?thesis by (cases, metis) |
|
855 |
qed |
|
856 |
||
857 |
lemma th_RAG: "Th th \<notin> Field (RAG s')" |
|
858 |
proof - |
|
859 |
have "Th th \<notin> Range (RAG s')" |
|
860 |
proof |
|
861 |
assume "Th th \<in> Range (RAG s')" |
|
862 |
then obtain cs where "holding (wq s') th cs" |
|
863 |
by (unfold Range_iff s_RAG_def, auto) |
|
864 |
with th_holdents[unfolded holdents_def] |
|
865 |
show False by (unfold eq_holding, auto) |
|
866 |
qed |
|
867 |
moreover have "Th th \<notin> Domain (RAG s')" |
|
868 |
proof |
|
869 |
assume "Th th \<in> Domain (RAG s')" |
|
870 |
then obtain cs where "waiting (wq s') th cs" |
|
871 |
by (unfold Domain_iff s_RAG_def, auto) |
|
872 |
with th_ready show False by (unfold readys_def eq_waiting, auto) |
|
873 |
qed |
|
874 |
ultimately show ?thesis by (auto simp:Field_def) |
|
875 |
qed |
|
876 |
||
877 |
lemma th_tRAG: "(Th th) \<notin> Field (tRAG s')" |
|
878 |
using th_RAG tRAG_Field[of s'] by auto |
|
879 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
880 |
lemma eq_cp: |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
881 |
assumes neq_th: "th' \<noteq> th" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
882 |
shows "cp s th' = cp s' th'" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
883 |
proof - |
60 | 884 |
have "(the_preced s \<circ> the_thread) ` subtree (tRAG s) (Th th') = |
885 |
(the_preced s' \<circ> the_thread) ` subtree (tRAG s') (Th th')" |
|
886 |
proof(unfold tRAG_kept, rule f_image_eq) |
|
887 |
fix a |
|
888 |
assume a_in: "a \<in> subtree (tRAG s') (Th th')" |
|
889 |
then obtain th_a where eq_a: "a = Th th_a" |
|
890 |
proof(cases rule:subtreeE) |
|
891 |
case 2 |
|
892 |
from ancestors_Field[OF 2(2)] |
|
893 |
and that show ?thesis by (unfold tRAG_alt_def, auto) |
|
894 |
qed auto |
|
895 |
have neq_th_a: "th_a \<noteq> th" |
|
896 |
proof - |
|
61 | 897 |
from vat_s'.readys_in_no_subtree[OF th_ready assms] |
60 | 898 |
have "(Th th) \<notin> subtree (RAG s') (Th th')" . |
899 |
with tRAG_subtree_RAG[of s' "Th th'"] |
|
900 |
have "(Th th) \<notin> subtree (tRAG s') (Th th')" by auto |
|
901 |
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
|
902 |
qed |
60 | 903 |
from preced_kept[OF this] |
904 |
show "(the_preced s \<circ> the_thread) a = (the_preced s' \<circ> the_thread) a" |
|
905 |
by (unfold eq_a, simp) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
906 |
qed |
60 | 907 |
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
|
908 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
909 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
910 |
end |
60 | 911 |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
912 |
end |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
913 |