Journal/Paper.thy
changeset 162 a8ceb68bfeb0
parent 161 f1d82f6c05a3
child 163 2ec13cfbb81c
equal deleted inserted replaced
161:f1d82f6c05a3 162:a8ceb68bfeb0
   907 *)
   907 *)
   908 
   908 
   909 (*<*)
   909 (*<*)
   910 context valid_trace
   910 context valid_trace
   911 begin
   911 begin
   912 (*>*)
   912   (*>*)
       
   913 (*<*)
   913 text {*
   914 text {*
   914 
   915 
   915   \endnote{In this section we prove facts that immediately follow from
   916   \endnote{In this section we prove facts that immediately follow from
   916   our definitions of valid traces.
   917   our definitions of valid traces.
   917 
   918 
   949   and @{text "th'\<^sub>2"} are the same threads. However, this also means the
   950   and @{text "th'\<^sub>2"} are the same threads. However, this also means the
   950   roots @{text "th\<^sub>1"} and @{text "th\<^sub>2"} must be the same.\qed
   951   roots @{text "th\<^sub>1"} and @{text "th\<^sub>2"} must be the same.\qed
   951   \end{proof}}
   952   \end{proof}}
   952 
   953 
   953   *}
   954   *}
       
   955 (*>*)
   954 (*<*)end(*>*)
   956 (*<*)end(*>*)
   955 
   957 
   956 section {* The Correctness Proof *}
   958 section {* The Correctness Proof *}
   957 
   959 
   958 (*<*)
   960 (*<*)
  1182   %\begin{lemma}
  1184   %\begin{lemma}
  1183   %If @{thm (prem 2) eq_pv_persist}
  1185   %If @{thm (prem 2) eq_pv_persist}
  1184   %then @{thm (concl) eq_pv_persist}
  1186   %then @{thm (concl) eq_pv_persist}
  1185   %\end{lemma}}
  1187   %\end{lemma}}
  1186 
  1188 
  1187   \endnote{{\bf OUTLINE}
  1189 %  \endnote{{\bf OUTLINE}
  1188 
  1190 
  1189   Since @{term "th"} is the most urgent thread, if it is somehow
  1191 %  Since @{term "th"} is the most urgent thread, if it is somehow
  1190   blocked, people want to know why and wether this blocking is
  1192 %  blocked, people want to know why and wether this blocking is
  1191   reasonable.
  1193 %  reasonable.
  1192 
  1194 
  1193   @{thm [source] th_blockedE} @{thm th_blockedE}
  1195 %  @{thm [source] th_blockedE} @{thm th_blockedE}
  1194 
  1196 
  1195   if @{term "th"} is blocked, then there is a path leading from 
  1197 %  if @{term "th"} is blocked, then there is a path leading from 
  1196   @{term "th"} to @{term "th'"}, which means:
  1198 %  @{term "th"} to @{term "th'"}, which means:
  1197   there is a chain of demand leading from @{term th} to @{term th'}.
  1199 %  there is a chain of demand leading from @{term th} to @{term th'}.
  1198 
  1200 
  1199   %%% in other words
  1201   %%% in other words
  1200   %%% th -> cs1 -> th1 -> cs2 -> th2 -> ... -> csn -> thn -> cs -> th'. 
  1202   %%% th -> cs1 -> th1 -> cs2 -> th2 -> ... -> csn -> thn -> cs -> th'. 
  1201   %%% 
  1203   %%% 
  1202   %%% We says that th is blocked by "th'".
  1204   %%% We says that th is blocked by "th'".
  1203 
  1205 
  1204   THEN
  1206 %  THEN
  1205 
  1207 
  1206   @{thm [source] vat_t.th_chain_to_ready} @{thm vat_t.th_chain_to_ready}
  1208 %  @ {thm [source] vat_t.th_chain_to_ready} @ {thm vat_t.th_chain_to_ready}
  1207 
  1209 
  1208   It is basic propery with non-trival proof. 
  1210 %  It is basic propery with non-trival proof. 
  1209 
  1211 
  1210   THEN
  1212 %  THEN
  1211 
  1213 
  1212   @{thm [source] max_preced} @{thm max_preced}
  1214 %  @ {thm [source] max_preced} @ {thm max_preced}
  1213 
  1215 
  1214   which says @{term "th"} holds the max precedence.
  1216 %  which says @{term "th"} holds the max precedence.
  1215 
  1217 
  1216   THEN
  1218 %  THEN
  1217  
  1219  
  1218   @{thm [source] th_cp_max th_cp_preced th_kept}
  1220 %  @ {thm [source] th_cp_max th_cp_preced th_kept}
  1219   @{thm th_cp_max th_cp_preced th_kept}
  1221 %  @ {thm th_cp_max th_cp_preced th_kept}
  1220 
  1222 
  1221   THENTHEN
  1223 %  THENTHEN
  1222 
  1224 
  1223   (here) %@ {thm [source] running_inversion_4} @  {thm running_inversion_4}
  1225  %@ {thm [source] running_inversion_4} @  {thm running_inversion_4}
  1224 
  1226 
  1225   which explains what the @{term "th'"} looks like. Now, we have found the 
  1227  % which explains what the @{term "th'"} looks like. Now, we have found the 
  1226   @{term "th'"} which blocks @{term th}, we need to know more about it.
  1228  % @{term "th'"} which blocks @{term th}, we need to know more about it.
  1227   To see what kind of thread can block @{term th}.
  1229  % To see what kind of thread can block @{term th}.
  1228 
  1230 
  1229   From these two lemmas we can see the correctness of PIP, which is
  1231  % From these two lemmas we can see the correctness of PIP, which is
  1230   that: the blockage of th is reasonable and under control.
  1232  % that: the blockage of th is reasonable and under control.
  1231 
  1233 
  1232   Lemmas we want to describe:
  1234  % Lemmas we want to describe:
  1233 
  1235 
  1234   
  1236  % \begin{lemma}
  1235 
  1237  % @ {thm running_cntP_cntV_inv}
  1236   \begin{lemma}
  1238  % \end{lemma}
  1237   @{thm running_cntP_cntV_inv}
  1239 
  1238   \end{lemma}
  1240 %  \noindent
  1239 
  1241 %  Remember we do not have the well-nestedness restriction in our
  1240   \noindent
  1242 %  proof, which means the difference between the counters @{const cntV}
  1241   Remember we do not have the well-nestedness restriction in our
  1243 %  and @{const cntP} can be larger than @{term 1}.
  1242   proof, which means the difference between the counters @{const cntV}
  1244 
  1243   and @{const cntP} can be larger than @{term 1}.
  1245 %  \begin{lemma}\label{runninginversion}
  1244 
  1246 %  @ {thm running_inversion}
  1245   \begin{lemma}\label{runninginversion}
  1247 %  \end{lemma}
  1246   @{thm running_inversion}
  1248   
  1247   \end{lemma}
  1249 %  explain tRAG
  1248   
  1250 %}
  1249   explain tRAG
  1251 
  1250   \bigskip}
  1252   
  1251 
  1253 %  Suppose the thread @ {term th} is \emph{not} running in state @ {term
  1252   
  1254 %  "t @ s"}, meaning that it should be blocked by some other thread.
  1253   Suppose the thread @{term th} is \emph{not} running in state @{term
  1255 %  It is first shown that there is a path in the RAG leading from node
  1254   "t @ s"}, meaning that it should be blocked by some other thread.
  1256 %  @ {term th} to another thread @ {text "th'"}, which is also in the
  1255   It is first shown that there is a path in the RAG leading from node
  1257 %  @ {term readys}-set.  Since @ {term readys}-set is non-empty, there
  1256   @{term th} to another thread @{text "th'"}, which is also in the
  1258 %  must be one in it which holds the highest @ {term cp}-value, which,
  1257   @{term readys}-set.  Since @{term readys}-set is non-empty, there
  1259 %  by definition, is currently the @ {term running}-thread.  However, we
  1258   must be one in it which holds the highest @{term cp}-value, which,
  1260 %  are going to show in the next lemma slightly more: this running
  1259   by definition, is currently the @{term running}-thread.  However, we
  1261 %  thread is exactly @ {term "th'"}.
  1260   are going to show in the next lemma slightly more: this running
  1262 
  1261   thread is exactly @{term "th'"}.
  1263 %  \begin{lemma}
  1262 
  1264 %  There exists a thread @{text "th'"}
  1263   \begin{lemma}
  1265 %  such that @{thm (no_quants) th_blockedE_pretty}.
  1264   There exists a thread @{text "th'"}
  1266 %  \end{lemma}
  1265   such that @{thm (no_quants) th_blockedE_pretty}.
  1267 
  1266   \end{lemma}
  1268 %  \begin{proof}
  1267 
  1269 %  We know that @{term th} cannot be in @{term readys}, because it has
  1268   \begin{proof}
  1270 %  the highest precedence and therefore must be running. This violates our
  1269   We know that @{term th} cannot be in @{term readys}, because it has
  1271 %  assumption. So by ?? we have that there must be a @{term "th'"} such that
  1270   the highest precedence and therefore must be running. This violates our
  1272 %  @{term "th' \<in> readys (t @ s)"} and @{term "(Th th, Th th') \<in> (RAG (t @ s))\<^sup>+"}.
  1271   assumption. So by ?? we have that there must be a @{term "th'"} such that
  1273 %  We are going to first show that this @{term "th'"} must be running. For this we 
  1272   @{term "th' \<in> readys (t @ s)"} and @{term "(Th th, Th th') \<in> (RAG (t @ s))\<^sup>+"}.
  1274 %  need to show that @{term th'} holds the highest @{term cp}-value.
  1273   We are going to first show that this @{term "th'"} must be running. For this we 
  1275 %  By ?? we know that the @{term "cp"}-value of @{term "th'"} must
  1274   need to show that @{term th'} holds the highest @{term cp}-value.
  1276 %  be the highest all precedences of all thread nodes in its @{term tRAG}-subtree.
  1275   By ?? we know that the @{term "cp"}-value of @{term "th'"} must
  1277 %  That is 
  1276   be the highest all precedences of all thread nodes in its @{term tRAG}-subtree.
  1278 
  1277   That is 
  1279 %  \begin{center}
  1278 
  1280 %  @ {term "cp (t @ s) th' = Max (the_preced (t @ s) ` 
  1279   \begin{center}
  1281 %    (the_thread ` subtree (tRAG (t @ s)) (Th th')))"}
  1280   @{term "cp (t @ s) th' = Max (the_preced (t @ s) ` 
  1282 %  \end{center}
  1281     (the_thread ` subtree (tRAG (t @ s)) (Th th')))"}
  1283 
  1282   \end{center}
  1284 %  But since @{term th} is in this subtree the right-hand side is equal
  1283 
  1285 %  to @{term "preced th (t @ s)"}.
  1284   But since @{term th} is in this subtree the right-hand side is equal
       
  1285   to @{term "preced th (t @ s)"}.
       
  1286 
  1286 
  1287   %Let me distinguish between cp (current precedence) and assigned precedence (the precedence the
  1287   %Let me distinguish between cp (current precedence) and assigned precedence (the precedence the
  1288   %thread ``normally'' has).
  1288   %thread ``normally'' has).
  1289   %So we want to show what the cp of th' is in state t @ s.
  1289   %So we want to show what the cp of th' is in state t @ s.
  1290   %We look at all the assingned precedences in the subgraph starting from th'
  1290   %We look at all the assingned precedences in the subgraph starting from th'
  1293   %so cp of th' in t @ s has this (assigned) precedence of th
  1293   %so cp of th' in t @ s has this (assigned) precedence of th
  1294   %We know that cp (t @ s) th' 
  1294   %We know that cp (t @ s) th' 
  1295   %is the Maximum of the threads in the subgraph starting from th'
  1295   %is the Maximum of the threads in the subgraph starting from th'
  1296   %this happens to be the precedence of th
  1296   %this happens to be the precedence of th
  1297   %th has the highest precedence of all threads
  1297   %th has the highest precedence of all threads
  1298   \end{proof}
  1298 %  \end{proof}
  1299 
  1299 
  1300   \begin{corollary}  
  1300 %  \begin{corollary}  
  1301   Using the lemma \ref{runninginversion} we can say more about the thread th'
  1301 %  Using the lemma \ref{runninginversion} we can say more about the thread th'
  1302   \end{corollary}
  1302 %  \end{corollary}
  1303 
  1303 
  1304   \endnote{\subsection*{END OUTLINE}}
  1304 %  \endnote{\subsection*{END OUTLINE}}
  1305 
  1305 
  1306   In what follows we will describe properties of PIP that allow us to prove 
  1306 %  In what follows we will describe properties of PIP that allow us to prove 
  1307   Theorem~\ref{mainthm} and, when instructive, briefly describe our argument. 
  1307 %  Theorem~\ref{mainthm} and, when instructive, briefly describe our argument. 
  1308   It is relatively easy to see that:
  1308 %  It is relatively easy to see that:
  1309 
  1309 
  1310   \begin{isabelle}\ \ \ \ \ %%%
  1310 %  \begin{isabelle}\ \ \ \ \ %%%
  1311   \begin{tabular}{@ {}l}
  1311 %  \begin{tabular}{@ {}l}
  1312   @{text "running s \<subseteq> ready s \<subseteq> threads s"}\\
  1312 %  @ {text "running s \<subseteq> ready s \<subseteq> threads s"}\\
  1313   @{thm[mode=IfThen]  finite_threads}
  1313 %  @ {thm[mode=IfThen]  finite_threads}
  1314   \end{tabular}
  1314 %  \end{tabular}
  1315   \end{isabelle}
  1315 %  \end{isabelle}
  1316 
  1316 
  1317   \noindent
  1317 %  \noindent
  1318   The second property is by induction on @{term vt}. The next three
  1318 %  The second property is by induction on @{term vt}. The next three
  1319   properties are: 
  1319 %  properties are: 
  1320 
  1320 
  1321   \begin{isabelle}\ \ \ \ \ %%%
  1321 %  \begin{isabelle}\ \ \ \ \ %%%
  1322   \begin{tabular}{@ {}l}
  1322 %  \begin{tabular}{@ {}l}
  1323   HERE??
  1323 %  HERE??
  1324   %@ {thm[mode=IfThen] waiting_unique[of _ _ "cs1" "cs2"]}\\
  1324   %@ {thm[mode=IfThen] waiting_unique[of _ _ "cs1" "cs2"]}\\
  1325   %@ {thm[mode=IfThen] held_unique[of _ "th1" _ "th2"]}\\
  1325   %@ {thm[mode=IfThen] held_unique[of _ "th1" _ "th2"]}\\
  1326   %@ {thm[mode=IfThen] running_unique[of _ "th1" "th2"]}
  1326   %@ {thm[mode=IfThen] running_unique[of _ "th1" "th2"]}
  1327   \end{tabular}
  1327 %  \end{tabular}
  1328   \end{isabelle}
  1328 %  \end{isabelle}
  1329 
  1329 
  1330   \noindent
  1330 %  \noindent
  1331   The first property states that every waiting thread can only wait for a single
  1331 %  The first property states that every waiting thread can only wait for a single
  1332   resource (because it gets suspended after requesting that resource); the second 
  1332 %  resource (because it gets suspended after requesting that resource); the second 
  1333   that every resource can only be held by a single thread; 
  1333 %  that every resource can only be held by a single thread; 
  1334   the third property establishes that in every given valid state, there is
  1334 %  the third property establishes that in every given valid state, there is
  1335   at most one running thread. We can also show the following properties 
  1335 %  at most one running thread. We can also show the following properties 
  1336   about the @{term RAG} in @{text "s"}.
  1336 %  about the @{term RAG} in @{text "s"}.
  1337 
  1337 
  1338   \begin{isabelle}\ \ \ \ \ %%%
  1338 %  \begin{isabelle}\ \ \ \ \ %%%
  1339   \begin{tabular}{@ {}l}
  1339 %  \begin{tabular}{@ {}l}
  1340   HERE?? %@{text If}~@ {thm (prem 1) acyclic_RAG}~@{text "then"}:\\
  1340 %  HERE?? %@{text If}~@ {thm (prem 1) acyclic_RAG}~@{text "then"}:\\
  1341   \hspace{5mm}@{thm (concl) acyclic_RAG},
  1341 %  \hspace{5mm}@{thm (concl) acyclic_RAG},
  1342   @{thm (concl) finite_RAG} and
  1342 %  @{thm (concl) finite_RAG} and
  1343   %@ {thm (concl) wf_dep_converse},\\
  1343 %  %@ {thm (concl) wf_dep_converse},\\
  1344   %\hspace{5mm}@{text "if"}~@ {thm (prem 2) dm_RAG_threads}~@{text "then"}~@{thm (concl) dm_RAG_threads}
  1344 %  %\hspace{5mm}@{text "if"}~@ {thm (prem 2) dm_RAG_threads}~@{text "then"}~@{thm (concl) dm_RAG_threads}
  1345   and\\
  1345 %  and\\
  1346   %\hspace{5mm}@{text "if"}~@ {thm (prem 2) range_in}~@{text "then"}~% @ {thm (concl) range_in}.
  1346 %  %\hspace{5mm}@{text "if"}~@ {thm (prem 2) range_in}~@{text "then"}~% @ {thm (concl) range_in}.
  1347   \end{tabular}
  1347 %  \end{tabular}
  1348   \end{isabelle}
  1348 %  \end{isabelle}
  1349 
  1349 
  1350   \noindent
  1350 %  \noindent
  1351   The acyclicity property follows from how we restricted the events in
  1351 %  The acyclicity property follows from how we restricted the events in
  1352   @{text step}; similarly the finiteness and well-foundedness property.
  1352 %  @{text step}; similarly the finiteness and well-foundedness property.
  1353   The last two properties establish that every thread in a @{text "RAG"}
  1353 %  The last two properties establish that every thread in a @{text "RAG"}
  1354   (either holding or waiting for a resource) is a live thread.
  1354 %  (either holding or waiting for a resource) is a live thread.
  1355 
  1355 
  1356   The key lemma in our proof of Theorem~\ref{mainthm} is as follows:
  1356 %  The key lemma in our proof of Theorem~\ref{mainthm} is as follows:
  1357 
  1357 
  1358   \begin{lemma}\label{mainlem}
  1358 %  \begin{lemma}\label{mainlem}
  1359   Given the assumptions about states @{text "s"} and @{text "s' @ s"},
  1359 %  Given the assumptions about states @{text "s"} and @{text "s' @ s"},
  1360   the thread @{text th} and the events in @{text "s'"},
  1360 %  the thread @{text th} and the events in @{text "s'"},
  1361   if @{term "th' \<in> threads (s' @ s)"}, @{text "th' \<noteq> th"} and @{text "detached (s' @ s) th'"}\\
  1361 %  if @{term "th' \<in> threads (s' @ s)"}, @{text "th' \<noteq> th"} and @{text "detached (s' @ s) th'"}\\
  1362   then @{text "th' \<notin> running (s' @ s)"}.
  1362 %  then @{text "th' \<notin> running (s' @ s)"}.
  1363   \end{lemma}
  1363 %  \end{lemma}
  1364 
  1364 
  1365   \noindent
  1365 %  \noindent
  1366   The point of this lemma is that a thread different from @{text th} (which has the highest
  1366 %  The point of this lemma is that a thread different from @{text th} (which has the highest
  1367   precedence in @{text s}) and not holding any resource, cannot be running 
  1367 %  precedence in @{text s}) and not holding any resource, cannot be running 
  1368   in the state @{text "s' @ s"}.
  1368 %  in the state @{text "s' @ s"}.
  1369 
  1369 
  1370   \begin{proof}
  1370 %  \begin{proof}
  1371   Since thread @{text "th'"} does not hold any resource, no thread can depend on it. 
  1371 %  Since thread @{text "th'"} does not hold any resource, no thread can depend on it. 
  1372   Therefore its current precedence @{term "cp (s' @ s) th'"} equals its own precedence
  1372 %  Therefore its current precedence @{term "cp (s' @ s) th'"} equals its own precedence
  1373   @{term "prec th' (s' @ s)"}. Since @{text "th"} has the highest precedence in the 
  1373 %  @{term "prec th' (s' @ s)"}. Since @{text "th"} has the highest precedence in the 
  1374   state @{text "(s' @ s)"} and precedences are distinct among threads, we have
  1374 %  state @{text "(s' @ s)"} and precedences are distinct among threads, we have
  1375   @{term "prec th' (s' @s ) < prec th (s' @ s)"}. From this 
  1375 %  @{term "prec th' (s' @s ) < prec th (s' @ s)"}. From this 
  1376   we have @{term "cp (s' @ s) th' < prec th (s' @ s)"}.
  1376 %  we have @{term "cp (s' @ s) th' < prec th (s' @ s)"}.
  1377   Since @{text "prec th (s' @ s)"} is already the highest 
  1377 %  Since @{text "prec th (s' @ s)"} is already the highest 
  1378   @{term "cp (s' @ s) th"} can not be higher than this and can not be lower either (by 
  1378 %  @{term "cp (s' @ s) th"} can not be higher than this and can not be lower either (by 
  1379   definition of @{term "cp"}). Consequently, we have @{term "prec th (s' @ s) = cp (s' @ s) th"}.
  1379 %  definition of @{term "cp"}). Consequently, we have @{term "prec th (s' @ s) = cp (s' @ s) th"}.
  1380   Finally we have @{term "cp (s' @ s) th' < cp (s' @ s) th"}.
  1380 %  Finally we have @{term "cp (s' @ s) th' < cp (s' @ s) th"}.
  1381   By defintion of @{text "running"}, @{text "th'"} can not be running in state
  1381 %  By defintion of @{text "running"}, @{text "th'"} can not be running in state
  1382   @{text "s' @ s"}, as we had to show.\qed
  1382 %  @{text "s' @ s"}, as we had to show.\qed
  1383   \end{proof}
  1383 %  \end{proof}
  1384 
  1384 
  1385   \noindent
  1385 %  \noindent
  1386   Since @{text "th'"} is not able to run in state @{text "s' @ s"}, it is not able to 
  1386 %  Since @{text "th'"} is not able to run in state @{text "s' @ s"}, it is not able to 
  1387   issue a @{text "P"} or @{text "V"} event. Therefore if @{text "s' @ s"} is extended
  1387 %  issue a @{text "P"} or @{text "V"} event. Therefore if @{text "s' @ s"} is extended
  1388   one step further, @{text "th'"} still cannot hold any resource. The situation will 
  1388 %  one step further, @{text "th'"} still cannot hold any resource. The situation will 
  1389   not change in further extensions as long as @{text "th"} holds the highest precedence.
  1389 %  not change in further extensions as long as @{text "th"} holds the highest precedence.
  1390 
  1390 
  1391   From this lemma we can deduce Theorem~\ref{mainthm}: that @{text th} can only be 
  1391 %  From this lemma we can deduce Theorem~\ref{mainthm}: that @{text th} can only be 
  1392   blocked by a thread @{text th'} that
  1392 %  blocked by a thread @{text th'} that
  1393   held some resource in state @{text s} (that is not @{text "detached"}). And furthermore
  1393 %  held some resource in state @{text s} (that is not @{text "detached"}). And furthermore
  1394   that the current precedence of @{text th'} in state @{text "(s' @ s)"} must be equal to the 
  1394 %  that the current precedence of @{text th'} in state @{text "(s' @ s)"} must be equal to the 
  1395   precedence of @{text th} in @{text "s"}.
  1395 %  precedence of @{text th} in @{text "s"}.
  1396   We show this theorem by induction on @{text "s'"} using Lemma~\ref{mainlem}.
  1396 %  We show this theorem by induction on @{text "s'"} using Lemma~\ref{mainlem}.
  1397   This theorem gives a stricter bound on the threads that can block @{text th} than the
  1397 %  This theorem gives a stricter bound on the threads that can block @{text th} than the
  1398   one obtained by Sha et al.~\cite{Sha90}:
  1398 %  one obtained by Sha et al.~\cite{Sha90}:
  1399   only threads that were alive in state @{text s} and moreover held a resource.
  1399 %  only threads that were alive in state @{text s} and moreover held a resource.
  1400   This means our bound is in terms of both---alive threads in state @{text s}
  1400 %  This means our bound is in terms of both---alive threads in state @{text s}
  1401   and number of critical resources. Finally, the theorem establishes that the blocking threads have the
  1401 %  and number of critical resources. Finally, the theorem establishes that the blocking threads have the
  1402   current precedence raised to the precedence of @{text th}.
  1402 %  current precedence raised to the precedence of @{text th}.
  1403 
  1403 
  1404   We can furthermore prove that under our assumptions no deadlock exists in the state @{text "s' @ s"}
  1404 %  We can furthermore prove that under our assumptions no deadlock exists in the state @{text "s' @ s"}
  1405   by showing that @{text "running (s' @ s)"} is not empty.
  1405 %  by showing that @{text "running (s' @ s)"} is not empty.
  1406 
  1406 
  1407   \begin{lemma}
  1407 %  \begin{lemma}
  1408   Given the assumptions about states @{text "s"} and @{text "s' @ s"},
  1408 %  Given the assumptions about states @{text "s"} and @{text "s' @ s"},
  1409   the thread @{text th} and the events in @{text "s'"},
  1409 %  the thread @{text th} and the events in @{text "s'"},
  1410   @{term "running (s' @ s) \<noteq> {}"}.
  1410 %  @{term "running (s' @ s) \<noteq> {}"}.
  1411   \end{lemma}
  1411 %  \end{lemma}
  1412 
  1412 
  1413   \begin{proof}
  1413 %  \begin{proof}
  1414   If @{text th} is blocked, then by following its dependants graph, we can always 
  1414 %  If @{text th} is blocked, then by following its dependants graph, we can always 
  1415   reach a ready thread @{text th'}, and that thread must have inherited the 
  1415 %  reach a ready thread @{text th'}, and that thread must have inherited the 
  1416   precedence of @{text th}.\qed
  1416 %  precedence of @{text th}.\qed
  1417   \end{proof}
  1417 %  \end{proof}
  1418 
  1418 
  1419 
  1419 
  1420   %The following lemmas show how every node in RAG can be chased to ready threads:
  1420   %The following lemmas show how every node in RAG can be chased to ready threads:
  1421   %\begin{enumerate}
  1421   %\begin{enumerate}
  1422   %\item Every node in RAG can be chased to a ready thread (@{text "chain_building"}):
  1422   %\item Every node in RAG can be chased to a ready thread (@{text "chain_building"}):
  1521   %Since there are only finite many threads live and holding some resource at any moment,
  1521   %Since there are only finite many threads live and holding some resource at any moment,
  1522   %if every such thread can release all its resources in finite duration, then after finite
  1522   %if every such thread can release all its resources in finite duration, then after finite
  1523   %duration, none of them may block @{term "th"} anymore. So, no priority inversion may happen
  1523   %duration, none of them may block @{term "th"} anymore. So, no priority inversion may happen
  1524   %then.
  1524   %then.
  1525 
  1525 
  1526   NOTE: about bounds in sha et al and ours: they prove a bound on the length of individual
  1526  % NOTE: about bounds in sha et al and ours: they prove a bound on the length of individual
  1527   blocages. We prove a bound for the overall-blockage.
  1527  % blocages. We prove a bound for the overall-blockage.
  1528 
  1528 
  1529   There are low priority threads, 
  1529  % There are low priority threads, 
  1530   which do not hold any resources, 
  1530  % which do not hold any resources, 
  1531   such thread will not block th. 
  1531  % such thread will not block th. 
  1532   Their Theorem 3 does not exclude such threads.
  1532  % Their Theorem 3 does not exclude such threads.
  1533 
  1533 
  1534   There are resources, which are not held by any low prioirty threads,
  1534  % There are resources, which are not held by any low prioirty threads,
  1535   such resources can not cause blockage of th neither. And similiary, 
  1535  % such resources can not cause blockage of th neither. And similiary, 
  1536   theorem 6 does not exlude them.
  1536  % theorem 6 does not exlude them.
  1537 
  1537 
  1538   Our one bound excudle them by using a different formaulation. "
  1538  % Our one bound excudle them by using a different formaulation. "
  1539 
  1539 
  1540   *}
  1540   *}
  1541 (*<*)
  1541 (*<*)
  1542 end
  1542 end
  1543 (*>*)
  1543 (*>*)
  1544 
  1544 
  1545 text {*
  1545 (*text {*
  1546    explan why Thm1 roughly corresponds to Sha's Thm 3
  1546    explan why Thm1 roughly corresponds to Sha's Thm 3
  1547 *}
  1547 *}*)
  1548 
  1548 
  1549 section {* A Finite Bound on Priority Inversion *}
  1549 section {* A Finite Bound on Priority Inversion *}
  1550 
  1550 
  1551 (*<*)
  1551 (*<*)
  1552 context extend_highest_gen
  1552 context extend_highest_gen