Implementation.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Thu, 28 Jan 2016 14:26:10 +0000
changeset 95 8d2cc27f45f3
parent 68 db196b066b97
child 97 c7ba70dc49bd
permissions -rw-r--r--
changes to my repository
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
95
8d2cc27f45f3 changes to my repository
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
     1
(*<*)
8d2cc27f45f3 changes to my repository
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
     2
theory Implementation
8d2cc27f45f3 changes to my repository
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
     3
imports PIPBasics
8d2cc27f45f3 changes to my repository
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
     4
begin
8d2cc27f45f3 changes to my repository
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
     5
(*>*)
53
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 45
diff changeset
     6
section {*
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 45
diff changeset
     7
  This file contains lemmas used to guide the recalculation of current precedence 
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 45
diff changeset
     8
  after every system call (or system operation)
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 45
diff changeset
     9
*}
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
    10
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    11
text {* (* ddd *)
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    12
  One beauty of our modelling is that we follow the definitional extension tradition of HOL.
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    13
  The benefit of such a concise and miniature model is that  large number of intuitively 
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    14
  obvious facts are derived as lemmas, rather than asserted as axioms.
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    15
*}
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    16
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    17
text {*
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    18
  However, the lemmas in the forthcoming several locales are no longer 
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    19
  obvious. These lemmas show how the current precedences should be recalculated 
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    20
  after every execution step (in our model, every step is represented by an event, 
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    21
  which in turn, represents a system call, or operation). Each operation is 
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    22
  treated in a separate locale.
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    23
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    24
  The complication of current precedence recalculation comes 
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    25
  because the changing of RAG needs to be taken into account, 
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    26
  in addition to the changing of precedence. 
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    27
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    28
  The reason RAG changing affects current precedence is that,
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    29
  according to the definition, current precedence 
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    30
  of a thread is the maximum of the precedences of every threads in its subtree, 
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    31
  where the notion of sub-tree in RAG is defined in RTree.thy.
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    32
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    33
  Therefore, for each operation, lemmas about the change of precedences 
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    34
  and RAG are derived first, on which lemmas about current precedence 
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    35
  recalculation are based on.
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    36
*}
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    37
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    38
section {* The @{term Set} operation *}
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    39
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    40
text {* (* ddd *)
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    41
  The following locale @{text "step_set_cps"} investigates the recalculation 
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    42
  after the @{text "Set"} operation.
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    43
*}
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    44
locale step_set_cps =
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
  fixes s' th prio s 
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    46
  -- {* @{text "s'"} is the system state before the operation *}
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    47
  -- {* @{text "s"} is the system state after the operation *}
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    48
  defines s_def : "s \<equiv> (Set th prio#s')" 
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    49
  -- {* @{text "s"} is assumed to be a legitimate state, from which
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    50
         the legitimacy of @{text "s"} can be derived. *}
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    51
  assumes vt_s: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
    53
sublocale step_set_cps < vat_s : valid_trace "s"
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
    54
proof
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
    55
  from vt_s show "vt s" .
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
    56
qed
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
    57
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
    58
sublocale step_set_cps < vat_s' : valid_trace "s'"
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
    59
proof
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
    60
  from step_back_vt[OF vt_s[unfolded s_def]] show "vt s'" .
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
    61
