Implementation.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Tue, 07 Jun 2016 13:51:39 +0100
changeset 126 a88af0e4731f
parent 122 420e03a2d9cc
child 127 38c6acf03f68
permissions -rw-r--r--
minor update
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
107
30ed212f268a updated Correctness, Implementation and PIPBasics so that they work with Isabelle 2014 and 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
     1
theory Implementation
30ed212f268a updated Correctness, Implementation and PIPBasics so that they work with Isabelle 2014 and 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
     2
imports PIPBasics
30ed212f268a updated Correctness, Implementation and PIPBasics so that they work with Isabelle 2014 and 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
     3
begin
30ed212f268a updated Correctness, Implementation and PIPBasics so that they work with Isabelle 2014 and 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
     4
117
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
     5
section {*
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
     6
  This file contains lemmas used to guide the recalculation of current precedence 
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
     7
  after every step of execution (or system operation, or event), 
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
     8
  which is the most tricky part in the implementation of PIP.
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
     9
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
    10
  Following convention, lemmas are grouped into locales corresponding to 
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
    11
  system operations, each explained in a separate section.
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
    12
*}
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
    13
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
    14
text {*
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
    15
  The following two lemmas are general about any valid system state, 
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
    16
  but are used in the derivation in more specific system operations. 
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
    17
*}
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    18
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    19
context valid_trace
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    20
begin
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    21
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    22
lemma readys_root:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    23
  assumes "th \<in> readys s"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    24
  shows "root (RAG s) (Th th)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    25
proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    26
  { fix x
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    27
    assume "x \<in> ancestors (RAG s) (Th th)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    28
    hence h: "(Th th, x) \<in> (RAG s)^+" by (auto simp:ancestors_def)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    29
    from tranclD[OF this]
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    30
    obtain z where "(Th th, z) \<in> RAG s" by auto
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    31
    with assms(1) have False
122
420e03a2d9cc all updated to Isabelle 2016
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 117
diff changeset
    32
         apply (case_tac z, auto simp:readys_def s_RAG_def s_waiting_def cs_waiting_raw)
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    33
         by (fold wq_def, blast)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    34
  } thus ?thesis by (unfold root_def, auto)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    35
qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    36
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    37
lemma readys_in_no_subtree:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    38
  assumes "th \<in> readys s"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    39
  and "th' \<noteq> th"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    40
  shows "Th th \<notin> subtree (RAG s) (Th th')" 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    41
proof
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    42
   assume "Th th \<in> subtree (RAG s) (Th th')"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    43
   thus False
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    44
   proof(cases rule:subtreeE)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    45
      case 1
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    46
      with assms show ?thesis by auto
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    47
   next
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    48
      case 2
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    49
      with readys_root[OF assms(1)]
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    50
      show ?thesis by (auto simp:root_def)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    51
   qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    52
qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    53
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    54
end
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
    55
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    56
section {* The @{term Set} operation *}
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    57
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
    58
