author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Fri, 15 Apr 2016 14:44:09 +0100 | |
changeset 124 | 71a3300d497b |
parent 122 | 420e03a2d9cc |
child 125 | 95e7933968f8 |
permissions | -rw-r--r-- |
93
524bd3caa6b6
The overwriten original .thy files are working now. The ones in last revision aren't.
zhangx
parents:
92
diff
changeset
|
1 |
theory Correctness |
524bd3caa6b6
The overwriten original .thy files are working now. The ones in last revision aren't.
zhangx
parents:
92
diff
changeset
|
2 |
imports PIPBasics |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
|
63 | 5 |
text {* |
6 |
The following two auxiliary lemmas are used to reason about @{term Max}. |
|
7 |
*} |
|
8 |
lemma image_Max_eqI: |
|
9 |
assumes "finite B" |
|
10 |
and "b \<in> B" |
|
11 |
and "\<forall> x \<in> B. f x \<le> f b" |
|
12 |
shows "Max (f ` B) = f b" |
|
13 |
using assms |
|
14 |
using Max_eqI by blast |
|
15 |
||
16 |
lemma image_Max_subset: |
|
17 |
assumes "finite A" |
|
18 |
and "B \<subseteq> A" |
|
19 |
and "a \<in> B" |
|
20 |
and "Max (f ` A) = f a" |
|
21 |
shows "Max (f ` B) = f a" |
|
22 |
proof(rule image_Max_eqI) |
|
23 |
show "finite B" |
|
24 |
using assms(1) assms(2) finite_subset by auto |
|
25 |
next |
|
26 |
show "a \<in> B" using assms by simp |
|
27 |
next |
|
28 |
show "\<forall>x\<in>B. f x \<le> f a" |
|
29 |
by (metis Max_ge assms(1) assms(2) assms(4) |
|
30 |
finite_imageI image_eqI subsetCE) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
31 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
32 |
|
63 | 33 |
text {* |
34 |
The following locale @{text "highest_gen"} sets the basic context for our |
|
35 |
investigation: supposing thread @{text th} holds the highest @{term cp}-value |
|
36 |
in state @{text s}, which means the task for @{text th} is the |
|
37 |
most urgent. We want to show that |
|
38 |
@{text th} is treated correctly by PIP, which means |
|
39 |
@{text th} will not be blocked unreasonably by other less urgent |
|
40 |
threads. |
|
41 |
*} |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
42 |
locale highest_gen = |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
43 |
fixes s th prio tm |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
44 |
assumes vt_s: "vt s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
45 |
and threads_s: "th \<in> threads s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
46 |
and highest: "preced th s = Max ((cp s)`threads s)" |
63 | 47 |
-- {* The internal structure of @{term th}'s precedence is exposed:*} |
48 |
and preced_th: "preced th s = Prc prio tm" |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
49 |
|
63 | 50 |
-- {* @{term s} is a valid trace, so it will inherit all results derived for |
51 |
a valid trace: *} |
|
122
420e03a2d9cc
all updated to Isabelle 2016
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
116
diff
changeset
|
52 |
sublocale highest_gen < vat_s?: valid_trace "s" |
62 | 53 |
by (unfold_locales, insert vt_s, simp) |
54 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
55 |
context highest_gen |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
56 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
57 |
|
63 | 58 |
text {* |
59 |
@{term tm} is the time when the precedence of @{term th} is set, so |
|
60 |
@{term tm} must be a valid moment index into @{term s}. |
|
61 |
*} |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
62 |
lemma lt_tm: "tm < length s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
63 |
by (insert preced_tm_lt[OF threads_s preced_th], simp) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
64 |
|
63 | 65 |
text {* |
66 |
Since @{term th} holds the highest precedence and @{text "cp"} |
|
67 |
is the highest precedence of all threads in the sub-tree of |
|
68 |
@{text "th"} and @{text th} is among these threads, |
|
69 |
its @{term cp} must equal to its precedence: |
|
70 |
*} |
|
62 | 71 |
lemma eq_cp_s_th: "cp s th = preced th s" (is "?L = ?R") |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
72 |
proof - |
62 | 73 |
have "?L \<le> ?R" |
74 |
by (unfold highest, rule Max_ge, |
|
63 | 75 |
auto simp:threads_s finite_threads) |
62 | 76 |
moreover have "?R \<le> ?L" |
77 |
by (unfold vat_s.cp_rec, rule Max_ge, |
|
78 |
auto simp:the_preced_def vat_s.fsbttRAGs.finite_children) |
|
79 |
ultimately show ?thesis by auto |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
80 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
81 |
|
68 | 82 |
lemma highest_cp_preced: "cp s th = Max (the_preced s ` threads s)" |
83 |
using eq_cp_s_th highest max_cp_eq the_preced_def by presburger |
|
84 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
85 |
|
68 | 86 |
lemma highest_preced_thread: "preced th s = Max (the_preced s ` threads s)" |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
87 |
by (fold eq_cp_s_th, unfold highest_cp_preced, simp) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
88 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
89 |
lemma highest': "cp s th = Max (cp s ` threads s)" |
68 | 90 |
by (simp add: eq_cp_s_th highest) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
91 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
92 |
end |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
93 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
94 |
locale extend_highest_gen = highest_gen + |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
95 |
fixes t |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
96 |
assumes vt_t: "vt (t@s)" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
97 |
and create_low: "Create th' prio' \<in> set t \<Longrightarrow> prio' \<le> prio" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
98 |
and set_diff_low: "Set th' prio' \<in> set t \<Longrightarrow> th' \<noteq> th \<and> prio' \<le> prio" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
99 |
and exit_diff: "Exit th' \<in> set t \<Longrightarrow> th' \<noteq> th" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
100 |
|
122
420e03a2d9cc
all updated to Isabelle 2016
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
116
diff
changeset
|
101 |
sublocale extend_highest_gen < vat_t?: valid_trace "t@s" |
63 | 102 |
by (unfold_locales, insert vt_t, simp) |
103 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
104 |
lemma step_back_vt_app: |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
105 |
assumes vt_ts: "vt (t@s)" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
106 |
shows "vt s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
107 |
proof - |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
108 |
from vt_ts show ?thesis |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
109 |
proof(induct t) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
110 |
case Nil |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
111 |
from Nil show ?case by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
112 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
113 |
case (Cons e t) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
114 |
assume ih: " vt (t @ s) \<Longrightarrow> vt s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
115 |
and vt_et: "vt ((e # t) @ s)" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
116 |
show ?case |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
117 |
proof(rule ih) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
118 |
show "vt (t @ s)" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
119 |
proof(rule step_back_vt) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
120 |
from vt_et show "vt (e # t @ s)" by simp |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
121 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
122 |
qed |
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 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
125 |
|
73 | 126 |
(* locale red_extend_highest_gen = extend_highest_gen + |
62 | 127 |
fixes i::nat |
73 | 128 |
*) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
129 |
|
73 | 130 |
(* |
62 | 131 |
sublocale red_extend_highest_gen < red_moment: extend_highest_gen "s" "th" "prio" "tm" "(moment i t)" |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
132 |
apply (insert extend_highest_gen_axioms, subst (asm) (1) moment_restm_s [of i t, symmetric]) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
133 |
apply (unfold extend_highest_gen_def extend_highest_gen_axioms_def, clarsimp) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
134 |
by (unfold highest_gen_def, auto dest:step_back_vt_app) |
73 | 135 |
*) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
136 |
|
62 | 137 |
context extend_highest_gen |
138 |
begin |
|
139 |
||
140 |
lemma ind [consumes 0, case_names Nil Cons, induct type]: |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
141 |
assumes |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
142 |
h0: "R []" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
143 |
and h2: "\<And> e t. \<lbrakk>vt (t@s); step (t@s) e; |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
144 |
extend_highest_gen s th prio tm t; |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
145 |
extend_highest_gen s th prio tm (e#t); R t\<rbrakk> \<Longrightarrow> R (e#t)" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
146 |
shows "R t" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
147 |
proof - |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
148 |
from vt_t extend_highest_gen_axioms show ?thesis |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
149 |
proof(induct t) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
150 |
from h0 show "R []" . |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
151 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
152 |
case (Cons e t') |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
153 |
assume ih: "\<lbrakk>vt (t' @ s); extend_highest_gen s th prio tm t'\<rbrakk> \<Longrightarrow> R t'" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
154 |
and vt_e: "vt ((e # t') @ s)" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
155 |
and et: "extend_highest_gen s th prio tm (e # t')" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
156 |
from vt_e and step_back_step have stp: "step (t'@s) e" by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
157 |
from vt_e and step_back_vt have vt_ts: "vt (t'@s)" by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
158 |
show ?case |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
159 |
proof(rule h2 [OF vt_ts stp _ _ _ ]) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
160 |
show "R t'" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
161 |
proof(rule ih) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
162 |
from et show ext': "extend_highest_gen s th prio tm t'" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
163 |
by (unfold extend_highest_gen_def extend_highest_gen_axioms_def, auto dest:step_back_vt) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
164 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
165 |
from vt_ts show "vt (t' @ s)" . |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
166 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
167 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
168 |
from et show "extend_highest_gen s th prio tm (e # t')" . |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
169 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
170 |
from et show ext': "extend_highest_gen s th prio tm t'" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
171 |
by (unfold extend_highest_gen_def extend_highest_gen_axioms_def, auto dest:step_back_vt) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
172 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
173 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
174 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
175 |
|
62 | 176 |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
177 |
lemma th_kept: "th \<in> threads (t @ s) \<and> |
62 | 178 |
preced th (t@s) = preced th s" (is "?Q t") |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
179 |
proof - |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
180 |
show ?thesis |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
181 |
proof(induct rule:ind) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
182 |
case Nil |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
183 |
from threads_s |
62 | 184 |
show ?case |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
185 |
by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
186 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
187 |
case (Cons e t) |
62 | 188 |
interpret h_e: extend_highest_gen _ _ _ _ "(e # t)" using Cons by auto |
189 |
interpret h_t: extend_highest_gen _ _ _ _ t using Cons by auto |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
190 |
show ?case |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
191 |
proof(cases e) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
192 |
case (Create thread prio) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
193 |
show ?thesis |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
194 |
proof - |
62 | 195 |
from Cons and Create have "step (t@s) (Create thread prio)" by auto |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
196 |
hence "th \<noteq> thread" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
197 |
proof(cases) |
62 | 198 |
case thread_create |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
199 |
with Cons show ?thesis by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
200 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
201 |
hence "preced th ((e # t) @ s) = preced th (t @ s)" |
62 | 202 |
by (unfold Create, auto simp:preced_def) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
203 |
moreover note Cons |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
204 |
ultimately show ?thesis |
62 | 205 |
by (auto simp:Create) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
206 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
207 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
208 |
case (Exit thread) |
62 | 209 |
from h_e.exit_diff and Exit |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
210 |
have neq_th: "thread \<noteq> th" by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
211 |
with Cons |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
212 |
show ?thesis |
62 | 213 |
by (unfold Exit, auto simp:preced_def) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
214 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
215 |
case (P thread cs) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
216 |
with Cons |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
217 |
show ?thesis |
62 | 218 |
by (auto simp:P preced_def) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
219 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
220 |
case (V thread cs) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
221 |
with Cons |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
222 |
show ?thesis |
62 | 223 |
by (auto simp:V preced_def) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
224 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
225 |
case (Set thread prio') |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
226 |
show ?thesis |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
227 |
proof - |
62 | 228 |
from h_e.set_diff_low and Set |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
229 |
have "th \<noteq> thread" by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
230 |
hence "preced th ((e # t) @ s) = preced th (t @ s)" |
62 | 231 |
by (unfold Set, auto simp:preced_def) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
232 |
moreover note Cons |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
233 |
ultimately show ?thesis |
62 | 234 |
by (auto simp:Set) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
235 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
236 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
237 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
238 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
239 |
|
63 | 240 |
text {* |
241 |
According to @{thm th_kept}, thread @{text "th"} has its living status |
|
242 |
and precedence kept along the way of @{text "t"}. The following lemma |
|
243 |
shows that this preserved precedence of @{text "th"} remains as the highest |
|
244 |
along the way of @{text "t"}. |
|
62 | 245 |
|
63 | 246 |
The proof goes by induction over @{text "t"} using the specialized |
247 |
induction rule @{thm ind}, followed by case analysis of each possible |
|
248 |
operations of PIP. All cases follow the same pattern rendered by the |
|
249 |
generalized introduction rule @{thm "image_Max_eqI"}. |
|
250 |
||
68 | 251 |
The very essence is to show that precedences, no matter whether they |
252 |
are newly introduced or modified, are always lower than the one held |
|
253 |
by @{term "th"}, which by @{thm th_kept} is preserved along the way. |
|
63 | 254 |
*} |
62 | 255 |
lemma max_kept: "Max (the_preced (t @ s) ` (threads (t@s))) = preced th s" |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
256 |
proof(induct rule:ind) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
257 |
case Nil |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
258 |
from highest_preced_thread |
68 | 259 |
show ?case by simp |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
260 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
261 |
case (Cons e t) |
62 | 262 |
interpret h_e: extend_highest_gen _ _ _ _ "(e # t)" using Cons by auto |
263 |
interpret h_t: extend_highest_gen _ _ _ _ t using Cons by auto |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
264 |
show ?case |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
265 |
proof(cases e) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
266 |
case (Create thread prio') |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
267 |
show ?thesis (is "Max (?f ` ?A) = ?t") |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
268 |
proof - |
63 | 269 |
-- {* The following is the common pattern of each branch of the case analysis. *} |
270 |
-- {* The major part is to show that @{text "th"} holds the highest precedence: *} |
|
271 |
have "Max (?f ` ?A) = ?f th" |
|
272 |
proof(rule image_Max_eqI) |
|
273 |
show "finite ?A" using h_e.finite_threads by auto |
|
274 |
next |
|
275 |
show "th \<in> ?A" using h_e.th_kept by auto |
|
276 |
next |
|
277 |
show "\<forall>x\<in>?A. ?f x \<le> ?f th" |
|
278 |
proof |
|
279 |
fix x |
|
280 |
assume "x \<in> ?A" |
|
281 |
hence "x = thread \<or> x \<in> threads (t@s)" by (auto simp:Create) |
|
282 |
thus "?f x \<le> ?f th" |
|
283 |
proof |
|
284 |
assume "x = thread" |
|
285 |
thus ?thesis |
|
286 |
apply (simp add:Create the_preced_def preced_def, fold preced_def) |
|
68 | 287 |
using Create h_e.create_low h_t.th_kept lt_tm preced_leI2 |
288 |
preced_th by force |
|
63 | 289 |
next |
290 |
assume h: "x \<in> threads (t @ s)" |
|
291 |
from Cons(2)[unfolded Create] |
|
292 |
have "x \<noteq> thread" using h by (cases, auto) |
|
293 |
hence "?f x = the_preced (t@s) x" |
|
294 |
by (simp add:Create the_preced_def preced_def) |
|
295 |
hence "?f x \<le> Max (the_preced (t@s) ` threads (t@s))" |
|
296 |
by (simp add: h_t.finite_threads h) |
|
297 |
also have "... = ?f th" |
|
298 |
by (metis Cons.hyps(5) h_e.th_kept the_preced_def) |
|
299 |
finally show ?thesis . |
|
300 |
qed |
|
301 |
qed |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
302 |
qed |
63 | 303 |
-- {* The minor part is to show that the precedence of @{text "th"} |
304 |
equals to preserved one, given by the foregoing lemma @{thm th_kept} *} |
|
305 |
also have "... = ?t" using h_e.th_kept the_preced_def by auto |
|
306 |
-- {* Then it follows trivially that the precedence preserved |
|
307 |
for @{term "th"} remains the maximum of all living threads along the way. *} |
|
308 |
finally show ?thesis . |
|
309 |
qed |
|
62 | 310 |
next |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
311 |
case (Exit thread) |
63 | 312 |
show ?thesis (is "Max (?f ` ?A) = ?t") |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
313 |
proof - |
63 | 314 |
have "Max (?f ` ?A) = ?f th" |
315 |
proof(rule image_Max_eqI) |
|
316 |
show "finite ?A" using h_e.finite_threads by auto |
|
62 | 317 |
next |
63 | 318 |
show "th \<in> ?A" using h_e.th_kept by auto |
62 | 319 |
next |
63 | 320 |
show "\<forall>x\<in>?A. ?f x \<le> ?f th" |
321 |
proof |
|
322 |
fix x |
|
323 |
assume "x \<in> ?A" |
|
324 |
hence "x \<in> threads (t@s)" by (simp add: Exit) |
|
325 |
hence "?f x \<le> Max (?f ` threads (t@s))" |
|
326 |
by (simp add: h_t.finite_threads) |
|
327 |
also have "... \<le> ?f th" |
|
328 |
apply (simp add:Exit the_preced_def preced_def, fold preced_def) |
|
329 |
using Cons.hyps(5) h_t.th_kept the_preced_def by auto |
|
330 |
finally show "?f x \<le> ?f th" . |
|
331 |
qed |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
332 |
qed |
63 | 333 |
also have "... = ?t" using h_e.th_kept the_preced_def by auto |
334 |
finally show ?thesis . |
|
335 |
qed |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
336 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
337 |
case (P thread cs) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
338 |
with Cons |
62 | 339 |
show ?thesis by (auto simp:preced_def the_preced_def) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
340 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
341 |
case (V thread cs) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
342 |
with Cons |
62 | 343 |
show ?thesis by (auto simp:preced_def the_preced_def) |
63 | 344 |
next |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
345 |
case (Set thread prio') |
63 | 346 |
show ?thesis (is "Max (?f ` ?A) = ?t") |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
347 |
proof - |
63 | 348 |
have "Max (?f ` ?A) = ?f th" |
349 |
proof(rule image_Max_eqI) |
|
350 |
show "finite ?A" using h_e.finite_threads by auto |
|
351 |
next |
|
352 |
show "th \<in> ?A" using h_e.th_kept by auto |
|
353 |
next |
|
354 |
show "\<forall>x\<in>?A. ?f x \<le> ?f th" |
|
355 |
proof |
|
356 |
fix x |
|
357 |
assume h: "x \<in> ?A" |
|
358 |
show "?f x \<le> ?f th" |
|
359 |
proof(cases "x = thread") |
|
360 |
case True |
|
361 |
moreover have "the_preced (Set thread prio' # t @ s) thread \<le> the_preced (t @ s) th" |
|
362 |
proof - |
|
363 |
have "the_preced (t @ s) th = Prc prio tm" |
|
364 |
using h_t.th_kept preced_th by (simp add:the_preced_def) |
|
365 |
moreover have "prio' \<le> prio" using Set h_e.set_diff_low by auto |
|
366 |
ultimately show ?thesis by (insert lt_tm, auto simp:the_preced_def preced_def) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
367 |
qed |
63 | 368 |
ultimately show ?thesis |
369 |
by (unfold Set, simp add:the_preced_def preced_def) |
|
370 |
next |
|
371 |
case False |
|
372 |
then have "?f x = the_preced (t@s) x" |
|
373 |
by (simp add:the_preced_def preced_def Set) |
|
374 |
also have "... \<le> Max (the_preced (t@s) ` threads (t@s))" |
|
375 |
using Set h h_t.finite_threads by auto |
|
376 |
also have "... = ?f th" by (metis Cons.hyps(5) h_e.th_kept the_preced_def) |
|
377 |
finally show ?thesis . |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
378 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
379 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
380 |
qed |
63 | 381 |
also have "... = ?t" using h_e.th_kept the_preced_def by auto |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
382 |
finally show ?thesis . |
63 | 383 |
qed |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
384 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
385 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
386 |
|
63 | 387 |
lemma max_preced: "preced th (t@s) = Max (the_preced (t@s) ` (threads (t@s)))" |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
388 |
by (insert th_kept max_kept, auto) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
389 |
|
63 | 390 |
text {* |
391 |
The reason behind the following lemma is that: |
|
392 |
Since @{term "cp"} is defined as the maximum precedence |
|
393 |
of those threads contained in the sub-tree of node @{term "Th th"} |
|
394 |
in @{term "RAG (t@s)"}, and all these threads are living threads, and |
|
395 |
@{term "th"} is also among them, the maximum precedence of |
|
396 |
them all must be the one for @{text "th"}. |
|
397 |
*} |
|
398 |
lemma th_cp_max_preced: |
|
399 |
"cp (t@s) th = Max (the_preced (t@s) ` (threads (t@s)))" (is "?L = ?R") |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
400 |
proof - |
63 | 401 |
let ?f = "the_preced (t@s)" |
402 |
have "?L = ?f th" |
|
403 |
proof(unfold cp_alt_def, rule image_Max_eqI) |
|
404 |
show "finite {th'. Th th' \<in> subtree (RAG (t @ s)) (Th th)}" |
|
405 |
proof - |
|
406 |
have "{th'. Th th' \<in> subtree (RAG (t @ s)) (Th th)} = |
|
407 |
the_thread ` {n . n \<in> subtree (RAG (t @ s)) (Th th) \<and> |
|
408 |
(\<exists> th'. n = Th th')}" |
|
107
30ed212f268a
updated Correctness, Implementation and PIPBasics so that they work with Isabelle 2014 and 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
409 |
by (force) |
63 | 410 |
moreover have "finite ..." by (simp add: vat_t.fsbtRAGs.finite_subtree) |
411 |
ultimately show ?thesis by simp |
|
412 |
qed |
|
413 |
next |
|
414 |
show "th \<in> {th'. Th th' \<in> subtree (RAG (t @ s)) (Th th)}" |
|
415 |
by (auto simp:subtree_def) |
|
416 |
next |
|
417 |
show "\<forall>x\<in>{th'. Th th' \<in> subtree (RAG (t @ s)) (Th th)}. |
|
418 |
the_preced (t @ s) x \<le> the_preced (t @ s) th" |
|
419 |
proof |
|
420 |
fix th' |
|
421 |
assume "th' \<in> {th'. Th th' \<in> subtree (RAG (t @ s)) (Th th)}" |
|
422 |
hence "Th th' \<in> subtree (RAG (t @ s)) (Th th)" by auto |
|
423 |
moreover have "... \<subseteq> Field (RAG (t @ s)) \<union> {Th th}" |
|
424 |
by (meson subtree_Field) |
|
425 |
ultimately have "Th th' \<in> ..." by auto |
|
426 |
hence "th' \<in> threads (t@s)" |
|
427 |
proof |
|
428 |
assume "Th th' \<in> {Th th}" |
|
429 |
thus ?thesis using th_kept by auto |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
430 |
next |
63 | 431 |
assume "Th th' \<in> Field (RAG (t @ s))" |
432 |
thus ?thesis using vat_t.not_in_thread_isolated by blast |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
433 |
qed |
63 | 434 |
thus "the_preced (t @ s) th' \<le> the_preced (t @ s) th" |
435 |
by (metis Max_ge finite_imageI finite_threads image_eqI |
|
436 |
max_kept th_kept the_preced_def) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
437 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
438 |
qed |
63 | 439 |
also have "... = ?R" by (simp add: max_preced the_preced_def) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
440 |
finally show ?thesis . |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
441 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
442 |
|
68 | 443 |
lemma th_cp_max[simp]: "Max (cp (t@s) ` threads (t@s)) = cp (t@s) th" |
63 | 444 |
using max_cp_eq th_cp_max_preced the_preced_def vt_t by presburger |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
445 |
|
68 | 446 |
lemma [simp]: "Max (cp (t@s) ` threads (t@s)) = Max (the_preced (t@s) ` threads (t@s))" |
447 |
by (simp add: th_cp_max_preced) |
|
448 |
||
449 |
lemma [simp]: "Max (the_preced (t@s) ` threads (t@s)) = the_preced (t@s) th" |
|
450 |
using max_kept th_kept the_preced_def by auto |
|
451 |
||
452 |
lemma [simp]: "the_preced (t@s) th = preced th (t@s)" |
|
453 |
using the_preced_def by auto |
|
454 |
||
455 |
lemma [simp]: "preced th (t@s) = preced th s" |
|
456 |
by (simp add: th_kept) |
|
457 |
||
458 |
lemma [simp]: "cp s th = preced th s" |
|
459 |
by (simp add: eq_cp_s_th) |
|
460 |
||
461 |
lemma th_cp_preced [simp]: "cp (t@s) th = preced th s" |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
462 |
by (fold max_kept, unfold th_cp_max_preced, simp) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
463 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
464 |
lemma preced_less: |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
465 |
assumes th'_in: "th' \<in> threads s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
466 |
and neq_th': "th' \<noteq> th" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
467 |
shows "preced th' s < preced th s" |
63 | 468 |
using assms |
469 |
by (metis Max.coboundedI finite_imageI highest not_le order.trans |
|
470 |
preced_linorder rev_image_eqI threads_s vat_s.finite_threads |
|
471 |
vat_s.le_cp) |
|
472 |
||
68 | 473 |
section {* The `blocking thread` *} |
474 |
||
475 |
text {* |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
476 |
The purpose of PIP is to ensure that the most |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
477 |
urgent thread @{term th} is not blocked unreasonably. |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
478 |
Therefore, a clear picture of the blocking thread is essential |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
479 |
to assure people that the purpose is fulfilled. |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
480 |
|
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
481 |
In this section, we are going to derive a series of lemmas |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
482 |
with finally give rise to a picture of the blocking thread. |
68 | 483 |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
484 |
By `blocking thread`, we mean a thread in running state but |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
485 |
different from thread @{term th}. |
68 | 486 |
*} |
487 |
||
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
488 |
text {* |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
489 |
The following lemmas shows that the @{term cp}-value |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
490 |
of the blocking thread @{text th'} equals to the highest |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
491 |
precedence in the whole system. |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
492 |
*} |
63 | 493 |
lemma runing_preced_inversion: |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
494 |
assumes runing': "th' \<in> runing (t@s)" |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
495 |
shows "cp (t@s) th' = preced th s" (is "?L = ?R") |
63 | 496 |
proof - |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
497 |
have "?L = Max (cp (t @ s) ` readys (t @ s))" using assms |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
498 |
by (unfold runing_def, auto) |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
499 |
also have "\<dots> = ?R" |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
500 |
by (metis th_cp_max th_cp_preced vat_t.max_cp_readys_threads) |
63 | 501 |
finally show ?thesis . |
502 |
qed |
|
503 |
||
68 | 504 |
text {* |
505 |
||
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
506 |
The following lemma shows how the counters for @{term "P"} and |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
507 |
@{term "V"} operations relate to the running threads in the states |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
508 |
@{term s} and @{term "t @ s"}. The lemma shows that if a thread's |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
509 |
@{term "P"}-count equals its @{term "V"}-count (which means it no |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
510 |
longer has any resource in its possession), it cannot be a running |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
511 |
thread. |
67 | 512 |
|
76
b6ea51cd2e88
some small changes to the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
513 |
The proof is by contraction with the assumption @{text "th' \<noteq> th"}. |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
514 |
The key is the use of @{thm eq_pv_dependants} to derive the |
76
b6ea51cd2e88
some small changes to the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
515 |
emptiness of @{text th'}s @{term dependants}-set from the balance of |
b6ea51cd2e88
some small changes to the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
516 |
its @{term P} and @{term V} counts. From this, it can be shown |
b6ea51cd2e88
some small changes to the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
517 |
@{text th'}s @{term cp}-value equals to its own precedence. |
67 | 518 |
|
76
b6ea51cd2e88
some small changes to the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
519 |
On the other hand, since @{text th'} is running, by @{thm |
b6ea51cd2e88
some small changes to the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
520 |
runing_preced_inversion}, its @{term cp}-value equals to the |
b6ea51cd2e88
some small changes to the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
521 |
precedence of @{term th}. |
68 | 522 |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
523 |
Combining the above two resukts we have that @{text th'} and @{term |
76
b6ea51cd2e88
some small changes to the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
524 |
th} have the same precedence. By uniqueness of precedences, we have |
b6ea51cd2e88
some small changes to the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
525 |
@{text "th' = th"}, which is in contradiction with the assumption |
b6ea51cd2e88
some small changes to the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
526 |
@{text "th' \<noteq> th"}. |
b6ea51cd2e88
some small changes to the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
527 |
|
68 | 528 |
*} |
67 | 529 |
|
530 |
lemma eq_pv_blocked: (* ddd *) |
|
531 |
assumes neq_th': "th' \<noteq> th" |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
532 |
and eq_pv: "cntP (t@s) th' = cntV (t@s) th'" |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
533 |
shows "th' \<notin> runing (t@s)" |
67 | 534 |
proof |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
535 |
assume otherwise: "th' \<in> runing (t@s)" |
67 | 536 |
show False |
537 |
proof - |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
538 |
have th'_in: "th' \<in> threads (t@s)" |
67 | 539 |
using otherwise readys_threads runing_def by auto |
540 |
have "th' = th" |
|
541 |
proof(rule preced_unique) |
|
542 |
-- {* The proof goes like this: |
|
543 |
it is first shown that the @{term preced}-value of @{term th'} |
|
544 |
equals to that of @{term th}, then by uniqueness |
|
545 |
of @{term preced}-values (given by lemma @{thm preced_unique}), |
|
546 |
@{term th'} equals to @{term th}: *} |
|
547 |
show "preced th' (t @ s) = preced th (t @ s)" (is "?L = ?R") |
|
548 |
proof - |
|
549 |
-- {* Since the counts of @{term th'} are balanced, the subtree |
|
550 |
of it contains only itself, so, its @{term cp}-value |
|
551 |
equals its @{term preced}-value: *} |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
552 |
have "?L = cp (t@s) th'" |
108 | 553 |
by (unfold cp_eq cpreced_def eq_dependants vat_t.eq_pv_dependants[OF eq_pv], simp) |
68 | 554 |
-- {* Since @{term "th'"} is running, by @{thm runing_preced_inversion}, |
555 |
its @{term cp}-value equals @{term "preced th s"}, |
|
556 |
which equals to @{term "?R"} by simplification: *} |
|
67 | 557 |
also have "... = ?R" |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
558 |
thm runing_preced_inversion |
68 | 559 |
using runing_preced_inversion[OF otherwise] by simp |
67 | 560 |
finally show ?thesis . |
561 |
qed |
|
562 |
qed (auto simp: th'_in th_kept) |
|
68 | 563 |
with `th' \<noteq> th` show ?thesis by simp |
67 | 564 |
qed |
565 |
qed |
|
566 |
||
567 |
text {* |
|
568 |
The following lemma is the extrapolation of @{thm eq_pv_blocked}. |
|
569 |
It says if a thread, different from @{term th}, |
|
570 |
does not hold any resource at the very beginning, |
|
571 |
it will keep hand-emptied in the future @{term "t@s"}. |
|
572 |
*} |
|
573 |
lemma eq_pv_persist: (* ddd *) |
|
574 |
assumes neq_th': "th' \<noteq> th" |
|
575 |
and eq_pv: "cntP s th' = cntV s th'" |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
576 |
shows "cntP (t@s) th' = cntV (t@s) th'" |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
577 |
proof(induction rule:ind) -- {* The proof goes by induction. *} |
67 | 578 |
-- {* The nontrivial case is for the @{term Cons}: *} |
579 |
case (Cons e t) |
|
580 |
-- {* All results derived so far hold for both @{term s} and @{term "t@s"}: *} |
|
581 |
interpret vat_t: extend_highest_gen s th prio tm t using Cons by simp |
|
582 |
interpret vat_e: extend_highest_gen s th prio tm "(e # t)" using Cons by simp |
|
102
3a801bbd2687
Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents:
93
diff
changeset
|
583 |
interpret vat_es: valid_trace_e "t@s" e using Cons(1,2) by (unfold_locales, auto) |
67 | 584 |
show ?case |
585 |
proof - |
|
586 |
-- {* It can be proved that @{term cntP}-value of @{term th'} does not change |
|
587 |
by the happening of event @{term e}: *} |
|
588 |
have "cntP ((e#t)@s) th' = cntP (t@s) th'" |
|
589 |
proof(rule ccontr) -- {* Proof by contradiction. *} |
|
590 |
-- {* Suppose @{term cntP}-value of @{term th'} is changed by @{term e}: *} |
|
591 |
assume otherwise: "cntP ((e # t) @ s) th' \<noteq> cntP (t @ s) th'" |
|
116 | 592 |
from cntP_diff_inv[OF this[simplified]] |
593 |
obtain cs' where "e = P th' cs'" by auto |
|
594 |
from vat_es.pip_e[unfolded this] |
|
595 |
have "th' \<in> runing (t@s)" |
|
596 |
by (cases, simp) |
|
67 | 597 |
-- {* However, an application of @{thm eq_pv_blocked} to induction hypothesis |
598 |
shows @{term th'} can not be running at moment @{term "t@s"}: *} |
|
599 |
moreover have "th' \<notin> runing (t@s)" |
|
600 |
using vat_t.eq_pv_blocked[OF neq_th' Cons(5)] . |
|
601 |
-- {* Contradiction is finally derived: *} |
|
602 |
ultimately show False by simp |
|
603 |
qed |
|
604 |
-- {* It can also be proved that @{term cntV}-value of @{term th'} does not change |
|
605 |
by the happening of event @{term e}: *} |
|
606 |
-- {* The proof follows exactly the same pattern as the case for @{term cntP}-value: *} |
|
607 |
moreover have "cntV ((e#t)@s) th' = cntV (t@s) th'" |
|
608 |
proof(rule ccontr) -- {* Proof by contradiction. *} |
|
609 |
assume otherwise: "cntV ((e # t) @ s) th' \<noteq> cntV (t @ s) th'" |
|
116 | 610 |
from cntV_diff_inv[OF this[simplified]] |
611 |
obtain cs' where "e = V th' cs'" by auto |
|
612 |
from vat_es.pip_e[unfolded this] |
|
613 |
have "th' \<in> runing (t@s)" by (cases, auto) |
|
67 | 614 |
moreover have "th' \<notin> runing (t@s)" |
615 |
using vat_t.eq_pv_blocked[OF neq_th' Cons(5)] . |
|
616 |
ultimately show False by simp |
|
617 |
qed |
|
618 |
-- {* Finally, it can be shown that the @{term cntP} and @{term cntV} |
|
619 |
value for @{term th'} are still in balance, so @{term th'} |
|
620 |
is still hand-emptied after the execution of event @{term e}: *} |
|
621 |
ultimately show ?thesis using Cons(5) by metis |
|
622 |
qed |
|
623 |
qed (auto simp:eq_pv) |
|
624 |
||
625 |
text {* |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
626 |
By combining @{thm eq_pv_blocked} and @{thm eq_pv_persist}, |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
627 |
it can be derived easily that @{term th'} can not be running in the future: |
67 | 628 |
*} |
629 |
lemma eq_pv_blocked_persist: |
|
630 |
assumes neq_th': "th' \<noteq> th" |
|
631 |
and eq_pv: "cntP s th' = cntV s th'" |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
632 |
shows "th' \<notin> runing (t@s)" |
67 | 633 |
using assms |
634 |
by (simp add: eq_pv_blocked eq_pv_persist) |
|
635 |
||
636 |
text {* |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
637 |
The following lemma shows the blocking thread @{term th'} |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
638 |
must hold some resource in the very beginning. |
67 | 639 |
*} |
640 |
lemma runing_cntP_cntV_inv: (* ddd *) |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
641 |
assumes is_runing: "th' \<in> runing (t@s)" |
67 | 642 |
and neq_th': "th' \<noteq> th" |
643 |
shows "cntP s th' > cntV s th'" |
|
644 |
using assms |
|
645 |
proof - |
|
646 |
-- {* First, it can be shown that the number of @{term P} and |
|
647 |
@{term V} operations can not be equal for thred @{term th'} *} |
|
648 |
have "cntP s th' \<noteq> cntV s th'" |
|
649 |
proof |
|
650 |
-- {* The proof goes by contradiction, suppose otherwise: *} |
|
651 |
assume otherwise: "cntP s th' = cntV s th'" |
|
652 |
-- {* By applying @{thm eq_pv_blocked_persist} to this: *} |
|
653 |
from eq_pv_blocked_persist[OF neq_th' otherwise] |
|
654 |
-- {* we have that @{term th'} can not be running at moment @{term "t@s"}: *} |
|
655 |
have "th' \<notin> runing (t@s)" . |
|
656 |
-- {* This is obvious in contradiction with assumption @{thm is_runing} *} |
|
657 |
thus False using is_runing by simp |
|
658 |
qed |
|
659 |
-- {* However, the number of @{term V} is always less or equal to @{term P}: *} |
|
660 |
moreover have "cntV s th' \<le> cntP s th'" using vat_s.cnp_cnv_cncs by auto |
|
661 |
-- {* Thesis is finally derived by combining the these two results: *} |
|
662 |
ultimately show ?thesis by auto |
|
663 |
qed |
|
664 |
||
63 | 665 |
|
666 |
text {* |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
667 |
The following lemmas shows the blocking thread @{text th'} must be live |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
668 |
at the very beginning, i.e. the moment (or state) @{term s}. |
67 | 669 |
|
670 |
The proof is a simple combination of the results above: |
|
63 | 671 |
*} |
67 | 672 |
lemma runing_threads_inv: |
66 | 673 |
assumes runing': "th' \<in> runing (t@s)" |
674 |
and neq_th': "th' \<noteq> th" |
|
63 | 675 |
shows "th' \<in> threads s" |
67 | 676 |
proof(rule ccontr) -- {* Proof by contradiction: *} |
677 |
assume otherwise: "th' \<notin> threads s" |
|
678 |
have "th' \<notin> runing (t @ s)" |
|
679 |
proof - |
|
680 |
from vat_s.cnp_cnv_eq[OF otherwise] |
|
681 |
have "cntP s th' = cntV s th'" . |
|
682 |
from eq_pv_blocked_persist[OF neq_th' this] |
|
683 |
show ?thesis . |
|
684 |
qed |
|
685 |
with runing' show False by simp |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
686 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
687 |
|
66 | 688 |
text {* |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
689 |
The following lemma summarizes several foregoing |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
690 |
lemmas to give an overall picture of the blocking thread @{text "th'"}: |
63 | 691 |
*} |
67 | 692 |
lemma runing_inversion: (* ddd, one of the main lemmas to present *) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
693 |
assumes runing': "th' \<in> runing (t@s)" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
694 |
and neq_th: "th' \<noteq> th" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
695 |
shows "th' \<in> threads s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
696 |
and "\<not>detached s th'" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
697 |
and "cp (t@s) th' = preced th s" |
66 | 698 |
proof - |
699 |
from runing_threads_inv[OF assms] |
|
700 |
show "th' \<in> threads s" . |
|
701 |
next |
|
67 | 702 |
from runing_cntP_cntV_inv[OF runing' neq_th] |
66 | 703 |
show "\<not>detached s th'" using vat_s.detached_eq by simp |
704 |
next |
|
705 |
from runing_preced_inversion[OF runing'] |
|
706 |
show "cp (t@s) th' = preced th s" . |
|
707 |
qed |
|
63 | 708 |
|
67 | 709 |
section {* The existence of `blocking thread` *} |
710 |
||
63 | 711 |
text {* |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
712 |
Suppose @{term th} is not running, it is first shown that |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
713 |
there is a path in RAG leading from node @{term th} to another thread @{text "th'"} |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
714 |
in the @{term readys}-set (So @{text "th'"} is an ancestor of @{term th}}). |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
715 |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
716 |
Now, since @{term readys}-set is non-empty, there must be |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
717 |
one in it which holds the highest @{term cp}-value, which, by definition, |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
718 |
is the @{term runing}-thread. However, we are going to show more: this running thread |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
719 |
is exactly @{term "th'"}. |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
720 |
*} |
67 | 721 |
lemma th_blockedE: (* ddd, the other main lemma to be presented: *) |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
722 |
assumes "th \<notin> runing (t@s)" |
63 | 723 |
obtains th' where "Th th' \<in> ancestors (RAG (t @ s)) (Th th)" |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
724 |
"th' \<in> runing (t@s)" |
63 | 725 |
proof - |
726 |
-- {* According to @{thm vat_t.th_chain_to_ready}, either |
|
727 |
@{term "th"} is in @{term "readys"} or there is path leading from it to |
|
728 |
one thread in @{term "readys"}. *} |
|
729 |
have "th \<in> readys (t @ s) \<or> (\<exists>th'. th' \<in> readys (t @ s) \<and> (Th th, Th th') \<in> (RAG (t @ s))\<^sup>+)" |
|
730 |
using th_kept vat_t.th_chain_to_ready by auto |
|
731 |
-- {* However, @{term th} can not be in @{term readys}, because otherwise, since |
|
732 |
@{term th} holds the highest @{term cp}-value, it must be @{term "runing"}. *} |
|
733 |
moreover have "th \<notin> readys (t@s)" |
|
734 |
using assms runing_def th_cp_max vat_t.max_cp_readys_threads by auto |
|
735 |
-- {* So, there must be a path from @{term th} to another thread @{text "th'"} in |
|
736 |
term @{term readys}: *} |
|
737 |
ultimately obtain th' where th'_in: "th' \<in> readys (t@s)" |
|
738 |
and dp: "(Th th, Th th') \<in> (RAG (t @ s))\<^sup>+" by auto |
|
739 |
-- {* We are going to show that this @{term th'} is running. *} |
|
740 |
have "th' \<in> runing (t@s)" |
|
741 |
proof - |
|
742 |
-- {* We only need to show that this @{term th'} holds the highest @{term cp}-value: *} |
|
743 |
have "cp (t@s) th' = Max (cp (t@s) ` readys (t@s))" (is "?L = ?R") |
|
744 |
proof - |
|
745 |
have "?L = Max ((the_preced (t @ s) \<circ> the_thread) ` subtree (tRAG (t @ s)) (Th th'))" |
|
746 |
by (unfold cp_alt_def1, simp) |
|
747 |
also have "... = (the_preced (t @ s) \<circ> the_thread) (Th th)" |
|
748 |
proof(rule image_Max_subset) |
|
749 |
show "finite (Th ` (threads (t@s)))" by (simp add: vat_t.finite_threads) |
|
750 |
next |
|
751 |
show "subtree (tRAG (t @ s)) (Th th') \<subseteq> Th ` threads (t @ s)" |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
752 |
by (metis Range.intros dp trancl_range vat_t.rg_RAG_threads vat_t.subtree_tRAG_thread) |
63 | 753 |
next |
754 |
show "Th th \<in> subtree (tRAG (t @ s)) (Th th')" using dp |
|
755 |
by (unfold tRAG_subtree_eq, auto simp:subtree_def) |
|
756 |
next |
|
757 |
show "Max ((the_preced (t @ s) \<circ> the_thread) ` Th ` threads (t @ s)) = |
|
758 |
(the_preced (t @ s) \<circ> the_thread) (Th th)" (is "Max ?L = _") |
|
759 |
proof - |
|
760 |
have "?L = the_preced (t @ s) ` threads (t @ s)" |
|
761 |
by (unfold image_comp, rule image_cong, auto) |
|
762 |
thus ?thesis using max_preced the_preced_def by auto |
|
763 |
qed |
|
764 |
qed |
|
765 |
also have "... = ?R" |
|
766 |
using th_cp_max th_cp_preced th_kept |
|
767 |
the_preced_def vat_t.max_cp_readys_threads by auto |
|
768 |
finally show ?thesis . |
|
769 |
qed |
|
770 |
-- {* Now, since @{term th'} holds the highest @{term cp} |
|
771 |
and we have already show it is in @{term readys}, |
|
772 |
it is @{term runing} by definition. *} |
|
773 |
with `th' \<in> readys (t@s)` show ?thesis by (simp add: runing_def) |
|
774 |
qed |
|
775 |
-- {* It is easy to show @{term th'} is an ancestor of @{term th}: *} |
|
776 |
moreover have "Th th' \<in> ancestors (RAG (t @ s)) (Th th)" |
|
777 |
using `(Th th, Th th') \<in> (RAG (t @ s))\<^sup>+` by (auto simp:ancestors_def) |
|
778 |
ultimately show ?thesis using that by metis |
|
779 |
qed |
|
780 |
||
781 |
text {* |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
782 |
Now it is easy to see there is always a thread to run by case analysis |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
783 |
on whether thread @{term th} is running: if the answer is Yes, the |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
784 |
the running thread is obviously @{term th} itself; otherwise, the running |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
785 |
thread is the @{text th'} given by lemma @{thm th_blockedE}. |
63 | 786 |
*} |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
787 |
lemma live: "runing (t@s) \<noteq> {}" |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
788 |
proof(cases "th \<in> runing (t@s)") |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
789 |
case True thus ?thesis by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
790 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
791 |
case False |
63 | 792 |
thus ?thesis using th_blockedE by auto |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
793 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
794 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
795 |
end |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
796 |
end |