qed
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
    62
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
context step_set_cps 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    64
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    65
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    66
text {* (* ddd *)
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    67
  The following two lemmas confirm that @{text "Set"}-operation
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    68
  only changes the precedence of the initiating thread (or actor)
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    69
  of the operation (or event).
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    70
*}
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    71
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    72
lemma eq_preced:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    73
  assumes "th' \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    74
  shows "preced th' s = preced th' s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    75
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    76
  from assms show ?thesis 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    77
    by (unfold s_def, auto simp:preced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    78
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    79
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    80
lemma eq_the_preced: 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    81
  assumes "th' \<noteq> th"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    82
  shows "the_preced s th' = the_preced s' th'"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    83
  using assms
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    84
  by (unfold the_preced_def, intro eq_preced, simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    85
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    86
text {*
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    87
  The following lemma assures that the resetting of priority does not change the RAG. 
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    88
*}
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    89
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
    90
lemma eq_dep: "RAG s = RAG s'"
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
    91
  by (unfold s_def RAG_set_unchanged, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    92
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    93
text {* (* ddd *)
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    94
  Th following lemma @{text "eq_cp_pre"} says that the priority change of @{text "th"}
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    95
  only affects those threads, which as @{text "Th th"} in their sub-trees.
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    96
  
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    97
  The proof of this lemma is simplified by using the alternative definition 
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    98
  of @{text "cp"}. 
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    99
*}
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   100
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   101
lemma eq_cp_pre:
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   102
  assumes nd: "Th th \<notin> subtree (RAG s') (Th th')"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   103
  shows "cp s th' = cp s' th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   104
proof -
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   105
  -- {* After unfolding using the alternative definition, elements 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   106
        affecting the @{term "cp"}-value of threads become explicit. 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   107
        We only need to prove the following: *}
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   108
  have "Max (the_preced s ` {th'a. Th th'a \<in> subtree (RAG s) (Th th')}) =
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   109
        Max (the_preced s' ` {th'a. Th th'a \<in> subtree (RAG s') (Th th')})"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   110
        (is "Max (?f ` ?S1) = Max (?g ` ?S2)")
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   111
  proof -
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   112
    -- {* The base sets are equal. *}
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   113
    have "?S1 = ?S2" using eq_dep by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   114
    -- {* The function values on the base set are equal as well. *}
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   115
    moreover have "\<forall> e \<in> ?S2. ?f e = ?g e"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   116
    proof
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   117
      fix th1
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   118
      assume "th1 \<in> ?S2"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   119
      with nd have "th1 \<noteq> th" by (auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   120
      from eq_the_preced[OF this]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   121
      show "the_preced s th1 = the_preced s' th1" .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   122
    qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   123
    -- {* Therefore, the image of the functions are equal. *}
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   124
    ultimately have "(?f ` ?S1) = (?g ` ?S2)" by (auto intro!:f_image_eq)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   125
    thus ?thesis by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   126
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   127
  thus ?thesis by (simp add:cp_alt_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   128
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   129
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   130
text {*
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   131
  The following lemma shows that @{term "th"} is not in the 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   132
  sub-tree of any other thread. 
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   133
*}
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   134
lemma th_in_no_subtree:
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   135
  assumes "th' \<noteq> th"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   136
  shows "Th th \<notin> subtree (RAG s') (Th th')"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   137
proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   138
  have "th \<in> readys s'"
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   139
  proof -
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   140
    from step_back_step [OF vt_s[unfolded s_def]]
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   141
    have "step s' (Set th prio)" .
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   142
    hence "th \<in> runing s'" by (cases, simp)
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   143
    thus ?thesis by (simp add:readys_def runing_def)
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   144
  qed
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
   145
  from vat_s'.readys_in_no_subtree[OF this assms(1)]
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   146
  show ?thesis by blast
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   147
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   148
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   149
text {* 
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   150
  By combining @{thm "eq_cp_pre"} and @{thm "th_in_no_subtree"}, 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   151
  it is obvious that the change of priority only affects the @{text "cp"}-value 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   152
  of the initiating thread @{text "th"}.
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   153
*}
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   154
lemma eq_cp:
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   155
  assumes "th' \<noteq> th"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   156
  shows "cp s th' = cp s' th'"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   157
  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
   158
56
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   159
end
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   160
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   161
section {* The @{term V} operation *}
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   162
56
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   163
text {*
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   164
  The following @{text "step_v_cps"} is the locale for @{text "V"}-operation.
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   165
*}
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   166
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   167
locale step_v_cps =
56
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   168
  -- {* @{text "th"} is the initiating thread *}
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   169
  -- {* @{text "cs"} is the critical resource release by the @{text "V"}-operation *}
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   170
  fixes s' th cs s    -- {* @{text "s'"} is the state before operation*}
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   171
  defines s_def : "s \<equiv> (V th cs#s')" -- {* @{text "s"} is the state after operation*}
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   172
  -- {* @{text "s"} is assumed to be valid, which implies the validity of @{text "s'"} *}
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   173
  assumes vt_s: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   174
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
   175
sublocale step_v_cps < vat_s : valid_trace "s"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   176
proof
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
   177
  from vt_s show "vt s" .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   178
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   179
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
   180
sublocale step_v_cps < vat_s' : valid_trace "s'"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   181
proof
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
   182
  from step_back_vt[OF vt_s[unfolded s_def]] show "vt s'" .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   183
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   184
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
   185
context step_v_cps
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
   186
begin
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   187
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   188
lemma ready_th_s': "th \<in> readys s'"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   189
  using step_back_step[OF vt_s[unfolded s_def]]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   190
  by (cases, simp add:runing_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   191
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   192
lemma ancestors_th: "ancestors (RAG s') (Th th) = {}"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   193
proof -
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
   194
  from vat_s'.readys_root[OF ready_th_s']
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   195
  show ?thesis
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   196
  by (unfold root_def, simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   197
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   198
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   199
lemma holding_th: "holding s' th cs"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   200
proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   201
  from vt_s[unfolded s_def]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   202
  have " PIP s' (V th cs)" by (cases, simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   203
  thus ?thesis by (cases, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   204
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   205
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   206
lemma edge_of_th:
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   207
    "(Cs cs, Th th) \<in> RAG s'" 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   208
proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   209
 from holding_th
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   210
 show ?thesis 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   211
    by (unfold s_RAG_def holding_eq, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   212
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   213
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   214
lemma ancestors_cs: 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   215
  "ancestors (RAG s') (Cs cs) = {Th th}"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   216
proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   217
  have "ancestors (RAG s') (Cs cs) = ancestors (RAG s') (Th th)  \<union>  {Th th}"
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
   218
  proof(rule vat_s'.rtree_RAG.ancestors_accum)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   219
    from vt_s[unfolded s_def]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   220
    have " PIP s' (V th cs)" by (cases, simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   221
    thus "(Cs cs, Th th) \<in> RAG s'" 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   222
    proof(cases)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   223
      assume "holding s' th cs"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   224
      from this[unfolded holding_eq]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   225
      show ?thesis by (unfold s_RAG_def, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   226
    qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   227
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   228
  from this[unfolded ancestors_th] show ?thesis by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   229
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   230
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   231
lemma preced_kept: "the_preced s = the_preced s'"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   232
  by (auto simp: s_def the_preced_def preced_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   233
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   234
end
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   235
56
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   236
text {*
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   237
  The following @{text "step_v_cps_nt"} is the sub-locale for @{text "V"}-operation, 
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   238
  which represents the case when there is another thread @{text "th'"}
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   239
  to take over the critical resource released by the initiating thread @{text "th"}.
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   240
*}
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   241
locale step_v_cps_nt = step_v_cps +
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   242
  fixes th'
56
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   243
  -- {* @{text "th'"} is assumed to take over @{text "cs"} *}
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   244
  assumes nt: "next_th s' th cs th'" 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   245
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   246
context step_v_cps_nt
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   247
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   248
56
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   249
text {*
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   250
  Lemma @{text "RAG_s"} confirms the change of RAG:
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   251
  two edges removed and one added, as shown by the following diagram.
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   252
*}
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   253
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   254
(*
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   255
  RAG before the V-operation
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   256
    th1 ----|
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   257
            |
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   258
    th' ----|
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   259
            |----> cs -----|
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   260
    th2 ----|              |
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   261
            |              |
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   262
    th3 ----|              |
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   263
                           |------> th
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   264
    th4 ----|              |
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   265
            |              |
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   266
    th5 ----|              |
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   267
            |----> cs'-----|
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   268
    th6 ----|
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   269
            |
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   270
    th7 ----|
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   271
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   272
 RAG after the V-operation
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   273
    th1 ----|
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   274
            |
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   275
            |----> cs ----> th'
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   276
    th2 ----|              
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   277
            |              
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   278
    th3 ----|              
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   279
                           
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   280
    th4 ----|              
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   281
            |              
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   282
    th5 ----|              
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   283
            |----> cs'----> th
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   284
    th6 ----|
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   285
            |
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   286
    th7 ----|
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   287
*)
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   288
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   289
lemma sub_RAGs': "{(Cs cs, Th th), (Th th', Cs cs)} \<subseteq> RAG s'"
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   290
                using next_th_RAG[OF nt]  .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   291
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   292
lemma ancestors_th': 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   293
  "ancestors (RAG s') (Th th') = {Th th, Cs cs}" 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   294
proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   295
  have "ancestors (RAG s') (Th th') = ancestors (RAG s') (Cs cs) \<union> {Cs cs}"
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
   296
  proof(rule  vat_s'.rtree_RAG.ancestors_accum)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   297
    from sub_RAGs' show "(Th th', Cs cs) \<in> RAG s'" by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   298
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   299
  thus ?thesis using ancestors_th ancestors_cs by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   300
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   301
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
   302
lemma RAG_s:
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
   303
  "RAG s = (RAG s' - {(Cs cs, Th th), (Th th', Cs cs)}) \<union>
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   304
                                         {(Cs cs, Th th')}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   305
proof -
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
  from step_RAG_v[OF vt_s[unfolded s_def], folded s_def]
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   307
    and nt show ?thesis  by (auto intro:next_th_unique)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   308
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   309
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   310
lemma subtree_kept: (* ddd *)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   311
  assumes "th1 \<notin> {th, th'}"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   312
  shows "subtree (RAG s) (Th th1) = subtree (RAG s') (Th th1)" (is "_ = ?R")
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   313
proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   314
  let ?RAG' = "(RAG s' - {(Cs cs, Th th), (Th th', Cs cs)})"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   315
  let ?RAG'' = "?RAG' \<union> {(Cs cs, Th th')}"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   316
  have "subtree ?RAG' (Th th1) = ?R" 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   317
  proof(rule subset_del_subtree_outside)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   318
    show "Range {(Cs cs, Th th), (Th th', Cs cs)} \<inter> subtree (RAG s') (Th th1) = {}"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   319
    proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   320
      have "(Th th) \<notin> subtree (RAG s') (Th th1)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   321
      proof(rule subtree_refute)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   322
        show "Th th1 \<notin> ancestors (RAG s') (Th th)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   323
          by (unfold ancestors_th, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   324
      next
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   325
        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
   326
      qed
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   327
      moreover have "(Cs cs) \<notin>  subtree (RAG s') (Th th1)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   328
      proof(rule subtree_refute)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   329
        show "Th th1 \<notin> ancestors (RAG s') (Cs cs)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   330
          by (unfold ancestors_cs, insert assms, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   331
      qed simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   332
      ultimately have "{Th th, Cs cs} \<inter> subtree (RAG s') (Th th1) = {}" by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   333
      thus ?thesis by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   334
     qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   335
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   336
  moreover have "subtree ?RAG'' (Th th1) =  subtree ?RAG' (Th th1)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   337
  proof(rule subtree_insert_next)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   338
    show "Th th' \<notin> subtree (RAG s' - {(Cs cs, Th th), (Th th', Cs cs)}) (Th th1)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   339
    proof(rule subtree_refute)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   340
      show "Th th1 \<notin> ancestors (RAG s' - {(Cs cs, Th th), (Th th', Cs cs)}) (Th th')"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   341
            (is "_ \<notin> ?R")
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   342
      proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   343
          have "?R \<subseteq> ancestors (RAG s') (Th th')" by (rule ancestors_mono, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   344
          moreover have "Th th1 \<notin> ..." using ancestors_th' assms by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   345
          ultimately show ?thesis by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   346
      qed
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   347
    next
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   348
      from assms show "Th th1 \<noteq> Th th'" by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   349
    qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   350
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   351
  ultimately show ?thesis by (unfold RAG_s, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   352
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   353
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   354
lemma cp_kept:
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   355
  assumes "th1 \<notin> {th, th'}"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   356
  shows "cp s th1 = cp s' th1"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   357
    by (unfold cp_alt_def preced_kept subtree_kept[OF assms], simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   358
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   359
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   360
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   361
locale step_v_cps_nnt = step_v_cps +
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   362
  assumes nnt: "\<And> th'. (\<not> next_th s' th cs th')"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   363
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   364
context step_v_cps_nnt
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   365
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   366
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
   367
lemma RAG_s: "RAG s = RAG s' - {(Cs cs, Th th)}"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   368
proof -
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
   369
  from nnt and  step_RAG_v[OF vt_s[unfolded s_def], folded s_def]
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   370
  show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   371
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   372
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   373
lemma subtree_kept:
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   374
  assumes "th1 \<noteq> th"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   375
  shows "subtree (RAG s) (Th th1) = subtree (RAG s') (Th th1)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   376
proof(unfold RAG_s, rule subset_del_subtree_outside)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   377
  show "Range {(Cs cs, Th th)} \<inter> subtree (RAG s') (Th th1) = {}"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   378
  proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   379
    have "(Th th) \<notin> subtree (RAG s') (Th th1)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   380
    proof(rule subtree_refute)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   381
      show "Th th1 \<notin> ancestors (RAG s') (Th th)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   382
          by (unfold ancestors_th, simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   383
    next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   384
      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
   385
    qed
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   386
    thus ?thesis by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   387
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   388
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   389
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   390
lemma cp_kept_1:
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   391
  assumes "th1 \<noteq> th"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   392
  shows "cp s th1 = cp s' th1"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   393
    by (unfold cp_alt_def preced_kept subtree_kept[OF assms], simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   394
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   395
lemma subtree_cs: "subtree (RAG s') (Cs cs) = {Cs cs}"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   396
proof -
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   397
  { fix n
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   398
    have "(Cs cs) \<notin> ancestors (RAG s') n"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   399
    proof
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   400
      assume "Cs cs \<in> ancestors (RAG s') n"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   401
      hence "(n, Cs cs) \<in> (RAG s')^+" by (auto simp:ancestors_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   402
      from tranclE[OF this] obtain nn where h: "(nn, Cs cs) \<in> RAG s'" by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   403
      then obtain th' where "nn = Th th'"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   404
        by (unfold s_RAG_def, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   405
      from h[unfolded this] have "(Th th', Cs cs) \<in> RAG s'" .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   406
      from this[unfolded s_RAG_def]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   407
      have "waiting (wq s') th' cs" by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   408
      from this[unfolded cs_waiting_def]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   409
      have "1 < length (wq s' cs)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   410
          by (cases "wq s' cs", auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   411
      from holding_next_thI[OF holding_th this]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   412
      obtain th' where "next_th s' th cs th'" by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   413
      with nnt show False by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   414
    qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   415
  } note h = this
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   416
  {  fix n
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   417
     assume "n \<in> subtree (RAG s') (Cs cs)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   418
     hence "n = (Cs cs)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   419
     by (elim subtreeE, insert h, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   420
  } moreover have "(Cs cs) \<in> subtree (RAG s') (Cs cs)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   421
      by (auto simp:subtree_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   422
  ultimately show ?thesis by auto 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   423
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   424
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   425
lemma subtree_th: 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   426
  "subtree (RAG s) (Th th) = subtree (RAG s') (Th th) - {Cs cs}"
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
   427
proof(unfold RAG_s, fold subtree_cs, rule vat_s'.rtree_RAG.subtree_del_inside)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   428
  from edge_of_th
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   429
  show "(Cs cs, Th th) \<in> edges_in (RAG s') (Th th)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   430
    by (unfold edges_in_def, auto simp:subtree_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   431
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   432
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   433
lemma cp_kept_2: 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   434
  shows "cp s th = cp s' th" 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   435
 by (unfold cp_alt_def subtree_th preced_kept, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   436
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   437
lemma eq_cp:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   438
  shows "cp s th' = cp s' th'"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   439
  using cp_kept_1 cp_kept_2
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   440
  by (cases "th' = th", auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   441
end
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   442
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   443
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   444
locale step_P_cps =
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   445
  fixes s' th cs s 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   446
  defines s_def : "s \<equiv> (P th cs#s')"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   447
  assumes vt_s: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   448
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   449
sublocale step_P_cps < vat_s : valid_trace "s"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   450
proof
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   451
  from vt_s show "vt s" .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   452
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   453
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   454
section {* The @{term P} operation *}
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   455
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   456
sublocale step_P_cps < vat_s' : valid_trace "s'"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   457
proof
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   458
  from step_back_vt[OF vt_s[unfolded s_def]] show "vt s'" .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   459
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   460
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   461
context step_P_cps
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   462
begin
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   463
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   464
lemma readys_th: "th \<in> readys s'"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   465
proof -
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   466
    from step_back_step [OF vt_s[unfolded s_def]]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   467
    have "PIP s' (P th cs)" .
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   468
    hence "th \<in> runing s'" by (cases, simp)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   469
    thus ?thesis by (simp add:readys_def runing_def)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   470
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   471
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   472
lemma root_th: "root (RAG s') (Th th)"
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
   473
  using readys_root[OF readys_th] .
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   474
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   475
lemma in_no_others_subtree:
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   476
  assumes "th' \<noteq> th"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   477
  shows "Th th \<notin> subtree (RAG s') (Th th')"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   478
proof
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   479
  assume "Th th \<in> subtree (RAG s') (Th th')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   480
  thus False
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   481
  proof(cases rule:subtreeE)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   482
    case 1
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   483
    with assms show ?thesis by auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   484
  next
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   485
    case 2
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   486
    with root_th show ?thesis by (auto simp:root_def)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   487
  qed
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   488
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   489
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   490
lemma preced_kept: "the_preced s = the_preced s'"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   491
  by (auto simp: s_def the_preced_def preced_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   492
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   493
end
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   494
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   495
locale step_P_cps_ne =step_P_cps +
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   496
  fixes th'
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   497
  assumes ne: "wq s' cs \<noteq> []"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   498
  defines th'_def: "th' \<equiv> hd (wq s' cs)"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   499
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   500
locale step_P_cps_e =step_P_cps +
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   501
  assumes ee: "wq s' cs = []"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   502
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   503
context step_P_cps_e
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   504
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   505
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
   506
lemma RAG_s: "RAG s = RAG s' \<union> {(Cs cs, Th th)}"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   507
proof -
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
   508
  from ee and  step_RAG_p[OF vt_s[unfolded s_def], folded s_def]
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   509
  show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   510
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   511
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   512
lemma subtree_kept:
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   513
  assumes "th' \<noteq> th"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   514
  shows "subtree (RAG s) (Th th') = subtree (RAG s') (Th th')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   515
proof(unfold RAG_s, rule subtree_insert_next)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   516
  from in_no_others_subtree[OF assms] 
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   517
  show "Th th \<notin> subtree (RAG s') (Th th')" .
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   518
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   519
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   520
lemma cp_kept: 
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   521
  assumes "th' \<noteq> th"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   522
  shows "cp s th' = cp s' th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   523
proof -
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   524
  have "(the_preced s ` {th'a. Th th'a \<in> subtree (RAG s) (Th th')}) =
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   525
        (the_preced s' ` {th'a. Th th'a \<in> subtree (RAG s') (Th th')})"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   526
        by (unfold preced_kept subtree_kept[OF assms], simp)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   527
  thus ?thesis by (unfold cp_alt_def, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   528
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   529
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   530
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   531
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   532
context step_P_cps_ne 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   533
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   534
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
   535
lemma RAG_s: "RAG s = RAG s' \<union> {(Th th, Cs cs)}"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   536
proof -
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
   537
  from step_RAG_p[OF vt_s[unfolded s_def]] and ne
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   538
  show ?thesis by (simp add:s_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   539
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   540
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   541
lemma cs_held: "(Cs cs, Th th') \<in> RAG s'"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   542
proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   543
  have "(Cs cs, Th th') \<in> hRAG s'"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   544
  proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   545
    from ne
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   546
    have " holding s' th' cs"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   547
      by (unfold th'_def holding_eq cs_holding_def, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   548
    thus ?thesis 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   549
      by (unfold hRAG_def, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   550
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   551
  thus ?thesis by (unfold RAG_split, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   552
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   553
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   554
lemma tRAG_s: 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   555
  "tRAG s = tRAG s' \<union> {(Th th, Th th')}"
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   556
  using RAG_tRAG_transfer[OF RAG_s cs_held] .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   557
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   558
lemma cp_kept:
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   559
  assumes "Th th'' \<notin> ancestors (tRAG s) (Th th)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   560
  shows "cp s th'' = cp s' th''"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   561
proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   562
  have h: "subtree (tRAG s) (Th th'') = subtree (tRAG s') (Th th'')"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   563
  proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   564
    have "Th th' \<notin> subtree (tRAG s') (Th th'')"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   565
    proof
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   566
      assume "Th th' \<in> subtree (tRAG s') (Th th'')"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   567
      thus False
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   568
      proof(rule subtreeE)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   569
         assume "Th th' = Th th''"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   570
         from assms[unfolded tRAG_s ancestors_def, folded this]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   571
         show ?thesis by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   572
      next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   573
         assume "Th th'' \<in> ancestors (tRAG s') (Th th')"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   574
         moreover have "... \<subseteq> ancestors (tRAG s) (Th th')"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   575
         proof(rule ancestors_mono)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   576
            show "tRAG s' \<subseteq> tRAG s" by (unfold tRAG_s, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   577
         qed 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   578
         ultimately have "Th th'' \<in> ancestors (tRAG s) (Th th')" by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   579
         moreover have "Th th' \<in> ancestors (tRAG s) (Th th)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   580
           by (unfold tRAG_s, auto simp:ancestors_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   581
         ultimately have "Th th'' \<in> ancestors (tRAG s) (Th th)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   582
                       by (auto simp:ancestors_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   583
         with assms show ?thesis by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   584
      qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   585
    qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   586
    from subtree_insert_next[OF this]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   587
    have "subtree (tRAG s' \<union> {(Th th, Th th')}) (Th th'') = subtree (tRAG s') (Th th'')" .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   588
    from this[folded tRAG_s] show ?thesis .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   589
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   590
  show ?thesis by (unfold cp_alt_def1 h preced_kept, simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   591
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   592
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   593
lemma cp_gen_update_stop: (* ddd *)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   594
  assumes "u \<in> ancestors (tRAG s) (Th th)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   595
  and "cp_gen s u = cp_gen s' u"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   596
  and "y \<in> ancestors (tRAG s) u"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   597
  shows "cp_gen s y = cp_gen s' y"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   598
  using assms(3)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   599
proof(induct rule:wf_induct[OF vat_s.fsbttRAGs.wf])
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   600
  case (1 x)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   601
  show ?case (is "?L = ?R")
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   602
  proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   603
    from tRAG_ancestorsE[OF 1(2)]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   604
    obtain th2 where eq_x: "x = Th th2" by blast
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   605
    from vat_s.cp_gen_rec[OF this]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   606
    have "?L = 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   607
          Max ({the_preced s th2} \<union> cp_gen s ` RTree.children (tRAG s) x)" .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   608
    also have "... = 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   609
          Max ({the_preced s' th2} \<union> cp_gen s' ` RTree.children (tRAG s') x)"
59
0a069a667301 removed some fixes about which Isabelle complains
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 58
diff changeset
   610
  
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   611
    proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   612
      from preced_kept have "the_preced s th2 = the_preced s' th2" by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   613
      moreover have "cp_gen s ` RTree.children (tRAG s) x =
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   614
                     cp_gen s' ` RTree.children (tRAG s') x"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   615
      proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   616
        have "RTree.children (tRAG s) x =  RTree.children (tRAG s') x"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   617
        proof(unfold tRAG_s, rule children_union_kept)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   618
          have start: "(Th th, Th th') \<in> tRAG s"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   619
            by (unfold tRAG_s, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   620
          note x_u = 1(2)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   621
          show "x \<notin> Range {(Th th, Th th')}"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   622
          proof
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   623
            assume "x \<in> Range {(Th th, Th th')}"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   624
            hence eq_x: "x = Th th'" using RangeE by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   625
            show False
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   626
            proof(cases rule:vat_s.rtree_s.ancestors_headE[OF assms(1) start])
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   627
              case 1
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   628
              from x_u[folded this, unfolded eq_x] vat_s.acyclic_tRAG
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   629
              show ?thesis by (auto simp:ancestors_def acyclic_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   630
            next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   631
              case 2
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   632
              with x_u[unfolded eq_x]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   633
              have "(Th th', Th th') \<in> (tRAG s)^+" by (auto simp:ancestors_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   634
              with vat_s.acyclic_tRAG show ?thesis by (auto simp:acyclic_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   635
            qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   636
          qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   637
        qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   638
        moreover have "cp_gen s ` RTree.children (tRAG s) x =
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   639
                       cp_gen s' ` RTree.children (tRAG s) x" (is "?f ` ?A = ?g ` ?A")
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   640
        proof(rule f_image_eq)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   641
          fix a
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   642
          assume a_in: "a \<in> ?A"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   643
          from 1(2)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   644
          show "?f a = ?g a"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   645
          proof(cases rule:vat_s.rtree_s.ancestors_childrenE[case_names in_ch out_ch])
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   646
             case in_ch
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   647
             show ?thesis
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   648
             proof(cases "a = u")
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   649
                case True
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   650
                from assms(2)[folded this] show ?thesis .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   651
             next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   652
                case False
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   653
                have a_not_in: "a \<notin> ancestors (tRAG s) (Th th)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   654
                proof
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   655
                  assume a_in': "a \<in> ancestors (tRAG s) (Th th)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   656
                  have "a = u"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   657
                  proof(rule vat_s.rtree_s.ancestors_children_unique)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   658
                    from a_in' a_in show "a \<in> ancestors (tRAG s) (Th th) \<inter> 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   659
                                          RTree.children (tRAG s) x" by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   660
                  next 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   661
                    from assms(1) in_ch show "u \<in> ancestors (tRAG s) (Th th) \<inter> 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   662
                                      RTree.children (tRAG s) x" by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   663
                  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   664
                  with False show False by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   665
                qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   666
                from a_in obtain th_a where eq_a: "a = Th th_a" 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   667
                    by (unfold RTree.children_def tRAG_alt_def, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   668
                from cp_kept[OF a_not_in[unfolded eq_a]]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   669
                have "cp s th_a = cp s' th_a" .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   670
                from this [unfolded cp_gen_def_cond[OF eq_a], folded eq_a]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   671
                show ?thesis .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   672
             qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   673
          next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   674
            case (out_ch z)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   675
            hence h: "z \<in> ancestors (tRAG s) u" "z \<in> RTree.children (tRAG s) x" by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   676
            show ?thesis
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   677
            proof(cases "a = z")
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   678
              case True
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   679
              from h(2) have zx_in: "(z, x) \<in> (tRAG s)" by (auto simp:RTree.children_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   680
              from 1(1)[rule_format, OF this h(1)]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   681
              have eq_cp_gen: "cp_gen s z = cp_gen s' z" .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   682
              with True show ?thesis by metis
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   683
            next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   684
              case False
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   685
              from a_in obtain th_a where eq_a: "a = Th th_a"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   686
                by (auto simp:RTree.children_def tRAG_alt_def)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   687
              have "a \<notin> ancestors (tRAG s) (Th th)"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   688
              proof
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   689
                assume a_in': "a \<in> ancestors (tRAG s) (Th th)"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   690
                have "a = z"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   691
                proof(rule vat_s.rtree_s.ancestors_children_unique)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   692
                  from assms(1) h(1) have "z \<in> ancestors (tRAG s) (Th th)"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   693
                      by (auto simp:ancestors_def)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   694
                  with h(2) show " z \<in> ancestors (tRAG s) (Th th) \<inter> 
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   695
                                       RTree.children (tRAG s) x" by auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   696
                next
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   697
                  from a_in a_in'
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   698
                  show "a \<in> ancestors (tRAG s) (Th th) \<inter> RTree.children (tRAG s) x"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   699
                    by auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   700
                qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   701
                with False show False by auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   702
              qed
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   703
              from cp_kept[OF this[unfolded eq_a]]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   704
              have "cp s th_a = cp s' th_a" .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   705
              from this[unfolded cp_gen_def_cond[OF eq_a], folded eq_a]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   706
              show ?thesis .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   707
            qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   708
          qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   709
        qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   710
        ultimately show ?thesis by metis
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   711
      qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   712
      ultimately show ?thesis by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   713
    qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   714
    also have "... = ?R"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   715
      by (fold vat_s'.cp_gen_rec[OF eq_x], simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   716
    finally show ?thesis .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   717
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   718
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   719
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   720
lemma cp_up:
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   721
  assumes "(Th th') \<in> ancestors (tRAG s) (Th th)"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   722
  and "cp s th' = cp s' th'"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   723
  and "(Th th'') \<in> ancestors (tRAG s) (Th th')"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   724
  shows "cp s th'' = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   725
proof -
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   726
  have "cp_gen s (Th th'') = cp_gen s' (Th th'')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   727
  proof(rule cp_gen_update_stop[OF assms(1) _ assms(3)])
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   728
    from assms(2) cp_gen_def_cond[OF refl[of "Th th'"]]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   729
    show "cp_gen s (Th th') = cp_gen s' (Th th')" by metis
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   730
  qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   731
  with cp_gen_def_cond[OF refl[of "Th th''"]]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   732
  show ?thesis by metis
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   733
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   734
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   735
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   736
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   737
section {* The @{term Create} operation *}
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   738
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   739
locale step_create_cps =
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   740
  fixes s' th prio s 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   741
  defines s_def : "s \<equiv> (Create th prio#s')"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   742
  assumes vt_s: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   743
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   744
sublocale step_create_cps < vat_s: valid_trace "s"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   745
  by (unfold_locales, insert vt_s, simp)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   746
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   747
sublocale step_create_cps < vat_s': valid_trace "s'"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   748
  by (unfold_locales, insert step_back_vt[OF vt_s[unfolded s_def]], simp)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   749
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   750
context step_create_cps
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   751
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   752
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   753
lemma RAG_kept: "RAG s = RAG s'"
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
   754
  by (unfold s_def RAG_create_unchanged, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   755
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   756
lemma tRAG_kept: "tRAG s = tRAG s'"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   757
  by (unfold tRAG_alt_def RAG_kept, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   758
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   759
lemma preced_kept:
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   760
  assumes "th' \<noteq> th"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   761
  shows "the_preced s th' = the_preced s' th'"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   762
  by (unfold s_def the_preced_def preced_def, insert assms, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   763
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   764
lemma th_not_in: "Th th \<notin> Field (tRAG s')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   765
proof -
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   766
  from vt_s[unfolded s_def]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   767
  have "PIP s' (Create th prio)" by (cases, simp)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   768
  hence "th \<notin> threads s'" by(cases, simp)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   769
  from vat_s'.not_in_thread_isolated[OF this]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   770
  have "Th th \<notin> Field (RAG s')" .
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   771
  with tRAG_Field show ?thesis by auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   772
qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   773
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   774
lemma eq_cp:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   775
  assumes neq_th: "th' \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   776
  shows "cp s th' = cp s' th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   777
proof -
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   778
  have "(the_preced s \<circ> the_thread) ` subtree (tRAG s) (Th th') =
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   779
        (the_preced s' \<circ> the_thread) ` subtree (tRAG s') (Th th')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   780
  proof(unfold tRAG_kept, rule f_image_eq)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   781
    fix a
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   782
    assume a_in: "a \<in> subtree (tRAG s') (Th th')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   783
    then obtain th_a where eq_a: "a = Th th_a" 
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   784
    proof(cases rule:subtreeE)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   785
      case 2
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   786
      from ancestors_Field[OF 2(2)]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   787
      and that show ?thesis by (unfold tRAG_alt_def, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   788
    qed auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   789
    have neq_th_a: "th_a \<noteq> th"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   790
    proof -
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   791
      have "(Th th) \<notin> subtree (tRAG s') (Th th')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   792
      proof
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   793
        assume "Th th \<in> subtree (tRAG s') (Th th')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   794
        thus False
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   795
        proof(cases rule:subtreeE)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   796
          case 2
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   797
          from ancestors_Field[OF this(2)]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   798
          and th_not_in[unfolded Field_def]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   799
          show ?thesis by auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   800
        qed (insert assms, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   801
      qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   802
      with a_in[unfolded eq_a] show ?thesis by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   803
    qed
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   804
    from preced_kept[OF this]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   805
    show "(the_preced s \<circ> the_thread) a = (the_preced s' \<circ> the_thread) a"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   806
      by (unfold eq_a, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   807
  qed
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   808
  thus ?thesis by (unfold cp_alt_def1, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   809
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   810
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   811
lemma children_of_th: "RTree.children (tRAG s) (Th th) = {}"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   812
proof -
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   813
  { fix a
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   814
    assume "a \<in> RTree.children (tRAG s) (Th th)"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   815
    hence "(a, Th th) \<in> tRAG s" by (auto simp:RTree.children_def)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   816
    with th_not_in have False 
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   817
     by (unfold Field_def tRAG_kept, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   818
  } thus ?thesis by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   819
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   820
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   821
lemma eq_cp_th: "cp s th = preced th s"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   822
 by (unfold vat_s.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
   823
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   824
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   825
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   826
locale step_exit_cps =
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   827
  fixes s' th prio s 
33
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   828
  defines s_def : "s \<equiv> Exit th # s'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   829
  assumes vt_s: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   830
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   831
sublocale step_exit_cps < vat_s: valid_trace "s"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   832
  by (unfold_locales, insert vt_s, simp)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   833
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   834
sublocale step_exit_cps < vat_s': valid_trace "s'"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   835
  by (unfold_locales, insert step_back_vt[OF vt_s[unfolded s_def]], simp)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   836
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   837
context step_exit_cps
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   838
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   839
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   840
lemma preced_kept:
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   841
  assumes "th' \<noteq> th"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   842
  shows "the_preced s th' = the_preced s' th'"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   843
  by (unfold s_def the_preced_def preced_def, insert assms, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   844
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   845
lemma RAG_kept: "RAG s = RAG s'"
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
   846
  by (unfold s_def RAG_exit_unchanged, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   847
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   848
lemma tRAG_kept: "tRAG s = tRAG s'"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   849
  by (unfold tRAG_alt_def RAG_kept, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   850
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   851
lemma th_ready: "th \<in> readys s'"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   852
proof -
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   853
  from vt_s[unfolded s_def]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   854
  have "PIP s' (Exit th)" by (cases, simp)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   855
  hence h: "th \<in> runing s' \<and> holdents s' th = {}" by (cases, metis)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   856
  thus ?thesis by (unfold runing_def, auto)
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
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   859
lemma th_holdents: "holdents s' th = {}"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   860
proof -
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   861
 from vt_s[unfolded s_def]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   862
  have "PIP s' (Exit th)" by (cases, simp)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   863
  thus ?thesis by (cases, metis)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   864
qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   865
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   866
lemma th_RAG: "Th th \<notin> Field (RAG s')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   867
proof -
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   868
  have "Th th \<notin> Range (RAG s')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   869
  proof
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   870
    assume "Th th \<in> Range (RAG s')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   871
    then obtain cs where "holding (wq s') th cs"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   872
      by (unfold Range_iff s_RAG_def, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   873
    with th_holdents[unfolded holdents_def]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   874
    show False by (unfold eq_holding, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   875
  qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   876
  moreover have "Th th \<notin> Domain (RAG s')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   877
  proof
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   878
    assume "Th th \<in> Domain (RAG s')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   879
    then obtain cs where "waiting (wq s') th cs"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   880
      by (unfold Domain_iff s_RAG_def, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   881
    with th_ready show False by (unfold readys_def eq_waiting, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   882
  qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   883
  ultimately show ?thesis by (auto simp:Field_def)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   884
qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   885
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   886
lemma th_tRAG: "(Th th) \<notin> Field (tRAG s')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   887
  using th_RAG tRAG_Field[of s'] by auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   888
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   889
lemma eq_cp:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   890
  assumes neq_th: "th' \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   891
  shows "cp s th' = cp s' th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   892
proof -
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   893
  have "(the_preced s \<circ> the_thread) ` subtree (tRAG s) (Th th') =
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   894
        (the_preced s' \<circ> the_thread) ` subtree (tRAG s') (Th th')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   895
  proof(unfold tRAG_kept, rule f_image_eq)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   896
    fix a
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   897
    assume a_in: "a \<in> subtree (tRAG s') (Th th')"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   898
    then obtain th_a where eq_a: "a = Th th_a" 
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   899
    proof(cases rule:subtreeE)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   900
      case 2
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   901
      from ancestors_Field[OF 2(2)]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   902
      and that show ?thesis by (unfold tRAG_alt_def, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   903
    qed auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   904
    have neq_th_a: "th_a \<noteq> th"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   905
    proof -
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
   906
      from vat_s'.readys_in_no_subtree[OF th_ready assms]
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   907
      have "(Th th) \<notin> subtree (RAG s') (Th th')" .
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   908
      with tRAG_subtree_RAG[of s' "Th th'"]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   909
      have "(Th th) \<notin> subtree (tRAG s') (Th th')" by auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   910
      with a_in[unfolded eq_a] show ?thesis by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   911
    qed
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   912
    from preced_kept[OF this]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   913
    show "(the_preced s \<circ> the_thread) a = (the_preced s' \<circ> the_thread) a"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   914
      by (unfold eq_a, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   915
  qed
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   916
  thus ?thesis by (unfold cp_alt_def1, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   917
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   918
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   919
end
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   920
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   921
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   922