context valid_trace_set
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    60
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    61
text {* (* ddd *)
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    62
  The following two lemmas confirm that @{text "Set"}-operation
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    63
  only changes the precedence of the initiating thread (or actor)
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    64
  of the operation (or event).
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    65
*}
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    66
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
    67
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
lemma eq_preced:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    69
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
    70
  shows "preced th' (e#s) = preced th' s"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    71
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    72
  from assms show ?thesis 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
    73
    by (unfold is_set, auto simp:preced_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    74
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    75
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    76
lemma eq_the_preced: 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    77
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
    78
  shows "the_preced (e#s) th' = the_preced s th'"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    79
  using assms
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    80
  by (unfold the_preced_def, intro eq_preced, simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    81
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    82
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    83
text {* (* ddd *)
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    84
  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
    85
  only affects those threads, which as @{text "Th th"} in their sub-trees.
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    86
  
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    87
  The proof of this lemma is simplified by using the alternative definition 
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
    88
  of @{text "cp"}. 
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    89
*}
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
    90
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    91
lemma eq_cp_pre:
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
    92
  assumes nd: "Th th \<notin> subtree (RAG s) (Th th')"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
    93
  shows "cp (e#s) th' = cp s th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    94
proof -
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    95
  -- {* After unfolding using the alternative definition, elements 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    96
        affecting the @{term "cp"}-value of threads become explicit. 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
    97
        We only need to prove the following: *}
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
    98
  have "Max (the_preced (e#s) ` {th'a. Th th'a \<in> subtree (RAG (e#s)) (Th th')}) =
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
    99
        Max (the_preced s ` {th'a. Th th'a \<in> subtree (RAG s) (Th th')})"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   100
        (is "Max (?f ` ?S1) = Max (?g ` ?S2)")
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   101
  proof -
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   102
    -- {* The base sets are equal. *}
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   103
    have "?S1 = ?S2" using RAG_es by simp
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   104
    -- {* The function values on the base set are equal as well. *}
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   105
    moreover have "\<forall> e \<in> ?S2. ?f e = ?g e"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   106
    proof
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   107
      fix th1
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   108
      assume "th1 \<in> ?S2"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   109
      with nd have "th1 \<noteq> th" by (auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   110
      from eq_the_preced[OF this]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   111
      show "the_preced (e#s) th1 = the_preced s th1" .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   112
    qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   113
    -- {* Therefore, the image of the functions are equal. *}
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   114
    ultimately have "(?f ` ?S1) = (?g ` ?S2)" by (auto intro!:f_image_eq)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   115
    thus ?thesis by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   116
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   117
  thus ?thesis by (simp add:cp_alt_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   118
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   119
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   120
text {*
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   121
  The following lemma shows that @{term "th"} is not in the 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   122
  sub-tree of any other thread. 
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   123
*}
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   124
lemma th_in_no_subtree:
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   125
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   126
  shows "Th th \<notin> subtree (RAG s) (Th th')"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   127
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   128
  from readys_in_no_subtree[OF th_ready_s assms(1)]
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   129
  show ?thesis by blast
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   130
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   131
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   132
text {* 
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   133
  By combining @{thm "eq_cp_pre"} and @{thm "th_in_no_subtree"}, 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   134
  it is obvious that the change of priority only affects the @{text "cp"}-value 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   135
  of the initiating thread @{text "th"}.
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   136
*}
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   137
lemma eq_cp:
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   138
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   139
  shows "cp (e#s) th' = cp s th'"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   140
  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
   141
56
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   142
end
55
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   143
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   144
section {* The @{term V} operation *}
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   145
56
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   146
text {*
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   147
  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
   148
*}
b85cfbd58f59 Comments for Set-operation finished
xingyuan zhang <xingyuanzhang@126.com>
parents: 53
diff changeset
   149
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   150
context valid_trace_v
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
   151
begin
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   152
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   153
lemma ancestors_th: "ancestors (RAG s) (Th th) = {}"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   154
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   155
  from readys_root[OF th_ready_s]
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   156
  show ?thesis
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   157
  by (unfold root_def, simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   158
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   159
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   160
lemma edge_of_th:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   161
    "(Cs cs, Th th) \<in> RAG s" 
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   162
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   163
 from holding_th_cs_s
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   164
 show ?thesis 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   165
    by (unfold s_RAG_def holding_eq, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   166
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   167
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   168
lemma ancestors_cs: 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   169
  "ancestors (RAG s) (Cs cs) = {Th th}"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   170
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   171
  have "ancestors (RAG s) (Cs cs) = ancestors (RAG s) (Th th)  \<union>  {Th th}"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   172
   by (rule rtree_RAG.ancestors_accum[OF edge_of_th])
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   173
  from this[unfolded ancestors_th] show ?thesis by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   174
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   175
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   176
end
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   177
56
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   178
text {*
0fd478e14e87 Before switching to generic theory of relational trees.
xingyuan zhang <xingyuanzhang@126.com>
parents: 55
diff changeset
   179
  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
   180
  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
   181
  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
   182
*}
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   183
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   184
lemma (in valid_trace_v)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   185
  the_preced_es: "the_preced (e#s) = the_preced s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   186
proof
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   187
  fix th'
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   188
  show "the_preced (e # s) th' = the_preced s th'"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   189
    by (unfold the_preced_def preced_def is_v, simp)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   190
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   191
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   192
context valid_trace_v_n
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   193
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   194
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   195
lemma sub_RAGs': 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   196
  "{(Cs cs, Th th), (Th taker, Cs cs)} \<subseteq> RAG s"
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
   197
  using waiting_taker holding_th_cs_s
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
   198
  by (unfold s_RAG_def, fold waiting_eq holding_eq, auto)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   199
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   200
lemma ancestors_th': 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   201
  "ancestors (RAG s) (Th taker) = {Th th, Cs cs}" 
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   202
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   203
  have "ancestors (RAG s) (Th taker) = ancestors (RAG s) (Cs cs) \<union> {Cs cs}"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   204
  proof(rule  rtree_RAG.ancestors_accum)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   205
    from sub_RAGs' show "(Th taker, Cs cs) \<in> RAG s" by auto
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   206
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   207
  thus ?thesis using ancestors_th ancestors_cs by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   208
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   209
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
   210
lemma RAG_s:
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   211
  "RAG (e#s) = (RAG s - {(Cs cs, Th th), (Th taker, Cs cs)}) \<union>
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   212
                                         {(Cs cs, Th taker)}"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   213
 by (unfold RAG_es waiting_set_eq holding_set_eq, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   214
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   215
lemma subtree_kept: (* ddd *)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   216
  assumes "th1 \<notin> {th, taker}"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   217
  shows "subtree (RAG (e#s)) (Th th1) = 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   218
                     subtree (RAG s) (Th th1)" (is "_ = ?R")
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   219
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   220
  let ?RAG' = "(RAG s - {(Cs cs, Th th), (Th taker, Cs cs)})"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   221
  let ?RAG'' = "?RAG' \<union> {(Cs cs, Th taker)}"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   222
  have "subtree ?RAG' (Th th1) = ?R" 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   223
  proof(rule subset_del_subtree_outside)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   224
    show "Range {(Cs cs, Th th), (Th taker, Cs cs)} \<inter> subtree (RAG s) (Th th1) = {}"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   225
    proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   226
      have "(Th th) \<notin> subtree (RAG s) (Th th1)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   227
      proof(rule subtree_refute)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   228
        show "Th th1 \<notin> ancestors (RAG s) (Th th)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   229
          by (unfold ancestors_th, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   230
      next
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   231
        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
   232
      qed
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   233
      moreover have "(Cs cs) \<notin>  subtree (RAG s) (Th th1)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   234
      proof(rule subtree_refute)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   235
        show "Th th1 \<notin> ancestors (RAG s) (Cs cs)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   236
          by (unfold ancestors_cs, insert assms, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   237
      qed simp
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   238
      ultimately have "{Th th, Cs cs} \<inter> subtree (RAG s) (Th th1) = {}" by auto
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   239
      thus ?thesis by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   240
     qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   241
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   242
  moreover have "subtree ?RAG'' (Th th1) =  subtree ?RAG' (Th th1)"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   243
  proof(rule subtree_insert_next)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   244
    show "Th taker \<notin> subtree (RAG s - {(Cs cs, Th th), (Th taker, Cs cs)}) (Th th1)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   245
    proof(rule subtree_refute)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   246
      show "Th th1 \<notin> ancestors (RAG s - {(Cs cs, Th th), (Th taker, Cs cs)}) (Th taker)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   247
            (is "_ \<notin> ?R")
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   248
      proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   249
          have "?R \<subseteq> ancestors (RAG s) (Th taker)" by (rule ancestors_mono, auto)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   250
          moreover have "Th th1 \<notin> ..." using ancestors_th' assms by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   251
          ultimately show ?thesis by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   252
      qed
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   253
    next
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   254
      from assms show "Th th1 \<noteq> Th taker" by simp
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   255
    qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   256
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   257
  ultimately show ?thesis by (unfold RAG_s, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   258
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   259
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   260
lemma cp_kept:
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   261
  assumes "th1 \<notin> {th, taker}"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   262
  shows "cp (e#s) th1 = cp s th1"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   263
    by (unfold cp_alt_def the_preced_es subtree_kept[OF assms], simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   264
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   265
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   266
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   267
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   268
context valid_trace_v_e
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   269
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   270
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   271
lemma RAG_s: "RAG (e#s) = RAG s - {(Cs cs, Th th)}"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   272
  by (unfold RAG_es waiting_set_eq holding_set_eq, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   273
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   274
lemma subtree_kept:
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   275
  assumes "th1 \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   276
  shows "subtree (RAG (e#s)) (Th th1) = subtree (RAG s) (Th th1)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   277
proof(unfold RAG_s, rule subset_del_subtree_outside)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   278
  show "Range {(Cs cs, Th th)} \<inter> subtree (RAG s) (Th th1) = {}"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   279
  proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   280
    have "(Th th) \<notin> subtree (RAG s) (Th th1)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   281
    proof(rule subtree_refute)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   282
      show "Th th1 \<notin> ancestors (RAG s) (Th th)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   283
          by (unfold ancestors_th, simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   284
    next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   285
      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
   286
    qed
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   287
    thus ?thesis by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   288
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   289
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   290
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   291
lemma cp_kept_1:
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   292
  assumes "th1 \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   293
  shows "cp (e#s) th1 = cp s th1"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   294
    by (unfold cp_alt_def the_preced_es subtree_kept[OF assms], simp)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   295
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   296
lemma subtree_cs: "subtree (RAG s) (Cs cs) = {Cs cs}"
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   297
  (is "?L = ?R")
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   298
proof -
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   299
  { fix n
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   300
    assume "n \<in> ?L"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   301
    hence "n \<in> ?R"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   302
    proof(cases rule:subtreeE)
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   303
      case 2
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   304
      from this(2) have "(n, Cs cs) \<in> (RAG s)^+"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   305
        by (auto simp:ancestors_def)
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   306
      from tranclD2[OF this]
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   307
      obtain th' where "waiting s th' cs"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   308
        by (auto simp:s_RAG_def waiting_eq)
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   309
      with no_waiter_before 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   310
      show ?thesis by simp
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   311
    qed simp
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   312
  } moreover {
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   313
    fix n
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   314
    assume "n \<in> ?R"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   315
    hence "n \<in> ?L" by (auto simp:subtree_def)
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   316
  } ultimately show ?thesis by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   317
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   318
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   319
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   320
lemma subtree_th: 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   321
  "subtree (RAG (e#s)) (Th th) = subtree (RAG s) (Th th) - {Cs cs}"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   322
proof(unfold RAG_s, fold subtree_cs, rule rtree_RAG.subtree_del_inside)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   323
  from edge_of_th
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   324
  show "(Cs cs, Th th) \<in> edges_in (RAG s) (Th th)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   325
    by (unfold edges_in_def, auto simp:subtree_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   326
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   327
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   328
lemma cp_kept_2: 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   329
  shows "cp (e#s) th = cp s th" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   330
 by (unfold cp_alt_def subtree_th the_preced_es, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   331
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   332
lemma eq_cp:
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   333
  shows "cp (e#s) th' = cp s th'"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   334
  using cp_kept_1 cp_kept_2
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   335
  by (cases "th' = th", auto)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   336
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   337
end
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   338
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   339
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   340
section {* The @{term P} operation *}
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   341
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   342
context valid_trace_p
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   343
begin
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   344
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   345
lemma root_th: "root (RAG s) (Th th)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   346
  by (simp add: ready_th_s readys_root)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   347
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   348
lemma in_no_others_subtree:
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   349
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   350
  shows "Th th \<notin> subtree (RAG s) (Th th')"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   351
proof
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   352
  assume "Th th \<in> subtree (RAG s) (Th th')"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   353
  thus False
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   354
  proof(cases rule:subtreeE)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   355
    case 1
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   356
    with assms show ?thesis by auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   357
  next
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   358
    case 2
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   359
    with root_th show ?thesis by (auto simp:root_def)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   360
  qed
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   361
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   362
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   363
lemma preced_kept: "the_preced (e#s) = the_preced s"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   364
proof
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   365
  fix th'
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   366
  show "the_preced (e # s) th' = the_preced s th'"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   367
    by (unfold the_preced_def is_p preced_def, simp)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   368
qed
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   369
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   370
end
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   371
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   372
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   373
context valid_trace_p_h
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   374
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   375
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   376
lemma subtree_kept:
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   377
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   378
  shows "subtree (RAG (e#s)) (Th th') = subtree (RAG s) (Th th')"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   379
proof(unfold RAG_es, rule subtree_insert_next)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   380
  from in_no_others_subtree[OF assms] 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   381
  show "Th th \<notin> subtree (RAG s) (Th th')" .
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   382
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   383
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   384
lemma cp_kept: 
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   385
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   386
  shows "cp (e#s) th' = cp s th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   387
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   388
  have "(the_preced (e#s) ` {th'a. Th th'a \<in> subtree (RAG (e#s)) (Th th')}) =
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   389
        (the_preced s ` {th'a. Th th'a \<in> subtree (RAG s) (Th th')})"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   390
        by (unfold preced_kept subtree_kept[OF assms], simp)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   391
  thus ?thesis by (unfold cp_alt_def, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   392
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   393
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   394
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   395
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   396
context valid_trace_p_w
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   397
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   398
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   399
lemma cs_held: "(Cs cs, Th holder) \<in> RAG s"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   400
  using holding_s_holder
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   401
  by (unfold s_RAG_def, fold holding_eq, auto)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   402
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   403
lemma tRAG_s: 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   404
  "tRAG (e#s) = tRAG s \<union> {(Th th, Th holder)}"
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   405
  using RAG_tRAG_transfer[OF RAG_es cs_held] .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   406
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   407
lemma cp_kept:
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   408
  assumes "Th th'' \<notin> ancestors (tRAG (e#s)) (Th th)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   409
  shows "cp (e#s) th'' = cp s th''"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   410
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   411
  have h: "subtree (tRAG (e#s)) (Th th'') = subtree (tRAG s) (Th th'')"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   412
  proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   413
    have "Th holder \<notin> subtree (tRAG s) (Th th'')"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   414
    proof
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   415
      assume "Th holder \<in> subtree (tRAG s) (Th th'')"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   416
      thus False
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   417
      proof(rule subtreeE)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   418
         assume "Th holder = Th th''"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   419
         from assms[unfolded tRAG_s ancestors_def, folded this]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   420
         show ?thesis by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   421
      next
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   422
         assume "Th th'' \<in> ancestors (tRAG s) (Th holder)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   423
         moreover have "... \<subseteq> ancestors (tRAG (e#s)) (Th holder)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   424
         proof(rule ancestors_mono)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   425
            show "tRAG s \<subseteq> tRAG (e#s)" by (unfold tRAG_s, auto)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   426
         qed 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   427
         ultimately have "Th th'' \<in> ancestors (tRAG (e#s)) (Th holder)" by auto
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   428
         moreover have "Th holder \<in> ancestors (tRAG (e#s)) (Th th)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   429
           by (unfold tRAG_s, auto simp:ancestors_def)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   430
         ultimately have "Th th'' \<in> ancestors (tRAG (e#s)) (Th th)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   431
                       by (auto simp:ancestors_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   432
         with assms show ?thesis by auto
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   433
      qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   434
    qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   435
    from subtree_insert_next[OF this]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   436
    have "subtree (tRAG s \<union> {(Th th, Th holder)}) (Th th'') = subtree (tRAG s) (Th th'')" .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   437
    from this[folded tRAG_s] show ?thesis .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   438
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   439
  show ?thesis by (unfold cp_alt_def1 h preced_kept, simp)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   440
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   441
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   442
lemma cp_gen_update_stop: (* ddd *)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   443
  assumes "u \<in> ancestors (tRAG (e#s)) (Th th)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   444
  and "cp_gen (e#s) u = cp_gen s u"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   445
  and "y \<in> ancestors (tRAG (e#s)) u"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   446
  shows "cp_gen (e#s) y = cp_gen s y"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   447
  using assms(3)
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 93
diff changeset
   448
proof(induct rule:wf_induct[OF vat_es.fsbttRAGs.wf])
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   449
  case (1 x)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   450
  show ?case (is "?L = ?R")
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   451
  proof -
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   452
    from tRAG_ancestorsE[OF 1(2)]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   453
    obtain th2 where eq_x: "x = Th th2" by blast
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 93
diff changeset
   454
    from vat_es.cp_gen_rec[OF this]
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   455
    have "?L = 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   456
          Max ({the_preced (e#s) th2} \<union> cp_gen (e#s) ` RTree.children (tRAG (e#s)) x)" .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   457
    also have "... = 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   458
          Max ({the_preced s th2} \<union> cp_gen s ` RTree.children (tRAG s) x)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   459
    proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   460
      from preced_kept have "the_preced (e#s) th2 = the_preced s th2" by simp
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   461
      moreover have "cp_gen (e#s) ` RTree.children (tRAG (e#s)) x =
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   462
                     cp_gen s ` RTree.children (tRAG s) x"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   463
      proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   464
        have "RTree.children (tRAG (e#s)) x =  RTree.children (tRAG s) x"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   465
        proof(unfold tRAG_s, rule children_union_kept)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   466
          have start: "(Th th, Th holder) \<in> tRAG (e#s)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   467
            by (unfold tRAG_s, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   468
          note x_u = 1(2)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   469
          show "x \<notin> Range {(Th th, Th holder)}"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   470
          proof
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   471
            assume "x \<in> Range {(Th th, Th holder)}"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   472
            hence eq_x: "x = Th holder" using RangeE by auto
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   473
            show False
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 93
diff changeset
   474
            proof(cases rule:vat_es.ancestors_headE[OF assms(1) start])
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   475
              case 1
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 93
diff changeset
   476
              from x_u[folded this, unfolded eq_x] vat_es.acyclic_tRAG
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   477
              show ?thesis by (auto simp:ancestors_def acyclic_def)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   478
            next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   479
              case 2
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   480
              with x_u[unfolded eq_x]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   481
              have "(Th holder, Th holder) \<in> (tRAG (e#s))^+" by (auto simp:ancestors_def)
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 93
diff changeset
   482
              with vat_es.acyclic_tRAG show ?thesis by (auto simp:acyclic_def)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   483
            qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   484
          qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   485
        qed
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   486
        moreover have "cp_gen (e#s) ` RTree.children (tRAG (e#s)) x =
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   487
                       cp_gen s ` RTree.children (tRAG (e#s)) x" (is "?f ` ?A = ?g ` ?A")
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   488
        proof(rule f_image_eq)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   489
          fix a
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   490
          assume a_in: "a \<in> ?A"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   491
          from 1(2)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   492
          show "?f a = ?g a"
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 93
diff changeset
   493
          proof(cases rule:vat_es.rtree_s.ancestors_childrenE[case_names in_ch out_ch])
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   494
             case in_ch
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   495
             show ?thesis
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   496
             proof(cases "a = u")
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   497
                case True
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   498
                from assms(2)[folded this] show ?thesis .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   499
             next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   500
                case False
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   501
                have a_not_in: "a \<notin> ancestors (tRAG (e#s)) (Th th)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   502
                proof
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   503
                  assume a_in': "a \<in> ancestors (tRAG (e#s)) (Th th)"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   504
                  have "a = u"
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 93
diff changeset
   505
                  proof(rule vat_es.rtree_s.ancestors_children_unique)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   506
                    from a_in' a_in show "a \<in> ancestors (tRAG (e#s)) (Th th) \<inter> 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   507
                                          RTree.children (tRAG (e#s)) x" by auto
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   508
                  next 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   509
                    from assms(1) in_ch show "u \<in> ancestors (tRAG (e#s)) (Th th) \<inter> 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   510
                                      RTree.children (tRAG (e#s)) x" by auto
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   511
                  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   512
                  with False show False by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   513
                qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   514
                from a_in obtain th_a where eq_a: "a = Th th_a" 
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   515
                    by (unfold RTree.children_def tRAG_alt_def, auto)
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   516
                from cp_kept[OF a_not_in[unfolded eq_a]]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   517
                have "cp (e#s) th_a = cp s th_a" .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   518
                from this [unfolded cp_gen_def_cond[OF eq_a], folded eq_a]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   519
                show ?thesis .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   520
             qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   521
          next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   522
            case (out_ch z)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   523
            hence h: "z \<in> ancestors (tRAG (e#s)) u" "z \<in> RTree.children (tRAG (e#s)) x" by auto
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   524
            show ?thesis
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   525
            proof(cases "a = z")
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   526
              case True
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   527
              from h(2) have zx_in: "(z, x) \<in> (tRAG (e#s))" by (auto simp:RTree.children_def)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   528
              from 1(1)[rule_format, OF this h(1)]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   529
              have eq_cp_gen: "cp_gen (e#s) z = cp_gen s z" .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   530
              with True show ?thesis by metis
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   531
            next
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   532
              case False
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   533
              from a_in obtain th_a where eq_a: "a = Th th_a"
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   534
                by (auto simp:RTree.children_def tRAG_alt_def)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   535
              have "a \<notin> ancestors (tRAG (e#s)) (Th th)"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   536
              proof
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   537
                assume a_in': "a \<in> ancestors (tRAG (e#s)) (Th th)"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   538
                have "a = z"
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 93
diff changeset
   539
                proof(rule vat_es.rtree_s.ancestors_children_unique)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   540
                  from assms(1) h(1) have "z \<in> ancestors (tRAG (e#s)) (Th th)"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   541
                      by (auto simp:ancestors_def)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   542
                  with h(2) show " z \<in> ancestors (tRAG (e#s)) (Th th) \<inter> 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   543
                                       RTree.children (tRAG (e#s)) x" by auto
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   544
                next
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   545
                  from a_in a_in'
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   546
                  show "a \<in> ancestors (tRAG (e#s)) (Th th) \<inter> RTree.children (tRAG (e#s)) x"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   547
                    by auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   548
                qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   549
                with False show False by auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   550
              qed
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   551
              from cp_kept[OF this[unfolded eq_a]]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   552
              have "cp (e#s) th_a = cp s th_a" .
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   553
              from this[unfolded cp_gen_def_cond[OF eq_a], folded eq_a]
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   554
              show ?thesis .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   555
            qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   556
          qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   557
        qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   558
        ultimately show ?thesis by metis
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   559
      qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   560
      ultimately show ?thesis by simp
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   561
    qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   562
    also have "... = ?R"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   563
      by (fold cp_gen_rec[OF eq_x], simp)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   564
    finally show ?thesis .
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   565
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   566
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 56
diff changeset
   567
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   568
lemma cp_up:
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   569
  assumes "(Th th') \<in> ancestors (tRAG (e#s)) (Th th)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   570
  and "cp (e#s) th' = cp s th'"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   571
  and "(Th th'') \<in> ancestors (tRAG (e#s)) (Th th')"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   572
  shows "cp (e#s) th'' = cp s th''"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   573
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   574
  have "cp_gen (e#s) (Th th'') = cp_gen s (Th th'')"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   575
  proof(rule cp_gen_update_stop[OF assms(1) _ assms(3)])
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   576
    from assms(2) cp_gen_def_cond[OF refl[of "Th th'"]]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   577
    show "cp_gen (e#s) (Th th') = cp_gen s (Th th')" by metis
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   578
  qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   579
  with cp_gen_def_cond[OF refl[of "Th th''"]]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   580
  show ?thesis by metis
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   581
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   582
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   583
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   584
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   585
section {* The @{term Create} operation *}
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 65
diff changeset
   586
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   587
context valid_trace_create
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   588
begin 
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   589
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   590
lemma tRAG_kept: "tRAG (e#s) = tRAG s"
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   591
  by (unfold tRAG_alt_def RAG_es, auto)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   592
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   593
lemma preced_kept:
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   594
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   595
  shows "the_preced (e#s) th' = the_preced s th'"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   596
  by (unfold the_preced_def preced_def is_create, insert assms, auto)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   597
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   598
lemma th_not_in: "Th th \<notin> Field (tRAG s)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   599
  by (meson not_in_thread_isolated subsetCE tRAG_Field th_not_live_s)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   600
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   601
lemma eq_cp:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   602
  assumes neq_th: "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   603
  shows "cp (e#s) th' = cp s th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   604
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   605
  have "(the_preced (e#s) \<circ> the_thread) ` subtree (tRAG (e#s)) (Th th') =
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   606
        (the_preced s \<circ> the_thread) ` subtree (tRAG s) (Th th')"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   607
  proof(unfold tRAG_kept, rule f_image_eq)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   608
    fix a
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   609
    assume a_in: "a \<in> subtree (tRAG s) (Th th')"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   610
    then obtain th_a where eq_a: "a = Th th_a" 
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   611
    proof(cases rule:subtreeE)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   612
      case 2
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   613
      from ancestors_Field[OF 2(2)]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   614
      and that show ?thesis by (unfold tRAG_alt_def, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   615
    qed auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   616
    have neq_th_a: "th_a \<noteq> th"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   617
    proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   618
      have "(Th th) \<notin> subtree (tRAG s) (Th th')"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   619
      proof
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   620
        assume "Th th \<in> subtree (tRAG s) (Th th')"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   621
        thus False
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   622
        proof(cases rule:subtreeE)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   623
          case 2
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   624
          from ancestors_Field[OF this(2)]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   625
          and th_not_in[unfolded Field_def]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   626
          show ?thesis by auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   627
        qed (insert assms, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   628
      qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   629
      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
   630
    qed
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   631
    from preced_kept[OF this]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   632
    show "(the_preced (e#s) \<circ> the_thread) a = (the_preced s \<circ> the_thread) a"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   633
      by (unfold eq_a, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   634
  qed
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   635
  thus ?thesis by (unfold cp_alt_def1, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   636
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   637
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   638
lemma children_of_th: "RTree.children (tRAG (e#s)) (Th th) = {}"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   639
proof -
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   640
  { fix a
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   641
    assume "a \<in> RTree.children (tRAG (e#s)) (Th th)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   642
    hence "(a, Th th) \<in> tRAG (e#s)" by (auto simp:RTree.children_def)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   643
    with th_not_in have False 
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   644
     by (unfold Field_def tRAG_kept, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   645
  } thus ?thesis by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   646
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   647
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   648
lemma eq_cp_th: "cp (e#s) th = preced th (e#s)"
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 93
diff changeset
   649
 by (unfold vat_es.cp_rec children_of_th, simp add:the_preced_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   650
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   651
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   652
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   653
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   654
context valid_trace_exit
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   655
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   656
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   657
lemma preced_kept:
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   658
  assumes "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   659
  shows "the_preced (e#s) th' = the_preced s th'"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   660
  using assms
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   661
  by (unfold the_preced_def is_exit preced_def, simp)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   662
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   663
lemma tRAG_kept: "tRAG (e#s) = tRAG s"
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 108
diff changeset
   664
  by (unfold tRAG_alt_def RAG_es, auto)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   665
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   666
lemma th_RAG: "Th th \<notin> Field (RAG s)"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   667
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   668
  have "Th th \<notin> Range (RAG s)"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   669
  proof
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   670
    assume "Th th \<in> Range (RAG s)"
122
420e03a2d9cc all updated to Isabelle 2016
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 117
diff changeset
   671
    then obtain cs where "holding_raw (wq s) th cs"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   672
      by (unfold Range_iff s_RAG_def, auto)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   673
    with holdents_th_s[unfolded holdents_def]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   674
    show False by (unfold holding_eq, auto)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   675
  qed
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   676
  moreover have "Th th \<notin> Domain (RAG s)"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   677
  proof
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   678
    assume "Th th \<in> Domain (RAG s)"
122
420e03a2d9cc all updated to Isabelle 2016
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 117
diff changeset
   679
    then obtain cs where "waiting_raw (wq s) th cs"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   680
      by (unfold Domain_iff s_RAG_def, auto)
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   681
    with th_ready_s show False by (unfold readys_def waiting_eq, auto)
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   682
  qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   683
  ultimately show ?thesis by (auto simp:Field_def)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   684
qed
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   685
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   686
lemma th_tRAG: "(Th th) \<notin> Field (tRAG s)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   687
  using th_RAG tRAG_Field by auto
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   688
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   689
lemma eq_cp:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   690
  assumes neq_th: "th' \<noteq> th"
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   691
  shows "cp (e#s) th' = cp s th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   692
proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   693
  have "(the_preced (e#s) \<circ> the_thread) ` subtree (tRAG (e#s)) (Th th') =
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   694
        (the_preced s \<circ> the_thread) ` subtree (tRAG s) (Th th')"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   695
  proof(unfold tRAG_kept, rule f_image_eq)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   696
    fix a
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   697
    assume a_in: "a \<in> subtree (tRAG s) (Th th')"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   698
    then obtain th_a where eq_a: "a = Th th_a" 
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   699
    proof(cases rule:subtreeE)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   700
      case 2
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   701
      from ancestors_Field[OF 2(2)]
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   702
      and that show ?thesis by (unfold tRAG_alt_def, auto)
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   703
    qed auto
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   704
    have neq_th_a: "th_a \<noteq> th"
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   705
    proof -
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   706
      from readys_in_no_subtree[OF th_ready_s assms]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   707
      have "(Th th) \<notin> subtree (RAG s) (Th th')" .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   708
      with tRAG_subtree_RAG[of s "Th th'"]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   709
      have "(Th th) \<notin> subtree (tRAG s) (Th th')" by auto
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   710
      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
   711
    qed
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   712
    from preced_kept[OF this]
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 68
diff changeset
   713
    show "(the_preced (e#s) \<circ> the_thread) a = (the_preced s \<circ> the_thread) a"
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   714
      by (unfold eq_a, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   715
  qed
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   716
  thus ?thesis by (unfold cp_alt_def1, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   717
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   718
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   719
end
60
f98a95f3deae Main proofs in CpsG.thy completed.
zhangx
parents: 59
diff changeset
   720
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   721
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   722