Implementation.thy
author Christian Urban <urbanc@in.tum.de>
Wed, 02 Aug 2017 14:56:47 +0100
changeset 190 312497c6d6b9
parent 189 914288aec495
child 197 ca4ddf26a7c7
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
107
30ed212f268a updated Correctness, Implementation and PIPBasics so that they work with Isabelle 2014 and 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
     1
theory Implementation
30ed212f268a updated Correctness, Implementation and PIPBasics so that they work with Isabelle 2014 and 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
     2
imports PIPBasics
30ed212f268a updated Correctness, Implementation and PIPBasics so that they work with Isabelle 2014 and 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
     3
begin
30ed212f268a updated Correctness, Implementation and PIPBasics so that they work with Isabelle 2014 and 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
     4
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
     5
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
     6
(*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
     7
  The use of dependants has been abandoned. Through a series of lemma 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
     8
  named xxx_alt_def, lemma originally expressed using dependants 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
     9
  is now expressed in terms of RAG, tRAG and tG.
179
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
    10
*)                                            
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    11
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
    12
text {*
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
    13
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
    14
  This file contains lemmas used to guide the recalculation of current
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
    15
  precedence after every step of execution (or system operation, or event),
117
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
    16
  which is the most tricky part in the implementation of PIP.
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
    17
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
    18
  Following convention, lemmas are grouped into locales corresponding to
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    19
  system operations, each explained in a separate section. To understand the relevant 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    20
  materials, one needs some acquaintance with locales, which are 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    21
  used to as contexts for lemmas to situate, where lemmas with the same assumptions
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    22
  are grouped under the same locale.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    23
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    24
  Locale @{text "valid_trace s"} assumes that @{text "s"} is a valid trace (or state)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    25
  of PIP. Lemmas talking about general properties of valid states can be put under this 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    26
  locale. The locale @{text "valid_trace_e s e"} is an extension of @{text valid_trace}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    27
  by introducing an event @{text e} and assuming @{text "e#s"} is also valid state. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    28
  The purpose of @{text valid_trace_e} is to set a context to investigate 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    29
  one step execution of PIP, where @{text e} is a fixed but arbitrary
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    30
  action legitimate to happen under state @{text "s"}. General Properties about 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    31
  one step action of PIP are grouped under this locale.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    32
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    33
  @{text "valid_trace_e"} is further extended to accommodate specific actions. For example,
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    34
  @{text "valid_trace_create s e th prio"} further assumes that the 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    35
  @{text "e"} action is @{text "Create th prio"}, and 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    36
  @{text "valid_trace_p s e th cs"} assumes that @{text "e"} is @{text "P th cs"}, etc.
117
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
    37
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    38
  Since the recalculation of current precedence happens only when certain actions 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    39
  are taken, it is natural to put the lemmas about recalculation under the respective 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    40
  locales. In the following, each section corresponds one particular action of PIP, which,
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    41
  in turn, is developed under the locale corresponding to the specific action.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    42
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    43
  By @{text cp_alt_def3}, the @{text cp}-value of one thread @{text th} is determined 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    44
  uniquely by static precedences of threads in its @{text "RAG"}-subtree 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    45
  (or @{text tRAG}-subtree, @{text "tG"}-subtree). Because of this, the decision where 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    46
  recalculation is needed is based on the change of @{text RAG} (@{text tRAG} or @{text tG})
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    47
  as well the precedence of threads. Since most of PIP actions (except the @{text Set}-operation) 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    48
  only changes the formation of @{text RAG}, therefore, for non-@{text Set} operations,
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    49
  if the change of @{text RAG} does not affect the subtree
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    50
  of one thread, its @{text cp}-value may not change. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    51
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    52
  In the following, the section corresponding to non-@{text Set} operations 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    53
  usually contain lemmas showing the subtrees of certain kind of threads are 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    54
  not changed. The proof of such lemmas is obvious based on the lemmas about the
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    55
  change of @{text RAG}, which have already been derived in theory @{text PIPBasics}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    56
  all under the name @{text "RAG_es"} in the locale corresponding to different PIP 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    57
  operations.
117
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
    58
*}
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    59
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    60
section {* The local recalculation principle for @{text cp}-value *}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    61
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    62
definition "cprecs Ths s = cp s ` Ths"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    63
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    64
context valid_trace
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    65
begin
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    66
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    67
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    68
  To minimize the cost of the recalculation, we derived the following localized alternative 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    69
  definition of @{term cp}:
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    70
*}
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    71
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    72
lemma cp_rec_tG:
188
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
    73
  "cp s th = Max (preceds {th} s \<union> cprecs (children (tG s) th) s)"
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    74
proof -
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    75
  have [simp]: "(cp s \<circ> the_thread \<circ> Th) = cp s" by (rule ext, simp)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    76
  have [simp]: "(cp s \<circ> the_thread) ` children (tRAG s) (Th th) = 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    77
                cp s ` children (tG s) th"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    78
                  apply (unfold tRAG_def_tG) 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    79
                  apply (subst fmap_children)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    80
                  apply (rule injI, simp)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    81
                  by (unfold image_comp, simp)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    82
  have [simp]: "preceds {th} s = {the_preced s th}"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    83
    by (unfold the_preced_def, simp)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    84
  show ?thesis 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    85
    by (unfold cp_rec cprecs_def, simp add:the_preced_def)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    86
qed    
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    87
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    88
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    89
  According to this lemma, @{text cp}-value of one thread can be calculated by calling recursively 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    90
  the @{text cp} function on its @{text tG}-children. However, one thing to be noted is that
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    91
  the lemma also means the recursive call needs not to descend into lower levels if the
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    92
  @{text "cp"}-value of one child is not changed. In this way, the recalculation can be {\em localized}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    93
  to those thread with changed @{text cp}-value. This is the reason why this lemma
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    94
  is called a {\em localized lemma}.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
    95
*}
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    96
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    97
end
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    98
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    99
section {* The @{term Set} operation *}
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   100
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   101
context valid_trace_set
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   102
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   103
188
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   104
find_theorems RAG "(e#s)" "_ = _"
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   105
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   106
text {* (* ddd *)
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   107
  The following two lemmas confirm that @{text "Set"}-operation
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   108
  only changes the precedence of the initiating thread (or actor)
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   109
  of the operation (or event).
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   110
*}
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   111
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   112
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   113
lemma eq_preced:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   114
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   115
  shows "preced th' (e#s) = preced th' s"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   116
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   117
  from assms show ?thesis 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   118
    by (unfold is_set, auto simp:preced_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   119
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   120
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   121
lemma eq_the_preced: 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   122
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   123
  shows "the_preced (e#s) th' = the_preced s th'"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   124
  using assms
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   125
  by (unfold the_preced_def, intro eq_preced, simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   126
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   127
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   128
text {* (* ddd *)
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   129
  According to @{thm RAG_es}, the @{text RAG} is not changed by @{text Set}-operation.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   130
  Moreover, because @{text th} is the only thread with precedence changed by @{text Set}, 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   131
  for any subtree, if it does not contain @{text th}, there will be no precedence change inside
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   132
  the subtree, which means the @{text cp}-value of the root thread is not changed. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   133
  This means that the @{text "cp"}-value of one thread needs to be recalculated only
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   134
  when the subtree rooted by the threads contains @{text "th"}.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   135
 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   136
  This argument is encapsulated in the following lemma:
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   137
*}
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   138
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   139
lemma eq_cp_pre:
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   140
  assumes nd: "Th th \<notin> subtree (RAG s) (Th th')"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   141
  shows "cp (e#s) th' = cp s th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   142
proof -
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   143
  -- {* After unfolding using the alternative definition, elements 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   144
        affecting the @{term "cp"}-value of threads become explicit. 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   145
        We only need to prove the following: *}
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   146
  have "Max (the_preced (e#s) ` {th'a. Th th'a \<in> subtree (RAG (e#s)) (Th th')}) =
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   147
        Max (the_preced s ` {th'a. Th th'a \<in> subtree (RAG s) (Th th')})"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   148
        (is "Max (?f ` ?S1) = Max (?g ` ?S2)")
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   149
  proof -
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   150
    -- {* The base sets are equal. *}
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   151
    have "?S1 = ?S2" using RAG_es by simp
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   152
    -- {* The function values on the base set are equal as well. *}
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   153
    moreover have "\<forall> e \<in> ?S2. ?f e = ?g e"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   154
    proof
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   155
      fix th1
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   156
      assume "th1 \<in> ?S2"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   157
      with nd have "th1 \<noteq> th" by (auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   158
      from eq_the_preced[OF this]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   159
      show "the_preced (e#s) th1 = the_preced s th1" .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   160
    qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   161
    -- {* Therefore, the image of the functions are equal. *}
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   162
    ultimately have "(?f ` ?S1) = (?g ` ?S2)" by (auto intro!:f_image_eq)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   163
    thus ?thesis by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   164
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   165
  thus ?thesis by (simp add:cp_alt_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   166
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   167
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   168
text {*
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   169
  However, the following lemma shows that @{term "th"} is not in the 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   170
  subtree of any thread except itself. 
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   171
*}
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   172
lemma th_in_no_subtree:
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   173
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   174
  shows "Th th \<notin> subtree (RAG s) (Th th')"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   175
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   176
  from readys_in_no_subtree[OF th_ready_s assms(1)]
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   177
  show ?thesis by blast
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   178
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   179
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   180
text {* 
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   181
  Combining the above two lemmas, it is concluded that the 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   182
  recalculation of @{text "cp"}-value is needed only on @{text th}.
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   183
*}
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   184
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   185
lemma eq_cp:
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   186
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   187
  shows "cp (e#s) th' = cp s th'"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   188
  by (rule eq_cp_pre[OF th_in_no_subtree[OF assms]])
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   189
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   190
text {* 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   191
  Under the local recalculation principle @{thm cp_rec_tG}, 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   192
  @{thm eq_cp} also means the recalculation of @{text cp} for @{text th}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   193
  can be done locally by inspecting only @{text th} and its children.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   194
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   195
56
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   196
end
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   197
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   198
section {* The @{term V} operation *}
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   199
56
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   200
text {*
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   201
  The following locale @{text "valid_trace_v"} is the locale for @{text "V"}-operation in 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   202
  general. The recalculation of @{text cp}-value needs to consider two more sub-case, each
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   203
  encapsulated into a sub-locale of @{text "valid_trace_v"}. But first, 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   204
  some general properties about the @{text V}-operation are derived:
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   205
*}
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   206
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   207
context valid_trace_v
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
   208
begin
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   209
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   210
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   211
  Because @{text th} is running in state @{text s}, it does not in waiting of 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   212
  any resource, therefore, it has no ancestor in @{text "RAG s"}:
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   213
*}
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   214
lemma ancestors_th: "ancestors (RAG s) (Th th) = {}"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   215
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   216
  from readys_root[OF th_ready_s]
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   217
  show ?thesis
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   218
  by (unfold root_def, simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   219
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   220
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   221
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   222
  Since @{text th} is holding @{text cs} (the resource to be released by this @{text V}-operation),
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   223
  the edge @{text "(Cs cs, Th th)"} represents this fact.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   224
*}
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   225
lemma edge_of_th:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   226
    "(Cs cs, Th th) \<in> RAG s" 
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   227
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   228
 from holding_th_cs_s
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   229
 show ?thesis 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   230
    by (unfold s_RAG_def s_holding_abv, auto)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   231
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   232
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   233
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   234
  Since @{text cs} is held by @{text th} which has no ancestors, 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   235
  @{text th} is the only ancestor of @{text cs}:
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   236
*}
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   237
lemma ancestors_cs: 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   238
  "ancestors (RAG s) (Cs cs) = {Th th}"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   239
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   240
  have "ancestors (RAG s) (Cs cs) = ancestors (RAG s) (Th th)  \<union>  {Th th}"
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   241
   by (rule forest_RAG.ancestors_accum[OF edge_of_th])
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   242
  from this[unfolded ancestors_th] show ?thesis by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   243
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   244
56
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   245
text {*
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   246
  As already said, all operations except @{text Set} may change precedence. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   247
  The following lemma confirms this fact of the @{text V}-operation:
56
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   248
*}
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   249
lemma 
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   250
  the_preced_es: "the_preced (e#s) = the_preced s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   251
proof
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   252
  fix th'
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   253
  show "the_preced (e # s) th' = the_preced s th'"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   254
    by (unfold the_preced_def preced_def is_v, simp)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   255
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   256
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   257
end
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   258
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   259
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   260
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   261
  The following sub-locale @{text "valid_trace_v_n"} 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   262
  deals with one of the sub-cases of @{text V}, which corresponds to the 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   263
  situation where there is another thread @{text "taker"}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   264
  to take over the release resource @{text cs}.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   265
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   266
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   267
context valid_trace_v_n
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   268
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   269
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   270
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   271
  The following lemma shows the two edges in @{text "RAG s"} which 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   272
  links @{text cs} with @{text taker} and @{text th} to form a chain. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   273
  The existence of this chain set the stage for the @{text V}-operation 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   274
  in question to happen.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   275
*}
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   276
lemma sub_RAGs': 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   277
  "{(Cs cs, Th th), (Th taker, Cs cs)} \<subseteq> RAG s"
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
   278
  using waiting_taker holding_th_cs_s
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   279
  by (unfold s_RAG_def, fold s_waiting_abv s_holding_abv, auto)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   280
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   281
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   282
  The following lemma shows that @{text taker} has only two the ancestors.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   283
  The reason for this is very simple: The chain starting from @{text taker}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   284
  stops at @{text th}, which, as shown by @{thm ancestors_th}, has no ancestor. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   285
*}
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   286
lemma ancestors_th': 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   287
  "ancestors (RAG s) (Th taker) = {Th th, Cs cs}" 
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   288
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   289
  have "ancestors (RAG s) (Th taker) = ancestors (RAG s) (Cs cs) \<union> {Cs cs}"
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   290
  proof(rule  forest_RAG.ancestors_accum)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   291
    from sub_RAGs' show "(Th taker, Cs cs) \<in> RAG s" by auto
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   292
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   293
  thus ?thesis using ancestors_th ancestors_cs by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   294
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   295
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   296
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   297
  By composing several existing results, the following lemma
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   298
  make clear the change of @{text RAG} where there is a 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   299
  @{text taker} to take over the resource @{text cs}. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   300
  More specifically, the lemma says the change of @{text RAG}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   301
  is by first removing the chain linking @{text taker}, @{text cs} and 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   302
  @{text th} and then adding in one edge from @{text cs} to @{text taker}.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   303
  The added edge represents acquisition of @{text cs} by @{text taker}.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   304
*}
188
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   305
35
92f61f6a0fe7 added a bit more text to the paper and separated a theory about Max
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 33
diff changeset
   306
lemma RAG_s:
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   307
  "RAG (e#s) = (RAG s - {(Cs cs, Th th), (Th taker, Cs cs)}) \<union>
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   308
                                         {(Cs cs, Th taker)}"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   309
 by (unfold RAG_es waiting_set_eq holding_set_eq, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   310
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   311
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   312
  The above lemma @{thm RAG_s} shows the effect of the @{text V}-operation
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   313
  on @{text RAG} is the removal of two edges followed by the addition of 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   314
  one edge. Based on this, the following lemma will show that 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   315
  the sub-trees of threads other than @{text th} and @{text taker} are unchanged.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   316
  The intuition behind this is rather simple: the edges added and removed are not
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   317
  in these sub-trees. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   318
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   319
  Formally, an edge is said to be outside of a sub-tree if its
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   320
  end point is. Note that when a set of edges are represented as a binary relation, the
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   321
  set of their end points is essentially range of the relation (formally defined 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   322
  as @{term Range}). Therefore, a set of edges (represented as a relation) 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   323
  are outside of a sub-tree if its @{text Range}-set does not intersect 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   324
  with the sub-tree.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   325
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   326
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   327
lemma subtree_kept: (* ddd *)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   328
  assumes "th1 \<notin> {th, taker}"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   329
  shows "subtree (RAG (e#s)) (Th th1) = 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   330
                     subtree (RAG s) (Th th1)" (is "_ = ?R")
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   331
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   332
  let ?RAG' = "(RAG s - {(Cs cs, Th th), (Th taker, Cs cs)})"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   333
  let ?RAG'' = "?RAG' \<union> {(Cs cs, Th taker)}"
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   334
  -- {* The first step is to show the deletion of edges does not change the sub-tree *}
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   335
  have "subtree ?RAG' (Th th1) = ?R" 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   336
  proof(rule subset_del_subtree_outside)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   337
    show "Range {(Cs cs, Th th), (Th taker, Cs cs)} \<inter> subtree (RAG s) (Th th1) = {}"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   338
    proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   339
      have "(Th th) \<notin> subtree (RAG s) (Th th1)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   340
      proof(rule subtree_refute)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   341
        show "Th th1 \<notin> ancestors (RAG s) (Th th)"
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   342
            by (unfold ancestors_th, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   343
      next
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   344
        from assms show "Th th1 \<noteq> Th th" by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   345
      qed
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   346
      moreover have "(Cs cs) \<notin>  subtree (RAG s) (Th th1)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   347
      proof(rule subtree_refute)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   348
        show "Th th1 \<notin> ancestors (RAG s) (Cs cs)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   349
          by (unfold ancestors_cs, insert assms, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   350
      qed simp
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   351
      ultimately have "{Th th, Cs cs} \<inter> subtree (RAG s) (Th th1) = {}" by auto
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   352
      thus ?thesis by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   353
     qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   354
  qed
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   355
  -- {* The second step is to show the addition of edges does not change the sub-tree *}
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   356
  moreover have "subtree ?RAG'' (Th th1) =  subtree ?RAG' (Th th1)"
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   357
  proof(rule subset_insert_subtree_outside)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   358
    show "Range {(Cs cs, Th taker)} \<inter> 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   359
          subtree (RAG s - {(Cs cs, Th th), (Th taker, Cs cs)}) (Th th1) = {}"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   360
    proof -
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   361
     have "Th taker \<notin> subtree (RAG s - {(Cs cs, Th th), (Th taker, Cs cs)}) (Th th1)"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   362
     proof(rule subtree_refute)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   363
        show "Th th1 \<notin> ancestors (RAG s - {(Cs cs, Th th), (Th taker, Cs cs)}) (Th taker)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   364
            (is "_ \<notin> ?R")
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   365
        proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   366
          have "?R \<subseteq> ancestors (RAG s) (Th taker)" by (rule ancestors_mono, auto)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   367
          moreover have "Th th1 \<notin> ..." using ancestors_th' assms by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   368
          ultimately show ?thesis by auto
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   369
        qed
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   370
     next
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   371
        from assms show "Th th1 \<noteq> Th taker" by simp
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   372
     qed
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   373
     thus ?thesis by auto
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   374
    qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   375
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   376
  ultimately show ?thesis by (unfold RAG_s, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   377
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   378
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   379
text {* 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   380
  The following lemma shows threads not involved in the @{text V}-operation (i.e.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   381
  threads other than @{text th} and @{text taker}) do not need to do any @{text cp}-recalculation.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   382
  The reason is simple: according to @{thm subtree_kept}, the sub-trees of such threads 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   383
  are not changed , additionally, since the @{text V}-operation does not change any precedence, 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   384
  the @{text "cp"}-value of such threads are not changed.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   385
*}
188
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   386
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   387
lemma cp_kept:
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   388
  assumes "th1 \<notin> {th, taker}"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   389
  shows "cp (e#s) th1 = cp s th1"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   390
    by (unfold cp_alt_def the_preced_es subtree_kept[OF assms], simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   391
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   392
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   393
  Lemma @{thm cp_kept} also means @{text cp}-recalculation is needed only for
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   394
  @{text th} and @{text taker}. The following lemmas are to ensure that
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   395
  the recalculation can done locally using {\em local recalculation principle}.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   396
  Since @{text taker} and @{text th} are the only threads with changed @{text cp}-values
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   397
  and neither one can not be a child of the other, it can be concluded that 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   398
  neither of these two threads has children with changed @{text cp}-value.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   399
  It means the recursive calls in @{thm cp_rec_tG} will not descend when recalculating 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   400
  the @{text cp}-values for @{text th} and @{text taker}.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   401
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   402
188
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   403
lemma "taker \<notin> children (tG (e#s)) th"
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   404
  by (metis children_subtree empty_iff in_mono neq_taker_th root_def set_mp
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   405
          subtree_ancestorsI taker_ready_es vat_es.root_readys_tG)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   406
  
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   407
188
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   408
lemma "th \<notin> children (tG (e#s)) taker"
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   409
  by (metis children_subtree empty_iff  neq_taker_th root_def 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   410
         subsetD subtree_ancestorsI th_ready_es vat_es.root_readys_tG)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   411
  
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   412
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   413
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   414
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   415
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   416
  The following locale @{text valid_trace_v_e} deals with the second sub-case 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   417
  of @{text V}-operation, where there is no thread to take over the release 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   418
  resource @{text cs}.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   419
*}
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   420
context valid_trace_v_e
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   421
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   422
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   423
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   424
  Since no thread to take over @{text cs}, only the edge representing 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   425
  the holding of @{text cs} by @{text th} needs to be removed:
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   426
*}
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   427
lemma RAG_s: "RAG (e#s) = RAG s - {(Cs cs, Th th)}"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   428
  by (unfold RAG_es waiting_set_eq holding_set_eq, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   429
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   430
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   431
  Since @{text th} has no ancestors, 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   432
  the removal of the holding edge only affects the sub-tree of @{text th}:
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   433
*}
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   434
lemma subtree_kept:
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   435
  assumes "th1 \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   436
  shows "subtree (RAG (e#s)) (Th th1) = subtree (RAG s) (Th th1)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   437
proof(unfold RAG_s, rule subset_del_subtree_outside)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   438
  show "Range {(Cs cs, Th th)} \<inter> subtree (RAG s) (Th th1) = {}"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   439
  proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   440
    have "(Th th) \<notin> subtree (RAG s) (Th th1)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   441
    proof(rule subtree_refute)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   442
      show "Th th1 \<notin> ancestors (RAG s) (Th th)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   443
          by (unfold ancestors_th, simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   444
    next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   445
      from assms show "Th th1 \<noteq> Th th" by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   446
    qed
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   447
    thus ?thesis by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   448
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   449
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   450
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   451
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   452
  From lemma @{thm subtree_kept} and the fact that no precedence are changed, it 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   453
  can be derived the @{text cp}-values of all threads (except @{text th})
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   454
  are not changed and therefore need no recalculation:
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   455
*}
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   456
lemma cp_kept_1:
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   457
  assumes "th1 \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   458
  shows "cp (e#s) th1 = cp s th1"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   459
    by (unfold cp_alt_def the_preced_es subtree_kept[OF assms], simp)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   460
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   461
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   462
  The next several lemmas try to show that even the @{text cp}-value of 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   463
  @{text th} needs not be recalculated.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   464
 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   465
  Although the @{text V}-operation detaches the sub-tree of @{text cs}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   466
  from the sub-tree of @{text th}, the @{text cp}-value of @{text th} 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   467
  is not affected. The reason is given by the following lemma @{text subtree_cs}, which
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   468
  says that the sub-tree of @{text cs} contains only itself. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   469
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   470
  According to @{text subtree_cs}, the detached sub-tree contains no thread node and
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   471
  therefore makes no contribution to the @{text cp}-value of @{text th}, 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   472
  so its removal does not affect the @{text cp}-value neither, as confirmed 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   473
  by the lemma @{text cp_kept_2}.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   474
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   475
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   476
lemma subtree_cs: "subtree (RAG s) (Cs cs) = {Cs cs}"
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   477
  (is "?L = ?R")
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   478
proof -
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   479
  { fix n
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   480
    assume "n \<in> ?L"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   481
    hence "n \<in> ?R"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   482
    proof(cases rule:subtreeE)
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   483
      case 2
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   484
      from this(2) have "(n, Cs cs) \<in> (RAG s)^+"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   485
        by (auto simp:ancestors_def)
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   486
      from tranclD2[OF this]
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   487
      obtain th' where "waiting s th' cs"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   488
        by (auto simp:s_RAG_def s_waiting_abv)
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   489
      with no_waiter_before 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   490
      show ?thesis by simp
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   491
    qed simp
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   492
  } moreover {
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   493
    fix n
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   494
    assume "n \<in> ?R"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   495
    hence "n \<in> ?L" by (auto simp:subtree_def)
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   496
  } ultimately show ?thesis by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   497
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   498
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   499
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   500
  The following @{text "subtree_th"} is just a technical lemma.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   501
*}
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   502
lemma subtree_th: 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   503
  "subtree (RAG (e#s)) (Th th) = subtree (RAG s) (Th th) - {Cs cs}"
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   504
proof(unfold RAG_s, fold subtree_cs, rule forest_RAG.subtree_del_inside)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   505
  from edge_of_th
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   506
  show "(Cs cs, Th th) \<in> edges_in (RAG s) (Th th)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   507
    by (unfold edges_in_def, auto simp:subtree_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   508
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   509
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   510
lemma cp_kept_2: 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   511
  shows "cp (e#s) th = cp s th" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   512
 by (unfold cp_alt_def subtree_th the_preced_es, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   513
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   514
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   515
  By combining @{thm cp_kept_1} and @{thm cp_kept_2}, it is shown that no @{text cp}-recalculation 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   516
  is needed at all for this sub-case of @{text V}-operation.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   517
*}
188
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   518
lemma eq_cp_pre:
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   519
  shows "cp (e#s) th' = cp s th'"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   520
  using cp_kept_1 cp_kept_2
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   521
  by (cases "th' = th", auto)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   522
188
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   523
lemma eq_cp: 
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   524
  shows "cp (e#s) = cp s"
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   525
  by (rule ext, unfold eq_cp_pre, simp)
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   526
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   527
end
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   528
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   529
section {* The @{term P} operation *} 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   530
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   531
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   532
  Like @{text V}-operation, the treatment of @{text P}-operation is also divided into
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   533
  tow sub-cases. If the requested resource is available, it is dealt with in
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   534
  sub-locale @{text valid_trace_p_h}, otherwise, it is dealt with 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   535
  in sub-locale @{text valid_trace_p_w}. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   536
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   537
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   538
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   539
  But first, the following base locale @{text valid_trace_p} contains
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   540
  some general properties of the @{text P}-operation:
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   541
*}
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   542
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   543
context valid_trace_p
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   544
begin
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   545
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   546
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   547
  The following lemma shows that @{text th} is a root in the 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   548
  @{text RAG} graph, which means @{text th} has no ancestors in the graph.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   549
  The reason is that: since @{text th} is in running state, it is 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   550
  in ready state, which means it is not waiting for any resource, therefore, 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   551
  it has no outbound edge.  
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   552
*}
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   553
lemma root_th: "root (RAG s) (Th th)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   554
  by (simp add: ready_th_s readys_root)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   555
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   556
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   557
  For the same reason as @{thm root_th}, @{text th} is not in 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   558
  the sub-tree of any thread other than @{text th}:
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   559
*}
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   560
lemma in_no_others_subtree:
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   561
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   562
  shows "Th th \<notin> subtree (RAG s) (Th th')"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   563
proof
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   564
  assume "Th th \<in> subtree (RAG s) (Th th')"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   565
  thus False
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   566
  proof(cases rule:subtreeE)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   567
    case 1
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   568
    with assms show ?thesis by auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   569
  next
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   570
    case 2
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   571
    with root_th show ?thesis by (auto simp:root_def)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   572
  qed
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   573
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   574
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   575
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   576
  The following lemma confirms that the @{text P}-operation does not 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   577
  affect the precedence of any thread. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   578
*}
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   579
lemma preced_kept: "the_preced (e#s) = the_preced s"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   580
proof
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   581
  fix th'
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   582
  show "the_preced (e # s) th' = the_preced s th'"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   583
    by (unfold the_preced_def is_p preced_def, simp)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   584
qed
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   585
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   586
end
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   587
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   588
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   589
  The following locale @{text valid_trace_p_h} deals with the 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   590
  sub-case of @{text P}-operation when the requested @{text cs}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   591
  is available and @{text th} gets hold of it instantaneously with 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   592
  the @{text P}-operation.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   593
*}
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   594
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   595
context valid_trace_p_h
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   596
begin
189
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   597
       
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   598
text {*
188
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   599
  It can be shown that the @{text tG} is not changed by 
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   600
  the @{text P}-action. The reason is that the edge added to @{text RAG}
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   601
  by the @{text P}-action, namely @{text "(Cs cs, Th th)"},
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   602
  does not bring any new thread into graph @{text tG}, because 
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   603
  the node of @{text cs} is isolated from the original @{text RAG}.
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   604
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   605
189
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   606
thm RAG_es
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   607
188
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   608
lemma tG_es: "tG (e # s) = tG s"
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   609
proof -
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   610
  have [simp]: "\<And> th1. (Th th1, Cs cs) \<notin> RAG s"
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   611
    by (metis in_RAG_E no_holder node.simps(4) the_cs.simps waiting_holding)
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   612
  show ?thesis
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   613
    apply (unfold tG_def_tRAG tRAG_alt_def RAG_es)
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   614
    by (auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   615
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   616
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   617
text {*
188
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   618
  Since both @{text tG} and precedences are not changed, it is easy
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   619
  to show that all @{text cp}-value are not changed, therefore, 
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   620
  no @{text cp}-recalculation is needed:
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   621
*}
188
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   622
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   623
lemma cp_kept: "cp (e#s) = cp s"
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
   624
  by (rule ext, simp add: cp_alt_def2 preced_kept tG_es)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   625
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   626
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   627
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   628
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   629
  The following locale @{text valid_trace_p_w} corresponds to 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   630
  the case when the requested resource @{text cs} is not available and
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   631
  thread @{text th} is blocked.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   632
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   633
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   634
context valid_trace_p_w
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   635
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   636
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   637
lemma cs_held: "(Cs cs, Th holder) \<in> RAG s"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   638
  using holding_s_holder
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   639
  by (unfold s_RAG_def, fold s_holding_abv, auto)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   640
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   641
lemma tRAG_s: 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   642
  "tRAG (e#s) = tRAG s \<union> {(Th th, Th holder)}"
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   643
  using RAG_tRAG_transfer[OF RAG_es cs_held] .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   644
189
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   645
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   646
lemma tG_ancestors_tRAG_refute:
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   647
  assumes "th'' \<notin> ancestors (tG (e#s)) th"
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   648
  shows "Th th'' \<notin> ancestors (tRAG (e#s)) (Th th)"
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   649
  using assms using node.inject(1) tRAG_ancestorsE_tG by force 
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   650
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   651
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   652
  The following lemma shows only the ancestors of @{text th} (the initiating 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   653
  thread of the @{text P}-operation) may possibly 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   654
  need a @{text cp}-recalculation. All other threads (including @{text th} itself)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   655
  do not need @{text cp}-recalculation. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   656
*}
189
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   657
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   658
lemma cp_kept:
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   659
  assumes "Th th'' \<notin> ancestors (tRAG (e#s)) (Th th)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   660
  shows "cp (e#s) th'' = cp s th''"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   661
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   662
  have h: "subtree (tRAG (e#s)) (Th th'') = subtree (tRAG s) (Th th'')"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   663
  proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   664
    have "Th holder \<notin> subtree (tRAG s) (Th th'')"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   665
    proof
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   666
      assume "Th holder \<in> subtree (tRAG s) (Th th'')"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   667
      thus False
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   668
      proof(rule subtreeE)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   669
         assume "Th holder = Th th''"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   670
         from assms[unfolded tRAG_s ancestors_def, folded this]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   671
         show ?thesis by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   672
      next
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   673
         assume "Th th'' \<in> ancestors (tRAG s) (Th holder)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   674
         moreover have "... \<subseteq> ancestors (tRAG (e#s)) (Th holder)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   675
         proof(rule ancestors_mono)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   676
            show "tRAG s \<subseteq> tRAG (e#s)" by (unfold tRAG_s, auto)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   677
         qed 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   678
         ultimately have "Th th'' \<in> ancestors (tRAG (e#s)) (Th holder)" by auto
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   679
         moreover have "Th holder \<in> ancestors (tRAG (e#s)) (Th th)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   680
           by (unfold tRAG_s, auto simp:ancestors_def)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   681
         ultimately have "Th th'' \<in> ancestors (tRAG (e#s)) (Th th)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   682
                       by (auto simp:ancestors_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   683
         with assms show ?thesis by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   684
      qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   685
    qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   686
    from subtree_insert_next[OF this]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   687
    have "subtree (tRAG s \<union> {(Th th, Th holder)}) (Th th'') = subtree (tRAG s) (Th th'')" .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   688
    from this[folded tRAG_s] show ?thesis .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   689
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   690
  show ?thesis by (unfold cp_alt_def1 h preced_kept, simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   691
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   692
190
312497c6d6b9 updated
Christian Urban <urbanc@in.tum.de>
parents: 189
diff changeset
   693
lemma cp_kept_tG: (* aaa *)
189
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   694
  assumes "th'' \<notin> ancestors (tG (e#s)) th"
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   695
  shows "cp (e#s) th'' = cp s th''"
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   696
  using cp_kept tG_ancestors_tRAG_refute assms
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   697
  by blast
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   698
  
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   699
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   700
  Lemma @{thm cp_kept} means that the @{text cp}-recalculation starts from the parent of @{text th},
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   701
  going upwards along the chain of ancestors until one root (which is a thread 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   702
  in ready queue) is reached. Actually, recalculation can terminate earlier, as 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   703
  confirmed by the following two lemmas. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   704
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   705
  The first lemma @{text cp_gen_update_stop} is a technical lemma used to
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   706
  prove the lemma that follows.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   707
*}
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   708
lemma cp_gen_update_stop: (* ddd *)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   709
  assumes "u \<in> ancestors (tRAG (e#s)) (Th th)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   710
  and "cp_gen (e#s) u = cp_gen s u"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   711
  and "y \<in> ancestors (tRAG (e#s)) u"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   712
  shows "cp_gen (e#s) y = cp_gen s y"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   713
  using assms(3)
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 93
diff changeset
   714
proof(induct rule:wf_induct[OF vat_es.fsbttRAGs.wf])
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   715
  case (1 x)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   716
  show ?case (is "?L = ?R")
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   717
  proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   718
    from tRAG_ancestorsE[OF 1(2)]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   719
    obtain th2 where eq_x: "x = Th th2" by blast
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 93
diff changeset
   720
    from vat_es.cp_gen_rec[OF this]
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   721
    have "?L = 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   722
          Max ({the_preced (e#s) th2} \<union> cp_gen (e#s) ` RTree.children (tRAG (e#s)) x)" .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   723
    also have "... = 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   724
          Max ({the_preced s th2} \<union> cp_gen s ` RTree.children (tRAG s) x)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   725
    proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   726
      from preced_kept have "the_preced (e#s) th2 = the_preced s th2" by simp
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   727
      moreover have "cp_gen (e#s) ` RTree.children (tRAG (e#s)) x =
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   728
                     cp_gen s ` RTree.children (tRAG s) x"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   729
      proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   730
        have "RTree.children (tRAG (e#s)) x =  RTree.children (tRAG s) x"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   731
        proof(unfold tRAG_s, rule children_union_kept)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   732
          have start: "(Th th, Th holder) \<in> tRAG (e#s)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   733
            by (unfold tRAG_s, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   734
          note x_u = 1(2)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   735
          show "x \<notin> Range {(Th th, Th holder)}"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   736
          proof
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   737
            assume "x \<in> Range {(Th th, Th holder)}"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   738
            hence eq_x: "x = Th holder" using RangeE by auto
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   739
            show False
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   740
            find_theorems ancestors tRAG
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   741
            proof(cases rule:vat_es.forest_s.ancestors_headE[OF assms(1) start])
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   742
              case 1
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 93
diff changeset
   743
              from x_u[folded this, unfolded eq_x] vat_es.acyclic_tRAG
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   744
              show ?thesis by (auto simp:ancestors_def acyclic_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   745
            next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   746
              case 2
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   747
              with x_u[unfolded eq_x]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   748
              have "(Th holder, Th holder) \<in> (tRAG (e#s))^+" by (auto simp:ancestors_def)
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 93
diff changeset
   749
              with vat_es.acyclic_tRAG show ?thesis by (auto simp:acyclic_def)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   750
            qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   751
          qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   752
        qed
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   753
        moreover have "cp_gen (e#s) ` RTree.children (tRAG (e#s)) x =
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   754
                       cp_gen s ` RTree.children (tRAG (e#s)) x" (is "?f ` ?A = ?g ` ?A")
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   755
        proof(rule f_image_eq)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   756
          fix a
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   757
          assume a_in: "a \<in> ?A"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   758
          from 1(2)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   759
          show "?f a = ?g a"
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   760
          proof(cases rule:vat_es.forest_s.ancestors_childrenE[case_names in_ch out_ch])
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   761
             case in_ch
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   762
             show ?thesis
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   763
             proof(cases "a = u")
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   764
                case True
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   765
                from assms(2)[folded this] show ?thesis .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   766
             next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   767
                case False
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   768
                have a_not_in: "a \<notin> ancestors (tRAG (e#s)) (Th th)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   769
                proof
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   770
                  assume a_in': "a \<in> ancestors (tRAG (e#s)) (Th th)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   771
                  have "a = u"
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   772
                  proof(rule vat_es.forest_s.ancestors_children_unique)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   773
                    from a_in' a_in show "a \<in> ancestors (tRAG (e#s)) (Th th) \<inter> 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   774
                                          RTree.children (tRAG (e#s)) x" by auto
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   775
                  next 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   776
                    from assms(1) in_ch show "u \<in> ancestors (tRAG (e#s)) (Th th) \<inter> 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   777
                                      RTree.children (tRAG (e#s)) x" by auto
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   778
                  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   779
                  with False show False by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   780
                qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   781
                from a_in obtain th_a where eq_a: "a = Th th_a" 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   782
                    by (unfold RTree.children_def tRAG_alt_def, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   783
                from cp_kept[OF a_not_in[unfolded eq_a]]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   784
                have "cp (e#s) th_a = cp s th_a" .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   785
                from this [unfolded cp_gen_def_cond[OF eq_a], folded eq_a]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   786
                show ?thesis .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   787
             qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   788
          next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   789
            case (out_ch z)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   790
            hence h: "z \<in> ancestors (tRAG (e#s)) u" "z \<in> RTree.children (tRAG (e#s)) x" by auto
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   791
            show ?thesis
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   792
            proof(cases "a = z")
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   793
              case True
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   794
              from h(2) have zx_in: "(z, x) \<in> (tRAG (e#s))" by (auto simp:RTree.children_def)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   795
              from 1(1)[rule_format, OF this h(1)]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   796
              have eq_cp_gen: "cp_gen (e#s) z = cp_gen s z" .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   797
              with True show ?thesis by metis
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   798
            next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   799
              case False
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   800
              from a_in obtain th_a where eq_a: "a = Th th_a"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   801
                by (auto simp:RTree.children_def tRAG_alt_def)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   802
              have "a \<notin> ancestors (tRAG (e#s)) (Th th)"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   803
              proof
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   804
                assume a_in': "a \<in> ancestors (tRAG (e#s)) (Th th)"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   805
                have "a = z"
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   806
                proof(rule vat_es.forest_s.ancestors_children_unique)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   807
                  from assms(1) h(1) have "z \<in> ancestors (tRAG (e#s)) (Th th)"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   808
                      by (auto simp:ancestors_def)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   809
                  with h(2) show " z \<in> ancestors (tRAG (e#s)) (Th th) \<inter> 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   810
                                       RTree.children (tRAG (e#s)) x" by auto
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   811
                next
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   812
                  from a_in a_in'
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   813
                  show "a \<in> ancestors (tRAG (e#s)) (Th th) \<inter> RTree.children (tRAG (e#s)) x"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   814
                    by auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   815
                qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   816
                with False show False by auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   817
              qed
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   818
              from cp_kept[OF this[unfolded eq_a]]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   819
              have "cp (e#s) th_a = cp s th_a" .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   820
              from this[unfolded cp_gen_def_cond[OF eq_a], folded eq_a]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   821
              show ?thesis .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   822
            qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   823
          qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   824
        qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   825
        ultimately show ?thesis by metis
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   826
      qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   827
      ultimately show ?thesis by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   828
    qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   829
    also have "... = ?R"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   830
      by (fold cp_gen_rec[OF eq_x], simp)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   831
    finally show ?thesis .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   832
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   833
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   834
189
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   835
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   836
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   837
  The following lemma is about the possible early termination of 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   838
  @{text cp}-recalculation. The lemma says that @{text cp}-recalculation 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   839
  can terminate as soon as the recalculation yields an unchanged @{text cp}-value. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   840
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   841
  The @{text th'} in the lemma is assumed to be the first ancestor of @{text th}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   842
  encountered by the recalculation procedure which has an unchanged @{text cp}-value 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   843
  and the @{text th''} represents any thread upstream of @{text th'}. The lemma shows 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   844
  that the @{text "cp"}-value @{text "th''"} is not changed, therefore, needs no 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   845
  recalculation. It means the recalculation can be stop at @{text "th'"}.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   846
*}
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   847
lemma cp_up:
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   848
  assumes "(Th th') \<in> ancestors (tRAG (e#s)) (Th th)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   849
  and "cp (e#s) th' = cp s th'"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   850
  and "(Th th'') \<in> ancestors (tRAG (e#s)) (Th th')"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   851
  shows "cp (e#s) th'' = cp s th''"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   852
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   853
  have "cp_gen (e#s) (Th th'') = cp_gen s (Th th'')"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   854
  proof(rule cp_gen_update_stop[OF assms(1) _ assms(3)])
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   855
    from assms(2) cp_gen_def_cond[OF refl[of "Th th'"]]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   856
    show "cp_gen (e#s) (Th th') = cp_gen s (Th th')" by metis
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   857
  qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   858
  with cp_gen_def_cond[OF refl[of "Th th''"]]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   859
  show ?thesis by metis
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   860
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   861
190
312497c6d6b9 updated
Christian Urban <urbanc@in.tum.de>
parents: 189
diff changeset
   862
lemma cp_up_tG: (* aaa *)
189
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   863
  assumes "th' \<in> ancestors (tG (e#s)) th"
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   864
  and "cp (e#s) th' = cp s th'"
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   865
  and "th'' \<in> ancestors (tG (e#s)) th'"
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   866
  shows "cp (e#s) th'' = cp s th''"
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   867
  using assms cp_up ancestors_tG_tRAG by blast   
914288aec495 updated
Christian Urban <urbanc@in.tum.de>
parents: 188
diff changeset
   868
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   869
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   870
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   871
text {* 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   872
  The following locale deals with the @{text Create}-operation.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   873
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   874
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   875
section {* The @{term Create} operation *}
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   876
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   877
context valid_trace_create
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   878
begin 
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   879
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   880
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   881
  Since @{text Create}-operation does not change @{text RAG} (according to 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   882
  @{thm RAG_es}) and @{text tRAG} is determined uniquely by @{text RAG}, 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   883
  therefore, @{text tRAG} is not not changed by @{text Create} neither.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   884
*}
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   885
lemma tRAG_kept: "tRAG (e#s) = tRAG s"
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   886
  by (unfold tRAG_alt_def RAG_es, auto)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   887
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   888
lemma tG_kept: "tG (e#s) = tG s"
179
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   889
  by (unfold tG_def_tRAG tRAG_kept, simp)
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   890
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   891
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   892
  The following lemma shows that @{text th} is completely isolated 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   893
  from @{text RAG}.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   894
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   895
lemma th_not_in: "Th th \<notin> Field (tRAG s)"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   896
  by (meson not_in_thread_isolated subsetCE tRAG_Field th_not_live_s)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   897
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   898
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   899
  Based on @{thm th_not_in}, it can be derived that @{text th} is also 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   900
  isolated from @{text RAG}.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   901
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   902
lemma th_not_in_tG: "th \<notin> Field (tG s)"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   903
  using tG_threads th_not_live_s by blast
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   904
  
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   905
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   906
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   907
  The @{text Create}-operation does not change the precedences
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   908
  of other threads excepting sets a the initial precedence for the 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   909
  thread being created (i.e. @{text th}).
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   910
*}
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   911
lemma preced_kept:
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   912
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   913
  shows "the_preced (e#s) th' = the_preced s th'"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   914
  by (unfold the_preced_def preced_def is_create, insert assms, auto)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   915
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   916
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   917
  The following lemma shows that the @{text cp}-values of
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   918
  all other threads need not be recalculated. The reason is twofold, first, 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   919
  since @{text tG} is not changed, sub-trees of these threads are not changed;
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   920
  second, the precedences of the threads in these sub-trees are not changed (because 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   921
  the only thread with a changed precedence is @{text th} and @{text th} is isolated
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   922
  from @{text tG}). 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   923
*}
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   924
lemma eq_cp:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   925
  assumes neq_th: "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   926
  shows "cp (e#s) th' = cp s th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   927
proof -
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   928
  have "(the_preced (e # s) ` subtree (tG (e # s)) th') =
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   929
        (the_preced s ` subtree (tG s) th')"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   930
  proof -
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   931
    { fix a
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   932
      assume "a \<in> subtree (tG s) th'"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   933
      with th_not_in_tG have "a \<noteq> th"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   934
        by (metis ancestors_Field dm_tG_threads neq_th subtree_ancestorsI th_not_live_s) 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   935
      from preced_kept[OF this]  
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   936
      have "the_preced (e # s) a = the_preced s a" .
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   937
    }
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   938
    thus ?thesis by (unfold tG_kept, auto intro!:f_image_eq)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   939
  qed   
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   940
  thus ?thesis by (unfold cp_alt_def2, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   941
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   942
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   943
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   944
  The following two lemmas deal with the @{text cp}-calculation of @{text th}. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   945
  The first lemma @{text children_of_th} says @{text th} has no children. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   946
  The reason is simple, @{text th} is isolated from @{text "RAG"} before the
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   947
  @{term Create}-operation and @{text Create} does not change @{text RAG}, so 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   948
  @{text th} keeps isolated after the operation.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   949
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   950
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   951
lemma children_of_th: "RTree.children (tRAG (e#s)) (Th th) = {}"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   952
proof -
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   953
  { fix a
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   954
    assume "a \<in> RTree.children (tRAG (e#s)) (Th th)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   955
    hence "(a, Th th) \<in> tRAG (e#s)" by (auto simp:RTree.children_def)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   956
    with th_not_in have False 
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   957
     by (unfold Field_def tRAG_kept, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   958
  } thus ?thesis by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   959
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   960
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   961
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   962
  Now, since @{term th} has no children, by definition its @{text cp} value 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   963
  equals its precedence:
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   964
*}
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   965
lemma eq_cp_th: "cp (e#s) th = preced th (e#s)"
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 93
diff changeset
   966
 by (unfold vat_es.cp_rec children_of_th, simp add:the_preced_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   967
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   968
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   969
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   970
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   971
  The following locale @{text valid_trace_exit} deals with the @{term Exit}-operation.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   972
*}
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   973
context valid_trace_exit
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   974
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   975
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   976
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   977
  The treatment of @{text Exit} is very similar to @{text Create}.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   978
  First, the precedences of threads other than @{text th} are not changed.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   979
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   980
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   981
lemma preced_kept:
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   982
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   983
  shows "the_preced (e#s) th' = the_preced s th'"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   984
  using assms
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   985
  by (unfold the_preced_def is_exit preced_def, simp)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   986
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   987
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   988
  Second, @{term tRAG} is not changed by @{text Exit} either.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   989
*}
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   990
lemma tRAG_kept: "tRAG (e#s) = tRAG s"
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   991
  by (unfold tRAG_alt_def RAG_es, auto)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   992
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   993
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   994
  Since @{term tG} is defined in terms of @{term tRAG}, @{term tG} is not changed neither.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   995
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   996
lemma tG_kept: "tG (e#s) = tG s"
179
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   997
  by (unfold tG_def_tRAG tRAG_kept, simp)
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
   998
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   999
lemma th_RAG: "Th th \<notin> Field (RAG s)"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
  1000
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
  1001
  have "Th th \<notin> Range (RAG s)"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
  1002
  proof
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
  1003
    assume "Th th \<in> Range (RAG s)"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
  1004
    then obtain cs where "holding s th cs"
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
  1005
    by (simp add: holdents_RAG holdents_th_s)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1006
    then show False by (unfold s_holding_abv, auto)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
  1007
  qed
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
  1008
  moreover have "Th th \<notin> Domain (RAG s)"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
  1009
  proof
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
  1010
    assume "Th th \<in> Domain (RAG s)"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
  1011
    then obtain cs where "waiting s th cs"
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
  1012
    by (simp add: readys_RAG)
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
  1013
    then show False
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
  1014
    using RAG_es \<open>Th th \<in> Domain (RAG s)\<close> 
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
  1015
    th_not_live_es valid_trace.dm_RAG_threads vat_es.valid_trace_axioms by blast
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
  1016
  qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
  1017
  ultimately show ?thesis by (auto simp:Field_def)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
  1018
qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
  1019
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1020
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
  1021
lemma th_tRAG: "(Th th) \<notin> Field (tRAG s)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
  1022
  using th_RAG tRAG_Field by auto
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
  1023
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1024
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1025
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1026
  Based on @{thm th_RAG}, it can be derived that @{text th} is also 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1027
  isolated from @{text tG}.
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1028
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1029
lemma th_not_in_tG: "th \<notin> Field (tG s)"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1030
  using tG_kept vat_es.tG_threads by auto
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1031
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1032
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1033
  Because of @{thm preced_kept}, @{thm tG_kept} and @{thm th_tRAG},
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1034
  the @{text cp}-values of all other threads are not changed. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1035
  The reasoning is almost the same as that of @{term Create}:
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1036
*}
188
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
  1037
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1038
lemma eq_cp:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1039
  assumes neq_th: "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
  1040
  shows "cp (e#s) th' = cp s th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1041
proof -
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1042
  have "(the_preced (e # s) ` subtree (tG (e # s)) th') =
179
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  1043
          (the_preced s ` subtree (tG s) th')"
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1044
  proof -
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1045
    { fix a
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1046
      assume "a \<in> subtree (tG s) th'"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1047
      with th_not_in_tG have "a \<noteq> th"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1048
        by (metis ex_in_conv neq_th root_def root_readys_tG subtree_ancestorsI th_ready_s)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1049
      from preced_kept[OF this]  
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1050
      have "the_preced (e # s) a = the_preced s a" .
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1051
    }
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1052
    thus ?thesis by (unfold tG_kept, auto intro!:f_image_eq)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1053
  qed   
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 136
diff changeset
  1054
  thus ?thesis by (unfold cp_alt_def2, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1055
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1056
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1057
end
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
  1058
188
2dd47ea013ac updated
Christian Urban <urbanc@in.tum.de>
parents: 185
diff changeset
  1059
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1060
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1061