author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Fri, 17 Jun 2016 09:46:25 +0100 | |
changeset 130 | 0f124691c191 |
parent 127 | 38c6acf03f68 |
child 136 | fb3f52fe99d1 |
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 |
||
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
55 |
fun occs where |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
56 |
"occs Q [] = (if Q [] then 1 else 0::nat)" | |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
57 |
"occs Q (x#xs) = (if Q (x#xs) then (1 + occs Q xs) else occs Q xs)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
58 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
59 |
lemma occs_le: "occs Q t + occs (\<lambda> e. \<not> Q e) t \<le> (1 + length t)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
60 |
by (induct t, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
61 |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
62 |
context highest_gen |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
63 |
begin |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
64 |
|
63 | 65 |
text {* |
66 |
@{term tm} is the time when the precedence of @{term th} is set, so |
|
67 |
@{term tm} must be a valid moment index into @{term s}. |
|
68 |
*} |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
69 |
lemma lt_tm: "tm < length s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
70 |
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
|
71 |
|
63 | 72 |
text {* |
73 |
Since @{term th} holds the highest precedence and @{text "cp"} |
|
74 |
is the highest precedence of all threads in the sub-tree of |
|
75 |
@{text "th"} and @{text th} is among these threads, |
|
76 |
its @{term cp} must equal to its precedence: |
|
77 |
*} |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
78 |
|
62 | 79 |
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
|
80 |
proof - |
62 | 81 |
have "?L \<le> ?R" |
82 |
by (unfold highest, rule Max_ge, |
|
63 | 83 |
auto simp:threads_s finite_threads) |
62 | 84 |
moreover have "?R \<le> ?L" |
85 |
by (unfold vat_s.cp_rec, rule Max_ge, |
|
86 |
auto simp:the_preced_def vat_s.fsbttRAGs.finite_children) |
|
87 |
ultimately show ?thesis by auto |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
88 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
89 |
|
68 | 90 |
lemma highest_cp_preced: "cp s th = Max (the_preced s ` threads s)" |
91 |
using eq_cp_s_th highest max_cp_eq the_preced_def by presburger |
|
92 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
93 |
|
68 | 94 |
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
|
95 |
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
|
96 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
97 |
lemma highest': "cp s th = Max (cp s ` threads s)" |
68 | 98 |
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
|
99 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
100 |
end |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
101 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
102 |
locale extend_highest_gen = highest_gen + |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
103 |
fixes t |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
104 |
assumes vt_t: "vt (t@s)" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
105 |
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
|
106 |
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
|
107 |
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
|
108 |
|
122
420e03a2d9cc
all updated to Isabelle 2016
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
116
diff
changeset
|
109 |
sublocale extend_highest_gen < vat_t?: valid_trace "t@s" |
63 | 110 |
by (unfold_locales, insert vt_t, simp) |
111 |
||
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
112 |
lemma step_back_vt_app: |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
113 |
assumes vt_ts: "vt (t@s)" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
114 |
shows "vt s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
115 |
proof - |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
116 |
from vt_ts show ?thesis |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
117 |
proof(induct t) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
118 |
case Nil |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
119 |
from Nil show ?case by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
120 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
121 |
case (Cons e t) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
122 |
assume ih: " vt (t @ s) \<Longrightarrow> vt s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
123 |
and vt_et: "vt ((e # t) @ s)" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
124 |
show ?case |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
125 |
proof(rule ih) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
126 |
show "vt (t @ s)" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
127 |
proof(rule step_back_vt) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
128 |
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
|
129 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
130 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
131 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
132 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
133 |
|
73 | 134 |
(* locale red_extend_highest_gen = extend_highest_gen + |
62 | 135 |
fixes i::nat |
73 | 136 |
*) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
137 |
|
73 | 138 |
(* |
62 | 139 |
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
|
140 |
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
|
141 |
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
|
142 |
by (unfold highest_gen_def, auto dest:step_back_vt_app) |
73 | 143 |
*) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
144 |
|
62 | 145 |
context extend_highest_gen |
146 |
begin |
|
147 |
||
148 |
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
|
149 |
assumes |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
150 |
h0: "R []" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
151 |
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
|
152 |
extend_highest_gen s th prio tm t; |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
153 |
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
|
154 |
shows "R t" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
155 |
proof - |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
156 |
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
|
157 |
proof(induct t) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
158 |
from h0 show "R []" . |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
159 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
160 |
case (Cons e t') |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
161 |
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
|
162 |
and vt_e: "vt ((e # t') @ s)" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
163 |
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
|
164 |
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
|
165 |
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
|
166 |
show ?case |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
167 |
proof(rule h2 [OF vt_ts stp _ _ _ ]) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
168 |
show "R t'" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
169 |
proof(rule ih) |
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 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
173 |
from vt_ts show "vt (t' @ s)" . |
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 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
176 |
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
|
177 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
178 |
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
|
179 |
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
|
180 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
181 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
182 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
183 |
|
62 | 184 |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
185 |
lemma th_kept: "th \<in> threads (t @ s) \<and> |
62 | 186 |
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
|
187 |
proof - |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
188 |
show ?thesis |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
189 |
proof(induct rule:ind) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
190 |
case Nil |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
191 |
from threads_s |
62 | 192 |
show ?case |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
193 |
by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
194 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
195 |
case (Cons e t) |
62 | 196 |
interpret h_e: extend_highest_gen _ _ _ _ "(e # t)" using Cons by auto |
197 |
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
|
198 |
show ?case |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
199 |
proof(cases e) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
200 |
case (Create thread prio) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
201 |
show ?thesis |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
202 |
proof - |
62 | 203 |
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
|
204 |
hence "th \<noteq> thread" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
205 |
proof(cases) |
62 | 206 |
case thread_create |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
207 |
with Cons show ?thesis by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
208 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
209 |
hence "preced th ((e # t) @ s) = preced th (t @ s)" |
62 | 210 |
by (unfold Create, auto simp:preced_def) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
211 |
moreover note Cons |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
212 |
ultimately show ?thesis |
62 | 213 |
by (auto simp:Create) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
214 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
215 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
216 |
case (Exit thread) |
62 | 217 |
from h_e.exit_diff and Exit |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
218 |
have neq_th: "thread \<noteq> th" by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
219 |
with Cons |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
220 |
show ?thesis |
62 | 221 |
by (unfold Exit, auto simp:preced_def) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
222 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
223 |
case (P thread cs) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
224 |
with Cons |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
225 |
show ?thesis |
62 | 226 |
by (auto simp:P preced_def) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
227 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
228 |
case (V thread cs) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
229 |
with Cons |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
230 |
show ?thesis |
62 | 231 |
by (auto simp:V preced_def) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
232 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
233 |
case (Set thread prio') |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
234 |
show ?thesis |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
235 |
proof - |
62 | 236 |
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
|
237 |
have "th \<noteq> thread" by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
238 |
hence "preced th ((e # t) @ s) = preced th (t @ s)" |
62 | 239 |
by (unfold Set, auto simp:preced_def) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
240 |
moreover note Cons |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
241 |
ultimately show ?thesis |
62 | 242 |
by (auto simp:Set) |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
243 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
244 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
245 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
246 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
247 |
|
63 | 248 |
text {* |
249 |
According to @{thm th_kept}, thread @{text "th"} has its living status |
|
250 |
and precedence kept along the way of @{text "t"}. The following lemma |
|
251 |
shows that this preserved precedence of @{text "th"} remains as the highest |
|
252 |
along the way of @{text "t"}. |
|
62 | 253 |
|
63 | 254 |
The proof goes by induction over @{text "t"} using the specialized |
255 |
induction rule @{thm ind}, followed by case analysis of each possible |
|
256 |
operations of PIP. All cases follow the same pattern rendered by the |
|
257 |
generalized introduction rule @{thm "image_Max_eqI"}. |
|
258 |
||
68 | 259 |
The very essence is to show that precedences, no matter whether they |
260 |
are newly introduced or modified, are always lower than the one held |
|
261 |
by @{term "th"}, which by @{thm th_kept} is preserved along the way. |
|
63 | 262 |
*} |
62 | 263 |
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
|
264 |
proof(induct rule:ind) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
265 |
case Nil |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
266 |
from highest_preced_thread |
68 | 267 |
show ?case by simp |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
268 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
269 |
case (Cons e t) |
62 | 270 |
interpret h_e: extend_highest_gen _ _ _ _ "(e # t)" using Cons by auto |
271 |
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
|
272 |
show ?case |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
273 |
proof(cases e) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
274 |
case (Create thread prio') |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
275 |
show ?thesis (is "Max (?f ` ?A) = ?t") |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
276 |
proof - |
63 | 277 |
-- {* The following is the common pattern of each branch of the case analysis. *} |
278 |
-- {* The major part is to show that @{text "th"} holds the highest precedence: *} |
|
279 |
have "Max (?f ` ?A) = ?f th" |
|
280 |
proof(rule image_Max_eqI) |
|
281 |
show "finite ?A" using h_e.finite_threads by auto |
|
282 |
next |
|
283 |
show "th \<in> ?A" using h_e.th_kept by auto |
|
284 |
next |
|
285 |
show "\<forall>x\<in>?A. ?f x \<le> ?f th" |
|
286 |
proof |
|
287 |
fix x |
|
288 |
assume "x \<in> ?A" |
|
289 |
hence "x = thread \<or> x \<in> threads (t@s)" by (auto simp:Create) |
|
290 |
thus "?f x \<le> ?f th" |
|
291 |
proof |
|
292 |
assume "x = thread" |
|
293 |
thus ?thesis |
|
294 |
apply (simp add:Create the_preced_def preced_def, fold preced_def) |
|
68 | 295 |
using Create h_e.create_low h_t.th_kept lt_tm preced_leI2 |
296 |
preced_th by force |
|
63 | 297 |
next |
298 |
assume h: "x \<in> threads (t @ s)" |
|
299 |
from Cons(2)[unfolded Create] |
|
300 |
have "x \<noteq> thread" using h by (cases, auto) |
|
301 |
hence "?f x = the_preced (t@s) x" |
|
302 |
by (simp add:Create the_preced_def preced_def) |
|
303 |
hence "?f x \<le> Max (the_preced (t@s) ` threads (t@s))" |
|
304 |
by (simp add: h_t.finite_threads h) |
|
305 |
also have "... = ?f th" |
|
306 |
by (metis Cons.hyps(5) h_e.th_kept the_preced_def) |
|
307 |
finally show ?thesis . |
|
308 |
qed |
|
309 |
qed |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
310 |
qed |
63 | 311 |
-- {* The minor part is to show that the precedence of @{text "th"} |
312 |
equals to preserved one, given by the foregoing lemma @{thm th_kept} *} |
|
313 |
also have "... = ?t" using h_e.th_kept the_preced_def by auto |
|
314 |
-- {* Then it follows trivially that the precedence preserved |
|
315 |
for @{term "th"} remains the maximum of all living threads along the way. *} |
|
316 |
finally show ?thesis . |
|
317 |
qed |
|
62 | 318 |
next |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
319 |
case (Exit thread) |
63 | 320 |
show ?thesis (is "Max (?f ` ?A) = ?t") |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
321 |
proof - |
63 | 322 |
have "Max (?f ` ?A) = ?f th" |
323 |
proof(rule image_Max_eqI) |
|
324 |
show "finite ?A" using h_e.finite_threads by auto |
|
62 | 325 |
next |
63 | 326 |
show "th \<in> ?A" using h_e.th_kept by auto |
62 | 327 |
next |
63 | 328 |
show "\<forall>x\<in>?A. ?f x \<le> ?f th" |
329 |
proof |
|
330 |
fix x |
|
331 |
assume "x \<in> ?A" |
|
332 |
hence "x \<in> threads (t@s)" by (simp add: Exit) |
|
333 |
hence "?f x \<le> Max (?f ` threads (t@s))" |
|
334 |
by (simp add: h_t.finite_threads) |
|
335 |
also have "... \<le> ?f th" |
|
336 |
apply (simp add:Exit the_preced_def preced_def, fold preced_def) |
|
337 |
using Cons.hyps(5) h_t.th_kept the_preced_def by auto |
|
338 |
finally show "?f x \<le> ?f th" . |
|
339 |
qed |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
340 |
qed |
63 | 341 |
also have "... = ?t" using h_e.th_kept the_preced_def by auto |
342 |
finally show ?thesis . |
|
343 |
qed |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
344 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
345 |
case (P thread cs) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
346 |
with Cons |
62 | 347 |
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
|
348 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
349 |
case (V thread cs) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
350 |
with Cons |
62 | 351 |
show ?thesis by (auto simp:preced_def the_preced_def) |
63 | 352 |
next |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
353 |
case (Set thread prio') |
63 | 354 |
show ?thesis (is "Max (?f ` ?A) = ?t") |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
355 |
proof - |
63 | 356 |
have "Max (?f ` ?A) = ?f th" |
357 |
proof(rule image_Max_eqI) |
|
358 |
show "finite ?A" using h_e.finite_threads by auto |
|
359 |
next |
|
360 |
show "th \<in> ?A" using h_e.th_kept by auto |
|
361 |
next |
|
362 |
show "\<forall>x\<in>?A. ?f x \<le> ?f th" |
|
363 |
proof |
|
364 |
fix x |
|
365 |
assume h: "x \<in> ?A" |
|
366 |
show "?f x \<le> ?f th" |
|
367 |
proof(cases "x = thread") |
|
368 |
case True |
|
369 |
moreover have "the_preced (Set thread prio' # t @ s) thread \<le> the_preced (t @ s) th" |
|
370 |
proof - |
|
371 |
have "the_preced (t @ s) th = Prc prio tm" |
|
372 |
using h_t.th_kept preced_th by (simp add:the_preced_def) |
|
373 |
moreover have "prio' \<le> prio" using Set h_e.set_diff_low by auto |
|
374 |
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
|
375 |
qed |
63 | 376 |
ultimately show ?thesis |
377 |
by (unfold Set, simp add:the_preced_def preced_def) |
|
378 |
next |
|
379 |
case False |
|
380 |
then have "?f x = the_preced (t@s) x" |
|
381 |
by (simp add:the_preced_def preced_def Set) |
|
382 |
also have "... \<le> Max (the_preced (t@s) ` threads (t@s))" |
|
383 |
using Set h h_t.finite_threads by auto |
|
384 |
also have "... = ?f th" by (metis Cons.hyps(5) h_e.th_kept the_preced_def) |
|
385 |
finally show ?thesis . |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
386 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
387 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
388 |
qed |
63 | 389 |
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
|
390 |
finally show ?thesis . |
63 | 391 |
qed |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
392 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
393 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
394 |
|
63 | 395 |
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
|
396 |
by (insert th_kept max_kept, auto) |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
397 |
|
63 | 398 |
text {* |
399 |
The reason behind the following lemma is that: |
|
400 |
Since @{term "cp"} is defined as the maximum precedence |
|
401 |
of those threads contained in the sub-tree of node @{term "Th th"} |
|
402 |
in @{term "RAG (t@s)"}, and all these threads are living threads, and |
|
403 |
@{term "th"} is also among them, the maximum precedence of |
|
404 |
them all must be the one for @{text "th"}. |
|
405 |
*} |
|
406 |
lemma th_cp_max_preced: |
|
407 |
"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
|
408 |
proof - |
63 | 409 |
let ?f = "the_preced (t@s)" |
410 |
have "?L = ?f th" |
|
411 |
proof(unfold cp_alt_def, rule image_Max_eqI) |
|
412 |
show "finite {th'. Th th' \<in> subtree (RAG (t @ s)) (Th th)}" |
|
413 |
proof - |
|
414 |
have "{th'. Th th' \<in> subtree (RAG (t @ s)) (Th th)} = |
|
415 |
the_thread ` {n . n \<in> subtree (RAG (t @ s)) (Th th) \<and> |
|
416 |
(\<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
|
417 |
by (force) |
63 | 418 |
moreover have "finite ..." by (simp add: vat_t.fsbtRAGs.finite_subtree) |
419 |
ultimately show ?thesis by simp |
|
420 |
qed |
|
421 |
next |
|
422 |
show "th \<in> {th'. Th th' \<in> subtree (RAG (t @ s)) (Th th)}" |
|
423 |
by (auto simp:subtree_def) |
|
424 |
next |
|
425 |
show "\<forall>x\<in>{th'. Th th' \<in> subtree (RAG (t @ s)) (Th th)}. |
|
426 |
the_preced (t @ s) x \<le> the_preced (t @ s) th" |
|
427 |
proof |
|
428 |
fix th' |
|
429 |
assume "th' \<in> {th'. Th th' \<in> subtree (RAG (t @ s)) (Th th)}" |
|
430 |
hence "Th th' \<in> subtree (RAG (t @ s)) (Th th)" by auto |
|
431 |
moreover have "... \<subseteq> Field (RAG (t @ s)) \<union> {Th th}" |
|
432 |
by (meson subtree_Field) |
|
433 |
ultimately have "Th th' \<in> ..." by auto |
|
434 |
hence "th' \<in> threads (t@s)" |
|
435 |
proof |
|
436 |
assume "Th th' \<in> {Th th}" |
|
437 |
thus ?thesis using th_kept by auto |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
438 |
next |
63 | 439 |
assume "Th th' \<in> Field (RAG (t @ s))" |
440 |
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
|
441 |
qed |
63 | 442 |
thus "the_preced (t @ s) th' \<le> the_preced (t @ s) th" |
443 |
by (metis Max_ge finite_imageI finite_threads image_eqI |
|
444 |
max_kept th_kept the_preced_def) |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
445 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
446 |
qed |
63 | 447 |
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
|
448 |
finally show ?thesis . |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
449 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
450 |
|
68 | 451 |
lemma th_cp_max[simp]: "Max (cp (t@s) ` threads (t@s)) = cp (t@s) th" |
63 | 452 |
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
|
453 |
|
68 | 454 |
lemma [simp]: "Max (cp (t@s) ` threads (t@s)) = Max (the_preced (t@s) ` threads (t@s))" |
455 |
by (simp add: th_cp_max_preced) |
|
456 |
||
457 |
lemma [simp]: "Max (the_preced (t@s) ` threads (t@s)) = the_preced (t@s) th" |
|
458 |
using max_kept th_kept the_preced_def by auto |
|
459 |
||
460 |
lemma [simp]: "the_preced (t@s) th = preced th (t@s)" |
|
461 |
using the_preced_def by auto |
|
462 |
||
463 |
lemma [simp]: "preced th (t@s) = preced th s" |
|
464 |
by (simp add: th_kept) |
|
465 |
||
466 |
lemma [simp]: "cp s th = preced th s" |
|
467 |
by (simp add: eq_cp_s_th) |
|
468 |
||
469 |
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
|
470 |
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
|
471 |
|
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
472 |
lemma preced_less: |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
473 |
assumes th'_in: "th' \<in> threads s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
474 |
and neq_th': "th' \<noteq> th" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
475 |
shows "preced th' s < preced th s" |
63 | 476 |
using assms |
477 |
by (metis Max.coboundedI finite_imageI highest not_le order.trans |
|
478 |
preced_linorder rev_image_eqI threads_s vat_s.finite_threads |
|
479 |
vat_s.le_cp) |
|
480 |
||
68 | 481 |
section {* The `blocking thread` *} |
482 |
||
483 |
text {* |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
484 |
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
|
485 |
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
|
486 |
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
|
487 |
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
|
488 |
|
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
489 |
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
|
490 |
with finally give rise to a picture of the blocking thread. |
68 | 491 |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
492 |
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
|
493 |
different from thread @{term th}. |
68 | 494 |
*} |
495 |
||
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
496 |
text {* |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
497 |
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
|
498 |
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
|
499 |
precedence in the whole system. |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
500 |
*} |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
501 |
lemma running_preced_inversion: |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
502 |
assumes running': "th' \<in> running (t@s)" |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
503 |
shows "cp (t@s) th' = preced th s" (is "?L = ?R") |
63 | 504 |
proof - |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
505 |
have "?L = Max (cp (t @ s) ` readys (t @ s))" using assms |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
506 |
by (unfold running_def, auto) |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
507 |
also have "\<dots> = ?R" |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
508 |
by (metis th_cp_max th_cp_preced vat_t.max_cp_readys_threads) |
63 | 509 |
finally show ?thesis . |
510 |
qed |
|
511 |
||
68 | 512 |
text {* |
513 |
||
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
514 |
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
|
515 |
@{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
|
516 |
@{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
|
517 |
@{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
|
518 |
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
|
519 |
thread. |
67 | 520 |
|
76
b6ea51cd2e88
some small changes to the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
521 |
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
|
522 |
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
|
523 |
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
|
524 |
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
|
525 |
@{text th'}s @{term cp}-value equals to its own precedence. |
67 | 526 |
|
76
b6ea51cd2e88
some small changes to the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
527 |
On the other hand, since @{text th'} is running, by @{thm |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
528 |
running_preced_inversion}, its @{term cp}-value equals to the |
76
b6ea51cd2e88
some small changes to the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
529 |
precedence of @{term th}. |
68 | 530 |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
531 |
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
|
532 |
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
|
533 |
@{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
|
534 |
@{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
|
535 |
|
68 | 536 |
*} |
67 | 537 |
|
538 |
lemma eq_pv_blocked: (* ddd *) |
|
539 |
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
|
540 |
and eq_pv: "cntP (t@s) th' = cntV (t@s) th'" |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
541 |
shows "th' \<notin> running (t@s)" |
67 | 542 |
proof |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
543 |
assume otherwise: "th' \<in> running (t@s)" |
67 | 544 |
show False |
545 |
proof - |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
546 |
have th'_in: "th' \<in> threads (t@s)" |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
547 |
using otherwise readys_threads running_def by auto |
67 | 548 |
have "th' = th" |
549 |
proof(rule preced_unique) |
|
550 |
-- {* The proof goes like this: |
|
551 |
it is first shown that the @{term preced}-value of @{term th'} |
|
552 |
equals to that of @{term th}, then by uniqueness |
|
553 |
of @{term preced}-values (given by lemma @{thm preced_unique}), |
|
554 |
@{term th'} equals to @{term th}: *} |
|
555 |
show "preced th' (t @ s) = preced th (t @ s)" (is "?L = ?R") |
|
556 |
proof - |
|
557 |
-- {* Since the counts of @{term th'} are balanced, the subtree |
|
558 |
of it contains only itself, so, its @{term cp}-value |
|
559 |
equals its @{term preced}-value: *} |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
560 |
have "?L = cp (t@s) th'" |
130
0f124691c191
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
561 |
by (simp add: detached_cp_preced eq_pv vat_t.detached_intro) |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
562 |
-- {* Since @{term "th'"} is running, by @{thm running_preced_inversion}, |
68 | 563 |
its @{term cp}-value equals @{term "preced th s"}, |
564 |
which equals to @{term "?R"} by simplification: *} |
|
67 | 565 |
also have "... = ?R" |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
566 |
thm running_preced_inversion |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
567 |
using running_preced_inversion[OF otherwise] by simp |
67 | 568 |
finally show ?thesis . |
569 |
qed |
|
570 |
qed (auto simp: th'_in th_kept) |
|
68 | 571 |
with `th' \<noteq> th` show ?thesis by simp |
67 | 572 |
qed |
573 |
qed |
|
574 |
||
575 |
text {* |
|
576 |
The following lemma is the extrapolation of @{thm eq_pv_blocked}. |
|
577 |
It says if a thread, different from @{term th}, |
|
578 |
does not hold any resource at the very beginning, |
|
579 |
it will keep hand-emptied in the future @{term "t@s"}. |
|
580 |
*} |
|
581 |
lemma eq_pv_persist: (* ddd *) |
|
582 |
assumes neq_th': "th' \<noteq> th" |
|
583 |
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
|
584 |
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
|
585 |
proof(induction rule:ind) -- {* The proof goes by induction. *} |
67 | 586 |
-- {* The nontrivial case is for the @{term Cons}: *} |
587 |
case (Cons e t) |
|
588 |
-- {* All results derived so far hold for both @{term s} and @{term "t@s"}: *} |
|
589 |
interpret vat_t: extend_highest_gen s th prio tm t using Cons by simp |
|
590 |
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
|
591 |
interpret vat_es: valid_trace_e "t@s" e using Cons(1,2) by (unfold_locales, auto) |
67 | 592 |
show ?case |
593 |
proof - |
|
594 |
-- {* It can be proved that @{term cntP}-value of @{term th'} does not change |
|
595 |
by the happening of event @{term e}: *} |
|
596 |
have "cntP ((e#t)@s) th' = cntP (t@s) th'" |
|
597 |
proof(rule ccontr) -- {* Proof by contradiction. *} |
|
598 |
-- {* Suppose @{term cntP}-value of @{term th'} is changed by @{term e}: *} |
|
599 |
assume otherwise: "cntP ((e # t) @ s) th' \<noteq> cntP (t @ s) th'" |
|
116 | 600 |
from cntP_diff_inv[OF this[simplified]] |
601 |
obtain cs' where "e = P th' cs'" by auto |
|
602 |
from vat_es.pip_e[unfolded this] |
|
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
603 |
have "th' \<in> running (t@s)" |
116 | 604 |
by (cases, simp) |
67 | 605 |
-- {* However, an application of @{thm eq_pv_blocked} to induction hypothesis |
606 |
shows @{term th'} can not be running at moment @{term "t@s"}: *} |
|
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
607 |
moreover have "th' \<notin> running (t@s)" |
67 | 608 |
using vat_t.eq_pv_blocked[OF neq_th' Cons(5)] . |
609 |
-- {* Contradiction is finally derived: *} |
|
610 |
ultimately show False by simp |
|
611 |
qed |
|
612 |
-- {* It can also be proved that @{term cntV}-value of @{term th'} does not change |
|
613 |
by the happening of event @{term e}: *} |
|
614 |
-- {* The proof follows exactly the same pattern as the case for @{term cntP}-value: *} |
|
615 |
moreover have "cntV ((e#t)@s) th' = cntV (t@s) th'" |
|
616 |
proof(rule ccontr) -- {* Proof by contradiction. *} |
|
617 |
assume otherwise: "cntV ((e # t) @ s) th' \<noteq> cntV (t @ s) th'" |
|
116 | 618 |
from cntV_diff_inv[OF this[simplified]] |
619 |
obtain cs' where "e = V th' cs'" by auto |
|
620 |
from vat_es.pip_e[unfolded this] |
|
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
621 |
have "th' \<in> running (t@s)" by (cases, auto) |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
622 |
moreover have "th' \<notin> running (t@s)" |
67 | 623 |
using vat_t.eq_pv_blocked[OF neq_th' Cons(5)] . |
624 |
ultimately show False by simp |
|
625 |
qed |
|
626 |
-- {* Finally, it can be shown that the @{term cntP} and @{term cntV} |
|
627 |
value for @{term th'} are still in balance, so @{term th'} |
|
628 |
is still hand-emptied after the execution of event @{term e}: *} |
|
629 |
ultimately show ?thesis using Cons(5) by metis |
|
630 |
qed |
|
631 |
qed (auto simp:eq_pv) |
|
632 |
||
633 |
text {* |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
634 |
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
|
635 |
it can be derived easily that @{term th'} can not be running in the future: |
67 | 636 |
*} |
637 |
lemma eq_pv_blocked_persist: |
|
638 |
assumes neq_th': "th' \<noteq> th" |
|
639 |
and eq_pv: "cntP s th' = cntV s th'" |
|
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
640 |
shows "th' \<notin> running (t@s)" |
67 | 641 |
using assms |
642 |
by (simp add: eq_pv_blocked eq_pv_persist) |
|
643 |
||
644 |
text {* |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
645 |
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
|
646 |
must hold some resource in the very beginning. |
67 | 647 |
*} |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
648 |
lemma running_cntP_cntV_inv: (* ddd *) |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
649 |
assumes is_running: "th' \<in> running (t@s)" |
67 | 650 |
and neq_th': "th' \<noteq> th" |
651 |
shows "cntP s th' > cntV s th'" |
|
652 |
using assms |
|
653 |
proof - |
|
654 |
-- {* First, it can be shown that the number of @{term P} and |
|
655 |
@{term V} operations can not be equal for thred @{term th'} *} |
|
656 |
have "cntP s th' \<noteq> cntV s th'" |
|
657 |
proof |
|
658 |
-- {* The proof goes by contradiction, suppose otherwise: *} |
|
659 |
assume otherwise: "cntP s th' = cntV s th'" |
|
660 |
-- {* By applying @{thm eq_pv_blocked_persist} to this: *} |
|
661 |
from eq_pv_blocked_persist[OF neq_th' otherwise] |
|
662 |
-- {* we have that @{term th'} can not be running at moment @{term "t@s"}: *} |
|
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
663 |
have "th' \<notin> running (t@s)" . |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
664 |
-- {* This is obvious in contradiction with assumption @{thm is_running} *} |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
665 |
thus False using is_running by simp |
67 | 666 |
qed |
667 |
-- {* However, the number of @{term V} is always less or equal to @{term P}: *} |
|
668 |
moreover have "cntV s th' \<le> cntP s th'" using vat_s.cnp_cnv_cncs by auto |
|
669 |
-- {* Thesis is finally derived by combining the these two results: *} |
|
670 |
ultimately show ?thesis by auto |
|
671 |
qed |
|
672 |
||
63 | 673 |
|
674 |
text {* |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
675 |
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
|
676 |
at the very beginning, i.e. the moment (or state) @{term s}. |
67 | 677 |
|
678 |
The proof is a simple combination of the results above: |
|
63 | 679 |
*} |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
680 |
lemma running_threads_inv: |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
681 |
assumes running': "th' \<in> running (t@s)" |
66 | 682 |
and neq_th': "th' \<noteq> th" |
63 | 683 |
shows "th' \<in> threads s" |
67 | 684 |
proof(rule ccontr) -- {* Proof by contradiction: *} |
685 |
assume otherwise: "th' \<notin> threads s" |
|
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
686 |
have "th' \<notin> running (t @ s)" |
67 | 687 |
proof - |
688 |
from vat_s.cnp_cnv_eq[OF otherwise] |
|
689 |
have "cntP s th' = cntV s th'" . |
|
690 |
from eq_pv_blocked_persist[OF neq_th' this] |
|
691 |
show ?thesis . |
|
692 |
qed |
|
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
693 |
with running' show False by simp |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
694 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
695 |
|
66 | 696 |
text {* |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
697 |
The following lemma summarizes several foregoing |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
698 |
lemmas to give an overall picture of the blocking thread @{text "th'"}: |
63 | 699 |
*} |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
700 |
lemma running_inversion: (* ddd, one of the main lemmas to present *) |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
701 |
assumes running': "th' \<in> running (t@s)" |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
702 |
and neq_th: "th' \<noteq> th" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
703 |
shows "th' \<in> threads s" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
704 |
and "\<not>detached s th'" |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
705 |
and "cp (t@s) th' = preced th s" |
66 | 706 |
proof - |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
707 |
from running_threads_inv[OF assms] |
66 | 708 |
show "th' \<in> threads s" . |
709 |
next |
|
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
710 |
from running_cntP_cntV_inv[OF running' neq_th] |
66 | 711 |
show "\<not>detached s th'" using vat_s.detached_eq by simp |
712 |
next |
|
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
713 |
from running_preced_inversion[OF running'] |
66 | 714 |
show "cp (t@s) th' = preced th s" . |
715 |
qed |
|
63 | 716 |
|
67 | 717 |
section {* The existence of `blocking thread` *} |
718 |
||
63 | 719 |
text {* |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
720 |
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
|
721 |
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
|
722 |
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
|
723 |
|
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
724 |
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
|
725 |
one in it which holds the highest @{term cp}-value, which, by definition, |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
726 |
is the @{term running}-thread. However, we are going to show more: this running thread |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
727 |
is exactly @{term "th'"}. |
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
728 |
*} |
67 | 729 |
lemma th_blockedE: (* ddd, the other main lemma to be presented: *) |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
730 |
assumes "th \<notin> running (t@s)" |
63 | 731 |
obtains th' where "Th th' \<in> ancestors (RAG (t @ s)) (Th th)" |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
732 |
"th' \<in> running (t@s)" |
63 | 733 |
proof - |
734 |
-- {* According to @{thm vat_t.th_chain_to_ready}, either |
|
735 |
@{term "th"} is in @{term "readys"} or there is path leading from it to |
|
736 |
one thread in @{term "readys"}. *} |
|
737 |
have "th \<in> readys (t @ s) \<or> (\<exists>th'. th' \<in> readys (t @ s) \<and> (Th th, Th th') \<in> (RAG (t @ s))\<^sup>+)" |
|
738 |
using th_kept vat_t.th_chain_to_ready by auto |
|
739 |
-- {* However, @{term th} can not be in @{term readys}, because otherwise, since |
|
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
740 |
@{term th} holds the highest @{term cp}-value, it must be @{term "running"}. *} |
63 | 741 |
moreover have "th \<notin> readys (t@s)" |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
742 |
using assms running_def th_cp_max vat_t.max_cp_readys_threads by auto |
63 | 743 |
-- {* So, there must be a path from @{term th} to another thread @{text "th'"} in |
744 |
term @{term readys}: *} |
|
745 |
ultimately obtain th' where th'_in: "th' \<in> readys (t@s)" |
|
746 |
and dp: "(Th th, Th th') \<in> (RAG (t @ s))\<^sup>+" by auto |
|
747 |
-- {* We are going to show that this @{term th'} is running. *} |
|
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
748 |
have "th' \<in> running (t@s)" |
63 | 749 |
proof - |
750 |
-- {* We only need to show that this @{term th'} holds the highest @{term cp}-value: *} |
|
751 |
have "cp (t@s) th' = Max (cp (t@s) ` readys (t@s))" (is "?L = ?R") |
|
752 |
proof - |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
753 |
-- {* First, by the alternative definition of @{term cp} (I mean @{thm cp_alt_def1}), |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
754 |
the @{term cp}-value of @{term th'} is the maximum of |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
755 |
all precedences of all thread nodes in its @{term tRAG}-subtree: *} |
63 | 756 |
have "?L = Max ((the_preced (t @ s) \<circ> the_thread) ` subtree (tRAG (t @ s)) (Th th'))" |
757 |
by (unfold cp_alt_def1, simp) |
|
758 |
also have "... = (the_preced (t @ s) \<circ> the_thread) (Th th)" |
|
759 |
proof(rule image_Max_subset) |
|
760 |
show "finite (Th ` (threads (t@s)))" by (simp add: vat_t.finite_threads) |
|
761 |
next |
|
762 |
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
|
763 |
by (metis Range.intros dp trancl_range vat_t.rg_RAG_threads vat_t.subtree_tRAG_thread) |
63 | 764 |
next |
765 |
show "Th th \<in> subtree (tRAG (t @ s)) (Th th')" using dp |
|
766 |
by (unfold tRAG_subtree_eq, auto simp:subtree_def) |
|
767 |
next |
|
768 |
show "Max ((the_preced (t @ s) \<circ> the_thread) ` Th ` threads (t @ s)) = |
|
769 |
(the_preced (t @ s) \<circ> the_thread) (Th th)" (is "Max ?L = _") |
|
770 |
proof - |
|
771 |
have "?L = the_preced (t @ s) ` threads (t @ s)" |
|
772 |
by (unfold image_comp, rule image_cong, auto) |
|
773 |
thus ?thesis using max_preced the_preced_def by auto |
|
774 |
qed |
|
775 |
qed |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
776 |
thm the_preced_def |
63 | 777 |
also have "... = ?R" |
778 |
using th_cp_max th_cp_preced th_kept |
|
779 |
the_preced_def vat_t.max_cp_readys_threads by auto |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
780 |
thm th_cp_max th_cp_preced th_kept |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
781 |
the_preced_def vat_t.max_cp_readys_threads |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
782 |
finally show ?thesis . |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
783 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
784 |
-- {* Now, since @{term th'} holds the highest @{term cp} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
785 |
and we have already show it is in @{term readys}, |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
786 |
it is @{term running} by definition. *} |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
787 |
with `th' \<in> readys (t@s)` show ?thesis by (simp add: running_def) |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
788 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
789 |
-- {* It is easy to show @{term th'} is an ancestor of @{term th}: *} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
790 |
moreover have "Th th' \<in> ancestors (RAG (t @ s)) (Th th)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
791 |
using `(Th th, Th th') \<in> (RAG (t @ s))\<^sup>+` by (auto simp:ancestors_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
792 |
ultimately show ?thesis using that by metis |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
793 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
794 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
795 |
lemma (* new proof of th_blockedE *) |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
796 |
assumes "th \<notin> running (t @ s)" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
797 |
obtains th' where "Th th' \<in> ancestors (RAG (t @ s)) (Th th)" |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
798 |
"th' \<in> running (t @ s)" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
799 |
proof - |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
800 |
|
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
801 |
-- {* According to @{thm vat_t.th_chain_to_ready}, either @{term "th"} is |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
802 |
in @{term "readys"} or there is path in the @{term RAG} leading from |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
803 |
it to a thread that is in @{term "readys"}. However, @{term th} cannot |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
804 |
be in @{term readys}, because otherwise, since @{term th} holds the |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
805 |
highest @{term cp}-value, it must be @{term "running"}. This would |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
806 |
violate our assumption. *} |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
807 |
have "th \<notin> readys (t @ s)" |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
808 |
using assms running_def th_cp_max vat_t.max_cp_readys_threads by auto |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
809 |
then have "\<exists>th'. th' \<in> readys (t @ s) \<and> (Th th, Th th') \<in> (RAG (t @ s))\<^sup>+" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
810 |
using th_kept vat_t.th_chain_to_ready by auto |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
811 |
then obtain th' where th'_in: "th' \<in> readys (t@s)" |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
812 |
and dp: "(Th th, Th th') \<in> (RAG (t @ s))\<^sup>+" by auto |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
813 |
|
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
814 |
-- {* We are going to first show that this @{term th'} is running. *} |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
815 |
have "th' \<in> running (t @ s)" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
816 |
proof - |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
817 |
-- {* For this we need to show that @{term th'} holds the highest @{term cp}-value: *} |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
818 |
have "cp (t @ s) th' = Max (cp (t @ s) ` readys (t @ s))" (is "?L = ?R") |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
819 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
820 |
-- {* First, by the alternative definition of @{term cp} (I mean @{thm cp_alt_def1}), |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
821 |
the @{term cp}-value of @{term th'} is the maximum of |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
822 |
all precedences of all thread nodes in its @{term tRAG}-subtree: *} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
823 |
have "?L = Max (the_preced (t @ s) ` (the_thread ` subtree (tRAG (t @ s)) (Th th')))" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
824 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
825 |
have "(the_preced (t @ s) \<circ> the_thread) ` subtree (tRAG (t @ s)) (Th th') = |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
826 |
the_preced (t @ s) ` the_thread ` subtree (tRAG (t @ s)) (Th th')" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
827 |
by fastforce |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
828 |
thus ?thesis by (unfold cp_alt_def1, simp) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
829 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
830 |
also have "... = (the_preced (t @ s) th)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
831 |
proof(rule image_Max_subset) |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
832 |
show "finite (threads (t @ s))" by (simp add: vat_t.finite_threads) |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
833 |
next |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
834 |
show "the_thread ` subtree (tRAG (t @ s)) (Th th') \<subseteq> threads (t @ s)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
835 |
by (smt imageE mem_Collect_eq readys_def subsetCE subsetI th'_in |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
836 |
the_thread.simps vat_t.subtree_tRAG_thread) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
837 |
next |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
838 |
show "th \<in> the_thread ` subtree (tRAG (t @ s)) (Th th')" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
839 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
840 |
have "Th th \<in> subtree (tRAG (t @ s)) (Th th')" using dp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
841 |
by (unfold tRAG_subtree_eq, auto simp:subtree_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
842 |
thus ?thesis by force |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
843 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
844 |
next |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
845 |
show "Max (the_preced (t @ s) ` threads (t @ s)) = the_preced (t @ s) th" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
846 |
by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
847 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
848 |
also have "... = ?R" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
849 |
using th_cp_max th_cp_preced th_kept |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
850 |
the_preced_def vat_t.max_cp_readys_threads by auto |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
851 |
finally show "cp (t @ s) th' = Max (cp (t @ s) ` readys (t @ s))" . |
63 | 852 |
qed |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
853 |
|
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
854 |
-- {* Now, since @{term th'} holds the highest @{term cp}-value in readys, |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
855 |
it is @{term running} by definition. *} |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
856 |
with `th' \<in> readys (t @ s)` show "th' \<in> running (t @ s)" by (simp add: running_def) |
63 | 857 |
qed |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
858 |
|
63 | 859 |
-- {* It is easy to show @{term th'} is an ancestor of @{term th}: *} |
860 |
moreover have "Th th' \<in> ancestors (RAG (t @ s)) (Th th)" |
|
861 |
using `(Th th, Th th') \<in> (RAG (t @ s))\<^sup>+` by (auto simp:ancestors_def) |
|
862 |
ultimately show ?thesis using that by metis |
|
863 |
qed |
|
864 |
||
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
865 |
lemma th_blockedE_pretty: |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
866 |
assumes "th \<notin> running (t@s)" |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
867 |
shows "\<exists>th'. Th th' \<in> ancestors (RAG (t @ s)) (Th th) \<and> th' \<in> running (t@s)" |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
868 |
using th_blockedE assms by blast |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
869 |
|
63 | 870 |
text {* |
106
5454387e42ce
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
871 |
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
|
872 |
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
|
873 |
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
|
874 |
thread is the @{text th'} given by lemma @{thm th_blockedE}. |
63 | 875 |
*} |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
876 |
lemma live: "running (t@s) \<noteq> {}" |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
877 |
proof(cases "th \<in> running (t@s)") |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
878 |
case True thus ?thesis by auto |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
879 |
next |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
880 |
case False |
63 | 881 |
thus ?thesis using th_blockedE by auto |
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
882 |
qed |
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
883 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
884 |
lemma blockedE: |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
885 |
assumes "th \<notin> running (t@s)" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
886 |
obtains th' where "Th th' \<in> ancestors (RAG (t @ s)) (Th th)" |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
887 |
"th' \<in> running (t@s)" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
888 |
"th' \<in> threads s" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
889 |
"\<not>detached s th'" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
890 |
"cp (t@s) th' = preced th s" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
891 |
"th' \<noteq> th" |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
892 |
by (metis assms running_inversion(2) running_preced_inversion running_threads_inv th_blockedE) |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
893 |
|
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
894 |
lemma detached_not_running: |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
895 |
assumes "detached (t@s) th'" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
896 |
and "th' \<noteq> th" |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
897 |
shows "th' \<notin> running (t@s)" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
898 |
proof |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
899 |
assume otherwise: "th' \<in> running (t @ s)" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
900 |
have "cp (t@s) th' = cp (t@s) th" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
901 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
902 |
have "cp (t@s) th' = Max (cp (t@s) ` readys (t@s))" using otherwise |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
903 |
by (simp add:running_def) |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
904 |
moreover have "cp (t@s) th = ..." by (simp add: vat_t.max_cp_readys_threads) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
905 |
ultimately show ?thesis by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
906 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
907 |
moreover have "cp (t@s) th' = preced th' (t@s)" using assms(1) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
908 |
by (simp add: detached_cp_preced) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
909 |
moreover have "cp (t@s) th = preced th (t@s)" by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
910 |
ultimately have "preced th' (t@s) = preced th (t@s)" by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
911 |
from preced_unique[OF this] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
912 |
have "th' \<in> threads (t @ s) \<Longrightarrow> th \<in> threads (t @ s) \<Longrightarrow> th' = th" . |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
913 |
moreover have "th' \<in> threads (t@s)" |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
914 |
using otherwise by (unfold running_def readys_def, auto) |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
915 |
moreover have "th \<in> threads (t@s)" by (simp add: th_kept) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
916 |
ultimately have "th' = th" by metis |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
917 |
with assms(2) show False by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
918 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
919 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
920 |
section {* The correctness theorem of PIP *} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
921 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
922 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
923 |
In this section, we identify two more conditions in addition to the ones already |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
924 |
specified in the forgoing locales, based on which the correctness of PIP is |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
925 |
formally proved. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
926 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
927 |
Note that Priority Inversion refers to the phenomenon where the thread with highest priority |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
928 |
is blocked by one with lower priority because the resource it is requesting is |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
929 |
currently held by the later. The objective of PIP is to avoid {\em Indefinite Priority Inversion}, |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
930 |
i.e. the number of occurrences of {\em Prioirty Inversion} becomes indefinitely large. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
931 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
932 |
For PIP to be correct, a finite upper bound needs to be found for the occurrence number, |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
933 |
and the existence. This section makes explicit two more conditions so that the existence |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
934 |
of such a upper bound can be proved to exist. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
935 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
936 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
937 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
938 |
The following set @{text "blockers"} characterizes the set of threads which |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
939 |
might block @{term th} in @{term t}: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
940 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
941 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
942 |
definition "blockers = {th'. \<not>detached s th' \<and> th' \<noteq> th}" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
943 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
944 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
945 |
The following lemma shows that the definition of @{term "blockers"} is correct, |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
946 |
i.e. blockers do block @{term "th"}. It is a very simple corollary of @{thm blockedE}. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
947 |
*} |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
948 |
lemma runningE: |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
949 |
assumes "th' \<in> running (t@s)" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
950 |
obtains (is_th) "th' = th" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
951 |
| (is_other) "th' \<in> blockers" |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
952 |
using assms blockers_def running_inversion(2) by auto |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
953 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
954 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
955 |
The following lemma shows that the number of blockers are finite. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
956 |
The reason is simple, because blockers are subset of thread set, which |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
957 |
has been shown finite. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
958 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
959 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
960 |
lemma finite_blockers: "finite blockers" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
961 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
962 |
have "finite {th'. \<not>detached s th'}" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
963 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
964 |
have "finite {th'. Th th' \<in> Field (RAG s)}" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
965 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
966 |
have "{th'. Th th' \<in> Field (RAG s)} \<subseteq> threads s" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
967 |
proof |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
968 |
fix x |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
969 |
assume "x \<in> {th'. Th th' \<in> Field (RAG s)}" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
970 |
thus "x \<in> threads s" using vat_s.RAG_threads by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
971 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
972 |
moreover have "finite ..." by (simp add: vat_s.finite_threads) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
973 |
ultimately show ?thesis using rev_finite_subset by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
974 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
975 |
thus ?thesis by (unfold detached_test, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
976 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
977 |
thus ?thesis unfolding blockers_def by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
978 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
979 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
980 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
981 |
The following lemma shows that a blocker may never die |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
982 |
as long as the highest thread @{term th} is living. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
983 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
984 |
The reason for this is that, before a thread can execute an @{term Exit} operation, |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
985 |
it must give up all its resource. However, the high priority inherited by a blocker |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
986 |
thread also goes with the resources it once held, and the consequence is the lost of |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
987 |
right to run, the other precondition for it to execute its own @{term Exit} operation. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
988 |
For this reason, a blocker may never exit before the exit of the highest thread @{term th}. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
989 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
990 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
991 |
lemma blockers_kept: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
992 |
assumes "th' \<in> blockers" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
993 |
shows "th' \<in> threads (t@s)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
994 |
proof(induct rule:ind) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
995 |
case Nil |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
996 |
from assms[unfolded blockers_def detached_test] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
997 |
have "Th th' \<in> Field (RAG s)" by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
998 |
from vat_s.RAG_threads[OF this] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
999 |
show ?case by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1000 |
next |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1001 |
case h: (Cons e t) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1002 |
interpret et: extend_highest_gen s th prio tm t |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1003 |
using h by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1004 |
show ?case |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1005 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1006 |
{ assume otherwise: "th' \<notin> threads ((e # t) @ s)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1007 |
from threads_Exit[OF h(5)] this have eq_e: "e = Exit th'" by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1008 |
from h(2)[unfolded this] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1009 |
have False |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1010 |
proof(cases) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1011 |
case h: (thread_exit) |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1012 |
hence "th' \<in> readys (t@s)" by (auto simp:running_def) |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1013 |
from readys_holdents_detached[OF this h(2)] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1014 |
have "detached (t @ s) th'" . |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1015 |
from et.detached_not_running[OF this] assms[unfolded blockers_def] |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1016 |
have "th' \<notin> running (t @ s)" by auto |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1017 |
with h(1) show ?thesis by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1018 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1019 |
} thus ?thesis by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1020 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1021 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1022 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1023 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1024 |
The following lemma shows that a blocker may never execute its @{term Create}-operation |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1025 |
during the period of @{term t}. The reason is that for a thread to be created |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1026 |
(or executing its @{term Create} operation), it must be non-existing (or dead). |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1027 |
However, since lemma @{thm blockers_kept} shows that blockers are always living, |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1028 |
it can not be created. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1029 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1030 |
A thread is created only when there is some external reason, there is need for it to run. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1031 |
The precondition for this is that it has already died (or get out of existence). |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1032 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1033 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1034 |
lemma blockers_no_create: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1035 |
assumes "th' \<in> blockers" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1036 |
and "e \<in> set t" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1037 |
and "actor e = th'" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1038 |
shows "\<not> isCreate e" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1039 |
using assms(2,3) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1040 |
proof(induct rule:ind) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1041 |
case h: (Cons e' t) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1042 |
interpret et: extend_highest_gen s th prio tm t |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1043 |
using h by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1044 |
{ assume eq_e: "e = e'" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1045 |
from et.blockers_kept assms |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1046 |
have "th' \<in> threads (t @ s)" by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1047 |
with h(2,7) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1048 |
have ?case |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1049 |
by (unfold eq_e, cases, auto simp:blockers_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1050 |
} with h |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1051 |
show ?case by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1052 |
qed auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1053 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1054 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1055 |
The following lemma shows that, same as blockers, |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1056 |
the highest thread @{term th} also can not execute its @{term Create}-operation. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1057 |
And the reason is similar: since @{thm th_kept} says that thread @{term th} is kept live |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1058 |
during @{term t}, it can not (or need not) be created another time. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1059 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1060 |
lemma th_no_create: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1061 |
assumes "e \<in> set t" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1062 |
and "actor e = th" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1063 |
shows "\<not> isCreate e" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1064 |
using assms |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1065 |
proof(induct rule:ind) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1066 |
case h:(Cons e' t) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1067 |
interpret et: extend_highest_gen s th prio tm t |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1068 |
using h by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1069 |
{ assume eq_e: "e = e'" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1070 |
from et.th_kept have "th \<in> threads (t @ s)" by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1071 |
with h(2,7) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1072 |
have ?case by (unfold eq_e, cases, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1073 |
} with h |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1074 |
show ?case by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1075 |
qed auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1076 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1077 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1078 |
The following is a preliminary lemma in order to show that the number of |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1079 |
actions (or operations) taken by the highest thread @{term th} is |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1080 |
less or equal to the number of occurrences when @{term th} is in running |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1081 |
state. What is proved in this lemma is essentially a strengthening, which |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1082 |
says the inequality holds even if the occurrence at the very beginning is |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1083 |
ignored. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1084 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1085 |
The reason for this lemma is that for every operation to be executed, its actor must |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1086 |
be in running state. Therefore, there is one occurrence of running state |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1087 |
behind every action. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1088 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1089 |
However, this property does not hold in general, because, for |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1090 |
the execution of @{term Create}-operation, the actor does not have to be in running state. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1091 |
Actually, the actor must be in dead state, in order to be created. For @{term th}, this |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1092 |
property holds because, according to lemma @{thm th_no_create}, @{term th} can not execute |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1093 |
any @{term Create}-operation during the period of @{term t}. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1094 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1095 |
lemma actions_th_occs_pre: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1096 |
assumes "t = e'#t'" |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1097 |
shows "length (actions_of {th} t) \<le> occs (\<lambda> t'. th \<in> running (t'@s)) t'" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1098 |
using assms |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1099 |
proof(induct arbitrary: e' t' rule:ind) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1100 |
case h: (Cons e t e' t') |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1101 |
interpret vt: valid_trace "(t@s)" using h(1) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1102 |
by (unfold_locales, simp) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1103 |
interpret ve: extend_highest_gen s th prio tm t using h by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1104 |
interpret ve': extend_highest_gen s th prio tm "e#t" using h by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1105 |
show ?case (is "?L \<le> ?R") |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1106 |
proof(cases t) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1107 |
case Nil |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1108 |
show ?thesis |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1109 |
proof(cases "actor e = th") |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1110 |
case True |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1111 |
from ve'.th_no_create[OF _ this] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1112 |
have "\<not> isCreate e" by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1113 |
from PIP_actorE[OF h(2) True this] Nil |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1114 |
have "th \<in> running s" by simp |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1115 |
hence "?R = 1" using Nil h by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1116 |
moreover have "?L = 1" using True Nil by (simp add:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1117 |
ultimately show ?thesis by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1118 |
next |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1119 |
case False |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1120 |
with Nil |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1121 |
show ?thesis by (auto simp:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1122 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1123 |
next |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1124 |
case h1: (Cons e1 t1) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1125 |
hence eq_t': "t' = e1#t1" using h by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1126 |
from h(5)[OF h1] |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1127 |
have le: "length (actions_of {th} t) \<le> occs (\<lambda>t'. th \<in> running (t' @ s)) t1" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1128 |
(is "?F t \<le> ?G t1") . |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1129 |
show ?thesis |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1130 |
proof(cases "actor e = th") |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1131 |
case True |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1132 |
from ve'.th_no_create[OF _ this] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1133 |
have "\<not> isCreate e" by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1134 |
from PIP_actorE[OF h(2) True this] |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1135 |
have "th \<in> running (t@s)" by simp |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1136 |
hence "?R = 1 + ?G t1" by (unfold h1 eq_t', simp) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1137 |
moreover have "?L = 1 + ?F t" using True by (simp add:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1138 |
ultimately show ?thesis using le by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1139 |
next |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1140 |
case False |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1141 |
with le |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1142 |
show ?thesis by (unfold h1 eq_t', simp add:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1143 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1144 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1145 |
qed auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1146 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1147 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1148 |
The following lemma is a simple corollary of @{thm actions_th_occs_pre}. It is the |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1149 |
lemma really needed in later proofs. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1150 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1151 |
lemma actions_th_occs: |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1152 |
shows "length (actions_of {th} t) \<le> occs (\<lambda> t'. th \<in> running (t'@s)) t" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1153 |
proof(cases t) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1154 |
case (Cons e' t') |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1155 |
from actions_th_occs_pre[OF this] |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1156 |
have "length (actions_of {th} t) \<le> occs (\<lambda>t'. th \<in> running (t' @ s)) t'" . |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1157 |
moreover have "... \<le> occs (\<lambda>t'. th \<in> running (t' @ s)) t" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1158 |
by (unfold Cons, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1159 |
ultimately show ?thesis by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1160 |
qed (auto simp:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1161 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1162 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1163 |
The following lemma splits all the operations in @{term t} into three |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1164 |
disjoint sets, namely the operations of @{term th}, the operations of |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1165 |
blockers and @{term Create}-operations. These sets are mutually disjoint |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1166 |
because: @{term "{th}"} and @{term blockers} are disjoint by definition, |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1167 |
and neither @{term th} nor any blocker can execute @{term Create}-operation |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1168 |
(according to lemma @{thm th_no_create} and @{thm blockers_no_create}). |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1169 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1170 |
One important caveat noted by this lemma is that: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1171 |
Although according to assumption @{thm create_low}, each thread created in |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1172 |
@{term t} has precedence lower than @{term th}, therefore, will get no |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1173 |
change to run after creation, therefore, can not acquire any resource |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1174 |
to become a blocker, the @{term Create}-operations of such |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1175 |
lower threads may still consume overall execution time of duration @{term t}, therefore, |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1176 |
may compete for execution time with the most urgent thread @{term th}. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1177 |
For PIP to be correct, the number of such competing operations needs to be |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1178 |
bounded somehow. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1179 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1180 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1181 |
lemma actions_split: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1182 |
"length t = length (actions_of {th} t) + |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1183 |
length (actions_of blockers t) + |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1184 |
length (filter (isCreate) t)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1185 |
proof(induct rule:ind) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1186 |
case h: (Cons e t) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1187 |
interpret ve : extend_highest_gen s th prio tm t using h by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1188 |
interpret ve': extend_highest_gen s th prio tm "e#t" using h by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1189 |
show ?case (is "?L (e#t) = ?T (e#t) + ?O (e#t) + ?C (e#t)") |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1190 |
proof(cases "actor e \<in> running (t@s)") |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1191 |
case True |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1192 |
thus ?thesis |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1193 |
proof(rule ve.runningE) |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1194 |
assume 1: "actor e = th" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1195 |
have "?T (e#t) = 1 + ?T (t)" using 1 by (simp add:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1196 |
moreover have "?O (e#t) = ?O t" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1197 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1198 |
have "actor e \<notin> blockers" using 1 |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1199 |
by (simp add:actions_of_def blockers_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1200 |
thus ?thesis by (simp add:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1201 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1202 |
moreover have "?C (e#t) = ?C t" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1203 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1204 |
from ve'.th_no_create[OF _ 1] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1205 |
have "\<not> isCreate e" by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1206 |
thus ?thesis by (simp add:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1207 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1208 |
ultimately show ?thesis using h by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1209 |
next |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1210 |
assume 2: "actor e \<in> ve'.blockers" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1211 |
have "?T (e#t) = ?T (t)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1212 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1213 |
from 2 have "actor e \<noteq> th" by (auto simp:blockers_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1214 |
thus ?thesis by (auto simp:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1215 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1216 |
moreover have "?O (e#t) = 1 + ?O(t)" using 2 |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1217 |
by (auto simp:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1218 |
moreover have "?C (e#t) = ?C(t)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1219 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1220 |
from ve'.blockers_no_create[OF 2, of e] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1221 |
have "\<not> isCreate e" by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1222 |
thus ?thesis by (simp add:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1223 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1224 |
ultimately show ?thesis using h by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1225 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1226 |
next |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1227 |
case False |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1228 |
from h(2) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1229 |
have is_create: "isCreate e" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1230 |
by (cases; insert False, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1231 |
have "?T (e#t) = ?T t" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1232 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1233 |
have "actor e \<noteq> th" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1234 |
proof |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1235 |
assume "actor e = th" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1236 |
from ve'.th_no_create[OF _ this] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1237 |
have "\<not> isCreate e" by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1238 |
with is_create show False by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1239 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1240 |
thus ?thesis by (auto simp:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1241 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1242 |
moreover have "?O (e#t) = ?O t" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1243 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1244 |
have "actor e \<notin> blockers" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1245 |
proof |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1246 |
assume "actor e \<in> blockers" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1247 |
from ve'.blockers_no_create[OF this, of e] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1248 |
have "\<not> isCreate e" by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1249 |
with is_create show False by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1250 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1251 |
thus ?thesis by (simp add:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1252 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1253 |
moreover have "?C (e#t) = 1 + ?C t" using is_create |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1254 |
by (auto simp:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1255 |
ultimately show ?thesis using h by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1256 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1257 |
qed (auto simp:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1258 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1259 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1260 |
By combining several of forging lemmas, this lemma gives a upper bound |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1261 |
of the occurrence number when the most urgent thread @{term th} is blocked. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1262 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1263 |
It says, the occasions when @{term th} is blocked during period @{term t} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1264 |
is no more than the number of @{term Create}-operations and |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1265 |
the operations taken by blockers plus one. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1266 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1267 |
Since the length of @{term t} may extend indefinitely, if @{term t} is full |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1268 |
of the above mentioned blocking operations, @{term th} may have not chance to run. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1269 |
And, since @{term t} can extend indefinitely, @{term th} my be blocked indefinitely |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1270 |
with the growth of @{term t}. Therefore, this lemma alone does not ensure |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1271 |
the correctness of PIP. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1272 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1273 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1274 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1275 |
theorem bound_priority_inversion: |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1276 |
"occs (\<lambda> t'. th \<notin> running (t'@s)) t \<le> |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1277 |
1 + (length (actions_of blockers t) + length (filter (isCreate) t))" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1278 |
(is "?L \<le> ?R") |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1279 |
proof - |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1280 |
let ?Q = "(\<lambda> t'. th \<in> running (t'@s))" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1281 |
from occs_le[of ?Q t] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1282 |
have "?L \<le> (1 + length t) - occs ?Q t" by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1283 |
also have "... \<le> ?R" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1284 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1285 |
have "length t - (length (actions_of blockers t) + length (filter (isCreate) t)) |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1286 |
\<le> occs (\<lambda> t'. th \<in> running (t'@s)) t" (is "?L1 \<le> ?R1") |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1287 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1288 |
have "?L1 = length (actions_of {th} t)" using actions_split by arith |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1289 |
also have "... \<le> ?R1" using actions_th_occs by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1290 |
finally show ?thesis . |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1291 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1292 |
thus ?thesis by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1293 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1294 |
finally show ?thesis . |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1295 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1296 |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1297 |
end |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1298 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1299 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1300 |
As explained before, lemma @{text bound_priority_inversion} alone does not |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1301 |
ensure the correctness of PIP. For PIP to be correct, the number of blocking operations |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1302 |
(by {\em blocking operation}, we mean the @{term Create}-operations and |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1303 |
operations taken by blockers) has to be bounded somehow. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1304 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1305 |
And the following lemma is for this purpose. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1306 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1307 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1308 |
locale bounded_extend_highest = extend_highest_gen + |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1309 |
-- {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1310 |
To bound operations of blockers, the locale specifies that each blocker |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1311 |
releases all resources and becomes detached after a certain number |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1312 |
of operations. In the assumption, this number is given by the |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1313 |
existential variable @{text span}. Notice that this number is fixed for each |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1314 |
blocker regardless of any particular instance of @{term t} in which it operates. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1315 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1316 |
This assumption is reasonable, because it is a common sense that |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1317 |
the total number of operations take by any standalone thread (or process) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1318 |
is only determined by its own input, and should not be affected by |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1319 |
the particular environment in which it operates. In this particular case, |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1320 |
we regard the @{term t} as the environment of thread @{term th}. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1321 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1322 |
assumes finite_span: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1323 |
"th' \<in> blockers \<Longrightarrow> |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1324 |
(\<exists> span. \<forall> t'. extend_highest_gen s th prio tm t' \<longrightarrow> |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1325 |
length (actions_of {th'} t') = span \<longrightarrow> detached (t'@s) th')" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1326 |
-- {* The following @{text BC} is bound of @{term Create}-operations *} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1327 |
fixes BC |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1328 |
-- {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1329 |
The following assumption requires the number of @{term Create}-operations is |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1330 |
less or equal to @{term BC} regardless of any particular extension of @{term t}. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1331 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1332 |
Although this assumption might seem doubtful at first sight, it is necessary |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1333 |
to ensure the occasions when @{term th} is blocked to be finite. Just consider |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1334 |
the extreme case when @{term Create}-operations consume all the time in duration |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1335 |
@{term "t"} and leave no space for neither @{term "th"} nor blockers to operate. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1336 |
An investigate of the precondition for @{term Create}-operation in the definition |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1337 |
of @{term PIP} may reveal that such extreme cases are well possible, because it |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1338 |
is only required the thread to be created be a fresh (or dead one), and there |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1339 |
are infinitely many such threads. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1340 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1341 |
However, if we relax the correctness criterion of PIP, allowing @{term th} to be |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1342 |
blocked indefinitely while still attaining a certain portion of @{term t} to complete |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1343 |
its task, then this bound @{term BC} can be lifted to function depending on @{term t} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1344 |
where @{text "BC t"} is of a certain proportion of @{term "length t"}. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1345 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1346 |
assumes finite_create: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1347 |
"\<forall> t'. extend_highest_gen s th prio tm t' \<longrightarrow> length (filter isCreate t') \<le> BC" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1348 |
begin |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1349 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1350 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1351 |
The following lemmas show that the number of @{term Create}-operations is bound by @{term BC}: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1352 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1353 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1354 |
lemma create_bc: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1355 |
shows "length (filter isCreate t) \<le> BC" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1356 |
by (meson extend_highest_gen_axioms finite_create) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1357 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1358 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1359 |
The following @{term span}-function gives the upper bound of |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1360 |
operations take by each particular blocker. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1361 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1362 |
definition "span th' = (SOME span. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1363 |
\<forall>t'. extend_highest_gen s th prio tm t' \<longrightarrow> |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1364 |
length (actions_of {th'} t') = span \<longrightarrow> detached (t' @ s) th')" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1365 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1366 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1367 |
The following lemmas shows the correctness of @{term span}, i.e. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1368 |
the number of operations of taken by @{term th'} is given by |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1369 |
@{term "span th"}. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1370 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1371 |
The reason for this lemma is that since @{term th'} gives up all resources |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1372 |
after @{term "span th'"} operations and becomes detached, |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1373 |
its inherited high priority is lost, with which the right to run goes as well. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1374 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1375 |
lemma le_span: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1376 |
assumes "th' \<in> blockers" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1377 |
shows "length (actions_of {th'} t) \<le> span th'" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1378 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1379 |
from finite_span[OF assms(1)] obtain span' |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1380 |
where span': "\<forall>t'. extend_highest_gen s th prio tm t' \<longrightarrow> |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1381 |
length (actions_of {th'} t') = span' \<longrightarrow> detached (t' @ s) th'" (is "?P span'") |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1382 |
by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1383 |
have "length (actions_of {th'} t) \<le> (SOME span. ?P span)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1384 |
proof(rule someI2[where a = span']) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1385 |
fix span |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1386 |
assume fs: "?P span" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1387 |
show "length (actions_of {th'} t) \<le> span" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1388 |
proof(induct rule:ind) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1389 |
case h: (Cons e t) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1390 |
interpret ve': extend_highest_gen s th prio tm "e#t" using h by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1391 |
show ?case |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1392 |
proof(cases "length (actions_of {th'} t) < span") |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1393 |
case True |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1394 |
thus ?thesis by (simp add:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1395 |
next |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1396 |
case False |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1397 |
have "actor e \<noteq> th'" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1398 |
proof |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1399 |
assume otherwise: "actor e = th'" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1400 |
from ve'.blockers_no_create [OF assms _ this] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1401 |
have "\<not> isCreate e" by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1402 |
from PIP_actorE[OF h(2) otherwise this] |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1403 |
have "th' \<in> running (t @ s)" . |
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1404 |
moreover have "th' \<notin> running (t @ s)" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1405 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1406 |
from False h(4) h(5) have "length (actions_of {th'} t) = span" by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1407 |
from fs[rule_format, OF h(3) this] have "detached (t @ s) th'" . |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1408 |
from extend_highest_gen.detached_not_running[OF h(3) this] assms |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1409 |
show ?thesis by (auto simp:blockers_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1410 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1411 |
ultimately show False by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1412 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1413 |
with h show ?thesis by (auto simp:actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1414 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1415 |
qed (simp add: actions_of_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1416 |
next |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1417 |
from span' |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1418 |
show "?P span'" . |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1419 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1420 |
thus ?thesis by (unfold span_def, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1421 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1422 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1423 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1424 |
The following lemma is a corollary of @{thm le_span}, which says |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1425 |
the total operations of blockers is bounded by the |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1426 |
sum of @{term span}-values of all blockers. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1427 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1428 |
lemma len_action_blockers: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1429 |
"length (actions_of blockers t) \<le> (\<Sum> th' \<in> blockers . span th')" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1430 |
(is "?L \<le> ?R") |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1431 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1432 |
from len_actions_of_sigma[OF finite_blockers] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1433 |
have "?L = (\<Sum>th'\<in>blockers. length (actions_of {th'} t))" by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1434 |
also have "... \<le> ?R" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1435 |
by (rule Groups_Big.setsum_mono, insert le_span, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1436 |
finally show ?thesis . |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1437 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1438 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1439 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1440 |
By combining forgoing lemmas, it is proved that the number of |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1441 |
blocked occurrences of the most urgent thread @{term th} is finitely bounded: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1442 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1443 |
theorem priority_inversion_is_finite: |
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1444 |
"occs (\<lambda> t'. th \<notin> running (t'@s)) t \<le> |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1445 |
1 + ((\<Sum> th' \<in> blockers . span th') + BC)" (is "?L \<le> ?R" is "_ \<le> 1 + (?A + ?B)" ) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1446 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1447 |
from bound_priority_inversion |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1448 |
have "?L \<le> 1 + (length (actions_of blockers t) + length (filter isCreate t))" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1449 |
(is "_ \<le> 1 + (?A' + ?B')") . |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1450 |
moreover have "?A' \<le> ?A" using len_action_blockers . |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1451 |
moreover have "?B' \<le> ?B" using create_bc . |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1452 |
ultimately show ?thesis by simp |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1453 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1454 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1455 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1456 |
The following lemma says the most urgent thread @{term th} will get as many |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1457 |
as operations it wishes, provided @{term t} is long enough. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1458 |
Similar result can also be obtained under the slightly weaker assumption where |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1459 |
@{term BC} is lifted to a function and @{text "BC t"} is a portion of |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1460 |
@{term "length t"}. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1461 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1462 |
theorem enough_actions_for_the_highest: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1463 |
"length t - ((\<Sum> th' \<in> blockers . span th') + BC) \<le> length (actions_of {th} t)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1464 |
using actions_split create_bc len_action_blockers by linarith |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1465 |
|
0
110247f9d47e
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1466 |
end |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1467 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
1468 |
end |