PIPBasics.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Fri, 09 Dec 2016 12:51:29 +0000
changeset 142 10c16b85a839
parent 141 f70344294e99
child 178 da27bece9575
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
93
524bd3caa6b6 The overwriten original .thy files are working now. The ones in last revision aren't.
zhangx
parents: 92
diff changeset
     1
theory PIPBasics
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
     2
imports PIPDefs RTree
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
117
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
     5
text {* (* ddd *)
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
     6
  
117
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
     7
  Following the HOL convention of {\em definitional extension}, we have
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
     8
  given a concise and miniature model of PIP. To assure ourselves of the
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
     9
  correctness of this model, we are going to derive a series of expected
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
    10
  properties out of it.
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
    11
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
    12
  This file contains the very basic properties, useful for self-assurance,
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
    13
  as well as for deriving more advance properties concerning the correctness
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
    14
  and implementation of PIP. *}
117
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
    15
8a6125caead2 Slight changes in commenting.
zhangx
parents: 116
diff changeset
    16
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
    17
section {* Generic auxiliary lemmas *}
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
    18
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    19
lemma rel_eqI:
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    20
  assumes "\<And> x y. (x,y) \<in> A \<Longrightarrow> (x,y) \<in> B"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    21
  and "\<And> x y. (x,y) \<in> B \<Longrightarrow> (x, y) \<in> A"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    22
  shows "A = B"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    23
  using assms by auto
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    24
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: 90
diff changeset
    25
lemma f_image_eq:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    26
  assumes h: "\<And> a. a \<in> A \<Longrightarrow> f a = g a"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    27
  shows "f ` A = g ` A"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    28
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: 90
diff changeset
    29
  show "f ` A \<subseteq> g ` A"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    30
    by(rule image_subsetI, auto intro:h)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    31
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    32
  show "g ` A \<subseteq> f ` A"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    33
   by (rule image_subsetI, auto intro:h[symmetric])
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    34
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    35
141
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
    36
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: 90
diff changeset
    37
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
    38
section {* Lemmas do not depend on trace validity *}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
    39
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    40
text {* The following lemma serves to proof @{text "preced_tm_lt"} *}
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    41
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: 90
diff changeset
    42
lemma birth_time_lt:  
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    43
  assumes "s \<noteq> []"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    44
  shows "last_set th s < length 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: 90
diff changeset
    45
  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: 90
diff changeset
    46
