prio/CpsG.thy
changeset 298 f2e0d031a395
parent 290 6a6d0bd16035
child 312 09281ccb31bd
equal deleted inserted replaced
297:0a4be67ea7f8 298:f2e0d031a395
     2 imports PrioG 
     2 imports PrioG 
     3 begin
     3 begin
     4 
     4 
     5 lemma not_thread_holdents:
     5 lemma not_thread_holdents:
     6   fixes th s
     6   fixes th s
     7   assumes vt: "vt step s"
     7   assumes vt: "vt s"
     8   and not_in: "th \<notin> threads s" 
     8   and not_in: "th \<notin> threads s" 
     9   shows "holdents s th = {}"
     9   shows "holdents s th = {}"
    10 proof -
    10 proof -
    11   from vt not_in show ?thesis
    11   from vt not_in show ?thesis
    12   proof(induct arbitrary:th)
    12   proof(induct arbitrary:th)
    13     case (vt_cons s e th)
    13     case (vt_cons s e th)
    14     assume vt: "vt step s"
    14     assume vt: "vt s"
    15       and ih: "\<And>th. th \<notin> threads s \<Longrightarrow> holdents s th = {}"
    15       and ih: "\<And>th. th \<notin> threads s \<Longrightarrow> holdents s th = {}"
    16       and stp: "step s e"
    16       and stp: "step s e"
    17       and not_in: "th \<notin> threads (e # s)"
    17       and not_in: "th \<notin> threads (e # s)"
    18     from stp show ?case
    18     from stp show ?case
    19     proof(cases)
    19     proof(cases)
    47       qed
    47       qed
    48     next
    48     next
    49       case (thread_P thread cs)
    49       case (thread_P thread cs)
    50       assume eq_e: "e = P thread cs"
    50       assume eq_e: "e = P thread cs"
    51       and is_runing: "thread \<in> runing s"
    51       and is_runing: "thread \<in> runing s"
    52       from prems have vtp: "vt step (P thread cs#s)" by auto
    52       from prems have vtp: "vt (P thread cs#s)" by auto
    53       have neq_th: "th \<noteq> thread" 
    53       have neq_th: "th \<noteq> thread" 
    54       proof -
    54       proof -
    55         from not_in eq_e have "th \<notin> threads s" by simp
    55         from not_in eq_e have "th \<notin> threads s" by simp
    56         moreover from is_runing have "thread \<in> threads s"
    56         moreover from is_runing have "thread \<in> threads s"
    57           by (simp add:runing_def readys_def)
    57           by (simp add:runing_def readys_def)
    75         from not_in eq_e have "th \<notin> threads s" by simp
    75         from not_in eq_e have "th \<notin> threads s" by simp
    76         moreover from is_runing have "thread \<in> threads s"
    76         moreover from is_runing have "thread \<in> threads s"
    77           by (simp add:runing_def readys_def)
    77           by (simp add:runing_def readys_def)
    78         ultimately show ?thesis by auto
    78         ultimately show ?thesis by auto
    79       qed
    79       qed
    80       from prems have vtv: "vt step (V thread cs#s)" by auto
    80       from prems have vtv: "vt (V thread cs#s)" by auto
    81       from hold obtain rest 
    81       from hold obtain rest 
    82         where eq_wq: "wq s cs = thread # rest"
    82         where eq_wq: "wq s cs = thread # rest"
    83         by (case_tac "wq s cs", auto simp:s_holding_def)
    83         by (case_tac "wq s cs", auto simp: wq_def s_holding_def)
    84       from not_in eq_e eq_wq
    84       from not_in eq_e eq_wq
    85       have "\<not> next_th s thread cs th"
    85       have "\<not> next_th s thread cs th"
    86         apply (auto simp:next_th_def)
    86         apply (auto simp:next_th_def)
    87       proof -
    87       proof -
    88         assume ne: "rest \<noteq> []"
    88         assume ne: "rest \<noteq> []"
   126 qed
   126 qed
   127 
   127 
   128 
   128 
   129 
   129 
   130 lemma next_th_neq: 
   130 lemma next_th_neq: 
   131   assumes vt: "vt step s"
   131   assumes vt: "vt s"
   132   and nt: "next_th s th cs th'"
   132   and nt: "next_th s th cs th'"
   133   shows "th' \<noteq> th"
   133   shows "th' \<noteq> th"
   134 proof -
   134 proof -
   135   from nt show ?thesis
   135   from nt show ?thesis
   136     apply (auto simp:next_th_def)
   136     apply (auto simp:next_th_def)
   165 
   165 
   166 lemma pp_sub: "(r^+)^+ \<subseteq> r^+"
   166 lemma pp_sub: "(r^+)^+ \<subseteq> r^+"
   167   by auto
   167   by auto
   168 
   168 
   169 lemma wf_depend:
   169 lemma wf_depend:
   170   assumes vt: "vt step s"
   170   assumes vt: "vt s"
   171   shows "wf (depend s)"
   171   shows "wf (depend s)"
   172 proof(rule finite_acyclic_wf)
   172 proof(rule finite_acyclic_wf)
   173   from finite_depend[OF vt] show "finite (depend s)" .
   173   from finite_depend[OF vt] show "finite (depend s)" .
   174 next
   174 next
   175   from acyclic_depend[OF vt] show "acyclic (depend s)" .
   175   from acyclic_depend[OF vt] show "acyclic (depend s)" .
   254 
   254 
   255 lemma children_dependents: "children s th \<subseteq> dependents (wq s) th"
   255 lemma children_dependents: "children s th \<subseteq> dependents (wq s) th"
   256   by (unfold children_def child_def cs_dependents_def, auto simp:eq_depend)
   256   by (unfold children_def child_def cs_dependents_def, auto simp:eq_depend)
   257 
   257 
   258 lemma child_unique:
   258 lemma child_unique:
   259   assumes vt: "vt step s"
   259   assumes vt: "vt s"
   260   and ch1: "(Th th, Th th1) \<in> child s"
   260   and ch1: "(Th th, Th th1) \<in> child s"
   261   and ch2: "(Th th, Th th2) \<in> child s"
   261   and ch2: "(Th th, Th th2) \<in> child s"
   262   shows "th1 = th2"
   262   shows "th1 = th2"
   263 proof -
   263 proof -
   264   from ch1 ch2 show ?thesis
   264   from ch1 ch2 show ?thesis
   327 
   327 
   328 lemma sub_child: "child s \<subseteq> (depend s)^+"
   328 lemma sub_child: "child s \<subseteq> (depend s)^+"
   329   by (unfold child_def, auto)
   329   by (unfold child_def, auto)
   330 
   330 
   331 lemma wf_child: 
   331 lemma wf_child: 
   332   assumes vt: "vt step s"
   332   assumes vt: "vt s"
   333   shows "wf (child s)"
   333   shows "wf (child s)"
   334 proof(rule wf_subset)
   334 proof(rule wf_subset)
   335   from wf_trancl[OF wf_depend[OF vt]]
   335   from wf_trancl[OF wf_depend[OF vt]]
   336   show "wf ((depend s)\<^sup>+)" .
   336   show "wf ((depend s)\<^sup>+)" .
   337 next
   337 next
   338   from sub_child show "child s \<subseteq> (depend s)\<^sup>+" .
   338   from sub_child show "child s \<subseteq> (depend s)\<^sup>+" .
   339 qed
   339 qed
   340 
   340 
   341 lemma depend_child_pre:
   341 lemma depend_child_pre:
   342   assumes vt: "vt step s"
   342   assumes vt: "vt s"
   343   shows
   343   shows
   344   "(Th th, n) \<in> (depend s)^+ \<longrightarrow> (\<forall> th'. n = (Th th') \<longrightarrow> (Th th, Th th') \<in> (child s)^+)" (is "?P n")
   344   "(Th th, n) \<in> (depend s)^+ \<longrightarrow> (\<forall> th'. n = (Th th') \<longrightarrow> (Th th, Th th') \<in> (child s)^+)" (is "?P n")
   345 proof -
   345 proof -
   346   from wf_trancl[OF wf_depend[OF vt]]
   346   from wf_trancl[OF wf_depend[OF vt]]
   347   have wf: "wf ((depend s)^+)" .
   347   have wf: "wf ((depend s)^+)" .
   369       qed
   369       qed
   370     qed
   370     qed
   371   qed
   371   qed
   372 qed
   372 qed
   373 
   373 
   374 lemma depend_child: "\<lbrakk>vt step s; (Th th, Th th') \<in> (depend s)^+\<rbrakk> \<Longrightarrow> (Th th, Th th') \<in> (child s)^+"
   374 lemma depend_child: "\<lbrakk>vt s; (Th th, Th th') \<in> (depend s)^+\<rbrakk> \<Longrightarrow> (Th th, Th th') \<in> (child s)^+"
   375   by (insert depend_child_pre, auto)
   375   by (insert depend_child_pre, auto)
   376 
   376 
   377 lemma child_depend_p:
   377 lemma child_depend_p:
   378   assumes "(n1, n2) \<in> (child s)^+"
   378   assumes "(n1, n2) \<in> (child s)^+"
   379   shows "(n1, n2) \<in> (depend s)^+"
   379   shows "(n1, n2) \<in> (depend s)^+"
   390     ultimately show ?case by auto
   390     ultimately show ?case by auto
   391   qed
   391   qed
   392 qed
   392 qed
   393 
   393 
   394 lemma child_depend_eq: 
   394 lemma child_depend_eq: 
   395   assumes vt: "vt step s"
   395   assumes vt: "vt s"
   396   shows 
   396   shows 
   397   "((Th th1, Th th2) \<in> (child s)^+) = 
   397   "((Th th1, Th th2) \<in> (child s)^+) = 
   398    ((Th th1, Th th2) \<in> (depend s)^+)"
   398    ((Th th1, Th th2) \<in> (depend s)^+)"
   399   by (auto intro: depend_child[OF vt] child_depend_p)
   399   by (auto intro: depend_child[OF vt] child_depend_p)
   400 
   400 
   401 lemma children_no_dep:
   401 lemma children_no_dep:
   402   fixes s th th1 th2 th3
   402   fixes s th th1 th2 th3
   403   assumes vt: "vt step s"
   403   assumes vt: "vt s"
   404   and ch1: "(Th th1, Th th) \<in> child s"
   404   and ch1: "(Th th1, Th th) \<in> child s"
   405   and ch2: "(Th th2, Th th) \<in> child s"
   405   and ch2: "(Th th2, Th th) \<in> child s"
   406   and ch3: "(Th th1, Th th2) \<in> (depend s)^+"
   406   and ch3: "(Th th1, Th th2) \<in> (depend s)^+"
   407   shows "False"
   407   shows "False"
   408 proof -
   408 proof -
   431     ultimately show False by auto
   431     ultimately show False by auto
   432   qed
   432   qed
   433 qed
   433 qed
   434 
   434 
   435 lemma unique_depend_p:
   435 lemma unique_depend_p:
   436   assumes vt: "vt step s"
   436   assumes vt: "vt s"
   437   and dp1: "(n, n1) \<in> (depend s)^+"
   437   and dp1: "(n, n1) \<in> (depend s)^+"
   438   and dp2: "(n, n2) \<in> (depend s)^+"
   438   and dp2: "(n, n2) \<in> (depend s)^+"
   439   and neq: "n1 \<noteq> n2"
   439   and neq: "n1 \<noteq> n2"
   440   shows "(n1, n2) \<in> (depend s)^+ \<or> (n2, n1) \<in> (depend s)^+"
   440   shows "(n1, n2) \<in> (depend s)^+ \<or> (n2, n1) \<in> (depend s)^+"
   441 proof(rule unique_chain [OF _ dp1 dp2 neq])
   441 proof(rule unique_chain [OF _ dp1 dp2 neq])
   443   show "\<And>a b c. \<lbrakk>(a, b) \<in> depend s; (a, c) \<in> depend s\<rbrakk> \<Longrightarrow> b = c" by auto
   443   show "\<And>a b c. \<lbrakk>(a, b) \<in> depend s; (a, c) \<in> depend s\<rbrakk> \<Longrightarrow> b = c" by auto
   444 qed
   444 qed
   445 
   445 
   446 lemma dependents_child_unique:
   446 lemma dependents_child_unique:
   447   fixes s th th1 th2 th3
   447   fixes s th th1 th2 th3
   448   assumes vt: "vt step s"
   448   assumes vt: "vt s"
   449   and ch1: "(Th th1, Th th) \<in> child s"
   449   and ch1: "(Th th1, Th th) \<in> child s"
   450   and ch2: "(Th th2, Th th) \<in> child s"
   450   and ch2: "(Th th2, Th th) \<in> child s"
   451   and dp1: "th3 \<in> dependents s th1"
   451   and dp1: "th3 \<in> dependents s th1"
   452   and dp2: "th3 \<in> dependents s th2"
   452   and dp2: "th3 \<in> dependents s th2"
   453 shows "th1 = th2"
   453 shows "th1 = th2"
   470   } thus ?thesis by auto
   470   } thus ?thesis by auto
   471 qed
   471 qed
   472 
   472 
   473 lemma cp_rec:
   473 lemma cp_rec:
   474   fixes s th
   474   fixes s th
   475   assumes vt: "vt step s"
   475   assumes vt: "vt s"
   476   shows "cp s th = Max ({preced th s} \<union> (cp s ` children s th))"
   476   shows "cp s th = Max ({preced th s} \<union> (cp s ` children s th))"
   477 proof(unfold cp_eq_cpreced_f cpreced_def)
   477 proof(unfold cp_eq_cpreced_f cpreced_def)
   478   let ?f = "(\<lambda>th. preced th s)"
   478   let ?f = "(\<lambda>th. preced th s)"
   479   show "Max ((\<lambda>th. preced th s) ` ({th} \<union> dependents (wq s) th)) =
   479   show "Max ((\<lambda>th. preced th s) ` ({th} \<union> dependents (wq s) th)) =
   480         Max ({preced th s} \<union> (\<lambda>th. Max ((\<lambda>th. preced th s) ` ({th} \<union> dependents (wq s) th))) ` children s th)"
   480         Max ({preced th s} \<union> (\<lambda>th. Max ((\<lambda>th. preced th s) ` ({th} \<union> dependents (wq s) th))) ` children s th)"
   623 where "cps s = {(th, cp s th) | th . th \<in> threads s}"
   623 where "cps s = {(th, cp s th) | th . th \<in> threads s}"
   624 
   624 
   625 locale step_set_cps =
   625 locale step_set_cps =
   626   fixes s' th prio s 
   626   fixes s' th prio s 
   627   defines s_def : "s \<equiv> (Set th prio#s')"
   627   defines s_def : "s \<equiv> (Set th prio#s')"
   628   assumes vt_s: "vt step s"
   628   assumes vt_s: "vt s"
   629 
   629 
   630 context step_set_cps 
   630 context step_set_cps 
   631 begin
   631 begin
   632 
   632 
   633 lemma eq_preced:
   633 lemma eq_preced:
   934   ultimately show ?thesis by auto
   934   ultimately show ?thesis by auto
   935 qed
   935 qed
   936 end
   936 end
   937 
   937 
   938 lemma next_waiting:
   938 lemma next_waiting:
   939   assumes vt: "vt step s"
   939   assumes vt: "vt s"
   940   and nxt: "next_th s th cs th'"
   940   and nxt: "next_th s th cs th'"
   941   shows "waiting s th' cs"
   941   shows "waiting s th' cs"
   942 proof -
   942 proof -
   943   from assms show ?thesis
   943   from assms show ?thesis
   944     apply (auto simp:next_th_def s_waiting_def)
   944     apply (auto simp:next_th_def s_waiting_def[folded wq_def])
   945   proof -
   945   proof -
   946     fix rest
   946     fix rest
   947     assume ni: "hd (SOME q. distinct q \<and> set q = set rest) \<notin> set rest"
   947     assume ni: "hd (SOME q. distinct q \<and> set q = set rest) \<notin> set rest"
   948       and eq_wq: "wq s cs = th # rest"
   948       and eq_wq: "wq s cs = th # rest"
   949       and ne: "rest \<noteq> []"
   949       and ne: "rest \<noteq> []"
   992 qed
   992 qed
   993 
   993 
   994 locale step_v_cps =
   994 locale step_v_cps =
   995   fixes s' th cs s 
   995   fixes s' th cs s 
   996   defines s_def : "s \<equiv> (V th cs#s')"
   996   defines s_def : "s \<equiv> (V th cs#s')"
   997   assumes vt_s: "vt step s"
   997   assumes vt_s: "vt s"
   998 
   998 
   999 locale step_v_cps_nt = step_v_cps +
   999 locale step_v_cps_nt = step_v_cps +
  1000   fixes th'
  1000   fixes th'
  1001   assumes nt: "next_th s' th cs th'"
  1001   assumes nt: "next_th s' th cs th'"
  1002 
  1002 
  1052           from dp'' eq_y yz eq_z have "(Cs cs, Cs cs') \<in> (depend s)^+" by auto
  1052           from dp'' eq_y yz eq_z have "(Cs cs, Cs cs') \<in> (depend s)^+" by auto
  1053           moreover have "cs' = cs"
  1053           moreover have "cs' = cs"
  1054           proof -
  1054           proof -
  1055             from next_waiting[OF step_back_vt[OF vt_s[unfolded s_def]] nt]
  1055             from next_waiting[OF step_back_vt[OF vt_s[unfolded s_def]] nt]
  1056             have "(Th th', Cs cs) \<in> depend s'"
  1056             have "(Th th', Cs cs) \<in> depend s'"
  1057               by (auto simp:s_waiting_def s_depend_def cs_waiting_def)
  1057               by (auto simp:s_waiting_def wq_def s_depend_def cs_waiting_def)
  1058             from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] this dp']
  1058             from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] this dp']
  1059             show ?thesis by simp
  1059             show ?thesis by simp
  1060           qed
  1060           qed
  1061           ultimately have "(Cs cs, Cs cs) \<in> (depend s)^+" by simp
  1061           ultimately have "(Cs cs, Cs cs) \<in> (depend s)^+" by simp
  1062           moreover note wf_trancl[OF wf_depend[OF vt_s]]
  1062           moreover note wf_trancl[OF wf_depend[OF vt_s]]
  1070           with depend_s have dps': "(Th th', z) \<in> depend s'" by auto
  1070           with depend_s have dps': "(Th th', z) \<in> depend s'" by auto
  1071           have "z = Cs cs"
  1071           have "z = Cs cs"
  1072           proof -
  1072           proof -
  1073             from next_waiting[OF step_back_vt[OF vt_s[unfolded s_def]] nt]
  1073             from next_waiting[OF step_back_vt[OF vt_s[unfolded s_def]] nt]
  1074             have "(Th th', Cs cs) \<in> depend s'"
  1074             have "(Th th', Cs cs) \<in> depend s'"
  1075               by (auto simp:s_waiting_def s_depend_def cs_waiting_def)
  1075               by (auto simp:s_waiting_def wq_def s_depend_def cs_waiting_def)
  1076             from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] dps' this]
  1076             from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] dps' this]
  1077             show ?thesis .
  1077             show ?thesis .
  1078           qed
  1078           qed
  1079           with dps depend_s show False by auto
  1079           with dps depend_s show False by auto
  1080         qed
  1080         qed
  1113           with yz have dp_yz: "(Cs cs, z) \<in> depend s'" by simp
  1113           with yz have dp_yz: "(Cs cs, z) \<in> depend s'" by simp
  1114           from this have eq_z: "z = Th th"
  1114           from this have eq_z: "z = Th th"
  1115           proof -
  1115           proof -
  1116             from step_back_step[OF vt_s[unfolded s_def]]
  1116             from step_back_step[OF vt_s[unfolded s_def]]
  1117             have "(Cs cs, Th th) \<in> depend s'"
  1117             have "(Cs cs, Th th) \<in> depend s'"
  1118               by(cases, auto simp: s_depend_def cs_holding_def s_holding_def)
  1118               by(cases, auto simp: wq_def s_depend_def cs_holding_def s_holding_def)
  1119             from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] this dp_yz]
  1119             from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] this dp_yz]
  1120             show ?thesis by simp
  1120             show ?thesis by simp
  1121           qed
  1121           qed
  1122           from converse_tranclE[OF ztp]
  1122           from converse_tranclE[OF ztp]
  1123           obtain u where "(z, u) \<in> depend s'" by auto
  1123           obtain u where "(z, u) \<in> depend s'" by auto
  1124           moreover 
  1124           moreover 
  1125           from step_back_step[OF vt_s[unfolded s_def]]
  1125           from step_back_step[OF vt_s[unfolded s_def]]
  1126           have "th \<in> readys s'" by (cases, simp add:runing_def)
  1126           have "th \<in> readys s'" by (cases, simp add:runing_def)
  1127           moreover note eq_z
  1127           moreover note eq_z
  1128           ultimately show False 
  1128           ultimately show False 
  1129             by (auto simp:readys_def s_depend_def s_waiting_def cs_waiting_def)
  1129             by (auto simp:readys_def wq_def s_depend_def s_waiting_def cs_waiting_def)
  1130         qed
  1130         qed
  1131       next
  1131       next
  1132         show "y \<noteq> Th th'"
  1132         show "y \<noteq> Th th'"
  1133         proof
  1133         proof
  1134           assume eq_y: "y = Th th'"
  1134           assume eq_y: "y = Th th'"
  1135           with yz have dps: "(Th th', z) \<in> depend s'" by simp
  1135           with yz have dps: "(Th th', z) \<in> depend s'" by simp
  1136           have "z = Cs cs"
  1136           have "z = Cs cs"
  1137           proof -
  1137           proof -
  1138             from next_waiting[OF step_back_vt[OF vt_s[unfolded s_def]] nt]
  1138             from next_waiting[OF step_back_vt[OF vt_s[unfolded s_def]] nt]
  1139             have "(Th th', Cs cs) \<in> depend s'"
  1139             have "(Th th', Cs cs) \<in> depend s'"
  1140               by (auto simp:s_waiting_def s_depend_def cs_waiting_def)
  1140               by (auto simp:s_waiting_def wq_def s_depend_def cs_waiting_def)
  1141             from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] dps this]
  1141             from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] dps this]
  1142             show ?thesis .
  1142             show ?thesis .
  1143           qed
  1143           qed
  1144           with ztp have cs_i: "(Cs cs, Th th'') \<in>  (depend s')\<^sup>+" by simp
  1144           with ztp have cs_i: "(Cs cs, Th th'') \<in>  (depend s')\<^sup>+" by simp
  1145           from step_back_step[OF vt_s[unfolded s_def]]
  1145           from step_back_step[OF vt_s[unfolded s_def]]
  1146           have cs_th: "(Cs cs, Th th) \<in> depend s'"
  1146           have cs_th: "(Cs cs, Th th) \<in> depend s'"
  1147             by(cases, auto simp: s_depend_def cs_holding_def s_holding_def)
  1147             by(cases, auto simp: s_depend_def wq_def cs_holding_def s_holding_def)
  1148           have "(Cs cs, Th th'') \<notin>  depend s'"
  1148           have "(Cs cs, Th th'') \<notin>  depend s'"
  1149           proof
  1149           proof
  1150             assume "(Cs cs, Th th'') \<in> depend s'"
  1150             assume "(Cs cs, Th th'') \<in> depend s'"
  1151             from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] this cs_th]
  1151             from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] this cs_th]
  1152             and neq1 show "False" by simp
  1152             and neq1 show "False" by simp
  1163           from converse_tranclE[OF this]
  1163           from converse_tranclE[OF this]
  1164           obtain v where "(Th th, v) \<in> (depend s')" by auto
  1164           obtain v where "(Th th, v) \<in> (depend s')" by auto
  1165           moreover from step_back_step[OF vt_s[unfolded s_def]]
  1165           moreover from step_back_step[OF vt_s[unfolded s_def]]
  1166           have "th \<in> readys s'" by (cases, simp add:runing_def)
  1166           have "th \<in> readys s'" by (cases, simp add:runing_def)
  1167           ultimately show False 
  1167           ultimately show False 
  1168             by (auto simp:readys_def s_depend_def s_waiting_def cs_waiting_def)
  1168             by (auto simp:readys_def wq_def s_depend_def s_waiting_def cs_waiting_def)
  1169         qed
  1169         qed
  1170       qed
  1170       qed
  1171       with depend_s yz have "(y, z) \<in> depend s" by auto
  1171       with depend_s yz have "(y, z) \<in> depend s" by auto
  1172       with ztp'
  1172       with ztp'
  1173       show "(y, Th th'') \<in> (depend s)\<^sup>+" by auto
  1173       show "(y, Th th'') \<in> (depend s)\<^sup>+" by auto
  1221     show "False"
  1221     show "False"
  1222     proof(cases)
  1222     proof(cases)
  1223       assume "holding s' th cs" 
  1223       assume "holding s' th cs" 
  1224       then obtain rest where
  1224       then obtain rest where
  1225         eq_wq: "wq s' cs = th#rest"
  1225         eq_wq: "wq s' cs = th#rest"
  1226         apply (unfold s_holding_def)
  1226         apply (unfold s_holding_def wq_def[symmetric])
  1227         by (case_tac "(wq s' cs)", auto)
  1227         by (case_tac "(wq s' cs)", auto)
  1228       with h1 h2 have ne: "rest \<noteq> []" by auto
  1228       with h1 h2 have ne: "rest \<noteq> []" by auto
  1229       with eq_wq
  1229       with eq_wq
  1230       have "next_th s' th cs (hd (SOME q. distinct q \<and> set q = set rest))"
  1230       have "next_th s' th cs (hd (SOME q. distinct q \<and> set q = set rest))"
  1231         by(unfold next_th_def, rule_tac x = "rest" in exI, auto)
  1231         by(unfold next_th_def, rule_tac x = "rest" in exI, auto)
  1349 end
  1349 end
  1350 
  1350 
  1351 locale step_P_cps =
  1351 locale step_P_cps =
  1352   fixes s' th cs s 
  1352   fixes s' th cs s 
  1353   defines s_def : "s \<equiv> (P th cs#s')"
  1353   defines s_def : "s \<equiv> (P th cs#s')"
  1354   assumes vt_s: "vt step s"
  1354   assumes vt_s: "vt s"
  1355 
  1355 
  1356 locale step_P_cps_ne =step_P_cps +
  1356 locale step_P_cps_ne =step_P_cps +
  1357   assumes ne: "wq s' cs \<noteq> []"
  1357   assumes ne: "wq s' cs \<noteq> []"
  1358 
  1358 
  1359 locale step_P_cps_e =step_P_cps +
  1359 locale step_P_cps_e =step_P_cps +
  1812 end
  1812 end
  1813 
  1813 
  1814 locale step_create_cps =
  1814 locale step_create_cps =
  1815   fixes s' th prio s 
  1815   fixes s' th prio s 
  1816   defines s_def : "s \<equiv> (Create th prio#s')"
  1816   defines s_def : "s \<equiv> (Create th prio#s')"
  1817   assumes vt_s: "vt step s"
  1817   assumes vt_s: "vt s"
  1818 
  1818 
  1819 context step_create_cps
  1819 context step_create_cps
  1820 begin
  1820 begin
  1821 
  1821 
  1822 lemma eq_dep: "depend s = depend s'"
  1822 lemma eq_dep: "depend s = depend s'"
  1900 
  1900 
  1901 
  1901 
  1902 locale step_exit_cps =
  1902 locale step_exit_cps =
  1903   fixes s' th prio s 
  1903   fixes s' th prio s 
  1904   defines s_def : "s \<equiv> (Exit th#s')"
  1904   defines s_def : "s \<equiv> (Exit th#s')"
  1905   assumes vt_s: "vt step s"
  1905   assumes vt_s: "vt s"
  1906 
  1906 
  1907 context step_exit_cps
  1907 context step_exit_cps
  1908 begin
  1908 begin
  1909 
  1909 
  1910 lemma eq_dep: "depend s = depend s'"
  1910 lemma eq_dep: "depend s = depend s'"
  1928     show False
  1928     show False
  1929     proof(cases)
  1929     proof(cases)
  1930       assume "th \<in> runing s'"
  1930       assume "th \<in> runing s'"
  1931       with bk show ?thesis
  1931       with bk show ?thesis
  1932         apply (unfold runing_def readys_def s_waiting_def s_depend_def)
  1932         apply (unfold runing_def readys_def s_waiting_def s_depend_def)
  1933         by (auto simp:cs_waiting_def)
  1933         by (auto simp:cs_waiting_def wq_def)
  1934     qed
  1934     qed
  1935   qed
  1935   qed
  1936   have eq_dp: "\<And> th. dependents (wq s) th = dependents (wq s') th"
  1936   have eq_dp: "\<And> th. dependents (wq s) th = dependents (wq s') th"
  1937     by (unfold cs_dependents_def, auto simp:eq_dep eq_depend)
  1937     by (unfold cs_dependents_def, auto simp:eq_dep eq_depend)
  1938   moreover {
  1938   moreover {