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