proof(induct 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: 90
diff changeset
    47
  case (Cons a 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: 90
diff changeset
    48
  show ?case
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    49
  proof(cases "s \<noteq> []")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    50
    case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    51
    thus ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    52
      by (cases a, 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: 90
diff changeset
    53
  next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    54
    case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    55
    show ?thesis using Cons(1)[OF True]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    56
      by (cases a, 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: 90
diff changeset
    57
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    58
qed 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: 90
diff changeset
    59
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    60
text {* The following lemma also serves to proof @{text "preced_tm_lt"} *}
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: 90
diff changeset
    61
lemma th_in_ne: "th \<in> threads s \<Longrightarrow> s \<noteq> []"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    62
  by (induct s, 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: 90
diff changeset
    63
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    64
text {* The following lemma is used in Correctness.thy *}
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: 90
diff changeset
    65
lemma preced_tm_lt: "th \<in> threads s \<Longrightarrow> preced th s = Prc x y \<Longrightarrow> y < length 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: 90
diff changeset
    66
  by (drule_tac th_in_ne, unfold preced_def, auto intro: birth_time_lt)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    67
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    68
text {*
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
    69
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
    70
  The following lemma says that if a resource is waited for, it must be held
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
    71
  by someone else. *}
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
    72
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: 90
diff changeset
    73
lemma waiting_holding:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    74
  assumes "waiting (s::state) th 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: 90
diff changeset
    75
  obtains th' where "holding s th' 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: 90
diff changeset
    76
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: 90
diff changeset
    77
  from assms[unfolded s_waiting_def, folded wq_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: 90
diff changeset
    78
  obtain th' where "th' \<in> set (wq s cs)" "th' = hd (wq s 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: 90
diff changeset
    79
    by (metis empty_iff hd_in_set list.set(1))
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    80
  hence "holding s th' cs" 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
    81
    unfolding s_holding_def by 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: 90
diff changeset
    82
  from that[OF this] show ?thesis .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    83
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    84
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    85
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    86
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    87
  The following @{text "children_RAG_alt_def"} relates
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    88
  @{term children} in @{term RAG} to the notion of @{term holding}.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    89
  It is a technical lemmas used to prove the two following lemmas.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    90
*}
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
    91
lemma children_RAG_alt_def:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
    92
  "children (RAG (s::state)) (Th th) = Cs ` {cs. holding s th cs}"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
    93
  by (unfold s_RAG_def, auto simp:children_def s_holding_abv)
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
    94
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    95
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    96
  The following two lemmas relate @{term holdents} and @{term cntCS}
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    97
  to @{term children} in @{term RAG}, so that proofs about
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    98
  @{term holdents} and @{term cntCS} can be carried out under 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
    99
  the support of the abstract theory of {\em relational graph}
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   100
  (and specifically {\em relational tree} and {\em relational forest}).
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   101
*}
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   102
lemma holdents_alt_def:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   103
  "holdents s th = the_cs ` (children (RAG (s::state)) (Th th))"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   104
  by (unfold children_RAG_alt_def holdents_def, simp add: image_image)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   105
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   106
lemma cntCS_alt_def:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   107
  "cntCS s th = card (children (RAG s) (Th th))"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   108
  apply (unfold children_RAG_alt_def cntCS_def holdents_def)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   109
  by (rule card_image[symmetric], auto simp:inj_on_def)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   110
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   111
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   112
  The following two lemmas show the inclusion relations
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   113
  among three key sets, namely @{term running}, @{term readys}
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   114
  and @{term threads}.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   115
*}
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   116
lemma running_ready: 
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   117
  shows "running s \<subseteq> readys s"
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   118
  unfolding running_def readys_def
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   119
  by auto 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   120
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   121
lemma readys_threads:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   122
  shows "readys s \<subseteq> threads s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   123
  unfolding readys_def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   124
  by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   125
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   126
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   127
  The following lemma says that if a thread is running, 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   128
  it must be the head of every waiting queue it is in. 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   129
  In other words, a running thread must have got every 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   130
  resource it has requested.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   131
*}
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   132
lemma running_wqE:
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   133
  assumes "th \<in> running 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: 90
diff changeset
   134
  and "th \<in> set (wq s 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: 90
diff changeset
   135
  obtains rest where "wq s cs = th#rest"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   136
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: 90
diff changeset
   137
  from assms(2) obtain th' rest where eq_wq: "wq s cs = th'#rest"
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
   138
    by (metis empty_iff list.exhaust list.set(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: 90
diff changeset
   139
  have "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: 90
diff changeset
   140
  proof(rule ccontr)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   141
    assume "th' \<noteq> 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: 90
diff changeset
   142
    hence "th \<noteq> hd (wq s cs)" using eq_wq 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: 90
diff changeset
   143
    with assms(2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   144
    have "waiting s th 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: 90
diff changeset
   145
      by (unfold s_waiting_def, fold wq_def, 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: 90
diff changeset
   146
    with assms show False 
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   147
      by (unfold running_def readys_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: 90
diff changeset
   148
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   149
  with eq_wq that show ?thesis by metis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   150
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   151
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   152
text {*
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   153
  Every thread can only be blocked on one critical resource, 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   154
  symmetrically, every critical resource can only be held by one thread. 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   155
  This fact is much more easier according to our definition. 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   156
*}
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   157
lemma held_unique:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   158
  assumes "holding (s::event list) th1 cs"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   159
  and "holding s th2 cs"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   160
  shows "th1 = th2"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   161
 by (insert assms, unfold s_holding_def, auto)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   162
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   163
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   164
  The following three lemmas establishes the uniqueness of
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   165
  precedence, a key property about precedence.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   166
  The first two are just technical lemmas to assist the proof
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   167
  of the third.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   168
*}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   169
lemma last_set_lt: "th \<in> threads s \<Longrightarrow> last_set th s < length s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   170
  apply (induct s, auto)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   171
  by (case_tac a, auto split:if_splits)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   172
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   173
lemma last_set_unique: 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   174
  "\<lbrakk>last_set th1 s = last_set th2 s; th1 \<in> threads s; th2 \<in> threads s\<rbrakk>
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   175
          \<Longrightarrow> th1 = th2"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   176
  apply (induct s, auto)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   177
  by (case_tac a, auto split:if_splits dest:last_set_lt)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   178
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   179
lemma preced_unique : 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   180
  assumes pcd_eq: "preced th1 s = preced th2 s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   181
  and th_in1: "th1 \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   182
  and th_in2: " th2 \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   183
  shows "th1 = th2"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   184
proof -
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   185
  from pcd_eq have "last_set th1 s = last_set th2 s" by (simp add:preced_def)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   186
  from last_set_unique [OF this th_in1 th_in2]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   187
  show ?thesis .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   188
qed
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   189
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   190
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   191
  The following lemma shows that there exits a linear order
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   192
  on precedences, which is crucial for the notion of 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   193
  @{term Max} to be applicable.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   194
*}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   195
lemma preced_linorder: 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   196
  assumes neq_12: "th1 \<noteq> th2"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   197
  and th_in1: "th1 \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   198
  and th_in2: " th2 \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   199
  shows "preced th1 s < preced th2 s \<or> preced th1 s > preced th2 s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   200
proof -
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   201
  from preced_unique [OF _ th_in1 th_in2] and neq_12 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   202
  have "preced th1 s \<noteq> preced th2 s" by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   203
  thus ?thesis by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   204
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   205
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   206
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   207
  The following lemma case analysis the situations when
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   208
  two nodes are in @{term RAG}.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   209
*}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   210
lemma in_RAG_E:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   211
  assumes "(n1, n2) \<in> RAG (s::state)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   212
  obtains (waiting) th cs where "n1 = Th th" "n2 = Cs cs" "waiting s th cs"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
   213
        | (holding) th cs where "n1 = Cs cs" "n2 = Th th" "holding s th cs"
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
   214
  using assms[unfolded s_RAG_def, folded s_waiting_abv s_holding_abv]
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   215
  by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   216
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   217
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   218
  The following lemmas are the simplification rules 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   219
  for @{term count}, @{term cntP}, @{term cntV}.
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
   220
  It is part of the scheme to use the counting 
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
   221
  of @{term "P"} and @{term "V"} operations to reason about
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
   222
  the number of resources occupied by one thread.
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   223
*}
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   224
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   225
lemma count_rec1 [simp]: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   226
  assumes "Q e"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   227
  shows "count Q (e#es) = Suc (count Q es)"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   228
  using assms
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   229
  by (unfold count_def, auto)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   230
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   231
lemma count_rec2 [simp]: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   232
  assumes "\<not>Q e"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   233
  shows "count Q (e#es) = (count Q es)"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   234
  using assms
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   235
  by (unfold count_def, auto)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   236
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   237
lemma count_rec3 [simp]: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   238
  shows "count Q [] =  0"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   239
  by (unfold count_def, auto)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   240
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   241
lemma cntP_simp1[simp]:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   242
  "cntP (P th cs'#s) th = cntP s th + 1"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   243
  by (unfold cntP_def, simp)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   244
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   245
lemma cntP_simp2[simp]:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   246
  assumes "th' \<noteq> th"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   247
  shows "cntP (P th cs'#s) th' = cntP s th'"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   248
  using assms
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   249
  by (unfold cntP_def, simp)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   250
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   251
lemma cntP_simp3[simp]:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   252
  assumes "\<not> isP e"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   253
  shows "cntP (e#s) th' = cntP s th'"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   254
  using assms
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   255
  by (unfold cntP_def, cases e, simp+)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   256
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   257
lemma cntV_simp1[simp]:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   258
  "cntV (V th cs'#s) th = cntV s th + 1"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   259
  by (unfold cntV_def, simp)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   260
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   261
lemma cntV_simp2[simp]:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   262
  assumes "th' \<noteq> th"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   263
  shows "cntV (V th cs'#s) th' = cntV s th'"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   264
  using assms
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   265
  by (unfold cntV_def, simp)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   266
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   267
lemma cntV_simp3[simp]:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   268
  assumes "\<not> isV e"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   269
  shows "cntV (e#s) th' = cntV s th'"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   270
  using assms
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   271
  by (unfold cntV_def, cases e, simp+)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   272
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
   273
text {*
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
   274
  The following two lemmas show that only @{term P}
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
   275
  and @{term V} operation can change the value 
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
   276
  of @{term cntP} and @{term cntV}, which is true
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
   277
  obviously.
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
   278
*}
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   279
lemma cntP_diff_inv:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   280
  assumes "cntP (e#s) th \<noteq> cntP s th"
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
   281
  obtains cs where "e = P th cs"
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   282
proof(cases e)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   283
  case (P th' pty)
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
   284
  show ?thesis using that
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   285
  by (cases "(\<lambda>e. \<exists>cs. e = P th cs) (P th' pty)", 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   286
        insert assms P, auto simp:cntP_def)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   287
qed (insert assms, auto simp:cntP_def)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   288
  
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   289
lemma cntV_diff_inv:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   290
  assumes "cntV (e#s) th \<noteq> cntV s th"
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
   291
  obtains cs' where "e = V th cs'"
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   292
proof(cases e)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   293
  case (V th' pty)
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
   294
  show ?thesis using that
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   295
  by (cases "(\<lambda>e. \<exists>cs. e = V th cs) (V th' pty)", 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   296
        insert assms V, auto simp:cntV_def)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   297
qed (insert assms, auto simp:cntV_def)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   298
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   299
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   300
text {* 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   301
  The following three lemmas shows the shape
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   302
  of nodes in @{term tRAG}.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   303
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   304
lemma tRAG_nodeE:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   305
  assumes "(n1, n2) \<in> tRAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   306
  obtains th1 th2 where "n1 = Th th1" "n2 = Th th2"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   307
  using assms
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   308
  by (auto simp: tRAG_def wRAG_def hRAG_def)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   309
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   310
lemma tRAG_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   311
  assumes "(n1, n2) \<in> tRAG s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   312
  shows "n1 = Th (the_thread n1)" "n2 = Th (the_thread n2)" "(the_thread n1, the_thread n2) \<in> tG s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   313
  using assms
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   314
  by (unfold tRAG_def_tG tG_alt_def, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   315
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   316
lemma tG_tRAG: 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   317
  assumes "(th1, th2) \<in> tG s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   318
  shows "(Th th1, Th th2) \<in> tRAG s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   319
  using assms
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   320
  by (unfold tRAG_def_tG, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   321
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   322
lemma tRAG_ancestorsE:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   323
  assumes "x \<in> ancestors (tRAG s) u"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   324
  obtains th where "x = Th th"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   325
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   326
  from assms have "(u, x) \<in> (tRAG s)^+" 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   327
      by (unfold ancestors_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   328
  from tranclE[OF this] obtain c where "(c, x) \<in> tRAG s" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   329
  then obtain th where "x = Th th"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   330
    by (unfold tRAG_alt_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   331
  from that[OF this] show ?thesis .
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   332
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   333
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   334
lemma map_prod_RE:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   335
  assumes "(u, v) \<in> (map_prod f f ` R)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   336
  obtains u' v' where "u = (f u')" "v = (f v')" "(u', v') \<in> R"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   337
  using assms
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   338
  by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   339
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   340
lemma map_prod_tranclE:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   341
  assumes "(u, v) \<in> (map_prod f f ` R)^+"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   342
  and "inj_on f (Field R)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   343
  obtains u' v' where "u = (f u')" "v = (f v')" "(u', v') \<in> R^+"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   344
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   345
  from assms(1)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   346
  have "\<exists>u' v'. u = f u' \<and> v = f v' \<and> (u', v') \<in> R\<^sup>+"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   347
  proof(induct rule:trancl_induct)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   348
    case (base y)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   349
    thus ?case by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   350
  next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   351
    case (step y z)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   352
    then obtain u' v' where h1: "u = f u'"  "y = f v'" "(u', v') \<in> R\<^sup>+" by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   353
    from map_prod_RE[OF step(2)] obtain v'' u'' 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   354
                      where h2: "y = f v''" "z = f u''" "(v'', u'') \<in> R" by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   355
    from h1 h2 have "f v' = f v''" by simp
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   356
    hence eq_v': "v' = v''"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   357
    proof(cases rule:inj_onD[OF assms(2), consumes 1])
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   358
      case 1
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   359
      from h1(3) show ?case using trancl_subset_Field2[of R] by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   360
    next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   361
      case 2
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   362
      from h2(3) show ?case by (simp add: Domain.DomainI Field_def) 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   363
    qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   364
    let ?u = "u'" and ?v = "u''"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   365
    have "(?u, ?v) \<in> R^+" using h1(3)[unfolded eq_v'] h2(3) by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   366
    with h1 h2
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   367
    show ?case by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   368
  qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   369
  thus ?thesis using that by metis
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   370
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   371
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   372
lemma map_prod_rtranclE:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   373
  assumes "(u, v) \<in> (map_prod f f ` R)^*"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   374
  and "inj_on f (Field R)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   375
  obtains (root) "u = v" 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   376
        | (trancl) u' v' where "u = (f u')" "v = (f v')" "(u', v') \<in> R^*"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   377
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   378
  from rtranclD[OF assms(1)]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   379
  have "u = v \<or> (\<exists>u' v'. u = f u' \<and> v = f v' \<and> (u', v') \<in> R\<^sup>*)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   380
  proof
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   381
    assume "u = v" thus ?thesis by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   382
  next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   383
    assume "u \<noteq> v \<and> (u, v) \<in> (map_prod f f ` R)\<^sup>+"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   384
    hence "(u, v) \<in> (map_prod f f ` R)\<^sup>+" by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   385
    thus ?thesis
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   386
     by (rule map_prod_tranclE[OF _ assms(2)], auto dest!:trancl_into_rtrancl)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   387
  qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   388
  with that show ?thesis by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   389
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   390
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   391
lemma Field_tRAGE:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   392
  assumes "n \<in> (Field (tRAG s))"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   393
  obtains th where "n = Th th"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   394
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   395
  from assms[unfolded tRAG_alt_def Field_def Domain_def Range_def]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   396
  show ?thesis using that by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   397
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   398
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   399
lemma trancl_tG_tRAG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   400
  assumes "(th1, th2) \<in> (tG s)^+"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   401
  shows "(Th th1, Th th2) \<in> (tRAG s)^+"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   402
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   403
  have "inj_on the_thread (Field (tRAG s))"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   404
    by (unfold inj_on_def Field_def tRAG_alt_def, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   405
  from map_prod_tranclE[OF assms[unfolded tG_def] this]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   406
  obtain u' v' where h: "th1 = the_thread u'" "th2 = the_thread v'" "(u', v') \<in> (tRAG s)\<^sup>+"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   407
    by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   408
  hence "u' \<in> Domain ((tRAG s)\<^sup>+)" "v' \<in> Range ((tRAG s)\<^sup>+)" by (auto simp:Domain_def Range_def)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   409
  from this[unfolded trancl_domain trancl_range]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   410
  have "u' \<in> Field (tRAG s)" "v' \<in> Field (tRAG s)" 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   411
    by (unfold Field_def, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   412
  then obtain th1' th2' where h': "u' = Th th1'" "v' = Th th2'"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   413
    by (auto elim!:Field_tRAGE)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   414
  with h have "th1' = th1" "th2' = th2" by (auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   415
  from h(3)[unfolded h' this]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   416
  show ?thesis by (auto simp:ancestors_def)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   417
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   418
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   419
lemma rtrancl_tG_tRAG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   420
  assumes "(th1, th2) \<in> (tG s)^*"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   421
  shows "(Th th1, Th th2) \<in> (tRAG s)^*"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   422
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   423
  from rtranclD[OF assms]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   424
  show ?thesis
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   425
  proof
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   426
    assume "th1 = th2" thus "(Th th1, Th th2) \<in> (tRAG s)\<^sup>*" by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   427
  next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   428
    assume "th1 \<noteq> th2 \<and> (th1, th2) \<in> (tG s)\<^sup>+"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   429
    hence "(th1, th2) \<in> (tG s)\<^sup>+" by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   430
    from trancl_into_rtrancl[OF trancl_tG_tRAG[OF this]]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   431
    show "(Th th1, Th th2) \<in> (tRAG s)\<^sup>*" .
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   432
  qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   433
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   434
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   435
lemma trancl_tRAG_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   436
  assumes "(n1, n2) \<in> (tRAG s)^+"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   437
  obtains "n1 = Th (the_thread n1)" "n2 = Th (the_thread n2)" 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   438
          "(the_thread n1, the_thread n2) \<in> (tG s)^+"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   439
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   440
  have inj: "inj_on Th (Field (tG s))" 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   441
    by (unfold inj_on_def Field_def, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   442
  show ?thesis 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   443
    by (rule map_prod_tranclE[OF assms[unfolded tRAG_def_tG] inj], auto intro!:that)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   444
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   445
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   446
lemma rtrancl_tRAG_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   447
  assumes "(n1, n2) \<in> (tRAG s)^*"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   448
  obtains "n1 = n2" 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   449
          | "n1 = Th (the_thread n1)" "n2 = Th (the_thread n2)" "the_thread n1 \<noteq> the_thread n2"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   450
            "(the_thread n1, the_thread n2) \<in> (tG s)^*"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   451
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   452
  from rtranclD[OF assms]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   453
  have "n1 = n2 \<or>
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   454
          n1 = Th (the_thread n1) \<and> n2 = Th (the_thread n2) \<and> the_thread n1 \<noteq> the_thread n2 \<and>
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   455
          (the_thread n1, the_thread n2) \<in> (tG s)^*"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   456
  proof
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   457
    assume h: "n1 \<noteq> n2 \<and> (n1, n2) \<in> (tRAG s)\<^sup>+"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   458
    hence "(n1, n2) \<in> (tRAG s)\<^sup>+" by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   459
    from trancl_tRAG_tG[OF this]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   460
    have "n1 = Th (the_thread n1)" "n2 = Th (the_thread n2)" 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   461
          "(the_thread n1, the_thread n2) \<in> (tG s)\<^sup>+" by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   462
    with h 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   463
    show ?thesis by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   464
  qed auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   465
    with that show ?thesis by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   466
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   467
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   468
lemma ancestors_imageE:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   469
  assumes "u \<in> ancestors ((map_prod f f) ` R) v"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   470
  and "inj_on f (Field R)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   471
  obtains u' v' where "u = (f u')" "v = (f v')" "u' \<in> ancestors R v'"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   472
  using assms unfolding ancestors_def
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   473
  by (metis map_prod_tranclE mem_Collect_eq)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   474
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   475
lemma tRAG_ancestorsE_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   476
  assumes "x \<in> ancestors (tRAG s) u"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   477
  obtains "x = Th (the_thread x)" "u = Th (the_thread u)" 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   478
           "the_thread x \<in> ancestors (tG s) (the_thread u)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   479
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   480
  from assms[unfolded ancestors_def]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   481
  have "(u, x) \<in> (tRAG s)\<^sup>+" by simp
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   482
  from trancl_tRAG_tG[OF this]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   483
  show ?thesis using that by (auto simp:ancestors_def)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   484
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   485
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   486
lemma ancestors_tG_tRAG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   487
  assumes "th1 \<in> ancestors (tG s) th2"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   488
  shows "Th th1 \<in> ancestors (tRAG s) (Th th2)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   489
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   490
  from assms[unfolded ancestors_def]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   491
  have "(th2, th1) \<in> (tG s)\<^sup>+" by simp
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   492
  from trancl_tG_tRAG[OF this]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   493
  show ?thesis by (simp add:ancestors_def)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   494
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   495
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   496
lemma subtree_nodeE:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   497
  assumes "n \<in> subtree (tRAG s) (Th th)"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   498
  obtains th1 where "n = Th th1"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   499
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   500
  show ?thesis
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   501
  proof(rule subtreeE[OF assms])
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   502
    assume "n = Th th"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   503
    from that[OF this] show ?thesis .
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   504
  next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   505
    assume "Th th \<in> ancestors (tRAG s) n"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   506
    hence "(n, Th th) \<in> (tRAG s)^+" by (auto simp:ancestors_def)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   507
    hence "\<exists> th1. n = Th th1"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   508
    proof(induct)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   509
      case (base y)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   510
      from tRAG_nodeE[OF this] show ?case by metis
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   511
    next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   512
      case (step y z)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   513
      thus ?case by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   514
    qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   515
    with that show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   516
  qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   517
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   518
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   519
lemma subtree_nodeE_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   520
  assumes "n \<in> subtree (tRAG s) (Th th)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   521
  obtains "n = Th (the_thread n)" "the_thread n \<in> subtree (tG s) th" 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   522
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   523
  from assms[unfolded subtree_def]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   524
  have "(n, Th th) \<in> (tRAG s)\<^sup>*" by simp
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   525
  hence "n = Th (the_thread n) \<and> the_thread n \<in> subtree (tG s) th"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   526
   by (cases rule:rtrancl_tRAG_tG, auto simp:subtree_def)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   527
  thus ?thesis using that by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   528
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   529
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   530
lemma subtree_tRAG_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   531
  "subtree (tRAG s) (Th th) = Th ` (subtree (tG s) th)" (is "?L = ?R")
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   532
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   533
  { fix n
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   534
    assume "n \<in> ?L"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   535
    from subtree_nodeE_tG[OF this]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   536
    have "n \<in> ?R" by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   537
  } moreover {
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   538
    fix n
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   539
    assume "n \<in> ?R"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   540
    then obtain th' where h: "th' \<in> subtree (tG s) th" "n = Th th'" by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   541
    hence "(th', th) \<in> (tG s)^*" by (auto simp:subtree_def)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   542
    from rtrancl_tG_tRAG[OF this] and h
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   543
    have "n \<in> ?L" by (auto simp:subtree_def)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   544
  } ultimately show ?thesis by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   545
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   546
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   547
lemma subtree_tG_tRAG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   548
  "(subtree (tG s) th) = the_thread ` (subtree (tRAG s) (Th th))" (is "?L = ?R")
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   549
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   550
  have "?R = (the_thread \<circ> Th) ` subtree (tG s) th"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   551
    by (unfold subtree_tRAG_tG image_comp, simp)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   552
  also have "... = id ` ?L" by (rule image_cong, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   553
  finally show ?thesis by simp
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   554
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   555
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   556
text {*
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   557
  The following lemmas relate @{term tRAG} with 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   558
  @{term RAG} from different perspectives. 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   559
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   560
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   561
lemma tRAG_star_RAG: "(tRAG s)^* \<subseteq> (RAG s)^*"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   562
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   563
  have "(wRAG s O hRAG s)^* \<subseteq> (RAG s O RAG s)^*" 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   564
    by (rule rtrancl_mono, auto simp:RAG_split)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   565
  also have "... \<subseteq> ((RAG s)^*)^*"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   566
    by (rule rtrancl_mono, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   567
  also have "... = (RAG s)^*" by simp
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   568
  finally show ?thesis by (unfold tRAG_def, simp)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   569
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   570
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   571
lemma tRAG_subtree_RAG: "subtree (tRAG s) x \<subseteq> subtree (RAG s) x"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   572
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   573
  { fix a
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   574
    assume "a \<in> subtree (tRAG s) x"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   575
    hence "(a, x) \<in> (tRAG s)^*" by (auto simp:subtree_def)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   576
    with tRAG_star_RAG
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   577
    have "(a, x) \<in> (RAG s)^*" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   578
    hence "a \<in> subtree (RAG s) x" by (auto simp:subtree_def)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   579
  } thus ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   580
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   581
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   582
lemma tRAG_trancl_eq:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   583
   "{th'. (Th th', Th th)  \<in> (tRAG s)^+} = 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   584
    {th'. (Th th', Th th)  \<in> (RAG s)^+}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   585
   (is "?L = ?R")
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   586
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   587
  { fix th'
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   588
    assume "th' \<in> ?L"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   589
    hence "(Th th', Th th) \<in> (tRAG s)^+" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   590
    from tranclD[OF this]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   591
    obtain z where h: "(Th th', z) \<in> tRAG s" "(z, Th th) \<in> (tRAG s)\<^sup>*" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   592
    from tRAG_subtree_RAG and this(2)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   593
    have "(z, Th th) \<in> (RAG s)^*" by (meson subsetCE tRAG_star_RAG) 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   594
    moreover from h(1) have "(Th th', z) \<in> (RAG s)^+" using tRAG_alt_def by auto 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   595
    ultimately have "th' \<in> ?R"  by auto 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   596
  } moreover 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   597
  { fix th'
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   598
    assume "th' \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   599
    hence "(Th th', Th th) \<in> (RAG s)^+" by (auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   600
    from plus_rpath[OF this]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   601
    obtain xs where rp: "rpath (RAG s) (Th th') xs (Th th)" "xs \<noteq> []" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   602
    hence "(Th th', Th th) \<in> (tRAG s)^+"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   603
    proof(induct xs arbitrary:th' th rule:length_induct)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   604
      case (1 xs th' th)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   605
      then obtain x1 xs1 where Cons1: "xs = x1#xs1" by (cases xs, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   606
      show ?case
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   607
      proof(cases "xs1")
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   608
        case Nil
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   609
        from 1(2)[unfolded Cons1 Nil]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   610
        have rp: "rpath (RAG s) (Th th') [x1] (Th th)" .
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   611
        hence "(Th th', x1) \<in> (RAG s)" 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   612
          by (cases, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   613
        then obtain cs where "x1 = Cs cs" 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   614
              by (unfold s_RAG_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   615
        from rpath_nnl_lastE[OF rp[unfolded this]]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   616
        show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   617
      next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   618
        case (Cons x2 xs2)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   619
        from 1(2)[unfolded Cons1[unfolded this]]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   620
        have rp: "rpath (RAG s) (Th th') (x1 # x2 # xs2) (Th th)" .
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   621
        from rpath_edges_on[OF this]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   622
        have eds: "edges_on (Th th' # x1 # x2 # xs2) \<subseteq> RAG s" .
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   623
        have "(Th th', x1) \<in> edges_on (Th th' # x1 # x2 # xs2)"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   624
            by (simp add: edges_on_unfold)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   625
        with eds have rg1: "(Th th', x1) \<in> RAG s" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   626
        then obtain cs1 where eq_x1: "x1 = Cs cs1" by (unfold s_RAG_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   627
        have "(x1, x2) \<in> edges_on (Th th' # x1 # x2 # xs2)"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   628
            by (simp add: edges_on_unfold)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   629
        from this eds
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   630
        have rg2: "(x1, x2) \<in> RAG s" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   631
        from this[unfolded eq_x1] 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   632
        obtain th1 where eq_x2: "x2 = Th th1" by (unfold s_RAG_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   633
        from rg1[unfolded eq_x1] rg2[unfolded eq_x1 eq_x2]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   634
        have rt1: "(Th th', Th th1) \<in> tRAG s" by (unfold tRAG_alt_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   635
        from rp have "rpath (RAG s) x2 xs2 (Th th)"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   636
           by  (elim rpath_ConsE, simp)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   637
        from this[unfolded eq_x2] have rp': "rpath (RAG s) (Th th1) xs2 (Th th)" .
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   638
        show ?thesis
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   639
        proof(cases "xs2 = []")
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   640
          case True
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   641
          from rpath_nilE[OF rp'[unfolded this]]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   642
          have "th1 = th" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   643
          from rt1[unfolded this] show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   644
        next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   645
          case False
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   646
          from 1(1)[rule_format, OF _ rp' this, unfolded Cons1 Cons]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   647
          have "(Th th1, Th th) \<in> (tRAG s)\<^sup>+" by simp
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   648
          with rt1 show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   649
        qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   650
      qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   651
    qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   652
    hence "th' \<in> ?L" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   653
  } ultimately show ?thesis by blast
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   654
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   655
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   656
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   657
lemma tRAG_trancl_eq_Th:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   658
   "{Th th' | th'. (Th th', Th th)  \<in> (tRAG s)^+} = 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   659
    {Th th' | th'. (Th th', Th th)  \<in> (RAG s)^+}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   660
    using tRAG_trancl_eq by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   661
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   662
lemma tRAG_Field:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   663
  "Field (tRAG s) \<subseteq> Field (RAG s)"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   664
  by (unfold tRAG_alt_def Field_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   665
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   666
lemma tRAG_mono:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   667
  assumes "RAG s' \<subseteq> RAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   668
  shows "tRAG s' \<subseteq> tRAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   669
  using assms 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   670
  by (unfold tRAG_alt_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   671
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   672
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   673
lemma tRAG_subtree_eq: 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   674
   "(subtree (tRAG s) (Th th)) = {Th th' | th'. Th th'  \<in> (subtree (RAG s) (Th th))}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   675
   (is "?L = ?R")
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   676
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   677
  { fix n 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   678
    assume h: "n \<in> ?L"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   679
    hence "n \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   680
    by (smt mem_Collect_eq subsetCE subtree_def subtree_nodeE tRAG_subtree_RAG) 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   681
  } moreover {
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   682
    fix n
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   683
    assume "n \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   684
    then obtain th' where h: "n = Th th'" "(Th th', Th th) \<in> (RAG s)^*"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   685
      by (auto simp:subtree_def)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   686
    from rtranclD[OF this(2)]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   687
    have "n \<in> ?L"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   688
    proof
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   689
      assume "Th th' \<noteq> Th th \<and> (Th th', Th th) \<in> (RAG s)\<^sup>+"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   690
      with h have "n \<in> {Th th' | th'. (Th th', Th th)  \<in> (RAG s)^+}" by auto
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   691
      thus ?thesis using subtree_def tRAG_trancl_eq 
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   692
        by fastforce (* ccc *)
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   693
    qed (insert h, auto simp:subtree_def)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   694
  } ultimately show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   695
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   696
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   697
lemma threads_set_eq: 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   698
   "the_thread ` (subtree (tRAG s) (Th th)) = 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   699
                  {th'. Th th' \<in> (subtree (RAG s) (Th th))}" (is "?L = ?R")
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   700
   by (auto intro:rev_image_eqI simp:tRAG_subtree_eq)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   701
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   702
text {*
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   703
  The following lemmas is an alternative definition of @{term cp},
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   704
  which is based on the notion of subtrees in @{term RAG} and 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   705
  is handy to use once the abstract theory of {\em relational graph}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   706
  (and specifically {\em relational tree} and {\em relational forest})
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   707
  are in place.
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   708
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   709
lemma cp_alt_def:
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   710
  "cp s th =  Max ((the_preced s) ` {th'. Th th' \<in> (subtree (RAG s) (Th th))})"
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   711
proof -
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   712
  have "Max (the_preced s ` ({th} \<union> dependants s th)) =
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   713
        Max (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)})" 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   714
          (is "Max (_ ` ?L) = Max (_ ` ?R)")
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   715
  proof -
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   716
    have "?L = ?R" 
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   717
    unfolding subtree_def
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   718
    apply(auto)
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   719
    apply (simp add: s_RAG_abv s_dependants_def wq_def)
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   720
    by (simp add: rtrancl_eq_or_trancl s_RAG_abv s_dependants_def wq_def)
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   721
    thus ?thesis by simp
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   722
  qed
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   723
  thus ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
   724
  by (metis (no_types, lifting) cp_eq cpreced_def2 f_image_eq 
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
   725
      s_dependants_abv the_preced_def)
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   726
qed
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   727
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   728
text {*
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   729
  The following is another definition of @{term cp}.
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   730
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   731
lemma cp_alt_def1: 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   732
  "cp s th = Max ((the_preced s o the_thread) ` (subtree (tRAG s) (Th th)))"
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   733
proof -
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   734
  have "(the_preced s ` the_thread ` subtree (tRAG s) (Th th)) =
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   735
       ((the_preced s \<circ> the_thread) ` subtree (tRAG s) (Th th))"
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   736
       by auto
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   737
  thus ?thesis by (unfold cp_alt_def, fold threads_set_eq, auto)
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   738
qed
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   739
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   740
text {*
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   741
  The following is another definition of @{term cp} based on @{term tG}:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   742
*}
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   743
lemma cp_alt_def2: 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   744
  "cp s th = Max (the_preced s ` (subtree (tG s) th))"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   745
  by (unfold cp_alt_def1 subtree_tG_tRAG image_comp, simp)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   746
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   747
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   748
lemma RAG_tRAG_transfer:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   749
  assumes  "RAG s' = RAG s \<union> {(Th th, Cs cs)}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   750
  and "(Cs cs, Th th'') \<in> RAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   751
  shows "tRAG s' = tRAG s \<union> {(Th th, Th th'')}" (is "?L = ?R")
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   752
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   753
  { fix n1 n2
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   754
    assume "(n1, n2) \<in> ?L"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   755
    from this[unfolded tRAG_alt_def]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   756
    obtain th1 th2 cs' where 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   757
      h: "n1 = Th th1" "n2 = Th th2" 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   758
         "(Th th1, Cs cs') \<in> RAG s'"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   759
         "(Cs cs', Th th2) \<in> RAG s'" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   760
    from h(4) and assms(1) have cs_in: "(Cs cs', Th th2) \<in> RAG s" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   761
    from h(3) and assms(1) 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   762
    have "(Th th1, Cs cs') = (Th th, Cs cs) \<or> 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   763
          (Th th1, Cs cs') \<in> RAG s" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   764
    hence "(n1, n2) \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   765
    proof
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   766
      assume h1: "(Th th1, Cs cs') = (Th th, Cs cs)"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   767
      with assms(1) have "(Th th1, Cs cs) \<in> RAG s'" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   768
      moreover have "th2 = th''"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   769
      proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   770
        from h1 have "cs' = cs" by simp
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   771
        from assms(2) cs_in[unfolded this]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   772
        have "holding s th'' cs" "holding s th2 cs"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
   773
          by (unfold s_RAG_def, fold s_holding_abv, auto)
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   774
        from held_unique[OF this]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   775
        show ?thesis by simp 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   776
      qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   777
      ultimately show ?thesis using h(1,2) h1 by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   778
    next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   779
      assume "(Th th1, Cs cs') \<in> RAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   780
      with cs_in have "(Th th1, Th th2) \<in> tRAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   781
        by (unfold tRAG_alt_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   782
      from this[folded h(1, 2)] show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   783
    qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   784
  } moreover {
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   785
    fix n1 n2
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   786
    assume "(n1, n2) \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   787
    hence "(n1, n2) \<in>tRAG s \<or> (n1, n2) = (Th th, Th th'')" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   788
    hence "(n1, n2) \<in> ?L" 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   789
    proof
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   790
      assume "(n1, n2) \<in> tRAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   791
      moreover have "... \<subseteq> ?L"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   792
      proof(rule tRAG_mono)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   793
        show "RAG s \<subseteq> RAG s'" by (unfold assms(1), auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   794
      qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   795
      ultimately show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   796
    next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   797
      assume eq_n: "(n1, n2) = (Th th, Th th'')"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   798
      from assms(1, 2) have "(Cs cs, Th th'') \<in> RAG s'" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   799
      moreover have "(Th th, Cs cs) \<in> RAG s'" using assms(1) by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   800
      ultimately show ?thesis 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   801
        by (unfold eq_n tRAG_alt_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   802
    qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   803
  } ultimately show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   804
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   805
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   806
text {* 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   807
  The following lemmas gives an alternative definition @{term dependants}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   808
  in terms of @{term tRAG}.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   809
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   810
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   811
lemma dependants_alt_def:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   812
  "dependants s th = {th'. (Th th', Th th) \<in> (tRAG s)^+}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   813
  by (metis eq_RAG s_dependants_def tRAG_trancl_eq)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   814
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   815
text {* 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   816
  The following lemmas gives another alternative definition @{term dependants}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   817
  in terms of @{term RAG}.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   818
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   819
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   820
lemma dependants_alt_def1:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   821
  "dependants (s::state) th = {th'. (Th th', Th th) \<in> (RAG s)^+}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   822
  using dependants_alt_def tRAG_trancl_eq by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   823
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   824
text {*
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   825
  Another definition of dependants based on @{term tG}:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   826
*}
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   827
lemma dependants_alt_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   828
  "dependants s th = {th'. (th', th) \<in> (tG s)^+}" (is "?L = ?R")
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   829
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   830
  have "?L = {th'. (Th th', Th th) \<in> (tRAG s)\<^sup>+}"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   831
    by (unfold dependants_alt_def, simp)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   832
  also have "... = ?R" (is "?LL = ?RR")
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   833
  proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   834
    { fix th'
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   835
      assume "th' \<in> ?LL"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   836
      hence "(Th th', Th th) \<in> (tRAG s)\<^sup>+" by simp
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   837
      from trancl_tRAG_tG[OF this]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   838
      have "th' \<in> ?RR" by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   839
    } moreover {
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   840
      fix th'
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   841
      assume "th' \<in> ?RR"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   842
      hence "(th', th) \<in> (tG s)\<^sup>+" by simp
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   843
      from trancl_tG_tRAG[OF this]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   844
      have "th' \<in> ?LL" by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   845
    } ultimately show ?thesis by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   846
  qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   847
  finally show ?thesis .
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   848
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   849
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   850
lemma dependants_alt_def_tG_ancestors:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   851
  "dependants s th =  {th'. th \<in> ancestors (tG s) th'}"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   852
  by (unfold dependants_alt_tG ancestors_def, simp)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   853
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
   854
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
   855
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   856
section {* Locales used to investigate the execution of PIP *}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   857
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   858
text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   859
  The following locale @{text valid_trace} is used to constrain the 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   860
  trace to be valid. All properties hold for valid traces are 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   861
  derived under this locale. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   862
*}
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   863
locale valid_trace = 
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   864
  fixes s
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   865
  assumes vt : "vt s"
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   866
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   867
text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   868
  The following locale @{text valid_trace_e} describes 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   869
  the valid extension of a valid trace. The event @{text "e"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   870
  represents an event in the system, which corresponds 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   871
  to a one step operation of the PIP protocol. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   872
  It is required that @{text "e"} is an event eligible to happen
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   873
  under state @{text "s"}, which is already required to be valid
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   874
  by the parent locale @{text "valid_trace"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   875
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   876
  This locale is used to investigate one step execution of PIP, 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   877
  properties concerning the effects of @{text "e"}'s execution, 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   878
  for example, how the values of observation functions are changed, 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   879
  or how desirable properties are kept invariant, are derived
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   880
  under this locale. The state before execution is @{text "s"}, while
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   881
  the state after execution is @{text "e#s"}. Therefore, the lemmas 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   882
  derived usually relate observations on @{text "e#s"} to those 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   883
  on @{text "s"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   884
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   885
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   886
locale valid_trace_e = valid_trace +
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   887
  fixes e
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   888
  assumes vt_e: "vt (e#s)"
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   889
begin
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   890
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   891
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   892
  The following lemma shows that @{text "e"} must be a 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   893
  eligible event (or a valid step) to be taken under
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   894
  the state represented by @{text "s"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   895
*}
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   896
lemma pip_e: "PIP s e"
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   897
  using vt_e by (cases, simp)  
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   898
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   899
end
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   900
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   901
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   902
  Because @{term "e#s"} is also a valid trace, properties 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   903
  derived for valid trace @{term s} also hold on @{term "e#s"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   904
*}
120
b3b8735c7c02 updated to Isabelle 2016
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 119
diff changeset
   905
sublocale valid_trace_e < vat_es: valid_trace "e#s" 
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   906
  using vt_e
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   907
  by (unfold_locales, simp)
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   908
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   909
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   910
  For each specific event (or operation), there is a sublocale
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   911
  further constraining that the event @{text e} to be that 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   912
  particular event. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   913
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   914
  For example, the following 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   915
  locale @{text "valid_trace_create"} is the sublocale for 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   916
  event @{term "Create"}:
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   917
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   918
locale valid_trace_create = valid_trace_e + 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   919
  fixes th prio
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   920
  assumes is_create: "e = Create th prio"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   921
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   922
locale valid_trace_exit = valid_trace_e + 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   923
  fixes th
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   924
  assumes is_exit: "e = Exit th"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   925
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   926
locale valid_trace_p = valid_trace_e + 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   927
  fixes th cs
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   928
  assumes is_p: "e = P th cs"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   929
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   930
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   931
  locale @{text "valid_trace_p"} is divided further into two 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   932
  sublocales, namely, @{text "valid_trace_p_h"} 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   933
  and @{text "valid_trace_p_w"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   934
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   935
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   936
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   937
  The following two sublocales @{text "valid_trace_p_h"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   938
  and @{text "valid_trace_p_w"} represent two complementary 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   939
  cases under @{text "valid_trace_p"}, where
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   940
  @{text "valid_trace_p_h"} further constraints that
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   941
  @{text "wq s cs = []"}, which means the waiting queue of 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   942
  the requested resource @{text "cs"} is empty, in which
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   943
  case,  the requesting thread @{text "th"} 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   944
  will take hold of @{text "cs"}. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   945
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   946
  Opposite to @{text "valid_trace_p_h"},
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   947
  @{text "valid_trace_p_w"} constraints that
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   948
  @{text "wq s cs \<noteq> []"}, which means the waiting queue of 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   949
  the requested resource @{text "cs"} is nonempty, in which
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   950
  case,  the requesting thread @{text "th"} will be blocked
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   951
  on @{text "cs"}: 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   952
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   953
  Peculiar properties will be derived under respective 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   954
  locales.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   955
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   956
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   957
locale valid_trace_p_h = valid_trace_p +
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   958
  assumes we: "wq s cs = []"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   959
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   960
locale valid_trace_p_w = valid_trace_p +
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   961
  assumes wne: "wq s cs \<noteq> []"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   962
begin
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   963
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   964
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   965
  The following @{text "holder"} designates
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   966
  the holder of @{text "cs"} before the @{text "P"}-operation.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   967
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   968
definition "holder = hd (wq s cs)"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   969
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   970
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   971
  The following @{text "waiters"} designates
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   972
  the list of threads waiting for @{text "cs"} 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   973
  before the @{text "P"}-operation.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   974
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   975
definition "waiters = tl (wq s cs)"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   976
end
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   977
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   978
text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   979
  @{text "valid_trace_v"} is set for the @{term V}-operation.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   980
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   981
locale valid_trace_v = valid_trace_e + 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   982
  fixes th cs
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   983
  assumes is_v: "e = V th cs"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   984
begin
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   985
  -- {* The following @{text "rest"} is the tail of 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   986
        waiting queue of the resource @{text "cs"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   987
        to be released by this @{text "V"}-operation.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   988
     *}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   989
  definition "rest = tl (wq s cs)"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   990
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   991
  text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   992
    The following @{text "wq'"} is the waiting
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   993
    queue of @{term "cs"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   994
    after the @{text "V"}-operation, which
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   995
    is simply a reordering of @{term "rest"}. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   996
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   997
    The effect of this reordering needs to be 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   998
    understood by two cases:
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   999
    \begin{enumerate}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1000
    \item When @{text "rest = []"},
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1001
    the reordering gives rise to an empty list as well, 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1002
    which means there is no thread holding or waiting 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1003
    for resource @{term "cs"}, therefore, it is free.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1004
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1005
    \item When @{text "rest \<noteq> []"}, the effect of 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1006
    this reordering is to arbitrarily 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1007
    switch one thread in @{term "rest"} to the 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1008
    head, which, by definition take over the hold
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1009
    of @{term "cs"} and is designated by @{text "taker"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1010
    in the following sublocale @{text "valid_trace_v_n"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1011
  *}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1012
  definition "wq' = (SOME q. distinct q \<and> set q = set rest)"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1013
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1014
  text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1015
  The following @{text "rest'"} is the tail of the 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1016
  waiting queue after the @{text "V"}-operation. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1017
  It plays only auxiliary role to ease reasoning. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1018
  *}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1019
  definition "rest' = tl wq'"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1020
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1021
end
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1022
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1023
text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1024
  In the following, @{text "valid_trace_v"} is also 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1025
  divided into two 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1026
  sublocales: when @{text "rest"} is empty (represented
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1027
  by @{text "valid_trace_v_e"}), which means, there is no thread waiting 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1028
  for @{text "cs"}, therefore, after the @{text "V"}-operation, 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1029
  it will become free; otherwise (represented 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1030
  by @{text "valid_trace_v_n"}), one thread 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1031
  will be picked from those in @{text "rest"} to take 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1032
  over @{text "cs"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1033
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1034
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1035
locale valid_trace_v_e = valid_trace_v +
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1036
  assumes rest_nil: "rest = []"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1037
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1038
locale valid_trace_v_n = valid_trace_v +
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1039
  assumes rest_nnl: "rest \<noteq> []"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1040
begin
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1041
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1042
text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1043
  The following @{text "taker"} is the thread to 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1044
  take over @{text "cs"}. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1045
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1046
  definition "taker = hd wq'"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1047
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1048
end
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1049
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1050
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1051
locale valid_trace_set = valid_trace_e + 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1052
  fixes th prio
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1053
  assumes is_set: "e = Set th prio"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1054
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1055
context valid_trace
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1056
begin
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1057
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1058
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1059
  Induction rule introduced to easy the 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1060
  derivation of properties for valid trace @{term "s"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1061
  One more premises, namely @{term "valid_trace_e s e"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1062
  is added, so that an interpretation of 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1063
  @{text "valid_trace_e"} can be instantiated 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1064
  so that all properties derived so far becomes 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1065
  available in the proof of induction step.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1066
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1067
  You will see its use in the proofs that follows.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1068
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1069
lemma ind [consumes 0, case_names Nil Cons, induct type]:
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1070
  assumes "PP []"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1071
     and "(\<And>s e. valid_trace_e s e \<Longrightarrow>
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1072
                   PP s \<Longrightarrow> PIP s e \<Longrightarrow> PP (e # s))"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1073
     shows "PP s"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1074
proof(induct rule:vt.induct[OF vt, case_names Init Step])
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1075
  case Init
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1076
  from assms(1) show ?case .
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1077
next
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1078
  case (Step s e)
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1079
  show ?case
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1080
  proof(rule assms(2))
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1081
    show "valid_trace_e s e" using Step by (unfold_locales, auto)
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1082
  next
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1083
    show "PP s" using Step by simp
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1084
  next
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1085
    show "PIP s e" using Step by simp
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1086
  qed
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1087
qed
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1088
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1089
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1090
lemma finite_threads:
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1091
  shows "finite (threads s)"
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1092
  using vt by (induct) (auto elim: step.cases)
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1093
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1094
lemma  finite_readys: "finite (readys s)"
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1095
  using finite_threads readys_threads rev_finite_subset by blast
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1096
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1097
end
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1098
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1099
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1100
section {* Waiting queues are distinct *}
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1101
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1102
text {*
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1103
  This section proves that every waiting queue in the system
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1104
  is distinct, given in lemma @{text wq_distinct}.
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1105
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1106
  The proof is split into the locales for events (or operations),
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1107
  all contain a lemma named @{text "wq_distinct_kept"} to show that
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1108
  the distinctiveness is preserved by the respective operation. All lemmas
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1109
  before are to facilitate the proof of @{text "wq_distinct_kept"}.
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1110
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1111
  The proof also demonstrates the common pattern to prove
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1112
  invariant properties over valid traces, i.e. to spread the 
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1113
  invariant proof into locales and to assemble the results of all 
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1114
  locales to complete the final proof.
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1115
  
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1116
*}
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1117
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: 90
diff changeset
  1118
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: 90
diff changeset
  1119
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1120
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1121
lemma wq_kept [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: 90
diff changeset
  1122
  shows "wq (e#s) cs' = wq s 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: 90
diff changeset
  1123
    using assms unfolding is_create wq_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: 90
diff changeset
  1124
  by (auto simp:Let_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: 90
diff changeset
  1125
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1126
lemma wq_distinct_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1127
  assumes "distinct (wq s 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: 90
diff changeset
  1128
  shows "distinct (wq (e#s) 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: 90
diff changeset
  1129
  using assms 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: 90
diff changeset
  1130
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1131
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1132
context valid_trace_exit
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1133
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1134
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1135
lemma wq_kept [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: 90
diff changeset
  1136
  shows "wq (e#s) cs' = wq s 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: 90
diff changeset
  1137
    using assms unfolding is_exit wq_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: 90
diff changeset
  1138
  by (auto simp:Let_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: 90
diff changeset
  1139
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1140
lemma wq_distinct_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1141
  assumes "distinct (wq s 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: 90
diff changeset
  1142
  shows "distinct (wq (e#s) 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: 90
diff changeset
  1143
  using assms 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: 90
diff changeset
  1144
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1145
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1146
context valid_trace_p 
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: 90
diff changeset
  1147
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1148
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1149
lemma wq_neq_simp [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: 90
diff changeset
  1150
  assumes "cs' \<noteq> 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: 90
diff changeset
  1151
  shows "wq (e#s) cs' = wq s 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: 90
diff changeset
  1152
    using assms unfolding is_p wq_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: 90
diff changeset
  1153
  by (auto simp:Let_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: 90
diff changeset
  1154
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1155
lemma running_th_s:
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1156
  shows "th \<in> running 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: 90
diff changeset
  1157
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: 90
diff changeset
  1158
  from pip_e[unfolded is_p]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1159
  show ?thesis by (cases, 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: 90
diff changeset
  1160
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1161
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1162
lemma th_not_in_wq: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1163
  shows "th \<notin> set (wq s 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: 90
diff changeset
  1164
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: 90
diff changeset
  1165
  assume otherwise: "th \<in> set (wq s cs)"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1166
  from running_wqE[OF running_th_s 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: 90
diff changeset
  1167
  obtain rest where eq_wq: "wq s cs = th#rest" by blast
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1168
  with otherwise
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1169
  have "holding s th cs"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1170
    unfolding s_holding_def by 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: 90
diff changeset
  1171
  hence cs_th_RAG: "(Cs cs, Th th) \<in> RAG s"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1172
    by (unfold s_RAG_def, fold s_holding_abv, 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: 90
diff changeset
  1173
  from pip_e[unfolded is_p]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1174
  show False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1175
  proof(cases)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1176
    case (thread_P)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1177
    with cs_th_RAG show ?thesis 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: 90
diff changeset
  1178
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1179
qed
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1180
                  
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: 90
diff changeset
  1181
lemma wq_es_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: 90
diff changeset
  1182
  "wq (e#s) cs =  wq s cs @ [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: 90
diff changeset
  1183
  by (unfold is_p wq_def, auto simp:Let_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: 90
diff changeset
  1184
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1185
lemma wq_distinct_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1186
  assumes "distinct (wq s 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: 90
diff changeset
  1187
  shows "distinct (wq (e#s) 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: 90
diff changeset
  1188
proof(cases "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: 90
diff changeset
  1189
  case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1190
  show ?thesis using True assms th_not_in_wq
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1191
    by (unfold True wq_es_cs, 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: 90
diff changeset
  1192
qed (insert assms, 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: 90
diff changeset
  1193
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1194
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1195
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1196
context valid_trace_v
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1197
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1198
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1199
lemma wq_neq_simp [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: 90
diff changeset
  1200
  assumes "cs' \<noteq> 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: 90
diff changeset
  1201
  shows "wq (e#s) cs' = wq s 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: 90
diff changeset
  1202
    using assms unfolding is_v wq_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: 90
diff changeset
  1203
  by (auto simp:Let_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: 90
diff changeset
  1204
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1205
lemma wq_s_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: 90
diff changeset
  1206
  "wq s cs = th#rest"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1207
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: 90
diff changeset
  1208
  from pip_e[unfolded is_v]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1209
  show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1210
  proof(cases)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1211
    case (thread_V)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1212
    from this(2) show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1213
      unfolding s_holding_def
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1214
      by (metis empty_iff empty_set hd_Cons_tl rest_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: 90
diff changeset
  1215
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1216
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1217
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1218
lemma wq_es_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: 90
diff changeset
  1219
  "wq (e#s) cs = wq'"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1220
 using wq_s_cs[unfolded wq_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: 90
diff changeset
  1221
 by (auto simp:Let_def wq_def rest_def wq'_def is_v, 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: 90
diff changeset
  1222
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1223
lemma wq_distinct_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1224
  assumes "distinct (wq s 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: 90
diff changeset
  1225
  shows "distinct (wq (e#s) 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: 90
diff changeset
  1226
proof(cases "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: 90
diff changeset
  1227
  case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1228
  show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1229
  proof(unfold True wq_es_cs wq'_def, rule someI2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1230
    show "distinct rest \<and> set rest = set rest"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1231
        using assms[unfolded True wq_s_cs] 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: 90
diff changeset
  1232
  qed 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: 90
diff changeset
  1233
qed (insert assms, 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: 90
diff changeset
  1234
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1235
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1236
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1237
context valid_trace_set
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1238
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1239
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1240
lemma wq_kept [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: 90
diff changeset
  1241
  shows "wq (e#s) cs' = wq s 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: 90
diff changeset
  1242
    using assms unfolding is_set wq_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: 90
diff changeset
  1243
  by (auto simp:Let_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: 90
diff changeset
  1244
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1245
lemma wq_distinct_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1246
  assumes "distinct (wq s 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: 90
diff changeset
  1247
  shows "distinct (wq (e#s) 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: 90
diff changeset
  1248
  using assms 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: 90
diff changeset
  1249
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1250
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1251
context valid_trace
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1252
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1253
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1254
text {*
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1255
  The proof of @{text "wq_distinct"} shows how the results 
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1256
  proved in the foregoing locales are assembled in
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1257
  a overall structure of induction and case analysis
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1258
  to get the final conclusion. This scheme will be 
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1259
  used repeatedly in the following.
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1260
*}
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1261
lemma wq_distinct: "distinct (wq s cs)"
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 67
diff changeset
  1262
proof(induct rule:ind)
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 67
diff changeset
  1263
  case (Cons s e)
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1264
  interpret vt_e: valid_trace_e s e using Cons by simp
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 67
diff changeset
  1265
  show ?case 
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1266
  proof(cases e)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1267
    case (Create th prio)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1268
    interpret vt_create: valid_trace_create s e th prio 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1269
      using Create by (unfold_locales, simp)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1270
    show ?thesis using Cons by (simp add: vt_create.wq_distinct_kept) 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1271
  next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1272
    case (Exit th)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1273
    interpret vt_exit: valid_trace_exit s e th  
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1274
        using Exit by (unfold_locales, simp)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1275
    show ?thesis using Cons by (simp add: vt_exit.wq_distinct_kept) 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1276
  next
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1277
    case (P th cs)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1278
    interpret vt_p: valid_trace_p s e th cs using P by (unfold_locales, simp)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1279
    show ?thesis using Cons by (simp add: vt_p.wq_distinct_kept) 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1280
  next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1281
    case (V th cs)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1282
    interpret vt_v: valid_trace_v s e th cs using V by (unfold_locales, simp)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1283
    show ?thesis using Cons by (simp add: vt_v.wq_distinct_kept) 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1284
  next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1285
    case (Set th prio)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1286
    interpret vt_set: valid_trace_set s e th prio
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1287
        using Set by (unfold_locales, simp)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1288
    show ?thesis using Cons by (simp add: vt_set.wq_distinct_kept) 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1289
  qed
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 67
diff changeset
  1290
qed (unfold wq_def Let_def, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1291
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1292
end
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1293
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1294
section {* Waiting queues and threads *}
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1295
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1296
text {*
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1297
  This section shows that all threads withing waiting queues are
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1298
  in the @{term threads}-set. In other words, @{term threads} covers
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1299
  all the threads in waiting queue.
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1300
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1301
  The proof follows the same pattern as @{thm valid_trace.wq_distinct}.
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1302
  The desired property is shown to be kept by all operations (or events)
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1303
  in their respective locales, and finally the main lemmas is 
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1304
  derived by assembling the invariant keeping results of the locales. 
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1305
*}
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1306
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1307
context valid_trace_create
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1308
begin
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1309
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1310
lemma 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1311
  th_not_in_threads: "th \<notin> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1312
proof -
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1313
  from pip_e[unfolded is_create]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1314
  show ?thesis by (cases, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1315
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1316
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1317
lemma 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1318
  threads_es [simp]: "threads (e#s) = threads s \<union> {th}"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1319
  by (unfold is_create, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1320
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1321
lemma wq_threads_kept:
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1322
  assumes "\<And> th' cs'. th' \<in> set (wq s cs') \<Longrightarrow> th' \<in> threads s"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1323
  and "th' \<in> set (wq (e#s) cs')"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1324
  shows "th' \<in> threads (e#s)"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1325
proof -
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1326
  have "th' \<in> threads s"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1327
  proof -
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1328
    from assms(2)[unfolded wq_kept]
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1329
    have "th' \<in> set (wq s cs')" .
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1330
    from assms(1)[OF this] show ?thesis .
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1331
  qed
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1332
  with threads_es show ?thesis by simp
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1333
qed
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1334
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1335
end
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1336
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1337
context valid_trace_exit
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1338
begin
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1339
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1340
lemma threads_es [simp]: "threads (e#s) = threads s - {th}"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1341
  by (unfold is_exit, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1342
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1343
lemma 
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1344
  th_not_in_wq: "th \<notin> set (wq s cs)"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1345
proof -
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1346
  from pip_e[unfolded is_exit]
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1347
  show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1348
  apply(cases)
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1349
  unfolding holdents_def s_holding_def
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1350
  by (metis (mono_tags, lifting) empty_iff list.sel(1) mem_Collect_eq running_wqE)
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1351
qed
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1352
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1353
lemma wq_threads_kept:
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1354
  assumes "\<And> th' cs'. th' \<in> set (wq s cs') \<Longrightarrow> th' \<in> threads s"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1355
  and "th' \<in> set (wq (e#s) cs')"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1356
  shows "th' \<in> threads (e#s)"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1357
proof -
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1358
  have "th' \<in> threads s"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1359
  proof -
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1360
    from assms(2)[unfolded wq_kept]
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1361
    have "th' \<in> set (wq s cs')" .
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1362
    from assms(1)[OF this] show ?thesis .
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1363
  qed
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1364
  moreover have "th' \<noteq> th"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1365
  proof
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1366
    assume otherwise: "th' = th"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1367
    from assms(2)[unfolded wq_kept]
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1368
    have "th' \<in> set (wq s cs')" .
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1369
    with th_not_in_wq[folded otherwise]
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1370
    show False by simp
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1371
  qed
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1372
  ultimately show ?thesis
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1373
    by (unfold threads_es, simp)
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1374
qed
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1375
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1376
end
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1377
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1378
context valid_trace_v
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1379
begin
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1380
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1381
lemma 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1382
  threads_es [simp]: "threads (e#s) = threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1383
  by (unfold is_v, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1384
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1385
lemma 
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1386
  th_not_in_rest: "th \<notin> set rest"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1387
proof
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1388
  assume otherwise: "th \<in> set rest"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1389
  have "distinct (wq s cs)" by (simp add: wq_distinct)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1390
  from this[unfolded wq_s_cs] and otherwise
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1391
  show False by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1392
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1393
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1394
lemma distinct_rest: "distinct rest"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1395
  by (simp add: distinct_tl rest_def wq_distinct)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1396
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1397
lemma
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1398
  set_wq_es_cs [simp]: "set (wq (e#s) cs) = set (wq s cs) - {th}"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1399
proof(unfold wq_es_cs wq'_def, rule someI2)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1400
  show "distinct rest \<and> set rest = set rest"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1401
    by (simp add: distinct_rest) 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1402
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1403
  fix x
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1404
  assume "distinct x \<and> set x = set rest"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1405
  thus "set x = set (wq s cs) - {th}" 
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1406
      by (unfold wq_s_cs, simp add:th_not_in_rest)
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1407
qed
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1408
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1409
lemma wq_threads_kept:
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1410
  assumes "\<And> th' cs'. th' \<in> set (wq s cs') \<Longrightarrow> th' \<in> threads s"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1411
  and "th' \<in> set (wq (e#s) cs')"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1412
  shows "th' \<in> threads (e#s)"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1413
proof(cases "cs' = cs")
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1414
  case True
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1415
  have " th' \<in> threads s"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1416
  proof -
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1417
    from assms(2)[unfolded True set_wq_es_cs]
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1418
    have "th' \<in> set (wq s cs) - {th}" .
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1419
    hence "th' \<in> set (wq s cs)" by simp
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1420
    from assms(1)[OF this]
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1421
    show ?thesis .
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1422
  qed
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1423
  with threads_es show ?thesis by simp
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1424
next
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1425
    case False
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1426
    have "th' \<in> threads s"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1427
    proof -
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1428
      from wq_neq_simp[OF False]
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1429
      have "wq (e # s) cs' = wq s cs'" .
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1430
      from assms(2)[unfolded this]
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1431
      have "th' \<in> set (wq s cs')" .
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1432
      from assms(1)[OF this]
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1433
      show ?thesis .
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1434
    qed
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1435
    with threads_es show ?thesis by simp
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1436
qed
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1437
end
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1438
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1439
context valid_trace_p
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1440
begin
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1441
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1442
lemma threads_es [simp]: "threads (e#s) = threads s"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1443
  by (unfold is_p, simp)
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1444
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1445
lemma ready_th_s: "th \<in> readys s"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1446
  using running_th_s
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1447
  by (unfold running_def, auto)
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1448
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1449
lemma live_th_s: "th \<in> threads s"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1450
  using readys_threads ready_th_s by auto
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1451
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1452
lemma wq_threads_kept:
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1453
  assumes "\<And> th' cs'. th' \<in> set (wq s cs') \<Longrightarrow> th' \<in> threads s"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1454
  and "th' \<in> set (wq (e#s) cs')"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1455
  shows "th' \<in> threads (e#s)"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1456
proof(cases "cs' = cs")
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1457
    case True
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1458
    from assms(2)[unfolded True wq_es_cs]
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1459
    have "th' \<in> set (wq s cs) \<or> th' = th" by auto
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1460
    thus ?thesis
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1461
    proof
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1462
      assume "th' \<in> set (wq s cs)"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1463
      from assms(1)[OF this] have "th' \<in> threads s" .
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1464
      with threads_es
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1465
      show ?thesis by simp
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1466
    next
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1467
      assume "th' = th"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1468
      with live_th_s have "th' \<in> threads s" by simp
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1469
      with threads_es show ?thesis by simp
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1470
    qed
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1471
next
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1472
    case False
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1473
    have "th' \<in> threads s"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1474
    proof -
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1475
      from wq_neq_simp[OF False]
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1476
      have "wq (e # s) cs' = wq s cs'" .
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1477
      from assms(2)[unfolded this]
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1478
      have "th' \<in> set (wq s cs')" .
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1479
      from assms(1)[OF this]
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1480
      show ?thesis .
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1481
    qed
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1482
    with threads_es show ?thesis by simp
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1483
qed
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1484
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1485
end
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1486
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1487
context valid_trace_set
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1488
begin
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1489
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1490
lemma threads_kept[simp]:
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1491
  "threads (e#s) = threads s"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1492
  by (unfold is_set, simp)
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1493
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1494
lemma wq_threads_kept: 
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1495
  assumes "\<And> th' cs'. th' \<in> set (wq s cs') \<Longrightarrow> th' \<in> threads s"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1496
  and "th' \<in> set (wq (e#s) cs')"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1497
  shows "th' \<in> threads (e#s)"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1498
proof -
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1499
  have "th' \<in> threads s"
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1500
     using assms(1)[OF assms(2)[unfolded wq_kept]] .
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1501
  with threads_kept show ?thesis by simp
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1502
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1503
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1504
end
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1505
129
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  1506
context valid_trace
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  1507
begin
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  1508
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1509
text {*
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1510
  The is the main lemma of this section, which is derived
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1511
  by induction, case analysis on event @{text e} and 
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1512
  assembling the @{text "wq_threads_kept"}-results of 
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1513
  all possible cases of @{text "e"}.
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1514
*}
129
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  1515
lemma wq_threads: 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1516
  assumes "th \<in> set (wq s cs)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1517
  shows "th \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1518
  using assms
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1519
proof(induct arbitrary:th cs rule:ind)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1520
  case (Nil)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1521
  thus ?case by (auto simp:wq_def)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1522
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1523
  case (Cons s e)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1524
  interpret vt_e: valid_trace_e s e using Cons by simp
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1525
  show ?case
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1526
  proof(cases e)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1527
    case (Create th' prio')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1528
    interpret vt: valid_trace_create s e th' prio'
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1529
      using Create by (unfold_locales, simp)
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1530
    show ?thesis using vt.wq_threads_kept Cons by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1531
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1532
    case (Exit th')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1533
    interpret vt: valid_trace_exit s e th'
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1534
      using Exit by (unfold_locales, simp)
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1535
    show ?thesis using vt.wq_threads_kept Cons by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1536
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1537
    case (P th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1538
    interpret vt: valid_trace_p s e th' cs'
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1539
      using P by (unfold_locales, simp)
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1540
   show ?thesis using vt.wq_threads_kept Cons by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1541
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1542
    case (V th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1543
    interpret vt: valid_trace_v s e th' cs'
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1544
      using V by (unfold_locales, simp)
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1545
   show ?thesis using vt.wq_threads_kept Cons by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1546
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1547
    case (Set th' prio)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1548
    interpret vt: valid_trace_set s e th' prio
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1549
      using Set by (unfold_locales, simp)
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1550
   show ?thesis using vt.wq_threads_kept Cons by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1551
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1552
qed 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1553
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1554
subsection {* RAG and threads *}
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 67
diff changeset
  1555
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1556
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1557
text {*
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1558
  As corollaries of @{thm wq_threads}, it is shown in this subsection
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1559
  that the fields (including both domain
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1560
  and range) of @{term RAG} are covered by @{term threads}.
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1561
*}
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1562
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1563
lemma  dm_RAG_threads:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1564
  assumes in_dom: "(Th th) \<in> Domain (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1565
  shows "th \<in> threads s"
104
43482ab31341 A fake merge. Used to revert to 98
zhangx
parents: 103 97
diff changeset
  1566
proof -
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1567
  from in_dom obtain n where "(Th th, n) \<in> RAG s" by auto
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1568
  moreover then obtain cs where "n = Cs cs" by (unfold s_RAG_def, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1569
  ultimately have "(Th th, Cs cs) \<in> RAG s" by simp
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1570
  then have "th \<in> set (wq s cs)"
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1571
    using in_RAG_E s_waiting_def wq_def by auto
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1572
  then show ?thesis using wq_threads by simp
104
43482ab31341 A fake merge. Used to revert to 98
zhangx
parents: 103 97
diff changeset
  1573
qed
43482ab31341 A fake merge. Used to revert to 98
zhangx
parents: 103 97
diff changeset
  1574
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1575
lemma dm_tG_threads: 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1576
  assumes "th \<in> Domain (tG s)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1577
  shows "th \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1578
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1579
  from assms[unfolded tG_alt_def]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1580
  have "(Th th) \<in> Domain (RAG s)" by (unfold Domain_def, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1581
  from dm_RAG_threads[OF this] show ?thesis .
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1582
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1583
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1584
lemma rg_RAG_threads: 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1585
  assumes "(Th th) \<in> Range (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1586
  shows "th \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1587
  using assms
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1588
  apply(erule_tac RangeE)
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1589
  apply(erule_tac in_RAG_E)
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1590
  apply(auto)
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1591
  using s_holding_def wq_def wq_threads by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1592
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1593
lemma rg_tG_threads: 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1594
  assumes "th \<in> Range (tG s)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1595
  shows "th \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1596
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1597
  from assms[unfolded tG_alt_def]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1598
  have "(Th th) \<in> Range (RAG s)" by (unfold Range_def, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1599
  from rg_RAG_threads[OF this] show ?thesis .
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1600
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1601
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1602
lemma RAG_threads:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1603
  assumes "(Th th) \<in> Field (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1604
  shows "th \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1605
  using assms
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1606
  by (metis Field_def UnE dm_RAG_threads rg_RAG_threads)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1607
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1608
lemma tG_threads:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1609
  assumes "th \<in> Field (tG s)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1610
  shows "th \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1611
  using assms
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1612
  by (metis Field_def UnE dm_tG_threads rg_tG_threads)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1613
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  1614
lemma not_in_thread_isolated:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  1615
  assumes "th \<notin> threads s"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  1616
  shows "(Th th) \<notin> Field (RAG s)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  1617
  using RAG_threads assms by auto
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  1618
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1619
lemma not_in_thread_isolated_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1620
  assumes "th \<notin> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1621
  shows "th \<notin> Field (tG s)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1622
  using assms
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1623
  using tG_threads by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1624
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1625
text {*
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1626
  As a corollary, this lemma shows that @{term tRAG}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1627
  is also covered by the @{term threads}-set.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1628
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1629
lemma subtree_tRAG_thread:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1630
  assumes "th \<in> threads s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1631
  shows "subtree (tRAG s) (Th th) \<subseteq> Th ` threads s" (is "?L \<subseteq> ?R")
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1632
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1633
  have "?L = {Th th' |th'. Th th' \<in> subtree (RAG s) (Th th)}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1634
    by (unfold tRAG_subtree_eq, simp)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1635
  also have "... \<subseteq> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1636
  proof
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1637
    fix x
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1638
    assume "x \<in> {Th th' |th'. Th th' \<in> subtree (RAG s) (Th th)}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1639
    then obtain th' where h: "x = Th th'" "Th th' \<in> subtree (RAG s) (Th th)" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1640
    from this(2)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1641
    show "x \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1642
    proof(cases rule:subtreeE)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1643
      case 1
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1644
      thus ?thesis by (simp add: assms h(1)) 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1645
    next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1646
      case 2
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1647
      thus ?thesis by (metis ancestors_Field dm_RAG_threads h(1) image_eqI) 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1648
    qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1649
  qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1650
  finally show ?thesis .
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1651
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1652
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1653
lemma subtree_tG_thread:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1654
  assumes "th \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1655
  shows "subtree (tG s) th \<subseteq> threads s" (is "?L \<subseteq> ?R")
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1656
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1657
  from subtree_tRAG_thread[OF assms]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1658
  have "subtree (tRAG s) (Th th) \<subseteq> Th ` threads s" .
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1659
  from this[unfolded subtree_tRAG_tG]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1660
  have " Th ` subtree (tG s) th \<subseteq> Th ` threads s" .
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1661
  thus ?thesis by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1662
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1663
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1664
end
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1665
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1666
section {* The formation of @{term RAG} *}
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1667
53
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  1668
text {*
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1669
  The whole of PIP resides on the understanding of the formation
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1670
  of @{term RAG}. We are going to show that @{term RAG}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1671
  forms a finite branching forest. The formalization is divided 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1672
  into a series of subsections.
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1673
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1674
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1675
subsection {* The change of @{term RAG} with each step of execution *}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1676
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1677
text {*
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1678
  The very essence to prove that @{term RAG} has a certain property is to 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1679
  show that this property is preserved as an invariant by the execution 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1680
  of the system, and the basis for such kind of invariant proofs is to 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1681
  show how @{term RAG} is changed with the execution of every execution step
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1682
  (or event, or system operation). In this subsection,
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1683
  the effect of every event on @{text RAG} is derived in its respective
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1684
  locale named @{text "RAG_es"} with all lemmas before auxiliary. 
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1685
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1686
  These derived @{text "RAG_es"}s constitute the foundation 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1687
  to show the various well-formed properties of @{term RAG},  
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1688
  for example, @{term RAG} is finite, acyclic, and single-valued, etc.
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1689
*}
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1690
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1691
text {*
53
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  1692
  The following three lemmas show that @{text "RAG"} does not change
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  1693
  by the happening of @{text "Set"}, @{text "Create"} and @{text "Exit"}
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  1694
  events, respectively.
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  1695
*}
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  1696
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1697
lemma (in valid_trace_set) RAG_es [simp]: "(RAG (e # s)) = RAG s"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1698
   by (unfold is_set s_RAG_def s_waiting_def wq_def, simp add:Let_def)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1699
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1700
lemma (in valid_trace_create) RAG_es [simp]: "(RAG (e # s)) = RAG s"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1701
 by (unfold is_create s_RAG_def s_waiting_def wq_def, simp add:Let_def)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1702
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1703
lemma (in valid_trace_exit) RAG_es[simp]: "(RAG (e # s)) = RAG s"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1704
  by (unfold is_exit s_RAG_def s_waiting_def wq_def, simp add:Let_def)
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1705
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: 90
diff changeset
  1706
context valid_trace_v
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1707
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1708
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1709
lemma holding_cs_eq_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: 90
diff changeset
  1710
  assumes "holding s t 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: 90
diff changeset
  1711
  shows "t = th"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1712
proof -
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1713
  from pip_e[unfolded is_v]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1714
  show ?thesis
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1715
  proof(cases)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1716
    case (thread_V)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1717
    from held_unique[OF this(2) assms]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1718
    show ?thesis by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1719
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1720
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1721
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: 90
diff changeset
  1722
lemma distinct_wq': "distinct wq'"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1723
  by (metis (mono_tags, lifting) distinct_rest  some_eq_ex wq'_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: 90
diff changeset
  1724
  
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1725
lemma set_wq': "set wq' = set rest"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1726
  by (metis (mono_tags, lifting) distinct_rest some_eq_ex wq'_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: 90
diff changeset
  1727
    
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1728
lemma th'_in_inv:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1729
  assumes "th' \<in> set wq'"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1730
  shows "th' \<in> set rest"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1731
  using assms set_wq' 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: 90
diff changeset
  1732
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1733
lemma running_th_s:
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1734
  shows "th \<in> running s"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1735
proof -
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1736
  from pip_e[unfolded is_v]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1737
  show ?thesis by (cases, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1738
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1739
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: 90
diff changeset
  1740
lemma neq_t_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: 90
diff changeset
  1741
  assumes "waiting (e#s) t c"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1742
  shows "t \<noteq> 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: 90
diff changeset
  1743
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: 90
diff changeset
  1744
  assume otherwise: "t = 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: 90
diff changeset
  1745
  show False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1746
  proof(cases "c = cs")
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1747
    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: 90
diff changeset
  1748
    have "t \<in> set wq'" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1749
     using assms[unfolded True s_waiting_def, folded wq_def, unfolded wq_es_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: 90
diff changeset
  1750
     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: 90
diff changeset
  1751
    from th'_in_inv[OF this] have "t \<in> set rest" .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1752
    with wq_s_cs[folded otherwise] wq_distinct[of 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: 90
diff changeset
  1753
    show ?thesis 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: 90
diff changeset
  1754
  next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1755
    case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1756
    have "wq (e#s) c = wq s c" using False
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1757
        by simp
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1758
    hence "waiting s t c" using assms
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1759
        by (simp add: s_waiting_def wq_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: 90
diff changeset
  1760
    hence "t \<notin> readys s" by (unfold readys_def, auto)
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1761
    hence "t \<notin> running s" using running_ready by auto 
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1762
    with running_th_s[folded otherwise] show ?thesis by 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: 90
diff changeset
  1763
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1764
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1765
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1766
lemma waiting_esI1:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1767
  assumes "waiting s t c"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1768
      and "c \<noteq> cs" 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1769
  shows "waiting (e#s) t c" 
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: 90
diff changeset
  1770
proof -
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1771
  have "wq (e#s) c = wq s c" 
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1772
    using assms(2) by auto
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1773
  with assms(1) show ?thesis
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1774
    by (simp add: s_waiting_def wq_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: 90
diff changeset
  1775
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1776
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1777
lemma holding_esI2:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1778
  assumes "c \<noteq> cs" 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1779
  and "holding s t c"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1780
  shows "holding (e#s) t c"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1781
proof -
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1782
  from assms(1) have "wq (e#s) c = wq s c"  by auto
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1783
  from assms(2)[unfolded s_holding_def, folded wq_def, 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1784
                folded this, folded s_holding_def]
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1785
  show ?thesis .
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1786
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1787
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1788
lemma holding_esI1:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1789
  assumes "holding s t c"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1790
  and "t \<noteq> th"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1791
  shows "holding (e#s) t c"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1792
proof -
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1793
  have "c \<noteq> cs" using assms using holding_cs_eq_th by blast 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1794
  from holding_esI2[OF this assms(1)]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1795
  show ?thesis .
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1796
qed
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1797
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: 90
diff changeset
  1798
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1799
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1800
context valid_trace_v_n
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1801
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1802
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1803
lemma neq_wq': "wq' \<noteq> []" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1804
proof (unfold wq'_def, rule someI2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1805
  show "distinct rest \<and> set rest = set rest"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1806
    by (simp add: distinct_rest) 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1807
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1808
  fix 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: 90
diff changeset
  1809
  assume " distinct x \<and> set x = set rest" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1810
  thus "x \<noteq> []" using rest_nnl 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: 90
diff changeset
  1811
qed 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1812
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1813
lemma eq_wq': "wq' = taker # rest'"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1814
  by (simp add: neq_wq' rest'_def taker_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: 90
diff changeset
  1815
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1816
lemma next_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: 90
diff changeset
  1817
  shows "next_th s th cs 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: 90
diff changeset
  1818
  using rest_nnl taker_def wq'_def wq_s_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: 90
diff changeset
  1819
  by (auto simp:next_th_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: 90
diff changeset
  1820
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1821
lemma taker_unique: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1822
  assumes "next_th s th cs 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: 90
diff changeset
  1823
  shows "taker' = 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: 90
diff changeset
  1824
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: 90
diff changeset
  1825
  from 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: 90
diff changeset
  1826
  obtain rest' where 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1827
    h: "wq s cs = th # rest'" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1828
       "taker' = hd (SOME q. distinct q \<and> set q = set rest')"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1829
          by (unfold next_th_def, 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: 90
diff changeset
  1830
  with wq_s_cs have "rest' = rest" 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: 90
diff changeset
  1831
  thus ?thesis using h(2) taker_def wq'_def 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: 90
diff changeset
  1832
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1833
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1834
lemma waiting_set_eq:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1835
  "{(Th th', Cs cs) |th'. next_th s th cs 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: 90
diff changeset
  1836
  by (smt all_not_in_conv bot.extremum insertI1 insert_subset 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1837
      mem_Collect_eq next_th_taker subsetI subset_antisym taker_def taker_unique)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1838
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1839
lemma holding_set_eq:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1840
  "{(Cs cs, Th th') |th'.  next_th s th cs th'} = {(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: 90
diff changeset
  1841
  using next_th_taker taker_def waiting_set_eq 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1842
  by fastforce
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1843
   
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1844
lemma holding_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: 90
diff changeset
  1845
  shows "holding (e#s) taker cs"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1846
    by (unfold s_holding_def, unfold wq_es_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: 90
diff changeset
  1847
        auto simp:neq_wq' taker_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: 90
diff changeset
  1848
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1849
lemma waiting_esI2:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1850
  assumes "waiting s t 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: 90
diff changeset
  1851
      and "t \<noteq> 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: 90
diff changeset
  1852
  shows "waiting (e#s) t cs" 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1853
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: 90
diff changeset
  1854
  have "t \<in> set wq'" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1855
  proof(unfold wq'_def, rule someI2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1856
    show "distinct rest \<and> set rest = set rest"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1857
          by (simp add: distinct_rest)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1858
  next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1859
    fix 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: 90
diff changeset
  1860
    assume "distinct x \<and> set x = set rest"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1861
    moreover have "t \<in> set rest"
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1862
        using assms(1) s_waiting_def set_ConsD wq_def wq_s_cs by 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: 90
diff changeset
  1863
    ultimately show "t \<in> set x" 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: 90
diff changeset
  1864
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1865
  moreover have "t \<noteq> hd wq'"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1866
    using assms(2) taker_def 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: 90
diff changeset
  1867
  ultimately show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1868
    by (unfold s_waiting_def, fold wq_def, unfold wq_es_cs, 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: 90
diff changeset
  1869
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1870
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1871
lemma waiting_esE:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1872
  assumes "waiting (e#s) t c" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1873
  obtains "c \<noteq> cs" "waiting s t c"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1874
     |    "c = cs" "t \<noteq> taker" "waiting s t cs" "t \<in> set rest'"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1875
proof(cases "c = 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: 90
diff changeset
  1876
  case False
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1877
  hence "wq (e#s) c = wq s c" by auto
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1878
  with assms have "waiting s t c"
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1879
    by (simp add: s_waiting_def wq_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: 90
diff changeset
  1880
  from that(1)[OF False this] show ?thesis .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1881
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1882
  case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1883
  from assms[unfolded s_waiting_def True, folded wq_def, unfolded wq_es_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: 90
diff changeset
  1884
  have "t \<noteq> hd wq'" "t \<in> set wq'" 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: 90
diff changeset
  1885
  hence "t \<noteq> taker" by (simp add: taker_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: 90
diff changeset
  1886
  moreover hence "t \<noteq> th" using assms neq_t_th by blast 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1887
  moreover have "t \<in> set rest" by (simp add: `t \<in> set wq'` th'_in_inv) 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1888
  ultimately have "waiting s t cs"
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1889
    by (metis list.sel(1) list.set_sel(2) list.simps(3) rest_def s_waiting_def wq_def wq_s_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: 90
diff changeset
  1890
  show ?thesis using that(2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1891
  using True `t \<in> set wq'` `t \<noteq> taker` `waiting s t cs` eq_wq' 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: 90
diff changeset
  1892
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1893
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1894
lemma holding_esI1:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1895
  assumes "c = 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: 90
diff changeset
  1896
  and "t = 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: 90
diff changeset
  1897
  shows "holding (e#s) t c"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1898
  by (unfold assms, simp add: holding_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: 90
diff changeset
  1899
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1900
lemma holding_esE:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1901
  assumes "holding (e#s) t c" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1902
  obtains "c = cs" "t = 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: 90
diff changeset
  1903
      | "c \<noteq> cs" "holding s t c"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1904
proof(cases "c = 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: 90
diff changeset
  1905
  case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1906
  from assms[unfolded True, unfolded s_holding_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: 90
diff changeset
  1907
             folded wq_def, unfolded wq_es_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: 90
diff changeset
  1908
  have "t = taker" by (simp add: taker_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: 90
diff changeset
  1909
  from that(1)[OF True this] show ?thesis .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1910
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1911
  case False
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1912
  hence "wq (e#s) c = wq s c" by 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: 90
diff changeset
  1913
  from assms[unfolded s_holding_def, folded wq_def, 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1914
             unfolded this, folded s_holding_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: 90
diff changeset
  1915
  have "holding s t c"  .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1916
  from that(2)[OF False this] show ?thesis .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1917
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1918
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1919
end 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1920
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1921
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1922
context valid_trace_v_e
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1923
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1924
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1925
lemma nil_wq': "wq' = []" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1926
proof (unfold wq'_def, rule someI2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1927
  show "distinct rest \<and> set rest = set rest"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1928
    by (simp add: distinct_rest) 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1929
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1930
  fix 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: 90
diff changeset
  1931
  assume " distinct x \<and> set x = set rest" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1932
  thus "x = []" using rest_nil 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: 90
diff changeset
  1933
qed 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1934
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1935
lemma no_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: 90
diff changeset
  1936
  assumes "next_th s th cs 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: 90
diff changeset
  1937
  shows "False"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1938
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: 90
diff changeset
  1939
  from assms[unfolded next_th_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: 90
diff changeset
  1940
  obtain rest' where "wq s cs = th # rest'" "rest' \<noteq> []"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1941
    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: 90
diff changeset
  1942
  thus ?thesis using rest_def rest_nil 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: 90
diff changeset
  1943
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1944
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1945
lemma waiting_set_eq:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1946
  "{(Th th', Cs cs) |th'. next_th s th cs 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: 90
diff changeset
  1947
  using no_taker 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: 90
diff changeset
  1948
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1949
lemma holding_set_eq:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1950
  "{(Cs cs, Th th') |th'.  next_th s th cs 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: 90
diff changeset
  1951
  using no_taker 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: 90
diff changeset
  1952
   
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1953
lemma no_holding:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1954
  assumes "holding (e#s) taker 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: 90
diff changeset
  1955
  shows False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1956
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: 90
diff changeset
  1957
  from wq_es_cs[unfolded nil_wq']
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1958
  have " wq (e # s) 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: 90
diff changeset
  1959
  from assms[unfolded s_holding_def, folded wq_def, unfolded this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1960
  show ?thesis 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: 90
diff changeset
  1961
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1962
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1963
lemma no_waiter_before: "\<not> waiting s t cs"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1964
proof
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1965
  assume otherwise: "waiting s t cs"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1966
  from this[unfolded s_waiting_def, folded wq_def, 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1967
            unfolded wq_s_cs rest_nil]
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1968
  show False by simp
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1969
qed
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1970
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1971
lemma no_waiter_after:
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: 90
diff changeset
  1972
  assumes "waiting (e#s) t 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: 90
diff changeset
  1973
  shows False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1974
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: 90
diff changeset
  1975
  from wq_es_cs[unfolded nil_wq']
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1976
  have " wq (e # s) 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: 90
diff changeset
  1977
  from assms[unfolded s_waiting_def, folded wq_def, unfolded this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1978
  show ?thesis 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: 90
diff changeset
  1979
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1980
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1981
lemma waiting_esI2:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1982
  assumes "waiting s t c"
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1983
  shows "waiting (e # s) t c"
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: 90
diff changeset
  1984
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: 90
diff changeset
  1985
  have "c \<noteq> cs" using assms
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1986
    using no_waiter_before by blast
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: 90
diff changeset
  1987
  from waiting_esI1[OF assms this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1988
  show ?thesis .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1989
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1990
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1991
lemma waiting_esE:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1992
  assumes "waiting (e#s) t c" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1993
  obtains "c \<noteq> cs" "waiting s t c"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1994
proof(cases "c = 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: 90
diff changeset
  1995
  case False
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1996
  hence "wq (e#s) c = wq s c"  by auto
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1997
  with assms have "waiting s t c"
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1998
    by (simp add: s_waiting_def wq_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: 90
diff changeset
  1999
  from that(1)[OF False this] show ?thesis .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2000
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2001
  case True
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  2002
  from no_waiter_after[OF assms[unfolded 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: 90
diff changeset
  2003
  show ?thesis 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: 90
diff changeset
  2004
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2005
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2006
lemma holding_esE:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2007
  assumes "holding (e#s) t c" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2008
  obtains "c \<noteq> cs" "holding s t c"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2009
proof(cases "c = 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: 90
diff changeset
  2010
  case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2011
  from no_holding[OF assms[unfolded True]] 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2012
  show ?thesis 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: 90
diff changeset
  2013
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2014
  case False
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  2015
  hence "wq (e#s) c = wq s c" by 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: 90
diff changeset
  2016
  from assms[unfolded s_holding_def, folded wq_def, 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2017
             unfolded this, folded s_holding_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: 90
diff changeset
  2018
  have "holding s t c"  .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2019
  from that[OF False this] show ?thesis .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2020
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2021
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2022
end 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2023
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2024
  
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2025
context valid_trace_v
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2026
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2027
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2028
lemma RAG_es:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2029
  "RAG (e # 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: 90
diff changeset
  2030
   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: 90
diff changeset
  2031
     {(Th th', Cs cs) |th'. next_th s th cs th'} \<union>
129
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  2032
     {(Cs cs, Th th') |th'. next_th s th cs th'}" (is "?L = ?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: 90
diff changeset
  2033
proof(rule rel_eqI)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2034
  fix n1 n2
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2035
  assume "(n1, n2) \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2036
  thus "(n1, n2) \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2037
  proof(cases rule:in_RAG_E)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2038
    case (waiting th' 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: 90
diff changeset
  2039
    show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2040
    proof(cases "rest = []")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2041
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2042
      interpret h_n: valid_trace_v_n s e th 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: 90
diff changeset
  2043
        by (unfold_locales, insert False, 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: 90
diff changeset
  2044
      from waiting(3)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2045
      show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2046
      proof(cases rule:h_n.waiting_esE)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2047
        case 1
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2048
        with waiting(1,2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2049
        show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2050
        by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2051
             fold s_waiting_abv, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2052
      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: 90
diff changeset
  2053
        case 2
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2054
        with waiting(1,2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2055
        show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2056
         by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2057
             fold s_waiting_abv, 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: 90
diff changeset
  2058
      qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2059
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2060
      case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2061
      interpret h_e: valid_trace_v_e s e th 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: 90
diff changeset
  2062
        by (unfold_locales, insert True, 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: 90
diff changeset
  2063
      from waiting(3)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2064
      show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2065
      proof(cases rule:h_e.waiting_esE)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2066
        case 1
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2067
        with waiting(1,2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2068
        show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2069
        by (unfold h_e.waiting_set_eq h_e.holding_set_eq s_RAG_def, 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2070
             fold s_waiting_abv, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2071
      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: 90
diff changeset
  2072
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2073
  next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2074
    case (holding th' 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: 90
diff changeset
  2075
    show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2076
    proof(cases "rest = []")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2077
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2078
      interpret h_n: valid_trace_v_n s e th 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: 90
diff changeset
  2079
        by (unfold_locales, insert False, 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: 90
diff changeset
  2080
      from holding(3)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2081
      show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2082
      proof(cases rule:h_n.holding_esE)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2083
        case 1
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2084
        with holding(1,2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2085
        show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2086
        by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2087
             fold s_waiting_abv, 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: 90
diff changeset
  2088
      next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2089
        case 2
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2090
        with holding(1,2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2091
        show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2092
         by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2093
             fold s_holding_abv, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2094
      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: 90
diff changeset
  2095
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2096
      case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2097
      interpret h_e: valid_trace_v_e s e th 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: 90
diff changeset
  2098
        by (unfold_locales, insert True, 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: 90
diff changeset
  2099
      from holding(3)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2100
      show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2101
      proof(cases rule:h_e.holding_esE)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2102
        case 1
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2103
        with holding(1,2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2104
        show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2105
        by (unfold h_e.waiting_set_eq h_e.holding_set_eq s_RAG_def, 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2106
             fold s_holding_abv, 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: 90
diff changeset
  2107
      qed
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2108
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2109
  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: 90
diff changeset
  2110
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2111
  fix n1 n2
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2112
  assume h: "(n1, n2) \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2113
  show "(n1, n2) \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2114
  proof(cases "rest = []")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2115
    case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2116
    interpret h_n: valid_trace_v_n s e th 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: 90
diff changeset
  2117
        by (unfold_locales, insert False, 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: 90
diff changeset
  2118
    from h[unfolded h_n.waiting_set_eq h_n.holding_set_eq]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2119
    have "((n1, n2) \<in> RAG s \<and> (n1 \<noteq> Cs cs \<or> n2 \<noteq> 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: 90
diff changeset
  2120
                            \<and> (n1 \<noteq> Th h_n.taker \<or> n2 \<noteq> Cs cs)) \<or> 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2121
          (n2 = Th h_n.taker \<and> n1 = 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: 90
diff changeset
  2122
      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: 90
diff changeset
  2123
   thus ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2124
   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: 90
diff changeset
  2125
      assume "n2 = Th h_n.taker \<and> n1 = 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: 90
diff changeset
  2126
      with h_n.holding_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: 90
diff changeset
  2127
      show ?thesis 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2128
        by (unfold s_RAG_def, fold s_holding_abv, 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: 90
diff changeset
  2129
   next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2130
    assume h: "(n1, n2) \<in> RAG s \<and>
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2131
        (n1 \<noteq> Cs cs \<or> n2 \<noteq> Th th) \<and> (n1 \<noteq> Th h_n.taker \<or> n2 \<noteq> 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: 90
diff changeset
  2132
    hence "(n1, n2) \<in> RAG s" 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: 90
diff changeset
  2133
    thus ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2134
    proof(cases rule:in_RAG_E)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2135
      case (waiting th' 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: 90
diff changeset
  2136
      from h and this(1,2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2137
      have "th' \<noteq> h_n.taker \<or> cs' \<noteq> cs" 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: 90
diff changeset
  2138
      hence "waiting (e#s) th' 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: 90
diff changeset
  2139
      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: 90
diff changeset
  2140
        assume "cs' \<noteq> 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: 90
diff changeset
  2141
        from waiting_esI1[OF waiting(3) this] 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2142
        show ?thesis .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2143
      next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2144
        assume neq_th': "th' \<noteq> h_n.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: 90
diff changeset
  2145
        show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2146
        proof(cases "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: 90
diff changeset
  2147
          case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2148
          from waiting_esI1[OF waiting(3) this] 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2149
          show ?thesis .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2150
        next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2151
          case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2152
          from h_n.waiting_esI2[OF waiting(3)[unfolded True] neq_th', folded True]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2153
          show ?thesis .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2154
        qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2155
      qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2156
      thus ?thesis using waiting(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2157
        by (unfold s_RAG_def, fold s_waiting_abv, 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: 90
diff changeset
  2158
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2159
      case (holding th' 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: 90
diff changeset
  2160
      from h this(1,2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2161
      have "cs' \<noteq> cs \<or> th' \<noteq> th" 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: 90
diff changeset
  2162
      hence "holding (e#s) th' 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: 90
diff changeset
  2163
      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: 90
diff changeset
  2164
        assume "cs' \<noteq> 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: 90
diff changeset
  2165
        from holding_esI2[OF this holding(3)] 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2166
        show ?thesis .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2167
      next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2168
        assume "th' \<noteq> 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: 90
diff changeset
  2169
        from holding_esI1[OF holding(3) this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2170
        show ?thesis .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2171
      qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2172
      thus ?thesis using holding(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2173
        by (unfold s_RAG_def, fold s_holding_abv, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2174
    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: 90
diff changeset
  2175
   qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2176
 next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2177
   case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2178
   interpret h_e: valid_trace_v_e s e th 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: 90
diff changeset
  2179
        by (unfold_locales, insert True, 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: 90
diff changeset
  2180
   from h[unfolded h_e.waiting_set_eq h_e.holding_set_eq]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2181
   have h_s: "(n1, n2) \<in> RAG s" "(n1, n2) \<noteq> (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: 90
diff changeset
  2182
      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: 90
diff changeset
  2183
   from h_s(1)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2184
   show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2185
   proof(cases rule:in_RAG_E)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2186
    case (waiting th' 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: 90
diff changeset
  2187
    from h_e.waiting_esI2[OF this(3)]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2188
    show ?thesis using waiting(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2189
      by (unfold s_RAG_def, fold s_waiting_abv, 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: 90
diff changeset
  2190
   next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2191
    case (holding th' 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: 90
diff changeset
  2192
    with h_s(2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2193
    have "cs' \<noteq> cs \<or> th' \<noteq> th" 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: 90
diff changeset
  2194
    thus ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2195
    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: 90
diff changeset
  2196
      assume neq_cs: "cs' \<noteq> 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: 90
diff changeset
  2197
      from holding_esI2[OF this holding(3)]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2198
      show ?thesis using holding(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2199
        by (unfold s_RAG_def, fold s_holding_abv, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2200
    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: 90
diff changeset
  2201
      assume "th' \<noteq> 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: 90
diff changeset
  2202
      from holding_esI1[OF holding(3) this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2203
      show ?thesis using holding(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2204
        by (unfold s_RAG_def, fold s_holding_abv, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2205
    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: 90
diff changeset
  2206
   qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2207
 qed
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2208
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2209
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: 90
diff changeset
  2210
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2211
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2212
context valid_trace_p
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2213
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2214
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2215
lemma waiting_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2216
  assumes "waiting s th' 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: 90
diff changeset
  2217
  shows "waiting (e#s) th' 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: 90
diff changeset
  2218
  using assms
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  2219
    by (metis butlast_snoc distinct.simps(2) distinct_singleton hd_append2 
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  2220
        in_set_butlastD s_waiting_def wq_def wq_es_cs wq_neq_simp)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2221
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: 90
diff changeset
  2222
lemma holding_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2223
  assumes "holding s th' 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: 90
diff changeset
  2224
  shows "holding (e#s) th' 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: 90
diff changeset
  2225
proof(cases "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: 90
diff changeset
  2226
  case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2227
  hence "wq (e#s) cs' = wq s cs'" by simp
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2228
  with assms show ?thesis unfolding holding_raw_def s_holding_abv by 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: 90
diff changeset
  2229
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2230
  case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2231
  from assms[unfolded s_holding_def, folded wq_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: 90
diff changeset
  2232
  obtain rest where eq_wq: "wq s cs' = th'#rest"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2233
    by (metis empty_iff list.collapse list.set(1)) 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2234
  hence "wq (e#s) cs' = th'#(rest@[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: 90
diff changeset
  2235
    by (simp add: True wq_es_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: 90
diff changeset
  2236
  thus ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2237
    by (simp add: holding_raw_def s_holding_abv) 
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: 90
diff changeset
  2238
qed
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2239
end 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2240
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2241
lemma (in valid_trace_p) th_not_waiting: "\<not> waiting s th c"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2242
proof -
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2243
  have "th \<in> readys s"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  2244
    using running_ready running_th_s by blast 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2245
  thus ?thesis
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2246
    by (unfold readys_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: 90
diff changeset
  2247
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2248
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2249
context valid_trace_p_h
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2250
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2251
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2252
lemma wq_es_cs': "wq (e#s) cs = [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: 90
diff changeset
  2253
  using wq_es_cs[unfolded we] 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: 90
diff changeset
  2254
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2255
lemma holding_es_th_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: 90
diff changeset
  2256
  shows "holding (e#s) th 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: 90
diff changeset
  2257
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: 90
diff changeset
  2258
  from wq_es_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: 90
diff changeset
  2259
  have "th \<in> set (wq (e#s) cs)" "th = hd (wq (e#s) cs)" by auto
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2260
  thus ?thesis unfolding holding_raw_def s_holding_abv by blast 
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: 90
diff changeset
  2261
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2262
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2263
lemma RAG_edge: "(Cs cs, Th th) \<in> RAG (e#s)"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2264
  by (unfold s_RAG_def, fold s_holding_abv, insert holding_es_th_cs, 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: 90
diff changeset
  2265
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2266
lemma waiting_esE:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2267
  assumes "waiting (e#s) th' 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: 90
diff changeset
  2268
  obtains "waiting s th' 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: 90
diff changeset
  2269
  using assms
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  2270
  by (metis empty_iff list.sel(1) list.set(1) s_waiting_def 
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  2271
      set_ConsD wq_def wq_es_cs' wq_neq_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: 90
diff changeset
  2272
  
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2273
lemma holding_esE:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2274
  assumes "holding (e#s) th' 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: 90
diff changeset
  2275
  obtains "cs' \<noteq> cs" "holding s th' 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: 90
diff changeset
  2276
    | "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: 90
diff changeset
  2277
proof(cases "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: 90
diff changeset
  2278
  case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2279
  from held_unique[OF holding_es_th_cs assms[unfolded True]]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2280
  have "th' = th" 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: 90
diff changeset
  2281
  from that(2)[OF True this] show ?thesis .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2282
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2283
  case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2284
  have "holding s th' cs'" using assms
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2285
    using False unfolding holding_raw_def s_holding_abv by 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: 90
diff changeset
  2286
  from that(1)[OF False this] show ?thesis .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2287
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2288
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2289
lemma RAG_es: "RAG (e # s) =  RAG s \<union> {(Cs cs, Th th)}" (is "?L = ?R")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2290
proof(rule rel_eqI)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2291
  fix n1 n2
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2292
  assume "(n1, n2) \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2293
  thus "(n1, n2) \<in> ?R" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2294
  proof(cases rule:in_RAG_E)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2295
    case (waiting th' 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: 90
diff changeset
  2296
    from this(3)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2297
    show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2298
    proof(cases rule:waiting_esE)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2299
      case 1
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2300
      thus ?thesis using waiting(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2301
        by (unfold s_RAG_def, fold s_waiting_abv, 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: 90
diff changeset
  2302
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2303
  next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2304
    case (holding th' 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: 90
diff changeset
  2305
    from this(3)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2306
    show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2307
    proof(cases rule:holding_esE)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2308
      case 1
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2309
      with holding(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2310
      show ?thesis by (unfold s_RAG_def, fold s_holding_abv, 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: 90
diff changeset
  2311
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2312
      case 2
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2313
      with holding(1,2) show ?thesis 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: 90
diff changeset
  2314
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2315
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2316
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2317
  fix n1 n2
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2318
  assume "(n1, n2) \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2319
  hence "(n1, n2) \<in> RAG s \<or> (n1 = Cs cs \<and> n2 = Th th)" 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: 90
diff changeset
  2320
  thus "(n1, n2) \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2321
  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: 90
diff changeset
  2322
    assume "(n1, n2) \<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: 90
diff changeset
  2323
    thus ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2324
    proof(cases rule:in_RAG_E)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2325
      case (waiting th' 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: 90
diff changeset
  2326
      from waiting_kept[OF this(3)]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2327
      show ?thesis using waiting(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2328
         by (unfold s_RAG_def, fold s_waiting_abv, 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: 90
diff changeset
  2329
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2330
      case (holding th' 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: 90
diff changeset
  2331
      from holding_kept[OF this(3)]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2332
      show ?thesis using holding(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2333
         by (unfold s_RAG_def, fold s_holding_abv, 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: 90
diff changeset
  2334
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2335
  next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2336
    assume "n1 = Cs cs \<and> n2 = 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: 90
diff changeset
  2337
    with holding_es_th_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: 90
diff changeset
  2338
    show ?thesis 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2339
      by (unfold s_RAG_def, fold s_holding_abv, 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: 90
diff changeset
  2340
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2341
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2342
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2343
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2344
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2345
context valid_trace_p_w
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2346
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2347
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2348
lemma wq_s_cs: "wq s cs = holder#waiters"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2349
    by (simp add: holder_def waiters_def wne)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2350
    
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2351
lemma wq_es_cs': "wq (e#s) cs = holder#waiters@[th]"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2352
  by (simp add: wq_es_cs wq_s_cs)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2353
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2354
lemma waiting_es_th_cs: "waiting (e#s) th cs"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2355
  using th_not_in_wq s_waiting_abv wq_es_cs' wq_s_cs
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2356
  using Un_iff list.sel(1) list.set_intros(1) s_waiting_def
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2357
   set_append wq_def wq_es_cs by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2358
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2359
lemma RAG_edge: "(Th th, Cs cs) \<in> RAG (e#s)"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2360
   by (unfold s_RAG_def, fold s_waiting_abv, insert waiting_es_th_cs, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2361
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2362
lemma holding_esE:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2363
  assumes "holding (e#s) th' cs'"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2364
  obtains "holding s th' cs'"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2365
  using assms 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2366
proof(cases "cs' = cs")
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2367
  case False
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2368
  hence "wq (e#s) cs' = wq s cs'" by simp
120
b3b8735c7c02 updated to Isabelle 2016
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 119
diff changeset
  2369
  with assms show ?thesis using that
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  2370
    using s_holding_def wq_def by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2371
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2372
  case True
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2373
  with assms show ?thesis
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  2374
    using s_holding_def that wq_def wq_es_cs' wq_s_cs by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2375
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2376
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2377
lemma waiting_esE:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2378
  assumes "waiting (e#s) th' cs'"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2379
  obtains "th' \<noteq> th" "waiting s th' cs'"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2380
     |  "th' = th" "cs' = cs"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2381
proof(cases "waiting s th' cs'")
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2382
  case True
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2383
  have "th' \<noteq> th"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2384
  proof
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2385
    assume otherwise: "th' = th"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2386
    from True[unfolded this]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2387
    show False by (simp add: th_not_waiting)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2388
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2389
  from that(1)[OF this True] show ?thesis .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2390
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2391
  case False
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2392
  hence "th' = th \<and> cs' = cs"
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  2393
      by (metis assms hd_append2 insert_iff list.simps(15) rotate1.simps(2) 
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  2394
          s_waiting_def set_rotate1 wne wq_def wq_es_cs wq_neq_simp)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2395
  with that(2) show ?thesis by metis
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2396
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2397
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2398
lemma RAG_es: "RAG (e # s) =  RAG s \<union> {(Th th, Cs cs)}" (is "?L = ?R")
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2399
proof(rule rel_eqI)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2400
  fix n1 n2
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2401
  assume "(n1, n2) \<in> ?L"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2402
  thus "(n1, n2) \<in> ?R" 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2403
  proof(cases rule:in_RAG_E)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2404
    case (waiting th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2405
    from this(3)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2406
    show ?thesis
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2407
    proof(cases rule:waiting_esE)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2408
      case 1
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2409
      thus ?thesis using waiting(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2410
        by (unfold s_RAG_def, fold s_waiting_abv, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2411
    next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2412
      case 2
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2413
      thus ?thesis using waiting(1,2) by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2414
    qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2415
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2416
    case (holding th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2417
    from this(3)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2418
    show ?thesis
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2419
    proof(cases rule:holding_esE)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2420
      case 1
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2421
      with holding(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2422
      show ?thesis by (unfold s_RAG_def, fold s_holding_abv, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2423
    qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2424
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2425
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2426
  fix n1 n2
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2427
  assume "(n1, n2) \<in> ?R"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2428
  hence "(n1, n2) \<in> RAG s \<or> (n1 = Th th \<and> n2 = Cs cs)" by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2429
  thus "(n1, n2) \<in> ?L"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2430
  proof
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2431
    assume "(n1, n2) \<in> RAG s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2432
    thus ?thesis
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2433
    proof(cases rule:in_RAG_E)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2434
      case (waiting th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2435
      from waiting_kept[OF this(3)]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2436
      show ?thesis using waiting(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2437
         by (unfold s_RAG_def, fold s_waiting_abv, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2438
    next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2439
      case (holding th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2440
      from holding_kept[OF this(3)]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2441
      show ?thesis using holding(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2442
         by (unfold s_RAG_def, fold s_holding_abv, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2443
    qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2444
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2445
    assume "n1 = Th th \<and> n2 = Cs cs"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2446
    thus ?thesis using RAG_edge by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2447
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2448
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2449
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2450
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2451
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: 90
diff changeset
  2452
context valid_trace_p
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2453
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2454
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2455
lemma RAG_es: "RAG (e # s) =  (if (wq s cs = []) then RAG s \<union> {(Cs cs, 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: 90
diff changeset
  2456
                                                  else RAG s \<union> {(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: 90
diff changeset
  2457
proof(cases "wq s 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: 90
diff changeset
  2458
  case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2459
  interpret vt_p: valid_trace_p_h using True
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  2460
    by (unfold_locales, 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: 90
diff changeset
  2461
  show ?thesis by (simp add: vt_p.RAG_es vt_p.we) 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2462
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2463
  case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2464
  interpret vt_p: valid_trace_p_w using False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2465
    by (unfold_locales, 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: 90
diff changeset
  2466
  show ?thesis by (simp add: vt_p.RAG_es vt_p.wne) 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2467
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2468
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2469
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2470
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  2471
subsection {* RAG is finite *}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2472
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2473
context valid_trace_v
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2474
begin
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2475
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2476
lemma 
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2477
  finite_RAG_kept:
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2478
  assumes "finite (RAG s)"
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2479
  shows "finite (RAG (e#s))"
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2480
proof(cases "rest = []")
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2481
  case True
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2482
  interpret vt: valid_trace_v_e using True
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2483
    by (unfold_locales, simp)
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2484
  show ?thesis using assms
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2485
    by  (unfold RAG_es vt.waiting_set_eq vt.holding_set_eq, simp)
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2486
next
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2487
  case False
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2488
  interpret vt: valid_trace_v_n using False
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2489
    by (unfold_locales, simp)
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2490
  show ?thesis using assms
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2491
    by  (unfold RAG_es vt.waiting_set_eq vt.holding_set_eq, simp)
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2492
qed
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2493
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2494
end
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2495
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2496
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2497
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2498
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2499
lemma finite_RAG:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2500
  shows "finite (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2501
proof(induct rule:ind)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2502
  case Nil
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2503
  show ?case 
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  2504
  by (auto simp: s_RAG_def waiting_raw_def
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  2505
                   holding_raw_def wq_def acyclic_def)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2506
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2507
  case (Cons s e)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2508
  interpret vt_e: valid_trace_e s e using Cons by simp
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2509
  show ?case
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2510
  proof(cases e)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2511
    case (Create th prio)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2512
    interpret vt: valid_trace_create s e th prio using Create
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2513
      by (unfold_locales, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2514
    show ?thesis using Cons by simp
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2515
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2516
    case (Exit th)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2517
    interpret vt: valid_trace_exit s e th using Exit
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2518
      by (unfold_locales, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2519
    show ?thesis using Cons by simp
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2520
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2521
    case (P th cs)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2522
    interpret vt: valid_trace_p s e th cs using P
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2523
      by (unfold_locales, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2524
    show ?thesis using Cons using vt.RAG_es by auto 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2525
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2526
    case (V th cs)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2527
    interpret vt: valid_trace_v s e th cs using V
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2528
      by (unfold_locales, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2529
    show ?thesis using Cons by (simp add: vt.finite_RAG_kept) 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2530
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2531
    case (Set th prio)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2532
    interpret vt: valid_trace_set s e th prio using Set
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2533
      by (unfold_locales, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2534
    show ?thesis using Cons by simp
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2535
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2536
qed
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2537
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2538
lemma finite_tRAG: "finite (tRAG s)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2539
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2540
  from finite_RAG[unfolded RAG_split]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2541
  have "finite (wRAG s)" "finite (hRAG s)" by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2542
  from finite_relcomp[OF this] tRAG_def
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2543
  show ?thesis by simp
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2544
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2545
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2546
lemma finite_tG: "finite (tG s)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2547
  by (unfold tG_def, insert finite_tRAG, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2548
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2549
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2550
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2551
subsection {* Uniqueness of waiting *}
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2552
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2553
text {*
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2554
  {\em Uniqueness of waiting} means that 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2555
  a thread can only be blocked on one resource.
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2556
  This property is needed in order to prove that @{term RAG}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2557
  is acyclic. Therefore, we need to prove it first in the following
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2558
  lemma @{text "waiting_unqiue"}, all lemmas before it are auxiliary. 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2559
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2560
  The property is expressed by the following predicate over system 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2561
  state (or event trace), which is also named @{text "waiting_unqiue"}.
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2562
*}
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2563
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2564
definition 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2565
  "waiting_unique (ss::state) = 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2566
     (\<forall> th cs1 cs2. waiting ss th cs1 \<longrightarrow> 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2567
                    waiting ss th cs2 \<longrightarrow> cs1 = cs2)"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2568
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2569
text {*
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2570
  We are going to show (in the 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2571
  lemma named @{text waiting_unique}) that
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2572
  this property holds on any valid trace (or system state).
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2573
*}
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2574
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2575
text {*
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2576
  As a first step to prove lemma @{text "waiting_unqiue"}, 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2577
  we need to understand how 
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2578
  a thread is get blocked. 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2579
  We show in the following lemmas 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2580
  (all named @{text "waiting_inv"}) that 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2581
  @{term P}-operation is the only cause. 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2582
*}
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2583
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2584
context valid_trace_create
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2585
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2586
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2587
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2588
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2589
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2590
  using assms 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2591
  by (unfold s_waiting_def, fold wq_def, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2592
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2593
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2594
context valid_trace_set
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2595
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2596
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2597
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2598
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2599
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2600
  using assms 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2601
  by (unfold s_waiting_def, fold wq_def, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2602
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2603
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2604
context valid_trace_exit
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2605
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2606
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2607
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2608
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2609
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2610
  using assms 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2611
  by (unfold s_waiting_def, fold wq_def, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2612
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2613
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2614
context valid_trace_p
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2615
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2616
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2617
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2618
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2619
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2620
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2621
proof(cases "cs' = cs")
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2622
  case True
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2623
  moreover have "th' = th"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2624
  proof(rule ccontr)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2625
    assume otherwise: "th' \<noteq> th"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2626
    have "waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2627
    proof -
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2628
      from assms(2)[unfolded True s_waiting_def, 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2629
              folded wq_def, unfolded wq_es_cs]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2630
      have h: "th' \<in> set (wq s cs @ [th])"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2631
              "th' \<noteq> hd (wq s cs @ [th])" by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2632
      from h(1) and otherwise
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2633
      have "th' \<in> set (wq s cs)" by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2634
      hence "wq s cs \<noteq> []" by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2635
      hence "hd (wq s cs @ [th]) = hd (wq s cs)" by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2636
      with h otherwise
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2637
      have "waiting s th' cs" 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2638
        by (unfold s_waiting_def, fold wq_def, auto)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2639
      from this[folded True] show ?thesis .
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2640
    qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2641
    with assms(1) show False by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2642
  qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2643
  ultimately show ?thesis using is_p by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2644
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2645
  case False
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2646
  hence "wq (e#s) cs' = wq s cs'" by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2647
  from assms[unfolded s_waiting_def, folded wq_def, 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2648
            unfolded this]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2649
  show ?thesis by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2650
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2651
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2652
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2653
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2654
context valid_trace_v_n
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2655
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2656
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2657
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2658
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2659
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2660
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2661
proof -
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2662
  from assms(2)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2663
  show ?thesis
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2664
  by (cases rule:waiting_esE, insert assms, auto)
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2665
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2666
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2667
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2668
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2669
context valid_trace_v_e
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2670
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2671
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2672
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2673
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2674
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2675
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2676
proof -
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2677
  from assms(2)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2678
  show ?thesis
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2679
  by (cases rule:waiting_esE, insert assms, auto)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2680
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2681
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2682
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2683
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2684
context valid_trace_e
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2685
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2686
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2687
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2688
  assumes "\<not> waiting s th cs"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2689
  and "waiting (e#s) th cs"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2690
  shows "e = P th cs"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2691
proof(cases e)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2692
  case (Create th' prio')
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2693
  then interpret vt: valid_trace_create s e th' prio'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2694
    by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2695
  show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2696
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2697
  case (Exit th')
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2698
  then interpret vt: valid_trace_exit s e th'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2699
    by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2700
  show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2701
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2702
  case (Set th' prio')
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2703
  then interpret vt: valid_trace_set s e th' prio'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2704
    by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2705
  show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2706
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2707
  case (P th' cs')
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2708
  then interpret vt: valid_trace_p s e th' cs'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2709
    by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2710
  show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2711
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2712
  case (V th' cs')
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2713
  then interpret vt_e: valid_trace_v s e th' cs'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2714
    by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2715
  show ?thesis
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2716
  proof(cases "vt_e.rest = []")
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2717
    case True
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2718
    then interpret vt: valid_trace_v_e s e th' cs'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2719
      by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2720
    show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2721
  next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2722
    case False
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2723
    then interpret vt: valid_trace_v_n s e th' cs'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2724
      by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2725
    show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2726
  qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2727
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2728
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2729
text {* 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2730
  Now, with @{thm waiting_inv} in place, the following lemma
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2731
  shows the uniqueness of waiting is kept by every operation 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2732
  in the PIP protocol. This lemma constitutes the main part
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2733
  in the proof of lemma @{text "waiting_unique"}.
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2734
*}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2735
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2736
lemma waiting_unique_kept:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2737
  assumes "waiting_unique s"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2738
  shows "waiting_unique (e#s)"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2739
proof -
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2740
  note h = assms[unfolded waiting_unique_def, rule_format]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2741
  { fix th cs1 cs2
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2742
    assume w1: "waiting (e#s) th cs1"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2743
       and w2: "waiting (e#s) th cs2"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2744
    have "cs1 = cs2"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2745
    proof(rule ccontr)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2746
      assume otherwise: "cs1 \<noteq> cs2"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2747
      show False
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2748
      proof(cases "waiting s th cs1")
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2749
        case True
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2750
        from h[OF this] and otherwise
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2751
        have "\<not> waiting s th cs2" by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2752
        from waiting_inv[OF this w2]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2753
        have "e = P th cs2" .
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2754
        then interpret vt: valid_trace_p  s e th cs2
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2755
          by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2756
        from vt.th_not_waiting and True
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2757
        show ?thesis by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2758
      next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2759
        case False 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2760
        from waiting_inv[OF this w1]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2761
        have "e = P th cs1" .
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2762
        then interpret vt: valid_trace_p s e th cs1
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2763
          by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2764
        have "wq (e # s) cs2 = wq s cs2" 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2765
          using otherwise by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2766
        from w2[unfolded s_waiting_def, folded wq_def, 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2767
                  unfolded this]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2768
        have "waiting s th cs2" 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2769
          by (unfold s_waiting_def, fold wq_def, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2770
        thus ?thesis by (simp add: vt.th_not_waiting) 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2771
      qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2772
    qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2773
  } thus ?thesis by (unfold waiting_unique_def, auto)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2774
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2775
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2776
end
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2777
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2778
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2779
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2780
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2781
text {*
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2782
  With @{thm valid_trace_e.waiting_unique_kept} in place,
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2783
  the proof of the following lemma @{text "waiting_unique"} 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2784
  needs only a very simple induction.
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2785
*}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2786
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2787
lemma waiting_unique 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2788
  [unfolded waiting_unique_def, rule_format]:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2789
  shows "waiting_unique s"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2790
proof(induct rule:ind)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2791
  case Nil
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2792
  show ?case 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2793
    by (unfold waiting_unique_def s_waiting_def, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2794
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2795
  case (Cons s e)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2796
  then interpret vt: valid_trace_e s e by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2797
  show ?case using Cons(2) vt.waiting_unique_kept
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2798
    by simp
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2799
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2800
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2801
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2802
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2803
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2804
subsection {* Acyclic keeping *}
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: 90
diff changeset
  2805
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2806
text {*
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2807
  To prove that @{term RAG} is acyclic, we need to show the acyclic property 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2808
  is preserved by all system operations. There are only two non-trivial cases, 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2809
  the @{term P} and @{term V} operation, where are treated in the following
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2810
  locales, under the name @{text "acylic_RAG_kept"}:
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2811
*}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2812
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: 90
diff changeset
  2813
context valid_trace_v_e
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2814
begin 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2815
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2816
lemma 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2817
  acylic_RAG_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2818
  assumes "acyclic (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: 90
diff changeset
  2819
  shows "acyclic (RAG (e#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: 90
diff changeset
  2820
proof(rule acyclic_subset[OF 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: 90
diff changeset
  2821
  show "RAG (e # s) \<subseteq> 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: 90
diff changeset
  2822
      by (unfold RAG_es waiting_set_eq holding_set_eq, 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: 90
diff changeset
  2823
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2824
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2825
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2826
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2827
context valid_trace_v_n
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2828
begin 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2829
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2830
lemma waiting_taker: "waiting s taker 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: 90
diff changeset
  2831
  apply (unfold s_waiting_def, fold wq_def, unfold wq_s_cs taker_def)
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2832
  using eq_wq' set_wq' th_not_in_rest by 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: 90
diff changeset
  2833
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2834
lemma 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2835
  acylic_RAG_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2836
  assumes "acyclic (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: 90
diff changeset
  2837
  shows "acyclic (RAG (e#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: 90
diff changeset
  2838
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: 90
diff changeset
  2839
  have "acyclic ((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: 90
diff changeset
  2840
                 {(Cs cs, Th taker)})" (is "acyclic (?A \<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: 90
diff changeset
  2841
  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: 90
diff changeset
  2842
    from 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: 90
diff changeset
  2843
    have "acyclic ?A"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2844
       by (rule acyclic_subset, 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: 90
diff changeset
  2845
    moreover have "(Th taker, Cs cs) \<notin> ?A^*"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2846
    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: 90
diff changeset
  2847
      assume otherwise: "(Th taker, Cs cs) \<in> ?A^*"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2848
      hence "(Th taker, Cs cs) \<in> ?A^+"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2849
        by (unfold rtrancl_eq_or_trancl, 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: 90
diff changeset
  2850
      from tranclD[OF this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2851
      obtain cs' where h: "(Th taker, Cs cs') \<in> ?A" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2852
                          "(Th taker, Cs cs') \<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: 90
diff changeset
  2853
        by (unfold s_RAG_def, 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: 90
diff changeset
  2854
      from this(2) have "waiting s taker cs'" 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2855
        by (unfold s_RAG_def, fold s_waiting_abv, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2856
      from waiting_unique[OF this waiting_taker] 
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: 90
diff changeset
  2857
      have "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: 90
diff changeset
  2858
      from h(1)[unfolded this] show False 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: 90
diff changeset
  2859
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2860
    ultimately show ?thesis 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: 90
diff changeset
  2861
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2862
  thus ?thesis 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2863
    by (unfold RAG_es waiting_set_eq holding_set_eq, 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: 90
diff changeset
  2864
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2865
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2866
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2867
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2868
context valid_trace_p_h
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2869
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2870
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2871
lemma 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2872
  acylic_RAG_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2873
  assumes "acyclic (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: 90
diff changeset
  2874
  shows "acyclic (RAG (e#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: 90
diff changeset
  2875
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: 90
diff changeset
  2876
  have "acyclic (RAG s \<union> {(Cs cs, Th th)})" (is "acyclic (?A \<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: 90
diff changeset
  2877
  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: 90
diff changeset
  2878
    from 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: 90
diff changeset
  2879
    have "acyclic ?A"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2880
       by (rule acyclic_subset, 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: 90
diff changeset
  2881
    moreover have "(Th th, Cs cs) \<notin> ?A^*"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2882
    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: 90
diff changeset
  2883
      assume otherwise: "(Th th, Cs cs) \<in> ?A^*"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2884
      hence "(Th th, Cs cs) \<in> ?A^+"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2885
        by (unfold rtrancl_eq_or_trancl, 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: 90
diff changeset
  2886
      from tranclD[OF this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2887
      obtain cs' where h: "(Th th, Cs cs') \<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: 90
diff changeset
  2888
        by (unfold s_RAG_def, 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: 90
diff changeset
  2889
      hence "waiting s th cs'" 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2890
        by (unfold s_RAG_def, fold s_waiting_abv, auto)
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  2891
      with th_not_waiting show False by 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: 90
diff changeset
  2892
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2893
    ultimately show ?thesis 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: 90
diff changeset
  2894
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2895
  thus ?thesis by (unfold RAG_es, 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: 90
diff changeset
  2896
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2897
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2898
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2899
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2900
context valid_trace_p_w
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2901
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2902
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2903
lemma 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2904
  acylic_RAG_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2905
  assumes "acyclic (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: 90
diff changeset
  2906
  shows "acyclic (RAG (e#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: 90
diff changeset
  2907
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: 90
diff changeset
  2908
  have "acyclic (RAG s \<union> {(Th th, Cs cs)})" (is "acyclic (?A \<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: 90
diff changeset
  2909
  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: 90
diff changeset
  2910
    from 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: 90
diff changeset
  2911
    have "acyclic ?A"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2912
       by (rule acyclic_subset, 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: 90
diff changeset
  2913
    moreover have "(Cs cs, Th th) \<notin> ?A^*"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2914
    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: 90
diff changeset
  2915
      assume otherwise: "(Cs cs, Th th) \<in> ?A^*"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2916
      from pip_e[unfolded is_p]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2917
      show False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2918
      proof(cases)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2919
        case (thread_P)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2920
        moreover from otherwise have "(Cs cs, Th th) \<in> ?A^+"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2921
            by (unfold rtrancl_eq_or_trancl, 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: 90
diff changeset
  2922
        ultimately show ?thesis 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: 90
diff changeset
  2923
      qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2924
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2925
    ultimately show ?thesis 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: 90
diff changeset
  2926
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2927
  thus ?thesis by (unfold RAG_es, 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: 90
diff changeset
  2928
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2929
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2930
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2931
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  2932
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  2933
subsection {* RAG is acyclic *}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  2934
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: 90
diff changeset
  2935
context valid_trace
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2936
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2937
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2938
text {* 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2939
  With these @{text "acylic_RAG_kept"}-lemmas proved, 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2940
  the proof of the following @{text "acyclic_RAG"} is
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2941
  straight forward. 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2942
 *}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2943
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: 90
diff changeset
  2944
lemma acyclic_RAG:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2945
  shows "acyclic (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: 90
diff changeset
  2946
proof(induct rule:ind)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2947
  case Nil
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2948
  show ?case 
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  2949
  by (auto simp: s_RAG_def waiting_raw_def
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  2950
                   holding_raw_def wq_def acyclic_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: 90
diff changeset
  2951
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2952
  case (Cons s e)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2953
  interpret vt_e: valid_trace_e s e using Cons 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: 90
diff changeset
  2954
  show ?case
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2955
  proof(cases e)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2956
    case (Create th prio)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2957
    interpret vt: valid_trace_create s e th prio using 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: 90
diff changeset
  2958
      by (unfold_locales, simp)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2959
    show ?thesis using Cons by 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: 90
diff changeset
  2960
  next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2961
    case (Exit 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: 90
diff changeset
  2962
    interpret vt: valid_trace_exit s e th using Exit
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2963
      by (unfold_locales, simp)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2964
    show ?thesis using Cons by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2965
  next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2966
    case (P th 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: 90
diff changeset
  2967
    interpret vt: valid_trace_p s e th cs using P
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2968
      by (unfold_locales, 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: 90
diff changeset
  2969
    show ?thesis
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2970
    proof(cases "wq s cs = []")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2971
      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: 90
diff changeset
  2972
      then interpret vt_h: valid_trace_p_h s e th 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: 90
diff changeset
  2973
        by (unfold_locales, 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: 90
diff changeset
  2974
      show ?thesis using Cons by (simp add: vt_h.acylic_RAG_kept) 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2975
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2976
      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: 90
diff changeset
  2977
      then interpret vt_w: valid_trace_p_w s e th 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: 90
diff changeset
  2978
        by (unfold_locales, 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: 90
diff changeset
  2979
      show ?thesis using Cons by (simp add: vt_w.acylic_RAG_kept) 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2980
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2981
  next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2982
    case (V th 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: 90
diff changeset
  2983
    interpret vt: valid_trace_v s e th cs using V
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2984
      by (unfold_locales, 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: 90
diff changeset
  2985
    show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2986
    proof(cases "vt.rest = []")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2987
      case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2988
      then interpret vt_e: valid_trace_v_e s e th 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: 90
diff changeset
  2989
        by (unfold_locales, 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: 90
diff changeset
  2990
      show ?thesis by (simp add: Cons.hyps(2) vt_e.acylic_RAG_kept) 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2991
    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: 90
diff changeset
  2992
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2993
      then interpret vt_n: valid_trace_v_n s e th 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: 90
diff changeset
  2994
        by (unfold_locales, 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: 90
diff changeset
  2995
      show ?thesis by (simp add: Cons.hyps(2) vt_n.acylic_RAG_kept) 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2996
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2997
  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: 90
diff changeset
  2998
    case (Set th prio)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2999
    interpret vt: valid_trace_set s e th prio using Set
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  3000
      by (unfold_locales, simp)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3001
    show ?thesis using Cons by 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: 90
diff changeset
  3002
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3003
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3004
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3005
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3006
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3007
subsection {* RAG is single-valued *}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3008
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  3009
text {*
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  3010
  The proof that @{term RAG} is single-valued makes use of 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  3011
  @{text "unique_waiting"} and @{thm held_unique} and the
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  3012
  proof itself is very simple:
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  3013
*}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  3014
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3015
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3016
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3017
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3018
lemma unique_RAG: "\<lbrakk>(n, n1) \<in> RAG s; (n, n2) \<in> RAG s\<rbrakk> \<Longrightarrow> n1 = n2"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  3019
  apply(unfold s_RAG_def, auto, fold s_waiting_abv s_holding_abv)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3020
  by(auto elim:waiting_unique held_unique)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3021
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3022
lemma sgv_RAG: "single_valued (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3023
  using unique_RAG by (auto simp:single_valued_def)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3024
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3025
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3026
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3027
subsection {* RAG is well-founded *}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3028
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3029
text {*
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3030
  In this section, it is proved that both @{term RAG} and 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3031
  its converse @{term "(RAG s)^-1"} are well-founded.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3032
  The proof is very simple with the help of
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3033
  already proved fact that @{term RAG} is finite.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3034
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3035
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3036
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3037
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3038
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: 90
diff changeset
  3039
lemma wf_RAG: "wf (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: 90
diff changeset
  3040
proof(rule finite_acyclic_wf)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3041
  from finite_RAG show "finite (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: 90
diff changeset
  3042
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3043
  from acyclic_RAG show "acyclic (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: 90
diff changeset
  3044
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3045
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3046
lemma wf_RAG_converse: 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3047
  shows "wf ((RAG s)^-1)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3048
proof(rule finite_acyclic_wf_converse)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3049
  from finite_RAG 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3050
  show "finite (RAG s)" .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3051
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3052
  from acyclic_RAG
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3053
  show "acyclic (RAG s)" .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3054
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3055
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3056
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3057
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3058
subsection {* RAG forms a finite-branching forest (or tree) *}
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3059
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3060
text {*
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3061
  With all the well-formedness proofs about @{term RAG} in place, 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3062
  it is easy to show.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3063
*}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3064
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3065
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3066
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3067
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3068
lemma forest_RAG: "forest (RAG s)"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3069
  using sgv_RAG acyclic_RAG
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3070
  by (unfold forest_def, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3071
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3072
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3073
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3074
sublocale valid_trace < forest_RAG?: forest "RAG s"
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3075
  using forest_RAG .
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3076
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3077
sublocale valid_trace < fsbtRAGs?: fforest "RAG s"
132
d9974794436a added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 131
diff changeset
  3078
proof
133
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3079
  show "\<And>x. finite (children (RAG s) x)"
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3080
    by (smt Collect_empty_eq Range.intros children_def finite.emptyI finite_RAG finite_fbranchI) 
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3081
    (*by (rule finite_fbranchI[OF finite_RAG])*)
132
d9974794436a added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 131
diff changeset
  3082
next
d9974794436a added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 131
diff changeset
  3083
  show "wf (RAG s)" using wf_RAG .
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3084
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3085
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3086
subsection {* Derived properties for sub-graphs of RAG *}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3087
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3088
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3089
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3090
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3091
lemma acyclic_tRAG: "acyclic (tRAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3092
proof(unfold tRAG_def, rule acyclic_compose)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3093
  show "acyclic (RAG s)" using acyclic_RAG .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3094
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3095
  show "wRAG s \<subseteq> RAG s" unfolding RAG_split by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3096
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3097
  show "hRAG s \<subseteq> RAG s" unfolding RAG_split by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3098
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3099
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3100
lemma rel_map_alt_def: "rel_map f R = map_prod f f ` R"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3101
  by (unfold rel_map_def pairself_def map_prod_def, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3102
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3103
lemma acyclic_tG: "acyclic (tG s)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3104
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3105
  have "acyclic (rel_map the_thread (tRAG s))"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3106
  proof(rule rel_map_acyclic [OF acyclic_tRAG])
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3107
    show "inj_on the_thread (Domain (tRAG s) \<union> Range (tRAG s))"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3108
      by (unfold tRAG_alt_def Domain_def Range_def inj_on_def, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3109
  qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3110
  thus ?thesis
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3111
  by (unfold tG_def, fold rel_map_alt_def, simp)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3112
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3113
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: 90
diff changeset
  3114
lemma sgv_wRAG: "single_valued (wRAG 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: 90
diff changeset
  3115
  using waiting_unique
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3116
  by (unfold single_valued_def wRAG_def, 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: 90
diff changeset
  3117
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3118
lemma sgv_hRAG: "single_valued (hRAG 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: 90
diff changeset
  3119
  using held_unique 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3120
  by (unfold single_valued_def hRAG_def, 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: 90
diff changeset
  3121
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3122
lemma sgv_tRAG: "single_valued (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: 90
diff changeset
  3123
  by (unfold tRAG_def, rule single_valued_relcomp, 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3124
              insert sgv_wRAG sgv_hRAG, 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: 90
diff changeset
  3125
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3126
lemma sgv_tG: "single_valued (tG s)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3127
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3128
  { fix x y z
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3129
    assume h: "(x, y) \<in> tG s" "(x, z) \<in> tG s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3130
    from tG_tRAG[OF h(1)] tG_tRAG[OF h(2)]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3131
    have "(Th x, Th y) \<in> tRAG s" "(Th x, Th z) \<in> tRAG s" by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3132
    from sgv_tRAG[unfolded single_valued_def, rule_format, OF this]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3133
    have "y = z" by simp
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3134
  } thus ?thesis by (unfold single_valued_def, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3135
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3136
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: 90
diff changeset
  3137
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3138
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3139
text {*
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3140
  It can be shown that @{term tRAG} is also a 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3141
  finite-branch relational tree (or forest):  
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3142
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3143
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3144
sublocale valid_trace < forest_s?: forest "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: 90
diff changeset
  3145
proof(unfold_locales)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3146
  from sgv_tRAG show "single_valued (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: 90
diff changeset
  3147
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3148
  from acyclic_tRAG show "acyclic (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: 90
diff changeset
  3149
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3150
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3151
sublocale valid_trace < forest_s_tG?: forest "tG s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3152
proof(unfold_locales)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3153
  from sgv_tG show "single_valued (tG s)" .
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3154
next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3155
  from acyclic_tG show "acyclic (tG s)" .
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3156
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3157
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3158
context valid_trace
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3159
begin
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3160
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3161
lemma wf_tRAG: "wf (tRAG s)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3162
proof(rule wf_subset)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3163
      show "wf (RAG s O RAG s)" using wf_RAG
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3164
        by (fold wf_comp_self, simp)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3165
next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3166
      show "tRAG s \<subseteq> (RAG s O RAG s)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3167
        by (unfold tRAG_alt_def, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3168
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3169
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3170
lemma wf_tG: "wf (tG s)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3171
proof(rule finite_acyclic_wf)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3172
  from finite_tG show "finite (tG s)" .
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3173
next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3174
  from acyclic_tG show "acyclic (tG s)" .
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3175
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3176
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3177
lemma finite_children_tRAG: "finite (children (tRAG s) x)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3178
  proof(unfold tRAG_def, rule fbranch_compose1[rule_format])
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3179
    fix x show "finite (children (wRAG s) x)" 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3180
    proof(rule finite_fbranchI1[rule_format])
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3181
      show "finite (wRAG s)" using finite_RAG[unfolded RAG_split] by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3182
    qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3183
  next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3184
    fix x
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3185
    show "finite (children (hRAG s) x)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3186
    proof(rule finite_fbranchI1[rule_format])
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3187
      show "finite (hRAG s)" using finite_RAG[unfolded RAG_split] by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3188
    qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3189
  qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3190
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3191
lemma children_map_prod: 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3192
  assumes "inj f"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3193
  shows " children (map_prod f f ` r) (f x) = f ` (children r x)" (is "?L = ?R")
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3194
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3195
  { fix e
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3196
    assume "e \<in> ?L"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3197
    then obtain e' x' where h: "e = f e'" "f x' = f x" "(e', x') \<in> r"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3198
      by (auto simp:children_def)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3199
    with assms[unfolded inj_on_def, rule_format]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3200
    have eq_x': "x' = x" by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3201
    with h
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3202
    have "e \<in> ?R" by  (unfold children_def, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3203
  } moreover {
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3204
    fix e
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3205
    assume "e \<in> ?R"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3206
    hence "e \<in> ?L" by (auto simp:children_def)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3207
  } ultimately show ?thesis by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3208
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3209
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3210
lemma finite_children_tG: "finite (children (tG s) x)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3211
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3212
  have "(children (tRAG s) (Th x)) = Th ` children (tG s) x"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3213
    by (unfold tRAG_def_tG, subst children_map_prod, auto simp:inj_on_def)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3214
  from finite_children_tRAG[of "Th x", unfolded this]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3215
  have "finite (Th ` children (tG s) x)" .
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3216
  from finite_imageD[OF this]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3217
  show ?thesis by (auto simp:inj_on_def)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3218
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3219
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3220
end
133
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3221
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3222
sublocale valid_trace < fsbttRAGs?: fforest "tRAG s"
132
d9974794436a added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 131
diff changeset
  3223
proof
133
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3224
  fix x
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3225
  show "finite (children (tRAG s) x)"
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3226
  proof(unfold tRAG_def, rule fbranch_compose1[rule_format])
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3227
    fix x show "finite (children (wRAG s) x)" 
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3228
    proof(rule finite_fbranchI1[rule_format])
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3229
      show "finite (wRAG s)" using finite_RAG[unfolded RAG_split] by auto
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3230
    qed
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3231
  next
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3232
    fix x
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3233
    show "finite (children (hRAG s) x)"
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3234
    proof(rule finite_fbranchI1[rule_format])
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3235
      show "finite (hRAG s)" using finite_RAG[unfolded RAG_split] by auto
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3236
    qed
132
d9974794436a added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 131
diff changeset
  3237
  qed
d9974794436a added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 131
diff changeset
  3238
next
d9974794436a added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 131
diff changeset
  3239
  show "wf (tRAG s)"
d9974794436a added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 131
diff changeset
  3240
  proof(rule wf_subset)
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: 90
diff changeset
  3241
      show "wf (RAG s O RAG s)" using wf_RAG
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3242
        by (fold wf_comp_self, simp)
132
d9974794436a added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 131
diff changeset
  3243
  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: 90
diff changeset
  3244
      show "tRAG s \<subseteq> (RAG s O 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: 90
diff changeset
  3245
        by (unfold tRAG_alt_def, 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: 90
diff changeset
  3246
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3247
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3248
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3249
sublocale valid_trace < fsbttGs?: fforest "tG s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3250
proof
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3251
  fix x
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3252
  show "finite (children (tG s) x)" 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3253
    by (simp add:finite_children_tG)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3254
next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3255
  show "wf (tG s)" by (simp add:wf_tG)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3256
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3257
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3258
section {* Chain to readys *}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3259
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3260
text {*
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3261
  In this section, based on the just derived
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3262
  properties about the shape of @{term RAG}, 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3263
  a more complete view of the relationship 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3264
  between threads is established.
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3265
*}
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3266
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: 90
diff changeset
  3267
context valid_trace
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3268
begin
53
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  3269
138
20c1d3a14143 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 137
diff changeset
  3270
text {* The first lemma is technical, which says out of any node in the
20c1d3a14143 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 137
diff changeset
  3271
domain of @{term RAG} (no matter whether it is thread node or resource
20c1d3a14143 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 137
diff changeset
  3272
node), there is a path leading to a ready thread.
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3273
*}
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3274
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3275
lemma chain_building:
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3276
  assumes "node \<in> Domain (RAG s)"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3277
  obtains th' where "th' \<in> readys s" "(node, Th th') \<in> (RAG s)^+"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3278
proof -
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3279
  from assms have "node \<in> Range ((RAG s)^-1)" by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3280
  from wf_base[OF wf_RAG_converse this]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3281
  obtain b where h_b: "(b, node) \<in> ((RAG s)\<inverse>)\<^sup>+" "\<forall>c. (c, b) \<notin> (RAG s)\<inverse>" by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3282
  obtain th' where eq_b: "b = Th th'"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3283
  proof(cases b)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3284
    case (Cs cs)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3285
    from h_b(1)[unfolded trancl_converse] 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3286
    have "(node, b) \<in> ((RAG s)\<^sup>+)" by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3287
    from tranclE[OF this]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3288
    obtain n where "(n, b) \<in> RAG s" by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3289
    from this[unfolded Cs]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3290
    obtain th1 where "waiting s th1 cs"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  3291
      by (unfold s_RAG_def, fold s_waiting_abv, auto)
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3292
    from waiting_holding[OF this]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3293
    obtain th2 where "holding s th2 cs" .
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3294
    hence "(Cs cs, Th th2) \<in> RAG s"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  3295
      by (unfold s_RAG_def, fold s_holding_abv, auto)
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3296
    with h_b(2)[unfolded Cs, rule_format]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3297
    have False by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3298
    thus ?thesis by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3299
  qed auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3300
  have "th' \<in> readys s" 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3301
  proof -
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3302
    from h_b(2)[unfolded eq_b]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3303
    have "\<forall>cs. \<not> waiting s th' cs"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  3304
      by (unfold s_RAG_def, fold s_waiting_abv, auto)
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3305
    moreover have "th' \<in> threads s"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3306
    proof(rule rg_RAG_threads)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3307
      from tranclD[OF h_b(1), unfolded eq_b]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3308
      obtain z where "(z, Th th') \<in> (RAG s)" by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3309
      thus "Th th' \<in> Range (RAG s)" by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3310
    qed
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3311
    ultimately show ?thesis by (auto simp:readys_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3312
  qed
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3313
  moreover have "(node, Th th') \<in> (RAG s)^+" 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3314
    using h_b(1)[unfolded trancl_converse] eq_b by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3315
  ultimately show ?thesis using that by metis
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3316
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3317
53
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  3318
text {* \noindent
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3319
  The following lemma says for any living thread, 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3320
  either it is ready or there is a path in @{term RAG}
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3321
  leading from it to a ready thread. The lemma is proved easily
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3322
  by instantiating @{thm "chain_building"}.
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3323
*}                    
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3324
lemma th_chain_to_ready:
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  3325
  assumes th_in: "th \<in> threads s"
35
92f61f6a0fe7 added a bit more text to the paper and separated a theory about Max
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
  3326
  shows "th \<in> readys s \<or> (\<exists> th'. th' \<in> readys s \<and> (Th th, Th th') \<in> (RAG s)^+)"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3327
proof(cases "th \<in> readys s")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3328
  case True
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3329
  thus ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3330
next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3331
  case False
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: 32
diff changeset
  3332
  from False and th_in have "Th th \<in> Domain (RAG s)" 
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3333
    by (auto simp: readys_def s_waiting_def s_RAG_def wq_def waiting_raw_def
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3334
 Domain_def)
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  3335
  from chain_building [rule_format, OF this]
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3336
  show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3337
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3338
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3339
lemma th_chain_to_ready_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3340
  assumes th_in: "th \<in> threads s"
138
20c1d3a14143 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 137
diff changeset
  3341
  shows "\<exists>th'\<in> nancestors (tG s) th. th' \<in> readys s"
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3342
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3343
  from th_chain_to_ready[OF assms]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3344
  show ?thesis
138
20c1d3a14143 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 137
diff changeset
  3345
  using dependants_alt_def1 dependants_alt_tG 
20c1d3a14143 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 137
diff changeset
  3346
  unfolding nancestors_def ancestors_def
20c1d3a14143 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 137
diff changeset
  3347
  by blast 
20c1d3a14143 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 137
diff changeset
  3348
qed
20c1d3a14143 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 137
diff changeset
  3349
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3350
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3351
text {*
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3352
  The following lemma is a technical one to show 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3353
  that the set of threads in the subtree of any thread
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3354
  is finite.
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3355
*}
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3356
lemma finite_subtree_threads:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3357
    "finite {th'. Th th' \<in> subtree (RAG s) (Th th)}" (is "finite ?A")
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3358
proof -
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3359
  have "?A = the_thread ` {Th th' | th' . Th th' \<in> subtree (RAG s) (Th th)}"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3360
        by (auto, insert image_iff, fastforce)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3361
  moreover have "finite {Th th' | th' . Th th' \<in> subtree (RAG s) (Th th)}"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3362
        (is "finite ?B")
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3363
  proof -
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3364
     have "?B = (subtree (RAG s) (Th th)) \<inter> {Th th' | th'. True}"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3365
      by auto
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3366
     moreover have "... \<subseteq> (subtree (RAG s) (Th th))" by auto
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3367
     moreover have "finite ..." by (simp add: fsbtRAGs.finite_subtree) 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3368
     ultimately show ?thesis by auto
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3369
  qed
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3370
  ultimately show ?thesis by auto
104
43482ab31341 A fake merge. Used to revert to 98
zhangx
parents: 103 97
diff changeset
  3371
qed
43482ab31341 A fake merge. Used to revert to 98
zhangx
parents: 103 97
diff changeset
  3372
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3373
(* ccc *)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3374
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3375
lemma readys_no_tRAG_chain:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3376
  assumes "th1 \<in> readys s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3377
  and "th2 \<in> readys s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3378
  and "th1 \<noteq> th2"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3379
  shows "(Th th1, Th th2) \<notin> (tRAG s)^*"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3380
proof
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3381
  assume "(Th th1, Th th2) \<in> (tRAG s)\<^sup>*"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3382
  from rtranclD[OF this]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3383
  show False
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3384
  proof
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3385
    assume "Th th1 = Th th2" with assms show ?thesis by simp
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3386
  next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3387
    assume "Th th1 \<noteq> Th th2 \<and> (Th th1, Th th2) \<in> (tRAG s)\<^sup>+"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3388
    hence "(Th th1, Th th2) \<in> (tRAG s)\<^sup>+" by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3389
    from tranclD[OF this] obtain cs where "(Th th1, Cs cs) \<in> RAG s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3390
      by (unfold tRAG_alt_def, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3391
    from in_RAG_E[OF this] have "th1 \<notin> readys s" by (unfold readys_def, auto)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3392
    with assms show ?thesis by simp
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3393
  qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3394
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3395
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3396
lemma root_readys:
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3397
  assumes "th \<in> readys s"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3398
  shows "root (tRAG s) (Th th)"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3399
proof -
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3400
  { assume "\<not> root (tRAG s) (Th th)"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3401
    then obtain n' where "(Th th, n') \<in> (tRAG s)^+"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3402
      unfolding root_def ancestors_def by auto
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3403
    then obtain cs where "(Th th, Cs cs) \<in> RAG s"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3404
      unfolding tRAG_alt_def using tranclD by fastforce 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3405
    then have "th \<notin> readys s" 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3406
      unfolding readys_def using in_RAG_E by blast 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3407
    with assms have False by simp
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3408
  } then show "root (tRAG s) (Th th)" by auto
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3409
qed
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3410
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3411
lemma root_readys_tG:
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3412
  assumes "th \<in> readys s"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3413
  shows "root (tG s) th"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3414
proof -
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3415
  { assume "\<not> root (tG s) th"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3416
    then obtain th' where "(th, th') \<in> (tG s)^+"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3417
      unfolding root_def ancestors_def by auto
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3418
    then have "(Th th, Th th') \<in> (tRAG s)^+" 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3419
      using trancl_tG_tRAG by simp
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3420
    with root_readys assms 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3421
    have False 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3422
      unfolding root_def ancestors_def by auto
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3423
  } then show "root (tG s) th" by auto
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3424
qed  
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3425
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3426
lemma readys_indep:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3427
  assumes "th1 \<in> readys s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3428
  and "th2 \<in> readys s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3429
  and "th1 \<noteq> th2"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3430
  shows "indep (tRAG s) (Th th1) (Th th2)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3431
  using assms readys_no_tRAG_chain
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3432
  unfolding indep_def by blast
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3433
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3434
lemma readys_indep_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3435
  assumes "th1 \<in> readys s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3436
  and "th2 \<in> readys s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3437
  and "th1 \<noteq> th2"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3438
  shows "indep (tG s) th1 th2"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3439
  using assms
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3440
  unfolding indep_def
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3441
  using readys_no_tRAG_chain rtrancl_tG_tRAG by blast
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3442
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3443
text {*
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3444
  The following lemma @{text "thread_chain"} holds on any living thread, 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3445
  not necessarily a running one. 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3446
*}
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3447
lemma thread_chain:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3448
  assumes "th \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3449
  obtains th' where "th' \<in> subtree (tG s) th" "th' \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3450
                    "the_preced s th' = Max (the_preced s ` subtree (tG s) th)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3451
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3452
  have "Max (the_preced s ` subtree (tG s) th) \<in> the_preced s ` subtree (tG s) th"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3453
  proof(rule Max_in)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3454
    show "finite (the_preced s ` subtree (tG s) th)" 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3455
        by (simp add: fsbttGs.finite_subtree)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3456
  next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3457
    show "the_preced s ` subtree (tG s) th \<noteq> {}" using subtree_def by fastforce 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3458
  qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3459
  then obtain th' where 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3460
       h: "th' \<in> subtree (tG s) th"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3461
                    "the_preced s th' = Max (the_preced s ` subtree (tG s) th)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3462
  by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3463
  moreover have "th' \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3464
  proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3465
    from assms have "th \<in> threads s" .
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3466
    from subtree_tG_thread[OF this] and h 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3467
    show ?thesis by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3468
  qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3469
  ultimately show ?thesis using that by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3470
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3471
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3472
text {*
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3473
  The following two lemmas shows there is at most one running thread 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3474
  in the system.
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3475
*}
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3476
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3477
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3478
lemma running_unique:
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3479
  assumes running_1: "th1 \<in> running s"
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3480
  and running_2: "th2 \<in> running s"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3481
  shows "th1 = th2"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3482
proof -
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3483
  -- {* 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3484
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3485
  According to lemma @{thm thread_chain}, each live thread is chained to a
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3486
  thread in its subtree, who holds the highest precedence of the subtree.
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3487
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3488
  The chains for @{term th1} and @{term th2} are established first in the
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3489
  following in @{text "chain1"} and @{text "chain2"}. These chains start
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3490
  with the threads @{text "th1'"} and @{text "th2'"} respectively. *}
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3491
  
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3492
  have "th1 \<in> threads s" using assms
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3493
    by (unfold running_def readys_def, auto)
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3494
  with thread_chain
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3495
  obtain th1' where 
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3496
      chain1: "th1' \<in> subtree (tG s) th1" 
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3497
          "the_preced s th1' = Max (the_preced s ` subtree (tG s) th1)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3498
          "th1' \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3499
      by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3500
  have "th2 \<in> threads s" using assms
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3501
    by (unfold running_def readys_def, auto)
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3502
  with thread_chain
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3503
  obtain th2' where 
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3504
      chain2: "th2' \<in> subtree (tG s) th2" 
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3505
          "the_preced s th2' = Max (the_preced s ` subtree (tG s) th2)"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3506
          "th2' \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3507
      by auto
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3508
  -- {* From these two chains we can be prove that the threads 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3509
        @{term th1} and @{term th2} must be equal. For this we first
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3510
        show that the starting points of the chains are equal.
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3511
     *}
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3512
  have eq_th': "th1' = th2'"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3513
  proof -
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3514
    -- {* from @{text th1} and @{text th2} running, we know their 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3515
          cp-value is the same *}
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3516
    from running_1 and running_2 have "cp s th1 = cp s th2"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3517
      unfolding running_def by auto
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3518
    -- {* that means the preced of @{text th1'} and @{text th2'} 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3519
          must be the same *}
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3520
    then 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3521
    have eq_max: "Max (the_preced s ` subtree (tG s) th1) = 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3522
                  Max (the_preced s ` subtree (tG s) th2)" 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3523
      unfolding cp_alt_def2 .
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3524
    with chain1(2) chain2(2)
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3525
    have "the_preced s th1' = the_preced s th2'" by simp
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3526
    -- {* since the precedences are the same, we can conclude
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3527
          that  @{text th1'} and @{text th2'} are the same *}
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3528
    with preced_unique chain1(3) chain2(3)
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3529
    show "th1' = th2'" unfolding the_preced_def by 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: 90
diff changeset
  3530
  qed
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3531
  moreover
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3532
  have "root (tG s) th1" "root (tG s) th2" using assms
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3533
    using assms root_readys_tG
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3534
    unfolding running_def by auto
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3535
  ultimately show "th1 = th2" using root_unique chain1(1) chain2(1)
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3536
     by fastforce
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3537
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3538
129
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  3539
lemma card_running: 
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  3540
  shows "card (running s) \<le> 1"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3541
proof(cases "running s = {}")
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3542
  case True
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3543
  thus ?thesis by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3544
next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3545
  case False
129
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  3546
  then obtain th where "th \<in> running s" by auto
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  3547
  with running_unique
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3548
  have "running s = {th}" by auto
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3549
  thus ?thesis by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3550
qed
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  3551
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3552
text {*
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3553
  The following two lemmas show that the set of living threads
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3554
  in the system can be partitioned into subtrees of those 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3555
  threads in the @{term readys} set. The first lemma
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3556
  @{text threads_alt_def} shows the union of 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3557
  these subtrees equals to the set of living threads
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3558
  and the second lemma @{text "readys_subtree_disjoint"} shows 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3559
  subtrees of different threads in @{term readys}-set
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3560
  are disjoint.
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3561
*}
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3562
140
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3563
lemma subtree_RAG_tG: 
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3564
  shows "subtree (tG s) th = {th'. Th th' \<in> subtree (RAG s) (Th th)}"
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3565
  using subtree_tG_tRAG threads_set_eq by auto
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3566
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3567
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3568
lemma threads_alt_def:
140
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3569
  "threads s = (\<Union> th \<in> readys s. {th'. Th th' \<in> subtree (RAG s) (Th th)})"
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3570
    (is "?L = ?R")
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3571
proof -
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3572
  { fix th1
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3573
    assume "th1 \<in> ?L"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3574
    from th_chain_to_ready[OF this]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3575
    have "th1 \<in> readys s \<or> (\<exists>th'. th' \<in> readys s \<and> (Th th1, Th th') \<in> (RAG s)\<^sup>+)" .
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3576
    hence "th1 \<in> ?R" by (auto simp:subtree_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3577
  } moreover 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3578
  { fix th'
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3579
    assume "th' \<in> ?R"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3580
    then obtain th where h: "th \<in> readys s" " Th th' \<in> subtree (RAG s) (Th th)"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3581
      by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3582
    from this(2)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3583
    have "th' \<in> ?L" 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3584
    proof(cases rule:subtreeE)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3585
      case 1
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3586
      with h(1) show ?thesis by (auto simp:readys_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3587
    next
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3588
      case 2
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3589
      from tranclD[OF this(2)[unfolded ancestors_def, simplified]]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3590
      have "Th th' \<in> Domain (RAG s)" by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3591
      from dm_RAG_threads[OF this]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3592
      show ?thesis .
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3593
    qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3594
  } ultimately show ?thesis by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3595
qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3596
140
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3597
lemma threads_alt_def1:
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3598
  shows "(threads s) = (\<Union> th \<in> readys s. subtree (tG s) th)"
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3599
unfolding threads_alt_def subtree_RAG_tG  ..
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3600
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3601
lemma readys_subtree_disjoint:
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3602
  assumes "th1 \<in> readys s"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3603
  and "th2 \<in> readys s"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3604
  and "th1 \<noteq> th2"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3605
  shows "subtree (RAG s) (Th th1) \<inter> subtree (RAG s) (Th th2) = {}"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3606
proof -
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3607
  { fix n
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3608
    assume "n \<in> subtree (RAG s) (Th th1) \<inter> subtree (RAG s) (Th th2)"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3609
    hence "(n, Th th1) \<in> (RAG s)^*" "(n, Th th2) \<in> (RAG s)^*"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3610
      by (auto simp:subtree_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3611
    from star_rpath[OF this(1)] star_rpath[OF this(2)]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3612
    obtain xs1 xs2 where "rpath (RAG s) n xs1 (Th th1)"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3613
                         "rpath (RAG s) n xs2 (Th th2)" by metis
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3614
    hence False
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3615
    proof(cases rule:forest_RAG.rpath_overlap')
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3616
      case (less_1 xs3)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3617
      from rpath_star[OF this(3)]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3618
      have "Th th1 \<in> subtree (RAG s) (Th th2)"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3619
        by (auto simp:subtree_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3620
      thus ?thesis
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3621
      proof(cases rule:subtreeE)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3622
        case 1
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3623
        with assms(3) show ?thesis by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3624
      next
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3625
        case 2
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3626
        hence "(Th th1, Th th2) \<in> (RAG s)^+" by (auto simp:ancestors_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3627
        from tranclD[OF this]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3628
        obtain z where "(Th th1, z) \<in> RAG s" by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3629
        from this[unfolded s_RAG_def, folded wq_def]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3630
        obtain cs' where "waiting s th1 cs'"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  3631
          by (auto simp:s_waiting_abv)
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3632
        with assms(1) show False by (auto simp:readys_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3633
      qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3634
    next
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3635
      case (less_2 xs3)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3636
      from rpath_star[OF this(3)]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3637
      have "Th th2 \<in> subtree (RAG s) (Th th1)"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3638
        by (auto simp:subtree_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3639
      thus ?thesis
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3640
      proof(cases rule:subtreeE)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3641
        case 1
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3642
        with assms(3) show ?thesis by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3643
      next
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3644
        case 2
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3645
        hence "(Th th2, Th th1) \<in> (RAG s)^+" by (auto simp:ancestors_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3646
        from tranclD[OF this]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3647
        obtain z where "(Th th2, z) \<in> RAG s" by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3648
        from this[unfolded s_RAG_def, folded wq_def]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3649
        obtain cs' where "waiting s th2 cs'"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  3650
          by (auto simp:s_waiting_abv)
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3651
        with assms(2) show False by (auto simp:readys_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3652
      qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3653
    qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3654
  } thus ?thesis by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3655
qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3656
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  3657
end
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  3658
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3659
section {* Relating @{term cp} and @{term the_preced} and @{term preced} *}
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3660
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3661
text {*
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3662
 @{term cp} of a thread is defined to be the maximum of 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3663
 the @{term preced}-values (precedences) of all threads in 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3664
 its subtree given by @{term RAG}. Therefore, there exits 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3665
 a relationship between @{term cp} and @{term preced} (and 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3666
 also its variation @{term "the_preced"}) to be explored, 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3667
 and this is the target of this section.
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3668
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3669
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3670
context valid_trace
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3671
begin
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3672
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3673
text {*
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3674
  Since @{term cp} is the maximum of all @{term preced}s in its subtree, 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3675
  which includes itself, it is not difficult to show
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3676
  that the one thread's precedence is less or equal to its
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3677
  @{text cp}-value:
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3678
*}
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3679
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3680
lemma le_cp:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3681
  shows "preced th s \<le> cp s th"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3682
  proof(unfold cp_alt_def, rule Max_ge)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3683
    show "finite (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)})"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3684
      by (simp add: finite_subtree_threads)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3685
  next
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3686
    show "preced th s \<in> the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)}"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3687
      by (simp add: subtree_def the_preced_def)   
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3688
  qed
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3689
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3690
text {*
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3691
  Since @{term cp} is the maximum precedence of its subtree,
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3692
  and the subtree is only a subset of the set of all threads,
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3693
  it can be shown that @{text cp} is less or equal to the maximum of
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3694
  all threads:
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3695
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3696
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3697
lemma cp_le:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3698
  assumes th_in: "th \<in> threads s"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3699
  shows "cp s th \<le> Max (the_preced s ` threads s)"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3700
proof(unfold cp_alt_def, rule Max_f_mono)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3701
  show "finite (threads s)" by (simp add: finite_threads) 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3702
next
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3703
  show " {th'. Th th' \<in> subtree (RAG s) (Th th)} \<noteq> {}"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3704
    using subtree_def by fastforce
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3705
next
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3706
  show "{th'. Th th' \<in> subtree (RAG s) (Th th)} \<subseteq> threads s"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3707
    using assms
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3708
    by (smt Domain.DomainI dm_RAG_threads mem_Collect_eq 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3709
        node.inject(1) rtranclD subsetI subtree_def trancl_domain) 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3710
qed
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3711
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3712
text {*
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3713
  Since the @{term cp}-value of each individual thread is less or equal to the 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3714
  maximum precedence value of all threads (shown in lemma @{thm cp_le}),
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3715
  it is easy to derive further that maximum @{term "cp"}-value of
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3716
  all threads is also less or equal to the latter.
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3717
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3718
  On the other hand, since the precedence value of each individual 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3719
  thread is less of equal to its own @{term cp}-value (shown in lemma @{thm le_cp}),
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3720
  it is easy to show that the maximum of the former is less or equal to the 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3721
  maximum of the latter. 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3722
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3723
  By combining these two perspectives, we get the following equality 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3724
  between the two maximums:
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3725
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3726
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3727
lemma max_cp_eq: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3728
  shows "Max ((cp s) ` threads s) = Max (the_preced s ` threads s)"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3729
  (is "?L = ?R")
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3730
proof -
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3731
  have "?L \<le> ?R" 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3732
  proof(cases "threads s = {}")
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3733
    case False
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3734
    show ?thesis 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3735
      by (rule Max.boundedI, 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3736
          insert cp_le, 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3737
          auto simp:finite_threads False)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3738
  qed auto
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3739
  moreover have "?R \<le> ?L"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3740
    by (rule Max_fg_mono, 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3741
        simp add: finite_threads,
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3742
        simp add: le_cp the_preced_def)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3743
  ultimately show ?thesis by auto
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3744
qed
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3745
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3746
text {* (* ddd *) \noindent
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3747
  According to @{thm threads_alt_def} and @{thm readys_subtree_disjoint} , 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3748
  the set of @{term threads} can be partitioned into subtrees of the 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3749
  threads in @{term readys}, and also because  @{term cp}-value of a thread is 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3750
  the maximum precedence of its own subtree, by applying 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3751
  the absorbing property of @{term Max} (lemma @{thm Max_UNION}) 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3752
  over the union of subtrees, the following equation can be derived:
103
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3753
*}
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3754
141
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3755
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3756
lemma cp_alt_def3:
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3757
  shows "cp s th = Max (preceds (subtree (tG s) th) s)"
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3758
unfolding cp_alt_def2
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3759
unfolding image_def
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3760
unfolding the_preced_def
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3761
by meson
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3762
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3763
lemma KK:
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3764
  shows "(\<Union>x\<in>C. B x) = (\<Union> {B x |x. x \<in> C})"
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3765
(*  and "\<Union>" *)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3766
by (simp_all add: Setcompr_eq_image)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3767
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3768
lemma Max_Segments: 
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3769
  assumes "finite C" "\<forall>x\<in> C. finite (B x)" "\<forall>x\<in> C. B x \<noteq> {}" "{B x |x. x \<in> C} \<noteq> {}" 
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3770
  shows "Max (\<Union>x \<in> C. B x) = Max {Max (B x) | x. x \<in> C}"
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3771
using assms
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3772
apply(subst KK(1))
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3773
apply(subst Max_Union)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3774
apply(auto)[3]
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3775
apply(simp add: Setcompr_eq_image)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3776
apply(simp add: image_eq_UN)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3777
done 
140
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3778
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3779
lemma max_cp_readys_max_preced_tG:
141
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3780
  shows "Max (cp s ` readys s) = Max (preceds (threads s) s)" (is "?L = ?R")
103
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3781
proof(cases "readys s = {}")
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3782
  case False
141
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3783
  have "Max (preceds (threads s) s) = Max (preceds (\<Union>th\<in>readys s. subtree (tG s) th) s)"
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3784
    unfolding threads_alt_def1 by simp
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3785
  also have "... = Max {Max (preceds (subtree (tG s) th) s) | th. th \<in> readys s}"
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3786
    apply(subst Max_Segments[symmetric])
142
10c16b85a839 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 141
diff changeset
  3787
    apply (simp add: finite_readys)
10c16b85a839 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 141
diff changeset
  3788
    apply (simp add: fsbttGs.finite_subtree)
10c16b85a839 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 141
diff changeset
  3789
    apply blast
10c16b85a839 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 141
diff changeset
  3790
    using False apply blast
141
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3791
    apply(rule arg_cong)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3792
    back
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3793
    apply(blast)
142
10c16b85a839 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 141
diff changeset
  3794
    done 
141
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3795
  also have "... = Max {cp s th | th. th \<in> readys s}"
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3796
    unfolding cp_alt_def3 ..
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3797
  finally show "Max (cp s ` readys s) = Max (preceds (threads s) s)"
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3798
   by (simp add: Setcompr_eq_image image_def) 
103
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3799
qed (auto simp:threads_alt_def)
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3800
140
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3801
141
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3802
lemma LL:
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3803
shows "the_preced s ` threads s = preceds (threads s) s"
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3804
using the_preced_def by auto
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3805
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3806
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3807
text {*
140
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3808
  The following lemma is simply a corollary of @{thm max_cp_readys_max_preced_tG}
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3809
  and @{thm max_cp_eq}:
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3810
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3811
lemma max_cp_readys_threads:
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3812
  shows "Max (cp s ` readys s) = Max (cp s ` threads s)" 
141
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3813
    apply(simp add: max_cp_readys_max_preced_tG)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3814
    apply(simp add: max_cp_eq)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3815
    apply(simp add: LL)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3816
    done
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3817
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3818
end
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3819
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3820
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3821
section {* Relating @{term cntP}, @{term cntV}, @{term cntCS} and @{term pvD} *}
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: 90
diff changeset
  3822
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3823
text {*
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3824
  As explained in the section where @{term "cntP"},
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3825
  @{term "cntV"} and @{term "cntCS"} are defined, 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3826
  we need to establish a equation (in lemma @{text "cnp_cnv_cncs"}) 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3827
  so that the last can be calculated out of the first two. 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3828
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3829
  While the calculation of @{term "cntV"} and @{term "cntCS"}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3830
  are relatively simple, the calculation of @{term "cntCS"} and 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3831
  @{term "pvD"} are complicated, because their definitions
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3832
  involve a number of other functions such as @{term holdents}, @{term readys}, 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3833
  and @{term threads}. To prove  @{text "cnp_cnv_cncs"}, 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3834
  we need to investigate how the values of these functions
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3835
  are changed with the execution of each kind of system operation.
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3836
  Following conventions, such investigation are divided into 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3837
  locales corresponding to system operations.
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3838
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3839
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: 90
diff changeset
  3840
context valid_trace_p_w
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3841
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3842
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3843
lemma holding_s_holder: "holding s holder cs"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  3844
  by (unfold s_holding_def, unfold wq_s_cs, 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: 90
diff changeset
  3845
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3846
lemma holding_es_holder: "holding (e#s) holder cs"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  3847
  by (unfold s_holding_def, unfold wq_es_cs wq_s_cs, 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: 90
diff changeset
  3848
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3849
lemma holdents_es:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3850
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R") 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3851
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: 90
diff changeset
  3852
  { fix 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: 90
diff changeset
  3853
    assume "cs' \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3854
    hence h: "holding (e#s) th' cs'" by (auto simp: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: 90
diff changeset
  3855
    have "holding s th' 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: 90
diff changeset
  3856
    proof(cases "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: 90
diff changeset
  3857
      case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3858
      from held_unique[OF h[unfolded True] holding_es_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: 90
diff changeset
  3859
      have "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: 90
diff changeset
  3860
      thus ?thesis 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3861
        by (unfold True holdents_def, insert holding_s_holder, 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: 90
diff changeset
  3862
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3863
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3864
      hence "wq (e#s) cs' = wq s cs'" 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: 90
diff changeset
  3865
      from h[unfolded s_holding_def, folded wq_def, unfolded this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3866
      show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  3867
       by (unfold s_holding_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: 90
diff changeset
  3868
    qed 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3869
    hence "cs' \<in> ?R" by (auto simp: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: 90
diff changeset
  3870
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3871
    fix 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: 90
diff changeset
  3872
    assume "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3873
    hence h: "holding s th' cs'" by (auto simp: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: 90
diff changeset
  3874
    have "holding (e#s) th' 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: 90
diff changeset
  3875
    proof(cases "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: 90
diff changeset
  3876
      case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3877
      from held_unique[OF h[unfolded True] 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: 90
diff changeset
  3878
      have "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: 90
diff changeset
  3879
      thus ?thesis 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3880
        by (unfold True holdents_def, insert holding_es_holder, 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: 90
diff changeset
  3881
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3882
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3883
      hence "wq s cs' = wq (e#s) cs'" 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: 90
diff changeset
  3884
      from h[unfolded s_holding_def, folded wq_def, unfolded this]
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3885
      show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  3886
       by (unfold s_holding_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: 90
diff changeset
  3887
    qed 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3888
    hence "cs' \<in> ?L" by (auto simp: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: 90
diff changeset
  3889
  } ultimately show ?thesis 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: 90
diff changeset
  3890
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3891
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3892
lemma cntCS_es_th[simp]: "cntCS (e#s) th' = cntCS 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: 90
diff changeset
  3893
 by (unfold cntCS_def holdents_es, 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: 90
diff changeset
  3894
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3895
lemma th_not_ready_es: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3896
  shows "th \<notin> readys (e#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: 90
diff changeset
  3897
  using waiting_es_th_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: 90
diff changeset
  3898
  by (unfold readys_def, 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: 90
diff changeset
  3899
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3900
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3901
  
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3902
lemma (in valid_trace) finite_holdents: "finite (holdents s th)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3903
  by (unfold holdents_alt_def, insert fsbtRAGs.finite_children, auto)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3904
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3905
context valid_trace_p 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3906
begin
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3907
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3908
lemma live_th_es: "th \<in> threads (e#s)"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3909
  using live_th_s 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3910
  by (unfold is_p, simp)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3911
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3912
lemma waiting_neq_th: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3913
  assumes "waiting s t c"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3914
  shows "t \<noteq> th"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3915
  using assms using th_not_waiting by blast 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3916
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3917
end
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3918
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: 90
diff changeset
  3919
context valid_trace_p_h
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3920
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3921
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3922
lemma th_not_waiting':
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3923
  "\<not> waiting (e#s) th 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: 90
diff changeset
  3924
proof(cases "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: 90
diff changeset
  3925
  case True
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3926
  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: 90
diff changeset
  3927
    by (unfold True s_waiting_def, fold wq_def, unfold wq_es_cs', 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: 90
diff changeset
  3928
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3929
  case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3930
  from th_not_waiting[of cs', unfolded s_waiting_def, folded wq_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: 90
diff changeset
  3931
  show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3932
    by (unfold s_waiting_def, fold wq_def, insert False, 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: 90
diff changeset
  3933
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3934
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3935
lemma ready_th_es: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3936
  shows "th \<in> readys (e#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: 90
diff changeset
  3937
  using th_not_waiting'
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3938
  by (unfold readys_def, insert live_th_es, 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: 90
diff changeset
  3939
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3940
lemma holdents_es_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: 90
diff changeset
  3941
  "holdents (e#s) th = (holdents s th) \<union> {cs}" (is "?L = ?R")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3942
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: 90
diff changeset
  3943
  { fix 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: 90
diff changeset
  3944
    assume "cs' \<in> ?L" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3945
    hence "holding (e#s) th 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: 90
diff changeset
  3946
      by (unfold holdents_def, 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: 90
diff changeset
  3947
    hence "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3948
     by (cases rule:holding_esE, auto simp: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: 90
diff changeset
  3949
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3950
    fix 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: 90
diff changeset
  3951
    assume "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3952
    hence "holding s th cs' \<or> 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: 90
diff changeset
  3953
      by (auto simp: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: 90
diff changeset
  3954
    hence "cs' \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3955
    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: 90
diff changeset
  3956
      assume "holding s th 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: 90
diff changeset
  3957
      from holding_kept[OF this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3958
      show ?thesis by (auto simp:holdents_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3959
    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: 90
diff changeset
  3960
      assume "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: 90
diff changeset
  3961
      thus ?thesis using holding_es_th_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: 90
diff changeset
  3962
        by (unfold holdents_def, 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: 90
diff changeset
  3963
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3964
  } ultimately show ?thesis 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: 90
diff changeset
  3965
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3966
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3967
lemma not_holding_s_th_cs: "\<not> holding s th cs"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3968
proof
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3969
  assume otherwise: "holding s th cs"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3970
  from pip_e[unfolded is_p]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3971
  show False
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3972
  proof(cases)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3973
    case (thread_P)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3974
    moreover have "(Cs cs, Th th) \<in> RAG s"
120
b3b8735c7c02 updated to Isabelle 2016
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 119
diff changeset
  3975
      using otherwise th_not_in_wq
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  3976
      using s_holding_def wq_def by auto
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3977
    ultimately show ?thesis by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3978
  qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3979
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3980
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: 90
diff changeset
  3981
lemma cntCS_es_th: "cntCS (e#s) th = cntCS s th + 1"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3982
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: 90
diff changeset
  3983
  have "card (holdents s th \<union> {cs}) = card (holdents s th) + 1"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3984
  proof(subst card_Un_disjoint)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3985
    show "holdents s th \<inter> {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: 90
diff changeset
  3986
      using not_holding_s_th_cs by (auto simp: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: 90
diff changeset
  3987
  qed (auto simp:finite_holdents)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3988
  thus ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3989
   by (unfold cntCS_def holdents_es_th, 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: 90
diff changeset
  3990
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3991
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3992
lemma no_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: 90
diff changeset
  3993
  "\<not> holding s th' 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: 90
diff changeset
  3994
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: 90
diff changeset
  3995
  assume otherwise: "holding s th' 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: 90
diff changeset
  3996
  from this[unfolded s_holding_def, folded wq_def, unfolded we]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3997
  show False 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: 90
diff changeset
  3998
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3999
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4000
lemma holdents_es_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: 90
diff changeset
  4001
  assumes "th' \<noteq> 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: 90
diff changeset
  4002
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4003
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: 90
diff changeset
  4004
  { fix 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: 90
diff changeset
  4005
    assume "cs' \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4006
    hence h_e: "holding (e#s) th' cs'" by (auto simp: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: 90
diff changeset
  4007
    have "cs' \<noteq> 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: 90
diff changeset
  4008
    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: 90
diff changeset
  4009
      assume "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: 90
diff changeset
  4010
      from held_unique[OF h_e[unfolded this] holding_es_th_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: 90
diff changeset
  4011
      have "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: 90
diff changeset
  4012
      with assms show False 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: 90
diff changeset
  4013
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4014
    from h_e[unfolded s_holding_def, folded wq_def, unfolded wq_neq_simp[OF this]]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4015
    have "th' \<in> set (wq s cs') \<and> th' = hd (wq s 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: 90
diff changeset
  4016
    hence "cs' \<in> ?R" 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4017
      by (unfold holdents_def s_holding_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: 90
diff changeset
  4018
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4019
    fix 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: 90
diff changeset
  4020
    assume "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4021
    hence "holding s th' cs'" by (auto simp: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: 90
diff changeset
  4022
    from holding_kept[OF this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4023
    have "holding (e # s) th' 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: 90
diff changeset
  4024
    hence "cs' \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4025
      by (unfold holdents_def, 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: 90
diff changeset
  4026
  } ultimately show ?thesis 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: 90
diff changeset
  4027
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4028
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4029
lemma cntCS_es_th'[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: 90
diff changeset
  4030
  assumes "th' \<noteq> 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: 90
diff changeset
  4031
  shows "cntCS (e#s) th' = cntCS 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: 90
diff changeset
  4032
  by (unfold cntCS_def holdents_es_th'[OF assms], 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: 90
diff changeset
  4033
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4034
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4035
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4036
context valid_trace_p
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4037
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4038
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4039
lemma readys_kept1: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4040
  assumes "th' \<noteq> 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: 90
diff changeset
  4041
  and "th' \<in> readys (e#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: 90
diff changeset
  4042
  shows "th' \<in> readys 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: 90
diff changeset
  4043
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: 90
diff changeset
  4044
  { fix 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: 90
diff changeset
  4045
    assume wait: "waiting s th' 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: 90
diff changeset
  4046
    have n_wait: "\<not> waiting (e#s) th' 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: 90
diff changeset
  4047
        using assms(2)[unfolded readys_def] 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: 90
diff changeset
  4048
    have False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4049
    proof(cases "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: 90
diff changeset
  4050
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4051
      with n_wait wait
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4052
      show ?thesis 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4053
        by (unfold s_waiting_def, fold wq_def, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4054
    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: 90
diff changeset
  4055
      case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4056
      show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4057
      proof(cases "wq s 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: 90
diff changeset
  4058
        case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4059
        then interpret vt: valid_trace_p_h
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4060
          by (unfold_locales, 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: 90
diff changeset
  4061
        show ?thesis using n_wait wait waiting_kept 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: 90
diff changeset
  4062
      next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4063
        case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4064
        then interpret vt: valid_trace_p_w by (unfold_locales, 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: 90
diff changeset
  4065
        show ?thesis using n_wait wait waiting_kept by blast 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4066
      qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4067
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4068
  } with assms(2) show ?thesis  
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4069
    by (unfold readys_def, 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: 90
diff changeset
  4070
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4071
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4072
lemma readys_kept2: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4073
  assumes "th' \<noteq> 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: 90
diff changeset
  4074
  and "th' \<in> readys 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: 90
diff changeset
  4075
  shows "th' \<in> readys (e#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: 90
diff changeset
  4076
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: 90
diff changeset
  4077
  { fix 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: 90
diff changeset
  4078
    assume wait: "waiting (e#s) th' 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: 90
diff changeset
  4079
    have n_wait: "\<not> waiting s th' 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: 90
diff changeset
  4080
        using assms(2)[unfolded readys_def] 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: 90
diff changeset
  4081
    have False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4082
    proof(cases "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: 90
diff changeset
  4083
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4084
      with n_wait wait
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4085
      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: 90
diff changeset
  4086
        by (unfold s_waiting_def, fold wq_def, 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: 90
diff changeset
  4087
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4088
      case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4089
      show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4090
      proof(cases "wq s 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: 90
diff changeset
  4091
        case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4092
        then interpret vt: valid_trace_p_h
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4093
          by (unfold_locales, 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: 90
diff changeset
  4094
        show ?thesis using n_wait vt.waiting_esE wait by blast 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4095
      next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4096
        case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4097
        then interpret vt: valid_trace_p_w by (unfold_locales, 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: 90
diff changeset
  4098
        show ?thesis using assms(1) n_wait vt.waiting_esE wait by auto 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4099
      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: 90
diff changeset
  4100
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4101
  } with assms(2) show ?thesis  
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4102
    by (unfold readys_def, 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: 90
diff changeset
  4103
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4104
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4105
lemma readys_simp [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: 90
diff changeset
  4106
  assumes "th' \<noteq> 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: 90
diff changeset
  4107
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys 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: 90
diff changeset
  4108
  using readys_kept1[OF assms] readys_kept2[OF 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: 90
diff changeset
  4109
  by metis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4110
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4111
lemma cnp_cnv_cncs_kept: (* ddd *)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4112
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD 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: 90
diff changeset
  4113
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#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: 90
diff changeset
  4114
proof(cases "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: 90
diff changeset
  4115
  case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4116
  note eq_th' = this
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4117
  show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4118
  proof(cases "wq s 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: 90
diff changeset
  4119
    case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4120
    then interpret vt: valid_trace_p_h by (unfold_locales, 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: 90
diff changeset
  4121
    show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4122
      using assms eq_th' is_p ready_th_s vt.cntCS_es_th vt.ready_th_es pvD_def 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: 90
diff changeset
  4123
  next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4124
    case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4125
    then interpret vt: valid_trace_p_w by (unfold_locales, 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: 90
diff changeset
  4126
    show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4127
      using add.commute add.left_commute assms eq_th' is_p live_th_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: 90
diff changeset
  4128
            ready_th_s vt.th_not_ready_es pvD_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: 90
diff changeset
  4129
      apply (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: 90
diff changeset
  4130
      by (fold is_p, 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: 90
diff changeset
  4131
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4132
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4133
  case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4134
  note h_False = False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4135
  thus ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4136
  proof(cases "wq s 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: 90
diff changeset
  4137
    case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4138
    then interpret vt: valid_trace_p_h by (unfold_locales, 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: 90
diff changeset
  4139
    show ?thesis 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: 90
diff changeset
  4140
      by (insert True h_False pvD_def, auto split:if_splits,unfold is_p, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4141
  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: 90
diff changeset
  4142
    case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4143
    then interpret vt: valid_trace_p_w by (unfold_locales, 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: 90
diff changeset
  4144
    show ?thesis 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: 90
diff changeset
  4145
      by (insert False h_False pvD_def, auto split:if_splits,unfold is_p, 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: 90
diff changeset
  4146
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4147
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4148
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4149
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4150
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4151
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  4152
context valid_trace_v 
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: 90
diff changeset
  4153
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4154
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4155
lemma holding_th_cs_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: 90
diff changeset
  4156
  "holding s th cs" 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4157
 by  (unfold s_holding_def, unfold wq_s_cs, 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: 90
diff changeset
  4158
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4159
lemma th_ready_s [simp]: "th \<in> readys s"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4160
  using running_th_s
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4161
  by (unfold running_def readys_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: 90
diff changeset
  4162
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4163
lemma th_live_s [simp]: "th \<in> threads 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: 90
diff changeset
  4164
  using th_ready_s by (unfold readys_def, 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: 90
diff changeset
  4165
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4166
lemma th_ready_es [simp]: "th \<in> readys (e#s)"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4167
  using running_th_s neq_t_th
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4168
  by (unfold is_v running_def readys_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: 90
diff changeset
  4169
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4170
lemma th_live_es [simp]: "th \<in> threads (e#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: 90
diff changeset
  4171
  using th_ready_es by (unfold readys_def, 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: 90
diff changeset
  4172
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4173
lemma pvD_th_s[simp]: "pvD s th = 0"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4174
  by (unfold pvD_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: 90
diff changeset
  4175
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4176
lemma pvD_th_es[simp]: "pvD (e#s) th = 0"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4177
  by (unfold pvD_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: 90
diff changeset
  4178
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4179
lemma cntCS_s_th [simp]: "cntCS s th > 0"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4180
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: 90
diff changeset
  4181
  have "cs \<in> holdents s th" using holding_th_cs_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: 90
diff changeset
  4182
    by (unfold holdents_def, simp)
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4183
  moreover have "finite (holdents s th)" using finite_holdents 
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: 90
diff changeset
  4184
    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: 90
diff changeset
  4185
  ultimately show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4186
    by (unfold cntCS_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: 90
diff changeset
  4187
        auto intro!:card_gt_0_iff[symmetric, THEN iffD1])
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4188
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4189
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4190
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4191
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4192
context valid_trace_v
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4193
begin
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4194
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4195
lemma th_not_waiting: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4196
  "\<not> waiting s th c"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4197
proof -
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4198
  have "th \<in> readys s"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4199
    using running_ready running_th_s by blast 
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4200
  thus ?thesis
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4201
    by (unfold readys_def, auto)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4202
qed
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4203
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4204
lemma waiting_neq_th: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4205
  assumes "waiting s t c"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4206
  shows "t \<noteq> th"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4207
  using assms using th_not_waiting by blast 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4208
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4209
end
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4210
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: 90
diff changeset
  4211
context valid_trace_v_n
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4212
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4213
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4214
lemma not_ready_taker_s[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: 90
diff changeset
  4215
  "taker \<notin> readys 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: 90
diff changeset
  4216
  using waiting_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: 90
diff changeset
  4217
  by (unfold readys_def, 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: 90
diff changeset
  4218
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4219
lemma taker_live_s [simp]: "taker \<in> threads 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: 90
diff changeset
  4220
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: 90
diff changeset
  4221
  have "taker \<in> set wq'" by (simp add: eq_wq') 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4222
  from th'_in_inv[OF this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4223
  have "taker \<in> set rest" .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4224
  hence "taker \<in> set (wq s cs)" by (simp add: wq_s_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: 90
diff changeset
  4225
  thus ?thesis using wq_threads 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: 90
diff changeset
  4226
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4227
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4228
lemma taker_live_es [simp]: "taker \<in> threads (e#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: 90
diff changeset
  4229
  using taker_live_s threads_es by blast
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4230
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4231
lemma taker_ready_es [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: 90
diff changeset
  4232
  shows "taker \<in> readys (e#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: 90
diff changeset
  4233
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: 90
diff changeset
  4234
  { fix 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: 90
diff changeset
  4235
    assume "waiting (e#s) taker 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: 90
diff changeset
  4236
    hence False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4237
    proof(cases rule:waiting_esE)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4238
      case 1
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4239
      thus ?thesis using waiting_taker waiting_unique 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: 90
diff changeset
  4240
    qed 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: 90
diff changeset
  4241
  } thus ?thesis by (unfold readys_def, 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: 90
diff changeset
  4242
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4243
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4244
lemma neq_taker_th: "taker \<noteq> th"
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4245
  using th_not_waiting waiting_taker by blast 
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: 90
diff changeset
  4246
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4247
lemma not_holding_taker_s_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: 90
diff changeset
  4248
  shows "\<not> holding s taker 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: 90
diff changeset
  4249
  using holding_cs_eq_th neq_taker_th 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: 90
diff changeset
  4250
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4251
lemma holdents_es_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: 90
diff changeset
  4252
  "holdents (e#s) taker = holdents s taker \<union> {cs}" (is "?L = ?R")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4253
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: 90
diff changeset
  4254
  { fix 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: 90
diff changeset
  4255
    assume "cs' \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4256
    hence "holding (e#s) taker cs'" by (auto simp: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: 90
diff changeset
  4257
    hence "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4258
    proof(cases rule:holding_esE)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4259
      case 2
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4260
      thus ?thesis by (auto simp: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: 90
diff changeset
  4261
    qed 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: 90
diff changeset
  4262
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4263
    fix 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: 90
diff changeset
  4264
    assume "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4265
    hence "holding s taker cs' \<or> cs' = cs" by (auto simp: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: 90
diff changeset
  4266
    hence "cs' \<in> ?L" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4267
    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: 90
diff changeset
  4268
      assume "holding s taker 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: 90
diff changeset
  4269
      hence "holding (e#s) taker 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: 90
diff changeset
  4270
          using holding_esI2 holding_taker by fastforce 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4271
      thus ?thesis by (auto simp:holdents_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4272
    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: 90
diff changeset
  4273
      assume "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: 90
diff changeset
  4274
      with holding_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: 90
diff changeset
  4275
      show ?thesis by (auto simp: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: 90
diff changeset
  4276
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4277
  } ultimately show ?thesis 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: 90
diff changeset
  4278
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4279
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4280
lemma cntCS_es_taker [simp]: "cntCS (e#s) taker = cntCS s taker + 1"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4281
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: 90
diff changeset
  4282
  have "card (holdents s taker \<union> {cs}) = card (holdents s taker) + 1"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4283
  proof(subst card_Un_disjoint)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4284
    show "holdents s taker \<inter> {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: 90
diff changeset
  4285
      using not_holding_taker_s_cs by (auto simp: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: 90
diff changeset
  4286
  qed (auto simp:finite_holdents)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4287
  thus ?thesis 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4288
    by (unfold cntCS_def, insert holdents_es_taker, 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: 90
diff changeset
  4289
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4290
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4291
lemma pvD_taker_s[simp]: "pvD s taker = 1"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4292
  by (unfold pvD_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: 90
diff changeset
  4293
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4294
lemma pvD_taker_es[simp]: "pvD (e#s) taker = 0"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4295
  by (unfold pvD_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: 90
diff changeset
  4296
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4297
lemma pvD_th_s[simp]: "pvD s th = 0"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4298
  by (unfold pvD_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: 90
diff changeset
  4299
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4300
lemma pvD_th_es[simp]: "pvD (e#s) th = 0"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4301
  by (unfold pvD_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: 90
diff changeset
  4302
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4303
lemma holdents_es_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: 90
diff changeset
  4304
  "holdents (e#s) th = holdents s th - {cs}" (is "?L = ?R")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4305
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: 90
diff changeset
  4306
  { fix 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: 90
diff changeset
  4307
    assume "cs' \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4308
    hence "holding (e#s) th cs'" by (auto simp: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: 90
diff changeset
  4309
    hence "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4310
    proof(cases rule:holding_esE)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4311
      case 2
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4312
      thus ?thesis by (auto simp: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: 90
diff changeset
  4313
    qed (insert neq_taker_th, 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: 90
diff changeset
  4314
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4315
    fix 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: 90
diff changeset
  4316
    assume "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4317
    hence "cs' \<noteq> cs" "holding s th cs'" by (auto simp: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: 90
diff changeset
  4318
    from holding_esI2[OF this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4319
    have "cs' \<in> ?L" by (auto simp: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: 90
diff changeset
  4320
  } ultimately show ?thesis 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: 90
diff changeset
  4321
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4322
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4323
lemma cntCS_es_th [simp]: "cntCS (e#s) th = cntCS s th - 1"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4324
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: 90
diff changeset
  4325
  have "card (holdents s th - {cs}) = card (holdents s th) - 1"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4326
  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: 90
diff changeset
  4327
    have "cs \<in> holdents s th" using holding_th_cs_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: 90
diff changeset
  4328
      by (auto simp: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: 90
diff changeset
  4329
    moreover have "finite (holdents 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: 90
diff changeset
  4330
        by (simp add: finite_holdents) 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4331
    ultimately show ?thesis 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: 90
diff changeset
  4332
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4333
  thus ?thesis by (unfold cntCS_def holdents_es_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: 90
diff changeset
  4334
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4335
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4336
lemma holdents_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4337
  assumes "th' \<noteq> 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: 90
diff changeset
  4338
  and "th' \<noteq> 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: 90
diff changeset
  4339
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4340
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: 90
diff changeset
  4341
  { fix 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: 90
diff changeset
  4342
    assume h: "cs' \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4343
    have "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4344
    proof(cases "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: 90
diff changeset
  4345
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4346
      hence eq_wq: "wq (e#s) cs' = wq s cs'" 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: 90
diff changeset
  4347
      from h have "holding (e#s) th' cs'" by (auto simp: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: 90
diff changeset
  4348
      from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4349
      show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4350
        by (unfold holdents_def s_holding_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: 90
diff changeset
  4351
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4352
      case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4353
      from h[unfolded this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4354
      have "holding (e#s) th' cs" by (auto simp: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: 90
diff changeset
  4355
      from held_unique[OF this holding_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: 90
diff changeset
  4356
      have "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: 90
diff changeset
  4357
      with assms show ?thesis 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: 90
diff changeset
  4358
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4359
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4360
    fix 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: 90
diff changeset
  4361
    assume h: "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4362
    have "cs' \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4363
    proof(cases "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: 90
diff changeset
  4364
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4365
      hence eq_wq: "wq (e#s) cs' = wq s cs'" 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: 90
diff changeset
  4366
      from h have "holding s th' cs'" by (auto simp: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: 90
diff changeset
  4367
      from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq]
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4368
      show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4369
        by (unfold holdents_def s_holding_def, insert eq_wq, 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: 90
diff changeset
  4370
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4371
      case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4372
      from h[unfolded this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4373
      have "holding s th' cs" by (auto simp: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: 90
diff changeset
  4374
      from held_unique[OF this holding_th_cs_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: 90
diff changeset
  4375
      have "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: 90
diff changeset
  4376
      with assms show ?thesis 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: 90
diff changeset
  4377
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4378
  } ultimately show ?thesis 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: 90
diff changeset
  4379
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4380
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4381
lemma cntCS_kept [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: 90
diff changeset
  4382
  assumes "th' \<noteq> 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: 90
diff changeset
  4383
  and "th' \<noteq> 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: 90
diff changeset
  4384
  shows "cntCS (e#s) th' = cntCS 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: 90
diff changeset
  4385
  by (unfold cntCS_def holdents_kept[OF assms], 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: 90
diff changeset
  4386
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4387
lemma readys_kept1: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4388
  assumes "th' \<noteq> 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: 90
diff changeset
  4389
  and "th' \<in> readys (e#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: 90
diff changeset
  4390
  shows "th' \<in> readys 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: 90
diff changeset
  4391
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: 90
diff changeset
  4392
  { fix 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: 90
diff changeset
  4393
    assume wait: "waiting s th' 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: 90
diff changeset
  4394
    have n_wait: "\<not> waiting (e#s) th' 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: 90
diff changeset
  4395
        using assms(2)[unfolded readys_def] 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: 90
diff changeset
  4396
    have False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4397
    proof(cases "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: 90
diff changeset
  4398
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4399
      with n_wait wait
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4400
      show ?thesis 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4401
        by (unfold s_waiting_def, fold wq_def, 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: 90
diff changeset
  4402
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4403
      case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4404
      have "th' \<in> set (th # rest) \<and> th' \<noteq> hd (th # rest)" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4405
        using wait[unfolded True s_waiting_def, folded wq_def, unfolded wq_s_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: 90
diff changeset
  4406
      moreover have "\<not> (th' \<in> set rest \<and> th' \<noteq> hd (taker # rest'))" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4407
        using n_wait[unfolded True s_waiting_def, folded wq_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: 90
diff changeset
  4408
                    unfolded wq_es_cs set_wq', unfolded eq_wq'] .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4409
      ultimately have "th' = taker" 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: 90
diff changeset
  4410
      with assms(1)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4411
      show ?thesis 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: 90
diff changeset
  4412
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4413
  } with assms(2) show ?thesis  
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4414
    by (unfold readys_def, 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: 90
diff changeset
  4415
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4416
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4417
lemma readys_kept2: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4418
  assumes "th' \<noteq> 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: 90
diff changeset
  4419
  and "th' \<in> readys 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: 90
diff changeset
  4420
  shows "th' \<in> readys (e#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: 90
diff changeset
  4421
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: 90
diff changeset
  4422
  { fix 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: 90
diff changeset
  4423
    assume wait: "waiting (e#s) th' 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: 90
diff changeset
  4424
    have n_wait: "\<not> waiting s th' 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: 90
diff changeset
  4425
        using assms(2)[unfolded readys_def] 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: 90
diff changeset
  4426
    have False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4427
    proof(cases "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: 90
diff changeset
  4428
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4429
      with n_wait wait
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4430
      show ?thesis 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4431
        by (unfold s_waiting_def, fold wq_def, 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: 90
diff changeset
  4432
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4433
      case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4434
      have "th' \<in> set rest \<and> th' \<noteq> hd (taker # rest')"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4435
          using  wait [unfolded True s_waiting_def, folded wq_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: 90
diff changeset
  4436
                    unfolded wq_es_cs set_wq', unfolded eq_wq']  .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4437
      moreover have "\<not> (th' \<in> set (th # rest) \<and> th' \<noteq> hd (th # rest))"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4438
          using n_wait[unfolded True s_waiting_def, folded wq_def, unfolded wq_s_cs] .
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  4439
      ultimately have "th' = taker" using th_not_in_rest by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  4440
      thm taker_def wq'_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: 90
diff changeset
  4441
      with assms(1)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4442
      show ?thesis 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: 90
diff changeset
  4443
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4444
  } with assms(2) show ?thesis  
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4445
    by (unfold readys_def, 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: 90
diff changeset
  4446
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4447
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4448
lemma readys_simp [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: 90
diff changeset
  4449
  assumes "th' \<noteq> 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: 90
diff changeset
  4450
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys 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: 90
diff changeset
  4451
  using readys_kept1[OF assms] readys_kept2[OF 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: 90
diff changeset
  4452
  by metis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4453
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4454
lemma cnp_cnv_cncs_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4455
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD 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: 90
diff changeset
  4456
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#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: 90
diff changeset
  4457
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: 90
diff changeset
  4458
  { assume eq_th': "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: 90
diff changeset
  4459
    have ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4460
      apply (unfold eq_th' pvD_taker_es cntCS_es_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: 90
diff changeset
  4461
      by (insert neq_taker_th assms[unfolded eq_th'], unfold is_v, 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: 90
diff changeset
  4462
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4463
    assume eq_th': "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: 90
diff changeset
  4464
    have ?thesis 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4465
      apply (unfold eq_th' pvD_th_es cntCS_es_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: 90
diff changeset
  4466
      by (insert assms[unfolded eq_th'], unfold is_v, 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: 90
diff changeset
  4467
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4468
    assume h: "th' \<noteq> taker" "th' \<noteq> 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: 90
diff changeset
  4469
    have ?thesis 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: 90
diff changeset
  4470
      apply (unfold cntCS_kept[OF h], insert h, unfold is_v, 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: 90
diff changeset
  4471
      by (fold is_v, unfold pvD_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: 90
diff changeset
  4472
  } ultimately show ?thesis by metis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4473
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4474
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4475
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4476
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4477
context valid_trace_v_e
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4478
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4479
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4480
lemma holdents_es_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: 90
diff changeset
  4481
  "holdents (e#s) th = holdents s th - {cs}" (is "?L = ?R")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4482
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: 90
diff changeset
  4483
  { fix 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: 90
diff changeset
  4484
    assume "cs' \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4485
    hence "holding (e#s) th cs'" by (auto simp: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: 90
diff changeset
  4486
    hence "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4487
    proof(cases rule:holding_esE)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4488
      case 1
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4489
      thus ?thesis by (auto simp: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: 90
diff changeset
  4490
    qed 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4491
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4492
    fix 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: 90
diff changeset
  4493
    assume "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4494
    hence "cs' \<noteq> cs" "holding s th cs'" by (auto simp: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: 90
diff changeset
  4495
    from holding_esI2[OF this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4496
    have "cs' \<in> ?L" by (auto simp: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: 90
diff changeset
  4497
  } ultimately show ?thesis 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: 90
diff changeset
  4498
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4499
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4500
lemma cntCS_es_th [simp]: "cntCS (e#s) th = cntCS s th - 1"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4501
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: 90
diff changeset
  4502
  have "card (holdents s th - {cs}) = card (holdents s th) - 1"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4503
  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: 90
diff changeset
  4504
    have "cs \<in> holdents s th" using holding_th_cs_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: 90
diff changeset
  4505
      by (auto simp: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: 90
diff changeset
  4506
    moreover have "finite (holdents 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: 90
diff changeset
  4507
        by (simp add: finite_holdents) 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4508
    ultimately show ?thesis 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: 90
diff changeset
  4509
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4510
  thus ?thesis by (unfold cntCS_def holdents_es_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: 90
diff changeset
  4511
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4512
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4513
lemma holdents_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4514
  assumes "th' \<noteq> 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: 90
diff changeset
  4515
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4516
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: 90
diff changeset
  4517
  { fix 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: 90
diff changeset
  4518
    assume h: "cs' \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4519
    have "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4520
    proof(cases "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: 90
diff changeset
  4521
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4522
      hence eq_wq: "wq (e#s) cs' = wq s cs'" 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: 90
diff changeset
  4523
      from h have "holding (e#s) th' cs'" by (auto simp: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: 90
diff changeset
  4524
      from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4525
      show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4526
        by (unfold holdents_def s_holding_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: 90
diff changeset
  4527
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4528
      case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4529
      from h[unfolded this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4530
      have "holding (e#s) th' cs" by (auto simp: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: 90
diff changeset
  4531
      from this[unfolded s_holding_def, folded wq_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: 90
diff changeset
  4532
            unfolded wq_es_cs nil_wq']
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4533
      show ?thesis 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: 90
diff changeset
  4534
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4535
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4536
    fix 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: 90
diff changeset
  4537
    assume h: "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4538
    have "cs' \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4539
    proof(cases "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: 90
diff changeset
  4540
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4541
      hence eq_wq: "wq (e#s) cs' = wq s cs'" 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: 90
diff changeset
  4542
      from h have "holding s th' cs'" by (auto simp: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: 90
diff changeset
  4543
      from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4544
      show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4545
        by (unfold holdents_def s_holding_def, insert eq_wq, 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: 90
diff changeset
  4546
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4547
      case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4548
      from h[unfolded this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4549
      have "holding s th' cs" by (auto simp: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: 90
diff changeset
  4550
      from held_unique[OF this holding_th_cs_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: 90
diff changeset
  4551
      have "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: 90
diff changeset
  4552
      with assms show ?thesis 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: 90
diff changeset
  4553
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4554
  } ultimately show ?thesis 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: 90
diff changeset
  4555
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4556
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4557
lemma cntCS_kept [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: 90
diff changeset
  4558
  assumes "th' \<noteq> 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: 90
diff changeset
  4559
  shows "cntCS (e#s) th' = cntCS 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: 90
diff changeset
  4560
  by (unfold cntCS_def holdents_kept[OF assms], 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: 90
diff changeset
  4561
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4562
lemma readys_kept1: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4563
  assumes "th' \<in> readys (e#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: 90
diff changeset
  4564
  shows "th' \<in> readys 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: 90
diff changeset
  4565
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: 90
diff changeset
  4566
  { fix 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: 90
diff changeset
  4567
    assume wait: "waiting s th' 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: 90
diff changeset
  4568
    have n_wait: "\<not> waiting (e#s) th' 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: 90
diff changeset
  4569
        using assms(1)[unfolded readys_def] 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: 90
diff changeset
  4570
    have False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4571
    proof(cases "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: 90
diff changeset
  4572
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4573
      with n_wait wait
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4574
      show ?thesis 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4575
        by (unfold s_waiting_def, fold wq_def, 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: 90
diff changeset
  4576
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4577
      case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4578
      have "th' \<in> set (th # rest) \<and> th' \<noteq> hd (th # rest)" 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4579
        using wait[unfolded True s_waiting_def, folded wq_def, unfolded wq_s_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: 90
diff changeset
  4580
      hence "th' \<in> set rest" 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: 90
diff changeset
  4581
      with set_wq' have "th' \<in> set wq'" by metis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4582
      with nil_wq' show ?thesis 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: 90
diff changeset
  4583
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4584
  } thus ?thesis 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: 90
diff changeset
  4585
    by (unfold readys_def, 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: 90
diff changeset
  4586
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4587
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4588
lemma readys_kept2: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4589
  assumes "th' \<in> readys 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: 90
diff changeset
  4590
  shows "th' \<in> readys (e#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: 90
diff changeset
  4591
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: 90
diff changeset
  4592
  { fix 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: 90
diff changeset
  4593
    assume wait: "waiting (e#s) th' 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: 90
diff changeset
  4594
    have n_wait: "\<not> waiting s th' 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: 90
diff changeset
  4595
        using assms[unfolded readys_def] 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: 90
diff changeset
  4596
    have False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4597
    proof(cases "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: 90
diff changeset
  4598
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4599
      with n_wait wait
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4600
      show ?thesis 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4601
        by (unfold s_waiting_def, fold wq_def, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4602
    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: 90
diff changeset
  4603
      case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4604
      have "th' \<in> set [] \<and> th' \<noteq> hd []"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4605
        using wait[unfolded True s_waiting_def, folded wq_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: 90
diff changeset
  4606
              unfolded wq_es_cs nil_wq'] .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4607
      thus ?thesis by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4608
    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: 90
diff changeset
  4609
  } with assms show ?thesis  
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4610
    by (unfold readys_def, 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: 90
diff changeset
  4611
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4612
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4613
lemma readys_simp [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: 90
diff changeset
  4614
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys 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: 90
diff changeset
  4615
  using readys_kept1[OF assms] readys_kept2[OF 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: 90
diff changeset
  4616
  by metis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4617
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4618
lemma cnp_cnv_cncs_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4619
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD 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: 90
diff changeset
  4620
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#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: 90
diff changeset
  4621
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: 90
diff changeset
  4622
  {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4623
    assume eq_th': "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: 90
diff changeset
  4624
    have ?thesis 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4625
      apply (unfold eq_th' pvD_th_es cntCS_es_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: 90
diff changeset
  4626
      by (insert assms[unfolded eq_th'], unfold is_v, 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: 90
diff changeset
  4627
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4628
    assume h: "th' \<noteq> 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: 90
diff changeset
  4629
    have ?thesis 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: 90
diff changeset
  4630
      apply (unfold cntCS_kept[OF h], insert h, unfold is_v, 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: 90
diff changeset
  4631
      by (fold is_v, unfold pvD_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: 90
diff changeset
  4632
  } ultimately show ?thesis by metis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4633
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4634
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4635
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4636
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4637
context valid_trace_v
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4638
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4639
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4640
lemma cnp_cnv_cncs_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4641
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD 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: 90
diff changeset
  4642
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#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: 90
diff changeset
  4643
proof(cases "rest = []")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4644
  case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4645
  then interpret vt: valid_trace_v_e by (unfold_locales, 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: 90
diff changeset
  4646
  show ?thesis using assms using vt.cnp_cnv_cncs_kept by blast 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4647
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4648
  case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4649
  then interpret vt: valid_trace_v_n by (unfold_locales, 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: 90
diff changeset
  4650
  show ?thesis using assms using vt.cnp_cnv_cncs_kept by blast 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4651
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4652
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4653
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4654
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4655
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: 90
diff changeset
  4656
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4657
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4658
lemma th_not_live_s [simp]: "th \<notin> threads 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: 90
diff changeset
  4659
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: 90
diff changeset
  4660
  from pip_e[unfolded is_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: 90
diff changeset
  4661
  show ?thesis by (cases, 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: 90
diff changeset
  4662
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4663
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4664
lemma th_not_ready_s [simp]: "th \<notin> readys 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: 90
diff changeset
  4665
  using th_not_live_s by (unfold readys_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: 90
diff changeset
  4666
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4667
lemma th_live_es [simp]: "th \<in> threads (e#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: 90
diff changeset
  4668
  by (unfold is_create, 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: 90
diff changeset
  4669
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4670
lemma not_waiting_th_s [simp]: "\<not> waiting s th 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: 90
diff changeset
  4671
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: 90
diff changeset
  4672
  assume "waiting s th cs'"
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4673
  from this[unfolded s_waiting_def, folded wq_def, unfolded wq_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: 90
diff changeset
  4674
  have "th \<in> set (wq s cs')" 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: 90
diff changeset
  4675
  from wq_threads[OF this] have "th \<in> threads 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: 90
diff changeset
  4676
  with th_not_live_s show False 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: 90
diff changeset
  4677
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4678
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4679
lemma not_holding_th_s [simp]: "\<not> holding s th 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: 90
diff changeset
  4680
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: 90
diff changeset
  4681
  assume "holding s th cs'"
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4682
  from this[unfolded s_holding_def, folded wq_def, unfolded wq_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: 90
diff changeset
  4683
  have "th \<in> set (wq s cs')" 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: 90
diff changeset
  4684
  from wq_threads[OF this] have "th \<in> threads 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: 90
diff changeset
  4685
  with th_not_live_s show False 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: 90
diff changeset
  4686
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4687
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4688
lemma not_waiting_th_es [simp]: "\<not> waiting (e#s) th 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: 90
diff changeset
  4689
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: 90
diff changeset
  4690
  assume "waiting (e # s) th cs'"
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4691
  from this[unfolded s_waiting_def, folded wq_def, unfolded wq_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: 90
diff changeset
  4692
  have "th \<in> set (wq s cs')" 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: 90
diff changeset
  4693
  from wq_threads[OF this] have "th \<in> threads 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: 90
diff changeset
  4694
  with th_not_live_s show False 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: 90
diff changeset
  4695
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4696
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4697
lemma not_holding_th_es [simp]: "\<not> holding (e#s) th 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: 90
diff changeset
  4698
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: 90
diff changeset
  4699
  assume "holding (e # s) th cs'"
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4700
  from this[unfolded s_holding_def, folded wq_def, unfolded wq_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: 90
diff changeset
  4701
  have "th \<in> set (wq s cs')" 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: 90
diff changeset
  4702
  from wq_threads[OF this] have "th \<in> threads 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: 90
diff changeset
  4703
  with th_not_live_s show False 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: 90
diff changeset
  4704
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4705
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4706
lemma ready_th_es [simp]: "th \<in> readys (e#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: 90
diff changeset
  4707
  by (simp add:readys_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: 90
diff changeset
  4708
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4709
lemma holdents_th_s: "holdents 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: 90
diff changeset
  4710
  by (unfold holdents_def, 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: 90
diff changeset
  4711
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4712
lemma holdents_th_es: "holdents (e#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: 90
diff changeset
  4713
  by (unfold holdents_def, 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: 90
diff changeset
  4714
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4715
lemma cntCS_th_s [simp]: "cntCS s th = 0"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4716
  by (unfold cntCS_def, simp add:holdents_th_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: 90
diff changeset
  4717
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4718
lemma cntCS_th_es [simp]: "cntCS (e#s) th = 0"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4719
  by (unfold cntCS_def, simp add:holdents_th_es)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4720
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4721
lemma pvD_th_s [simp]: "pvD s th = 0"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4722
  by (unfold pvD_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: 90
diff changeset
  4723
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4724
lemma pvD_th_es [simp]: "pvD (e#s) th = 0"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4725
  by (unfold pvD_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: 90
diff changeset
  4726
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4727
lemma holdents_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4728
  assumes "th' \<noteq> 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: 90
diff changeset
  4729
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4730
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: 90
diff changeset
  4731
  { fix 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: 90
diff changeset
  4732
    assume h: "cs' \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4733
    hence "cs' \<in> ?R"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4734
      by (unfold holdents_def s_holding_def, unfold wq_kept, 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: 90
diff changeset
  4735
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4736
    fix 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: 90
diff changeset
  4737
    assume h: "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4738
    hence "cs' \<in> ?L"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4739
      by (unfold holdents_def s_holding_def, unfold wq_kept, 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: 90
diff changeset
  4740
  } ultimately show ?thesis 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: 90
diff changeset
  4741
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4742
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4743
lemma cntCS_kept [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: 90
diff changeset
  4744
  assumes "th' \<noteq> 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: 90
diff changeset
  4745
  shows "cntCS (e#s) th' = cntCS s th'" (is "?L = ?R")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4746
  using holdents_kept[OF 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: 90
diff changeset
  4747
  by (unfold cntCS_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: 90
diff changeset
  4748
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4749
lemma readys_kept1: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4750
  assumes "th' \<noteq> 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: 90
diff changeset
  4751
  and "th' \<in> readys (e#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: 90
diff changeset
  4752
  shows "th' \<in> readys 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: 90
diff changeset
  4753
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: 90
diff changeset
  4754
  { fix 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: 90
diff changeset
  4755
    assume wait: "waiting s th' 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: 90
diff changeset
  4756
    have n_wait: "\<not> waiting (e#s) th' 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: 90
diff changeset
  4757
      using assms by (auto simp:readys_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: 90
diff changeset
  4758
    from wait[unfolded s_waiting_def, folded wq_def]
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4759
         n_wait[unfolded s_waiting_def, folded wq_def, unfolded wq_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: 90
diff changeset
  4760
    have False 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: 90
diff changeset
  4761
  } thus ?thesis 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: 90
diff changeset
  4762
    by (unfold readys_def, 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: 90
diff changeset
  4763
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4764
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4765
lemma readys_kept2: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4766
  assumes "th' \<noteq> 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: 90
diff changeset
  4767
  and "th' \<in> readys 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: 90
diff changeset
  4768
  shows "th' \<in> readys (e#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: 90
diff changeset
  4769
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: 90
diff changeset
  4770
  { fix 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: 90
diff changeset
  4771
    assume wait: "waiting (e#s) th' 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: 90
diff changeset
  4772
    have n_wait: "\<not> waiting s th' 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: 90
diff changeset
  4773
      using assms(2) by (auto simp:readys_def)
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4774
    from wait[unfolded s_waiting_def, folded wq_def, unfolded wq_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: 90
diff changeset
  4775
         n_wait[unfolded s_waiting_def, folded wq_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: 90
diff changeset
  4776
    have False 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: 90
diff changeset
  4777
  } with assms show ?thesis  
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4778
    by (unfold readys_def, 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: 90
diff changeset
  4779
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4780
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4781
lemma readys_simp [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: 90
diff changeset
  4782
  assumes "th' \<noteq> 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: 90
diff changeset
  4783
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys 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: 90
diff changeset
  4784
  using readys_kept1[OF assms] readys_kept2[OF 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: 90
diff changeset
  4785
  by metis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4786
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4787
lemma pvD_kept [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: 90
diff changeset
  4788
  assumes "th' \<noteq> 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: 90
diff changeset
  4789
  shows "pvD (e#s) th' = pvD 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: 90
diff changeset
  4790
  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: 90
diff changeset
  4791
  by (unfold pvD_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: 90
diff changeset
  4792
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4793
lemma cnp_cnv_cncs_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4794
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD 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: 90
diff changeset
  4795
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#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: 90
diff changeset
  4796
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: 90
diff changeset
  4797
  {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4798
    assume eq_th': "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: 90
diff changeset
  4799
    have ?thesis 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: 90
diff changeset
  4800
      by (unfold eq_th', simp, unfold is_create, 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: 90
diff changeset
  4801
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4802
    assume h: "th' \<noteq> 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: 90
diff changeset
  4803
    hence ?thesis 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: 90
diff changeset
  4804
      by (simp, simp add:is_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: 90
diff changeset
  4805
  } ultimately show ?thesis by metis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4806
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4807
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4808
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4809
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4810
context valid_trace_exit
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4811
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4812
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4813
lemma th_live_s [simp]: "th \<in> threads 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: 90
diff changeset
  4814
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: 90
diff changeset
  4815
  from pip_e[unfolded is_exit]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4816
  show ?thesis
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4817
  by (cases, unfold running_def readys_def, 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: 90
diff changeset
  4818
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4819
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4820
lemma th_ready_s [simp]: "th \<in> readys 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: 90
diff changeset
  4821
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: 90
diff changeset
  4822
  from pip_e[unfolded is_exit]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4823
  show ?thesis
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4824
  by (cases, unfold running_def, 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: 90
diff changeset
  4825
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4826
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4827
lemma th_not_live_es [simp]: "th \<notin> threads (e#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: 90
diff changeset
  4828
  by (unfold is_exit, 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: 90
diff changeset
  4829
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4830
lemma not_holding_th_s [simp]: "\<not> holding s th 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: 90
diff changeset
  4831
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: 90
diff changeset
  4832
  from pip_e[unfolded is_exit]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4833
  show ?thesis 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4834
   by (cases, unfold holdents_def, 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: 90
diff changeset
  4835
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4836
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4837
lemma cntCS_th_s [simp]: "cntCS s th = 0"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4838
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: 90
diff changeset
  4839
  from pip_e[unfolded is_exit]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4840
  show ?thesis 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4841
   by (cases, unfold cntCS_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: 90
diff changeset
  4842
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4843
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4844
lemma not_holding_th_es [simp]: "\<not> holding (e#s) th 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: 90
diff changeset
  4845
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: 90
diff changeset
  4846
  assume "holding (e # s) th cs'"
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4847
  from this[unfolded s_holding_def, folded wq_def, unfolded wq_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: 90
diff changeset
  4848
  have "holding s th cs'" 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4849
    by (unfold s_holding_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: 90
diff changeset
  4850
  with not_holding_th_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: 90
diff changeset
  4851
  show False 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: 90
diff changeset
  4852
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4853
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4854
lemma ready_th_es [simp]: "th \<notin> readys (e#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: 90
diff changeset
  4855
  by (simp add:readys_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: 90
diff changeset
  4856
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4857
lemma holdents_th_s: "holdents 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: 90
diff changeset
  4858
  by (unfold holdents_def, 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: 90
diff changeset
  4859
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4860
lemma holdents_th_es: "holdents (e#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: 90
diff changeset
  4861
  by (unfold holdents_def, 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: 90
diff changeset
  4862
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4863
lemma cntCS_th_es [simp]: "cntCS (e#s) th = 0"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4864
  by (unfold cntCS_def, simp add:holdents_th_es)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4865
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4866
lemma pvD_th_s [simp]: "pvD s th = 0"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4867
  by (unfold pvD_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: 90
diff changeset
  4868
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4869
lemma pvD_th_es [simp]: "pvD (e#s) th = 0"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4870
  by (unfold pvD_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: 90
diff changeset
  4871
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4872
lemma holdents_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4873
  assumes "th' \<noteq> 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: 90
diff changeset
  4874
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4875
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: 90
diff changeset
  4876
  { fix 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: 90
diff changeset
  4877
    assume h: "cs' \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4878
    hence "cs' \<in> ?R"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4879
      by (unfold holdents_def s_holding_def, unfold wq_kept, 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: 90
diff changeset
  4880
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4881
    fix 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: 90
diff changeset
  4882
    assume h: "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4883
    hence "cs' \<in> ?L"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4884
      by (unfold holdents_def s_holding_def, unfold wq_kept, 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: 90
diff changeset
  4885
  } ultimately show ?thesis 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: 90
diff changeset
  4886
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4887
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4888
lemma cntCS_kept [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: 90
diff changeset
  4889
  assumes "th' \<noteq> 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: 90
diff changeset
  4890
  shows "cntCS (e#s) th' = cntCS s th'" (is "?L = ?R")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4891
  using holdents_kept[OF 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: 90
diff changeset
  4892
  by (unfold cntCS_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: 90
diff changeset
  4893
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4894
lemma readys_kept1: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4895
  assumes "th' \<noteq> 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: 90
diff changeset
  4896
  and "th' \<in> readys (e#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: 90
diff changeset
  4897
  shows "th' \<in> readys 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: 90
diff changeset
  4898
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: 90
diff changeset
  4899
  { fix 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: 90
diff changeset
  4900
    assume wait: "waiting s th' 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: 90
diff changeset
  4901
    have n_wait: "\<not> waiting (e#s) th' 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: 90
diff changeset
  4902
      using assms by (auto simp:readys_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: 90
diff changeset
  4903
    from wait[unfolded s_waiting_def, folded wq_def]
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4904
         n_wait[unfolded s_waiting_def, folded wq_def, unfolded wq_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: 90
diff changeset
  4905
    have False 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: 90
diff changeset
  4906
  } thus ?thesis 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: 90
diff changeset
  4907
    by (unfold readys_def, 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: 90
diff changeset
  4908
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4909
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4910
lemma readys_kept2: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4911
  assumes "th' \<noteq> 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: 90
diff changeset
  4912
  and "th' \<in> readys 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: 90
diff changeset
  4913
  shows "th' \<in> readys (e#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: 90
diff changeset
  4914
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: 90
diff changeset
  4915
  { fix 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: 90
diff changeset
  4916
    assume wait: "waiting (e#s) th' 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: 90
diff changeset
  4917
    have n_wait: "\<not> waiting s th' 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: 90
diff changeset
  4918
      using assms(2) by (auto simp:readys_def)
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4919
    from wait[unfolded s_waiting_def, folded wq_def, unfolded wq_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: 90
diff changeset
  4920
         n_wait[unfolded s_waiting_def, folded wq_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: 90
diff changeset
  4921
    have False 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: 90
diff changeset
  4922
  } with assms show ?thesis  
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4923
    by (unfold readys_def, 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: 90
diff changeset
  4924
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4925
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4926
lemma readys_simp [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: 90
diff changeset
  4927
  assumes "th' \<noteq> 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: 90
diff changeset
  4928
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys 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: 90
diff changeset
  4929
  using readys_kept1[OF assms] readys_kept2[OF 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: 90
diff changeset
  4930
  by metis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4931
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4932
lemma pvD_kept [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: 90
diff changeset
  4933
  assumes "th' \<noteq> 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: 90
diff changeset
  4934
  shows "pvD (e#s) th' = pvD 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: 90
diff changeset
  4935
  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: 90
diff changeset
  4936
  by (unfold pvD_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: 90
diff changeset
  4937
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4938
lemma cnp_cnv_cncs_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4939
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD 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: 90
diff changeset
  4940
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#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: 90
diff changeset
  4941
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: 90
diff changeset
  4942
  {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4943
    assume eq_th': "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: 90
diff changeset
  4944
    have ?thesis 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: 90
diff changeset
  4945
      by (unfold eq_th', simp, unfold is_exit, 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: 90
diff changeset
  4946
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4947
    assume h: "th' \<noteq> 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: 90
diff changeset
  4948
    hence ?thesis 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: 90
diff changeset
  4949
      by (simp, simp add:is_exit)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4950
  } ultimately show ?thesis by metis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4951
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4952
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4953
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4954
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4955
context valid_trace_set
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4956
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4957
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4958
lemma th_live_s [simp]: "th \<in> threads 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: 90
diff changeset
  4959
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: 90
diff changeset
  4960
  from pip_e[unfolded is_set]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4961
  show ?thesis
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4962
  by (cases, unfold running_def readys_def, 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: 90
diff changeset
  4963
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4964
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4965
lemma th_ready_s [simp]: "th \<in> readys 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: 90
diff changeset
  4966
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: 90
diff changeset
  4967
  from pip_e[unfolded is_set]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4968
  show ?thesis
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4969
  by (cases, unfold running_def, 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: 90
diff changeset
  4970
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4971
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4972
lemma th_not_live_es [simp]: "th \<in> threads (e#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: 90
diff changeset
  4973
  by (unfold is_set, 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: 90
diff changeset
  4974
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4975
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4976
lemma holdents_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4977
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4978
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: 90
diff changeset
  4979
  { fix 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: 90
diff changeset
  4980
    assume h: "cs' \<in> ?L"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4981
    hence "cs' \<in> ?R"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4982
      by (unfold holdents_def s_holding_def, unfold wq_kept, 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: 90
diff changeset
  4983
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4984
    fix 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: 90
diff changeset
  4985
    assume h: "cs' \<in> ?R"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4986
    hence "cs' \<in> ?L"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4987
      by (unfold holdents_def s_holding_def, unfold wq_kept, 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: 90
diff changeset
  4988
  } ultimately show ?thesis 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: 90
diff changeset
  4989
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4990
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4991
lemma cntCS_kept [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: 90
diff changeset
  4992
  shows "cntCS (e#s) th' = cntCS s th'" (is "?L = ?R")
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4993
  using holdents_kept
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4994
  by (unfold cntCS_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: 90
diff changeset
  4995
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4996
lemma readys_kept1: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4997
  assumes "th' \<in> readys (e#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: 90
diff changeset
  4998
  shows "th' \<in> readys 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: 90
diff changeset
  4999
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: 90
diff changeset
  5000
  { fix 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: 90
diff changeset
  5001
    assume wait: "waiting s th' 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: 90
diff changeset
  5002
    have n_wait: "\<not> waiting (e#s) th' 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: 90
diff changeset
  5003
      using assms by (auto simp:readys_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: 90
diff changeset
  5004
    from wait[unfolded s_waiting_def, folded wq_def]
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  5005
         n_wait[unfolded s_waiting_def, folded wq_def, unfolded wq_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: 90
diff changeset
  5006
    have False 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: 90
diff changeset
  5007
  } moreover have "th' \<in> threads 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: 90
diff changeset
  5008
    using assms[unfolded readys_def] 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: 90
diff changeset
  5009
  ultimately show ?thesis 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5010
    by (unfold readys_def, 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: 90
diff changeset
  5011
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5012
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5013
lemma readys_kept2: 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5014
  assumes "th' \<in> readys 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: 90
diff changeset
  5015
  shows "th' \<in> readys (e#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: 90
diff changeset
  5016
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: 90
diff changeset
  5017
  { fix 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: 90
diff changeset
  5018
    assume wait: "waiting (e#s) th' 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: 90
diff changeset
  5019
    have n_wait: "\<not> waiting s th' 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: 90
diff changeset
  5020
      using assms by (auto simp:readys_def)
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  5021
    from wait[unfolded s_waiting_def, folded wq_def, unfolded wq_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: 90
diff changeset
  5022
         n_wait[unfolded s_waiting_def, folded wq_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: 90
diff changeset
  5023
    have False 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: 90
diff changeset
  5024
  } with assms show ?thesis  
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5025
    by (unfold readys_def, 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: 90
diff changeset
  5026
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5027
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5028
lemma readys_simp [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: 90
diff changeset
  5029
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys 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: 90
diff changeset
  5030
  using readys_kept1 readys_kept2
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5031
  by metis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5032
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5033
lemma pvD_kept [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: 90
diff changeset
  5034
  shows "pvD (e#s) th' = pvD 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: 90
diff changeset
  5035
  by (unfold pvD_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: 90
diff changeset
  5036
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5037
lemma cnp_cnv_cncs_kept:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5038
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD 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: 90
diff changeset
  5039
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#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: 90
diff changeset
  5040
  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: 90
diff changeset
  5041
  by (unfold is_set, simp, fold is_set, 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: 90
diff changeset
  5042
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5043
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5044
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5045
context valid_trace
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5046
begin
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5047
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5048
lemma cnp_cnv_cncs: "cntP s th' = cntV s th' + cntCS s th' + pvD 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: 90
diff changeset
  5049
proof(induct rule:ind)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5050
  case Nil
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5051
  thus ?case 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  5052
    unfolding cntP_def  cntV_def pvD_def cntCS_def holdents_def s_holding_def
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  5053
    by(simp add: wq_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: 90
diff changeset
  5054
next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5055
  case (Cons s e)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5056
  interpret vt_e: valid_trace_e s e using Cons 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: 90
diff changeset
  5057
  show ?case
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5058
  proof(cases e)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5059
    case (Create th prio)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5060
    interpret vt_create: valid_trace_create s e th prio 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5061
      using Create by (unfold_locales, 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: 90
diff changeset
  5062
    show ?thesis using Cons by (simp add: vt_create.cnp_cnv_cncs_kept) 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5063
  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: 90
diff changeset
  5064
    case (Exit 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: 90
diff changeset
  5065
    interpret vt_exit: valid_trace_exit s e 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: 90
diff changeset
  5066
        using Exit by (unfold_locales, 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: 90
diff changeset
  5067
   show ?thesis using Cons by (simp add: vt_exit.cnp_cnv_cncs_kept) 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5068
  next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5069
    case (P th 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: 90
diff changeset
  5070
    interpret vt_p: valid_trace_p s e th cs using P by (unfold_locales, 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: 90
diff changeset
  5071
    show ?thesis using Cons by (simp add: vt_p.cnp_cnv_cncs_kept) 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5072
  next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5073
    case (V th 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: 90
diff changeset
  5074
    interpret vt_v: valid_trace_v s e th cs using V by (unfold_locales, 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: 90
diff changeset
  5075
    show ?thesis using Cons by (simp add: vt_v.cnp_cnv_cncs_kept) 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5076
  next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5077
    case (Set th prio)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5078
    interpret vt_set: valid_trace_set s e th prio
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5079
        using Set by (unfold_locales, 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: 90
diff changeset
  5080
    show ?thesis using Cons by (simp add: vt_set.cnp_cnv_cncs_kept) 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5081
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5082
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5083
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  5084
end
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  5085
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  5086
section {* Corollaries of @{thm valid_trace.cnp_cnv_cncs} *}
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  5087
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  5088
context valid_trace
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  5089
begin
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  5090
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5091
text {*
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5092
  The following two lemmas are purely technical, which says
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5093
  a non-living thread can not hold any resource.
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5094
*}
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: 90
diff changeset
  5095
lemma not_thread_holdents:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5096
  assumes not_in: "th \<notin> threads 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: 90
diff changeset
  5097
  shows "holdents 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: 90
diff changeset
  5098
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: 90
diff changeset
  5099
  { fix 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: 90
diff changeset
  5100
    assume "cs \<in> holdents 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: 90
diff changeset
  5101
    hence "holding s th cs" by (auto simp: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: 90
diff changeset
  5102
    from this[unfolded s_holding_def, folded wq_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: 90
diff changeset
  5103
    have "th \<in> set (wq s cs)" 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: 90
diff changeset
  5104
    with wq_threads have "th \<in> threads s" 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: 90
diff changeset
  5105
    with 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: 90
diff changeset
  5106
    have False 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: 90
diff changeset
  5107
  } thus ?thesis 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: 90
diff changeset
  5108
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5109
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5110
lemma not_thread_cncs:
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5111
  assumes not_in: "th \<notin> threads s" 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5112
  shows "cntCS s th = 0"
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: 90
diff changeset
  5113
  using not_thread_holdents[OF 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: 90
diff changeset
  5114
  by (simp add:cntCS_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: 90
diff changeset
  5115
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5116
text {*
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5117
  Starting from the following @{text cnp_cnv_eq}, all 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5118
  lemmas in this section concern the meaning of 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5119
  condition @{prop "cntP s th = cntV s th"}, i.e.
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5120
  when the numbers of resource requesting and resource releasing
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5121
  are equal.
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5122
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5123
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: 90
diff changeset
  5124
lemma cnp_cnv_eq:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5125
  assumes "th \<notin> threads 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: 90
diff changeset
  5126
  shows "cntP s th = cntV 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: 90
diff changeset
  5127
  using assms cnp_cnv_cncs not_thread_cncs pvD_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: 90
diff changeset
  5128
  by (auto)
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5129
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: 90
diff changeset
  5130
lemma eq_pv_children:
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5131
  assumes eq_pv: "cntP s th = cntV s th"
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5132
  shows "children (RAG s) (Th th) = {}"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5133
proof -
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5134
    from cnp_cnv_cncs and eq_pv
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5135
    have "cntCS s th = 0" 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5136
      by (auto split:if_splits)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5137
    from this[unfolded cntCS_def holdents_alt_def]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5138
    have card_0: "card (the_cs ` children (RAG s) (Th th)) = 0" .
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5139
    have "finite (the_cs ` children (RAG s) (Th th))"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5140
      by (simp add: fsbtRAGs.finite_children)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5141
    from card_0[unfolded card_0_eq[OF this]]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5142
    show ?thesis by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5143
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5144
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5145
lemma eq_pv_holdents:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5146
  assumes eq_pv: "cntP s th = cntV s th"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5147
  shows "holdents s th = {}"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5148
  by (unfold holdents_alt_def eq_pv_children[OF assms], simp)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5149
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5150
lemma eq_pv_subtree:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5151
  assumes eq_pv: "cntP s th = cntV s th"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5152
  shows "subtree (RAG s) (Th th) = {Th th}"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5153
  using eq_pv_children[OF assms]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5154
    by (unfold subtree_children, simp)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5155
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: 90
diff changeset
  5156
lemma count_eq_RAG_plus:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5157
  assumes "cntP s th = cntV 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: 90
diff changeset
  5158
  shows "{th'. (Th th', Th th) \<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: 90
diff changeset
  5159
proof(rule ccontr)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5160
    assume otherwise: "{th'. (Th th', Th th) \<in> (RAG s)\<^sup>+} \<noteq> {}"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5161
    then obtain th' where "(Th th', Th th) \<in> (RAG s)^+" 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: 90
diff changeset
  5162
    from tranclD2[OF this]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5163
    obtain z where "z \<in> children (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: 90
diff changeset
  5164
      by (auto simp:children_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: 90
diff changeset
  5165
    with eq_pv_children[OF 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: 90
diff changeset
  5166
    show False 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: 90
diff changeset
  5167
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5168
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5169
lemma count_eq_RAG_plus_Th:
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5170
  assumes "cntP s th = cntV s th"
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5171
  shows "{Th th' | th'. (Th th', Th th) \<in> (RAG s)^+} = {}"
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5172
  using count_eq_RAG_plus[OF assms] by auto
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5173
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: 90
diff changeset
  5174
lemma eq_pv_dependants:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5175
  assumes eq_pv: "cntP s th = cntV 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: 90
diff changeset
  5176
  shows "dependants 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: 90
diff changeset
  5177
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: 90
diff changeset
  5178
  from count_eq_RAG_plus[OF assms, folded dependants_alt_def1]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5179
  show ?thesis .
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5180
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5181
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5182
lemma count_eq_tRAG_plus:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5183
  assumes "cntP s th = cntV s th"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5184
  shows "{th'. (Th th', Th th) \<in> (tRAG s)^+} = {}"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  5185
  using assms count_eq_RAG_plus dependants_alt_def s_dependants_def by blast
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5186
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5187
lemma count_eq_tRAG_plus_Th:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5188
  assumes "cntP s th = cntV s th"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5189
  shows "{Th th' | th'. (Th th', Th th) \<in> (tRAG s)^+} = {}"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5190
   using count_eq_tRAG_plus[OF assms] by auto
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5191
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5192
end
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5193
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5194
subsection {* A notion @{text detached} and its relation with @{term cntP} 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5195
  and @{term cntV} *}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5196
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5197
definition detached :: "state \<Rightarrow> thread \<Rightarrow> bool"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5198
  where "detached s th \<equiv> (\<not>(\<exists> cs. holding s th cs)) \<and> (\<not>(\<exists>cs. waiting s th cs))"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5199
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5200
text {*
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5201
  The following lemma shows that a thread is detached means 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5202
  it is isolated from @{term RAG}:
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5203
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  5204
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5205
lemma detached_test:
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: 32
diff changeset
  5206
  shows "detached s th = (Th th \<notin> Field (RAG s))"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5207
apply(simp add: detached_def Field_def)
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: 32
diff changeset
  5208
apply(simp add: s_RAG_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5209
apply(simp add: s_holding_abv s_waiting_abv)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5210
apply(simp add: Domain_iff Range_iff)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5211
apply(simp add: wq_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5212
apply(auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5213
done
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5214
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5215
lemma detached_cp_the_preced:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5216
  assumes "detached s th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5217
  shows "cp s th = the_preced s th" (is "?L = ?R")
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5218
proof -
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5219
  have "?L =  Max (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)})"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5220
      by (unfold cp_alt_def, simp)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5221
  moreover have "{th'. Th th' \<in> subtree (RAG s) (Th th)} = {th}" 
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5222
  proof -
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5223
    { fix n
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5224
      assume "n \<in> subtree (RAG s) (Th th)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5225
      hence "n = Th th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5226
      proof(cases rule:subtreeE)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5227
        case 2
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5228
        from 2(2) have "Th th \<in> Range (RAG s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5229
          by (elim ancestors_Field, simp)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5230
        moreover from assms[unfolded detached_test] have "Th th \<notin> Field (RAG s)" .
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5231
        ultimately have False by (auto simp:Field_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5232
        thus ?thesis by simp
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5233
      qed simp
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5234
    } thus ?thesis by auto
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5235
  qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5236
  ultimately show ?thesis by auto
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5237
qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5238
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5239
lemma detached_cp_preced:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5240
  assumes "detached s th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5241
  shows "cp s th = preced th s" 
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5242
  using detached_cp_the_preced[OF assms] 
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5243
  by (simp add:the_preced_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5244
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5245
context valid_trace
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5246
begin
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5247
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5248
lemma detached_intro:
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5249
  assumes eq_pv: "cntP s th = cntV s th"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5250
  shows "detached s th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5251
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: 90
diff changeset
  5252
  from eq_pv cnp_cnv_cncs
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5253
  have "th \<in> readys s \<or> th \<notin> threads s" by (auto simp:pvD_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: 90
diff changeset
  5254
  thus ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5255
  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: 90
diff changeset
  5256
    assume "th \<notin> threads 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: 90
diff changeset
  5257
    with rg_RAG_threads dm_RAG_threads
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5258
    show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5259
      by (auto simp add: detached_def s_RAG_def s_waiting_abv 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5260
              s_holding_abv wq_def Domain_iff Range_iff)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5261
  next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5262
    assume "th \<in> readys 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: 90
diff changeset
  5263
    moreover have "Th th \<notin> Range (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: 90
diff changeset
  5264
    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: 90
diff changeset
  5265
      from eq_pv_children[OF 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: 90
diff changeset
  5266
      have "children (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: 90
diff changeset
  5267
      thus ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5268
      by (unfold children_def, 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: 90
diff changeset
  5269
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5270
    ultimately show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5271
      by (auto simp add: detached_def s_RAG_def s_waiting_abv 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5272
              s_holding_abv wq_def readys_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: 90
diff changeset
  5273
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5274
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5275
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5276
lemma detached_elim:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5277
  assumes dtc: "detached 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: 90
diff changeset
  5278
  shows "cntP s th = cntV 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: 90
diff changeset
  5279
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: 90
diff changeset
  5280
  have cncs_z: "cntCS s th = 0"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5281
  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: 90
diff changeset
  5282
    from dtc have "holdents 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: 90
diff changeset
  5283
      unfolding detached_def holdents_test s_RAG_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: 90
diff changeset
  5284
      by (simp add: s_waiting_abv wq_def s_holding_abv Domain_iff Range_iff)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5285
    thus ?thesis by (auto simp:cntCS_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: 90
diff changeset
  5286
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5287
  show ?thesis
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5288
  proof(cases "th \<in> threads 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: 90
diff changeset
  5289
    case True
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5290
    with dtc 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5291
    have "th \<in> readys 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: 90
diff changeset
  5292
      by (unfold readys_def detached_def Field_def Domain_def Range_def, 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  5293
           auto simp:s_waiting_abv s_RAG_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: 90
diff changeset
  5294
    with cncs_z  show ?thesis using cnp_cnv_cncs by (simp add:pvD_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: 90
diff changeset
  5295
  next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5296
    case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5297
    with cncs_z and cnp_cnv_cncs show ?thesis by (simp add:pvD_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: 90
diff changeset
  5298
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5299
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5300
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5301
lemma detached_eq:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5302
  shows "(detached s th) = (cntP s th = cntV 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: 90
diff changeset
  5303
  by (insert vt, auto intro:detached_intro detached_elim)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5304
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5305
end
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5306
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5307
section {* Recursive calculation of @{term "cp"} *}
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5308
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5309
text {*
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5310
  According to the normal definitions, such as @{thm cp_def}, @{thm cp_alt_def}
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5311
  and @{thm cp_alt_def1}, the @{term cp}-value of a thread depends 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5312
  on the @{term preced}-values of all threads in its subtree. To calculate 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5313
  a @{term cp}-value, one needs to traverse a whole subtree. 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5314
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5315
  However, in this section, we are going to show that @{term cp}-value 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5316
  can be calculate locally (given by the lemma @{text "cp_rec"} in the following).
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5317
  According to this lemma,  the @{term cp}-value of a thread can be calculated only from 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5318
  the @{term cp}-values of its children in @{term RAG}. 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5319
  Therefore, if the @{term cp}-values of one thread's children are not
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5320
  changed by an execution step, there is no need to recalculate. This
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5321
  is particularly useful to in Implementation.thy to speed up the 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5322
  recalculation of @{term cp}-values. 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5323
*}
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5324
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5325
text {*
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5326
  The following function @{text "cp_gen"} is a generalization 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5327
  of @{term cp}. Unlike @{term cp} which returns a precedence 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5328
  for a thread, @{text "cp_gen"} returns precedence for a node
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5329
  in @{term RAG}. When the node represent a thread, @{text cp_gen} is
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5330
  coincident with @{term cp} (to be shown in lemma @{text "cp_gen_def_cond"}), 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5331
  and this is the only meaningful use of @{text cp_gen}. 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5332
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5333
  The introduction of @{text cp_gen} is purely technical to easy some
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5334
  of the proofs leading to the finally lemma @{text cp_rec}.
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5335
*}
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5336
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5337
definition "cp_gen s x =
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5338
                  Max ((the_preced s \<circ> the_thread) ` subtree (tRAG s) x)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5339
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5340
lemma cp_gen_alt_def:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5341
  "cp_gen s = (Max \<circ> (\<lambda>x. (the_preced s \<circ> the_thread) ` subtree (tRAG s) x))"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5342
    by (auto simp:cp_gen_def)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5343
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5344
lemma cp_gen_def_cond: 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5345
  assumes "x = Th th"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5346
  shows "cp s th = cp_gen s (Th th)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5347
by (unfold cp_alt_def1 cp_gen_def, simp)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5348
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5349
lemma cp_gen_over_set:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5350
  assumes "\<forall> x \<in> A. \<exists> th. x = Th th"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5351
  shows "cp_gen s ` A = (cp s \<circ> the_thread) ` A"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5352
proof(rule f_image_eq)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5353
  fix a
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5354
  assume "a \<in> A"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5355
  from assms[rule_format, OF this]
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5356
  obtain th where eq_a: "a = Th th" by auto
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5357
  show "cp_gen s a = (cp s \<circ> the_thread) a"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5358
    by  (unfold eq_a, simp, unfold cp_gen_def_cond[OF refl[of "Th th"]], simp)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5359
qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5360
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 77
diff changeset
  5361
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 101
diff changeset
  5362
context valid_trace
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 101
diff changeset
  5363
begin
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5364
(* ddd *)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5365
lemma cp_gen_rec:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5366
  assumes "x = Th th"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5367
  shows "cp_gen s x = Max ({the_preced s th} \<union> (cp_gen s) ` children (tRAG s) x)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5368
proof(cases "children (tRAG s) x = {}")
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5369
  case True
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5370
  show ?thesis
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5371
    by (unfold True cp_gen_def subtree_children, simp add:assms)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5372
next
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5373
  case False
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5374
  hence [simp]: "children (tRAG s) x \<noteq> {}" by auto
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5375
  note fsbttRAGs.finite_subtree[simp]
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5376
  have [simp]: "finite (children (tRAG s) x)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5377
     by (intro rev_finite_subset[OF fsbttRAGs.finite_subtree], 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5378
            rule children_subtree)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5379
  { fix r x
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5380
    have "subtree r x \<noteq> {}" by (auto simp:subtree_def)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5381
  } note this[simp]
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5382
  have [simp]: "\<exists>x\<in>children (tRAG s) x. subtree (tRAG s) x \<noteq> {}"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5383
  proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5384
    from False obtain q where "q \<in> children (tRAG s) x" by blast
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5385
    moreover have "subtree (tRAG s) q \<noteq> {}" by simp
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5386
    ultimately show ?thesis by blast
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5387
  qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5388
  have h: "Max ((the_preced s \<circ> the_thread) `
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5389
                ({x} \<union> \<Union>(subtree (tRAG s) ` children (tRAG s) x))) =
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5390
        Max ({the_preced s th} \<union> cp_gen s ` children (tRAG s) x)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5391
                     (is "?L = ?R")
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5392
  proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5393
    let "Max (?f ` (?A \<union> \<Union> (?g ` ?B)))" = ?L
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5394
    let "Max (_ \<union> (?h ` ?B))" = ?R
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5395
    let ?L1 = "?f ` \<Union>(?g ` ?B)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5396
    have eq_Max_L1: "Max ?L1 = Max (?h ` ?B)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5397
    proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5398
      have "?L1 = ?f ` (\<Union> x \<in> ?B.(?g x))" by simp
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5399
      also have "... =  (\<Union> x \<in> ?B. ?f ` (?g x))" by auto
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5400
      finally have "Max ?L1 = Max ..." by simp
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5401
      also have "... = Max (Max ` (\<lambda>x. ?f ` subtree (tRAG s) x) ` ?B)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5402
        by (subst Max_UNION, simp+)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5403
      also have "... = Max (cp_gen s ` children (tRAG s) x)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5404
          by (unfold image_comp cp_gen_alt_def, simp)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5405
      finally show ?thesis .
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5406
    qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5407
    show ?thesis
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5408
    proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5409
      have "?L = Max (?f ` ?A \<union> ?L1)" by simp
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5410
      also have "... = max (the_preced s (the_thread x)) (Max ?L1)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5411
            by (subst Max_Un, simp+)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5412
      also have "... = max (?f x) (Max (?h ` ?B))"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5413
        by (unfold eq_Max_L1, simp)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5414
      also have "... =?R"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5415
        by (rule max_Max_eq, (simp)+, unfold assms, simp)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5416
      finally show ?thesis .
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5417
    qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5418
  qed  thus ?thesis 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5419
          by (fold h subtree_children, unfold cp_gen_def, simp) 
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 101
diff changeset
  5420
qed
65
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5421
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5422
lemma cp_rec:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5423
  "cp s th = Max ({the_preced s th} \<union> 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5424
                     (cp s o the_thread) ` children (tRAG s) (Th th))"
65
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5425
proof -
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5426
  have "Th th = Th th" by simp
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5427
  note h =  cp_gen_def_cond[OF this] cp_gen_rec[OF this]
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5428
  show ?thesis 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5429
  proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5430
    have "cp_gen s ` children (tRAG s) (Th th) = 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5431
                (cp s \<circ> the_thread) ` children (tRAG s) (Th th)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5432
    proof(rule cp_gen_over_set)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5433
      show " \<forall>x\<in>children (tRAG s) (Th th). \<exists>th. x = Th th"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5434
        by (unfold tRAG_alt_def, auto simp:children_def)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5435
    qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5436
    thus ?thesis by (subst (1) h(1), unfold h(2), simp)
65
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5437
  qed
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5438
qed
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5439
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5440
end
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5441
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5442
lemma PIP_actorE:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5443
  assumes "PIP s e"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5444
  and "actor e = th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5445
  and "\<not> isCreate e"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  5446
  shows "th \<in> running s"
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5447
  using assms
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5448
  by (cases, auto)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5449
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5450
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5451
lemma holdents_RAG:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5452
  assumes "holdents s th = {}"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5453
  shows "Th th \<notin> Range (RAG s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5454
proof
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5455
  assume "Th th \<in> Range (RAG s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5456
  thus False
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5457
  proof(rule RangeE)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5458
    fix a
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5459
    assume "(a, Th th) \<in> RAG s"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5460
    with assms[unfolded holdents_test]
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5461
    show False
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  5462
    using assms children_def holdents_alt_def by fastforce
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5463
  qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5464
qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5465
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5466
lemma readys_RAG:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5467
  assumes "th \<in> readys s"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5468
  shows "Th th \<notin> Domain (RAG s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5469
proof
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5470
  assume "Th th \<in> Domain (RAG s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5471
  thus False
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5472
  proof(rule DomainE)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5473
    fix b
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5474
    assume "(Th th, b) \<in> RAG s"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5475
    with assms[unfolded readys_def s_waiting_def]
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5476
    show False
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  5477
      using Collect_disj_eq s_RAG_def s_waiting_abv s_waiting_def wq_def by fastforce
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5478
  qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5479
qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5480
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5481
lemma readys_holdents_detached:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5482
  assumes "th \<in> readys s"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5483
  and "holdents s th = {}"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5484
  shows "detached s th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5485
proof -
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5486
  from readys_RAG[OF assms(1)] holdents_RAG[OF assms(2)]
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5487
  show ?thesis
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5488
    by (unfold detached_test Field_def, auto)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5489
qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5490
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5491
lemma len_actions_of_sigma:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5492
  assumes "finite A"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5493
  shows "length (actions_of A t) = (\<Sum> th' \<in> A. length (actions_of {th'} t))"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5494
proof(induct t)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5495
  case h: (Cons e t)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5496
  thus ?case (is "?L = ?R" is "_ = ?T (e#t)") 
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5497
  proof(cases "actor e \<in> A")
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5498
    case True
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5499
    have "?L = 1 + ?T t"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5500
      by (fold h, insert True, simp add:actions_of_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5501
    moreover have "?R = 1 + ?T t"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5502
    proof -
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5503
      have "?R = length (actions_of {actor e} (e # t)) +
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5504
                 (\<Sum>th'\<in>A - {actor e}. length (actions_of {th'} (e # t)))"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5505
            (is "_ = ?F (e#t) + ?G (e#t)")
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5506
            by (subst comm_monoid_add_class.setsum.remove[where x = "actor e", 
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5507
                OF assms True], simp)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5508
      moreover have "?F (e#t) = 1 + ?F t" using True
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5509
          by  (simp add:actions_of_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5510
      moreover have "?G (e#t) = ?G t"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5511
        by (rule setsum.cong, auto simp:actions_of_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5512
      moreover have "?F t + ?G t = ?T t"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5513
        by (subst comm_monoid_add_class.setsum.remove[where x = "actor e", 
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5514
              OF assms True], simp)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5515
      ultimately show ?thesis by simp
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5516
    qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5517
    ultimately show ?thesis by simp
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5518
  next
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5519
    case False
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5520
    hence "?L = length (actions_of A t)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5521
      by (simp add:actions_of_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5522
    also have "... = (\<Sum>th'\<in>A. length (actions_of {th'} t))" by (simp add: h)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5523
    also have "... = ?R"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5524
      by (rule setsum.cong; insert False, auto simp:actions_of_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5525
    finally show ?thesis .
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5526
  qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5527
qed (auto simp:actions_of_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5528
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5529
lemma threads_Exit:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5530
    assumes "th \<in> threads s"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5531
    and "th \<notin> threads (e#s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5532
    shows "e = Exit th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5533
    using assms
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5534
    by (cases e, auto)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5535
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  5536
end
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  5537