PIPBasics.thy
author Christian Urban <urbanc@in.tum.de>
Tue, 27 Jun 2017 14:49:42 +0100
changeset 179 f9e6c4166476
parent 178 da27bece9575
child 197 ca4ddf26a7c7
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
179
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   399
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   400
lemma trancl_tG_tRAG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   401
  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
   402
  shows "(Th th1, Th th2) \<in> (tRAG s)^+"
179
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   403
  using assms unfolding tRAG_def_tG
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   404
proof(induct rule:trancl_induct)
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   405
  case (step y z)
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   406
  from step(2) have "(Th y, Th z) \<in> map_prod Th Th ` (tG s)" by auto
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   407
  with step(3)
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   408
  show ?case by auto
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   409
qed auto
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   410
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   411
lemma rtrancl_tG_tRAG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   412
  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
   413
  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
   414
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   415
  from rtranclD[OF assms]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   416
  show ?thesis
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   417
  proof
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   418
    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
   419
  next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   420
    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
   421
    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
   422
    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
   423
    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
   424
  qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   425
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   426
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   427
lemma trancl_tRAG_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   428
  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
   429
  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
   430
          "(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
   431
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   432
  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
   433
    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
   434
  show ?thesis 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   435
    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
   436
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   437
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   438
lemma rtrancl_tRAG_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   439
  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
   440
  obtains "n1 = n2" 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   441
          | "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
   442
            "(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
   443
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   444
  from rtranclD[OF assms]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   445
  have "n1 = n2 \<or>
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   446
          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
   447
          (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
   448
  proof
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   449
    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
   450
    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
   451
    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
   452
    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
   453
          "(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
   454
    with h 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   455
    show ?thesis by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   456
  qed auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   457
    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
   458
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   459
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   460
lemma ancestors_imageE:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   461
  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
   462
  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
   463
  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
   464
  using assms unfolding ancestors_def
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   465
  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
   466
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   467
lemma tRAG_ancestorsE_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   468
  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
   469
  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
   470
           "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
   471
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   472
  from assms[unfolded ancestors_def]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   473
  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
   474
  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
   475
  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
   476
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   477
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   478
lemma ancestors_tG_tRAG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   479
  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
   480
  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
   481
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   482
  from assms[unfolded ancestors_def]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   483
  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
   484
  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
   485
  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
   486
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   487
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   488
lemma subtree_nodeE:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   489
  assumes "n \<in> subtree (tRAG s) (Th th)"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   490
  obtains th1 where "n = Th th1"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   491
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   492
  show ?thesis
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   493
  proof(rule subtreeE[OF assms])
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   494
    assume "n = Th th"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   495
    from that[OF this] show ?thesis .
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   496
  next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   497
    assume "Th th \<in> ancestors (tRAG s) n"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   498
    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
   499
    hence "\<exists> th1. n = Th th1"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   500
    proof(induct)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   501
      case (base y)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   502
      from tRAG_nodeE[OF this] show ?case by metis
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   503
    next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   504
      case (step y z)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   505
      thus ?case by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   506
    qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   507
    with that show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   508
  qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   509
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   510
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   511
lemma subtree_nodeE_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   512
  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
   513
  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
   514
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   515
  from assms[unfolded subtree_def]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   516
  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
   517
  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
   518
   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
   519
  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
   520
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   521
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   522
lemma subtree_tRAG_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   523
  "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
   524
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   525
  { fix n
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   526
    assume "n \<in> ?L"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   527
    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
   528
    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
   529
  } moreover {
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   530
    fix n
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   531
    assume "n \<in> ?R"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   532
    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
   533
    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
   534
    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
   535
    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
   536
  } ultimately show ?thesis by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   537
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   538
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   539
lemma subtree_tG_tRAG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   540
  "(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
   541
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   542
  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
   543
    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
   544
  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
   545
  finally show ?thesis by simp
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   546
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   547
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   548
text {*
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   549
  The following lemmas relate @{term tRAG} with 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   550
  @{term RAG} from different perspectives. 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   551
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   552
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   553
lemma tRAG_star_RAG: "(tRAG s)^* \<subseteq> (RAG s)^*"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   554
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   555
  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
   556
    by (rule rtrancl_mono, auto simp:RAG_split)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   557
  also have "... \<subseteq> ((RAG s)^*)^*"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   558
    by (rule rtrancl_mono, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   559
  also have "... = (RAG s)^*" by simp
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   560
  finally show ?thesis by (unfold tRAG_def, simp)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   561
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   562
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   563
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
   564
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   565
  { fix a
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   566
    assume "a \<in> subtree (tRAG s) x"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   567
    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
   568
    with tRAG_star_RAG
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   569
    have "(a, x) \<in> (RAG s)^*" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   570
    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
   571
  } thus ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   572
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   573
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   574
lemma tRAG_trancl_eq:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   575
   "{th'. (Th th', Th th)  \<in> (tRAG s)^+} = 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   576
    {th'. (Th th', Th th)  \<in> (RAG s)^+}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   577
   (is "?L = ?R")
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   578
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   579
  { fix th'
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   580
    assume "th' \<in> ?L"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   581
    hence "(Th th', Th th) \<in> (tRAG s)^+" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   582
    from tranclD[OF this]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   583
    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
   584
    from tRAG_subtree_RAG and this(2)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   585
    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
   586
    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
   587
    ultimately have "th' \<in> ?R"  by auto 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   588
  } moreover 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   589
  { fix th'
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   590
    assume "th' \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   591
    hence "(Th th', Th th) \<in> (RAG s)^+" by (auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   592
    from plus_rpath[OF this]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   593
    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
   594
    hence "(Th th', Th th) \<in> (tRAG s)^+"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   595
    proof(induct xs arbitrary:th' th rule:length_induct)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   596
      case (1 xs th' th)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   597
      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
   598
      show ?case
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   599
      proof(cases "xs1")
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   600
        case Nil
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   601
        from 1(2)[unfolded Cons1 Nil]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   602
        have rp: "rpath (RAG s) (Th th') [x1] (Th th)" .
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   603
        hence "(Th th', x1) \<in> (RAG s)" 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   604
          by (cases, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   605
        then obtain cs where "x1 = Cs cs" 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   606
              by (unfold s_RAG_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   607
        from rpath_nnl_lastE[OF rp[unfolded this]]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   608
        show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   609
      next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   610
        case (Cons x2 xs2)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   611
        from 1(2)[unfolded Cons1[unfolded this]]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   612
        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
   613
        from rpath_edges_on[OF this]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   614
        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
   615
        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
   616
            by (simp add: edges_on_unfold)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   617
        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
   618
        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
   619
        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
   620
            by (simp add: edges_on_unfold)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   621
        from this eds
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   622
        have rg2: "(x1, x2) \<in> RAG s" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   623
        from this[unfolded eq_x1] 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   624
        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
   625
        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
   626
        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
   627
        from rp have "rpath (RAG s) x2 xs2 (Th th)"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   628
           by  (elim rpath_ConsE, simp)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   629
        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
   630
        show ?thesis
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   631
        proof(cases "xs2 = []")
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   632
          case True
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   633
          from rpath_nilE[OF rp'[unfolded this]]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   634
          have "th1 = th" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   635
          from rt1[unfolded this] show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   636
        next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   637
          case False
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   638
          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
   639
          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
   640
          with rt1 show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   641
        qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   642
      qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   643
    qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   644
    hence "th' \<in> ?L" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   645
  } ultimately show ?thesis by blast
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   646
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   647
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   648
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   649
lemma tRAG_trancl_eq_Th:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   650
   "{Th th' | th'. (Th th', Th th)  \<in> (tRAG s)^+} = 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   651
    {Th th' | th'. (Th th', Th th)  \<in> (RAG s)^+}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   652
    using tRAG_trancl_eq by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   653
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   654
lemma tRAG_Field:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   655
  "Field (tRAG s) \<subseteq> Field (RAG s)"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   656
  by (unfold tRAG_alt_def Field_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   657
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   658
lemma tRAG_mono:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   659
  assumes "RAG s' \<subseteq> RAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   660
  shows "tRAG s' \<subseteq> tRAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   661
  using assms 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   662
  by (unfold tRAG_alt_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   663
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   664
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   665
lemma tRAG_subtree_eq: 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   666
   "(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
   667
   (is "?L = ?R")
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   668
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   669
  { fix n 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   670
    assume h: "n \<in> ?L"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   671
    hence "n \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   672
    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
   673
  } moreover {
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   674
    fix n
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   675
    assume "n \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   676
    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
   677
      by (auto simp:subtree_def)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   678
    from rtranclD[OF this(2)]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   679
    have "n \<in> ?L"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   680
    proof
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   681
      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
   682
      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
   683
      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
   684
        by fastforce (* ccc *)
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   685
    qed (insert h, auto simp:subtree_def)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   686
  } ultimately show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   687
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   688
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   689
lemma threads_set_eq: 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   690
   "the_thread ` (subtree (tRAG s) (Th th)) = 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   691
                  {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
   692
   by (auto intro:rev_image_eqI simp:tRAG_subtree_eq)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   693
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
   694
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
   695
  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
   696
  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
   697
  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
   698
  (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
   699
  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
   700
*}
179
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   701
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   702
lemma cp_s_def: "cp s th = Max (preceds (subtree (tG s) th) s)"
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   703
  by (unfold cp_eq cpreced_def s_tG_abv, simp)
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   704
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
   705
lemma cp_alt_def:
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   706
  "cp s th =  Max ((the_preced s) ` {th'. Th th' \<in> (subtree (RAG s) (Th th))})"
179
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   707
  apply (unfold cp_s_def subtree_tG_tRAG threads_set_eq)
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
   708
  by (smt Collect_cong Setcompr_eq_image 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
   709
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
   710
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
   711
  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
   712
*}
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
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
   714
  "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
   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 "(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
   717
       ((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
   718
       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
   719
  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
   720
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
   721
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   722
text {*
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   723
  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
   724
*}
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   725
lemma cp_alt_def2: 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   726
  "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
   727
  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
   728
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
   729
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   730
lemma RAG_tRAG_transfer:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   731
  assumes  "RAG s' = RAG s \<union> {(Th th, Cs cs)}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   732
  and "(Cs cs, Th th'') \<in> RAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   733
  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
   734
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   735
  { fix n1 n2
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   736
    assume "(n1, n2) \<in> ?L"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   737
    from this[unfolded tRAG_alt_def]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   738
    obtain th1 th2 cs' where 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   739
      h: "n1 = Th th1" "n2 = Th th2" 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   740
         "(Th th1, Cs cs') \<in> RAG s'"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   741
         "(Cs cs', Th th2) \<in> RAG s'" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   742
    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
   743
    from h(3) and assms(1) 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   744
    have "(Th th1, Cs cs') = (Th th, Cs cs) \<or> 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   745
          (Th th1, Cs cs') \<in> RAG s" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   746
    hence "(n1, n2) \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   747
    proof
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   748
      assume h1: "(Th th1, Cs cs') = (Th th, Cs cs)"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   749
      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
   750
      moreover have "th2 = th''"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   751
      proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   752
        from h1 have "cs' = cs" by simp
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   753
        from assms(2) cs_in[unfolded this]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   754
        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
   755
          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
   756
        from held_unique[OF this]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   757
        show ?thesis by simp 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   758
      qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   759
      ultimately show ?thesis using h(1,2) h1 by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   760
    next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   761
      assume "(Th th1, Cs cs') \<in> RAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   762
      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
   763
        by (unfold tRAG_alt_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   764
      from this[folded h(1, 2)] show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   765
    qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   766
  } moreover {
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   767
    fix n1 n2
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   768
    assume "(n1, n2) \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   769
    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
   770
    hence "(n1, n2) \<in> ?L" 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   771
    proof
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   772
      assume "(n1, n2) \<in> tRAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   773
      moreover have "... \<subseteq> ?L"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   774
      proof(rule tRAG_mono)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   775
        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
   776
      qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   777
      ultimately show ?thesis 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 eq_n: "(n1, n2) = (Th th, Th th'')"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   780
      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
   781
      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
   782
      ultimately show ?thesis 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   783
        by (unfold eq_n tRAG_alt_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   784
    qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   785
  } ultimately show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   786
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   787
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   788
section {* Locales used to investigate the execution of PIP *}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   789
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   790
text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   791
  The following locale @{text valid_trace} is used to constrain the 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   792
  trace to be valid. All properties hold for valid traces are 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   793
  derived under this locale. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   794
*}
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   795
locale valid_trace = 
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   796
  fixes s
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   797
  assumes vt : "vt s"
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   798
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   799
text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   800
  The following locale @{text valid_trace_e} describes 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   801
  the valid extension of a valid trace. The event @{text "e"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   802
  represents an event in the system, which corresponds 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   803
  to a one step operation of the PIP protocol. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   804
  It is required that @{text "e"} is an event eligible to happen
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   805
  under state @{text "s"}, which is already required to be valid
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   806
  by the parent locale @{text "valid_trace"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   807
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   808
  This locale is used to investigate one step execution of PIP, 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   809
  properties concerning the effects of @{text "e"}'s execution, 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   810
  for example, how the values of observation functions are changed, 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   811
  or how desirable properties are kept invariant, are derived
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   812
  under this locale. The state before execution is @{text "s"}, while
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   813
  the state after execution is @{text "e#s"}. Therefore, the lemmas 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   814
  derived usually relate observations on @{text "e#s"} to those 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   815
  on @{text "s"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   816
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   817
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   818
locale valid_trace_e = valid_trace +
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   819
  fixes e
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   820
  assumes vt_e: "vt (e#s)"
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   821
begin
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   822
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   823
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   824
  The following lemma shows that @{text "e"} must be a 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   825
  eligible event (or a valid step) to be taken under
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   826
  the state represented by @{text "s"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   827
*}
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   828
lemma pip_e: "PIP s e"
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   829
  using vt_e by (cases, simp)  
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   830
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   831
end
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   832
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   833
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   834
  Because @{term "e#s"} is also a valid trace, properties 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   835
  derived for valid trace @{term s} also hold on @{term "e#s"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   836
*}
120
b3b8735c7c02 updated to Isabelle 2016
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 119
diff changeset
   837
sublocale valid_trace_e < vat_es: valid_trace "e#s" 
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   838
  using vt_e
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   839
  by (unfold_locales, simp)
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   840
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   841
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   842
  For each specific event (or operation), there is a sublocale
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   843
  further constraining that the event @{text e} to be that 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   844
  particular event. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   845
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   846
  For example, the following 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   847
  locale @{text "valid_trace_create"} is the sublocale for 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   848
  event @{term "Create"}:
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   849
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   850
locale valid_trace_create = valid_trace_e + 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   851
  fixes th prio
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   852
  assumes is_create: "e = Create th prio"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   853
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   854
locale valid_trace_exit = valid_trace_e + 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   855
  fixes th
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   856
  assumes is_exit: "e = Exit th"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   857
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   858
locale valid_trace_p = valid_trace_e + 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   859
  fixes th cs
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   860
  assumes is_p: "e = P th cs"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   861
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   862
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   863
  locale @{text "valid_trace_p"} is divided further into two 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   864
  sublocales, namely, @{text "valid_trace_p_h"} 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   865
  and @{text "valid_trace_p_w"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   866
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   867
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   868
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   869
  The following two sublocales @{text "valid_trace_p_h"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   870
  and @{text "valid_trace_p_w"} represent two complementary 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   871
  cases under @{text "valid_trace_p"}, where
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   872
  @{text "valid_trace_p_h"} further constraints that
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   873
  @{text "wq s cs = []"}, which means the waiting queue of 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   874
  the requested resource @{text "cs"} is empty, in which
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   875
  case,  the requesting thread @{text "th"} 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   876
  will take hold of @{text "cs"}. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   877
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   878
  Opposite to @{text "valid_trace_p_h"},
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   879
  @{text "valid_trace_p_w"} constraints that
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   880
  @{text "wq s cs \<noteq> []"}, which means the waiting queue of 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   881
  the requested resource @{text "cs"} is nonempty, in which
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   882
  case,  the requesting thread @{text "th"} will be blocked
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   883
  on @{text "cs"}: 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   884
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   885
  Peculiar properties will be derived under respective 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   886
  locales.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   887
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   888
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   889
locale valid_trace_p_h = valid_trace_p +
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   890
  assumes we: "wq s cs = []"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   891
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   892
locale valid_trace_p_w = valid_trace_p +
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   893
  assumes wne: "wq s cs \<noteq> []"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   894
begin
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   895
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   896
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   897
  The following @{text "holder"} designates
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   898
  the holder of @{text "cs"} before the @{text "P"}-operation.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   899
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   900
definition "holder = hd (wq s cs)"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   901
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   902
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   903
  The following @{text "waiters"} designates
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   904
  the list of threads waiting for @{text "cs"} 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   905
  before the @{text "P"}-operation.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   906
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   907
definition "waiters = tl (wq s cs)"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   908
end
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   909
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   910
text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   911
  @{text "valid_trace_v"} is set for the @{term V}-operation.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   912
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   913
locale valid_trace_v = valid_trace_e + 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   914
  fixes th cs
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   915
  assumes is_v: "e = V th cs"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   916
begin
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   917
  -- {* The following @{text "rest"} is the tail of 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   918
        waiting queue of the resource @{text "cs"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   919
        to be released by this @{text "V"}-operation.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   920
     *}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   921
  definition "rest = tl (wq s cs)"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   922
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   923
  text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   924
    The following @{text "wq'"} is the waiting
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   925
    queue of @{term "cs"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   926
    after the @{text "V"}-operation, which
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   927
    is simply a reordering of @{term "rest"}. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   928
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   929
    The effect of this reordering needs to be 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   930
    understood by two cases:
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   931
    \begin{enumerate}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   932
    \item When @{text "rest = []"},
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   933
    the reordering gives rise to an empty list as well, 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   934
    which means there is no thread holding or waiting 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   935
    for resource @{term "cs"}, therefore, it is free.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   936
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   937
    \item When @{text "rest \<noteq> []"}, the effect of 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   938
    this reordering is to arbitrarily 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   939
    switch one thread in @{term "rest"} to the 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   940
    head, which, by definition take over the hold
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   941
    of @{term "cs"} and is designated by @{text "taker"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   942
    in the following sublocale @{text "valid_trace_v_n"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   943
  *}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   944
  definition "wq' = (SOME q. distinct q \<and> set q = set rest)"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   945
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   946
  text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   947
  The following @{text "rest'"} is the tail of the 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   948
  waiting queue after the @{text "V"}-operation. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   949
  It plays only auxiliary role to ease reasoning. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   950
  *}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   951
  definition "rest' = tl wq'"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   952
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   953
end
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   954
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   955
text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   956
  In the following, @{text "valid_trace_v"} is also 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   957
  divided into two 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   958
  sublocales: when @{text "rest"} is empty (represented
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   959
  by @{text "valid_trace_v_e"}), which means, there is no thread waiting 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   960
  for @{text "cs"}, therefore, after the @{text "V"}-operation, 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   961
  it will become free; otherwise (represented 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   962
  by @{text "valid_trace_v_n"}), one thread 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   963
  will be picked from those in @{text "rest"} to take 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   964
  over @{text "cs"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   965
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   966
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   967
locale valid_trace_v_e = valid_trace_v +
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   968
  assumes rest_nil: "rest = []"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   969
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   970
locale valid_trace_v_n = valid_trace_v +
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   971
  assumes rest_nnl: "rest \<noteq> []"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   972
begin
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   973
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   974
text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   975
  The following @{text "taker"} is the thread to 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   976
  take over @{text "cs"}. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   977
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   978
  definition "taker = hd wq'"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   979
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   980
end
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   981
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   982
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   983
locale valid_trace_set = valid_trace_e + 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   984
  fixes th prio
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   985
  assumes is_set: "e = Set th prio"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   986
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   987
context valid_trace
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   988
begin
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   989
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   990
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   991
  Induction rule introduced to easy the 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   992
  derivation of properties for valid trace @{term "s"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   993
  One more premises, namely @{term "valid_trace_e s e"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   994
  is added, so that an interpretation of 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   995
  @{text "valid_trace_e"} can be instantiated 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   996
  so that all properties derived so far becomes 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   997
  available in the proof of induction step.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   998
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   999
  You will see its use in the proofs that follows.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1000
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1001
lemma ind [consumes 0, case_names Nil Cons, induct type]:
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1002
  assumes "PP []"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1003
     and "(\<And>s e. valid_trace_e s e \<Longrightarrow>
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1004
                   PP s \<Longrightarrow> PIP s e \<Longrightarrow> PP (e # s))"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1005
     shows "PP s"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1006
proof(induct rule:vt.induct[OF vt, case_names Init Step])
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1007
  case Init
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1008
  from assms(1) show ?case .
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1009
next
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1010
  case (Step s e)
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1011
  show ?case
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1012
  proof(rule assms(2))
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1013
    show "valid_trace_e s e" using Step by (unfold_locales, auto)
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1014
  next
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1015
    show "PP s" using Step by simp
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1016
  next
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1017
    show "PIP s e" using Step by simp
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1018
  qed
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1019
qed
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1020
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
  1021
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
  1022
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
  1023
  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
  1024
  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
  1025
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
  1026
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
  1027
  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
  1028
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1029
end
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1030
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1031
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
  1032
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
  1033
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1034
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
  1035
  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
  1036
  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
  1037
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1038
  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
  1039
  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
  1040
  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
  1041
  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
  1042
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1043
  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
  1044
  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
  1045
  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
  1046
  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
  1047
  
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1048
*}
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1049
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1050
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
  1051
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
  1052
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1053
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
  1054
  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
  1055
    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
  1056
  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
  1057
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1058
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
  1059
  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
  1060
  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
  1061
  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
  1062
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
  1063
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1064
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
  1065
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
  1066
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1067
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
  1068
  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
  1069
    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
  1070
  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
  1071
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1072
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
  1073
  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
  1074
  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
  1075
  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
  1076
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
  1077
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1078
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
  1079
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
  1080
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1081
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
  1082
  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
  1083
  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
  1084
    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
  1085
  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
  1086
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1087
lemma running_th_s:
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1088
  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
  1089
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
  1090
  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
  1091
  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
  1092
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
  1093
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1094
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
  1095
  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
  1096
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
  1097
  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
  1098
  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
  1099
  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
  1100
  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
  1101
  have "holding s th cs"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1102
    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
  1103
  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
  1104
    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
  1105
  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
  1106
  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
  1107
  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
  1108
    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
  1109
    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
  1110
  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
  1111
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
  1112
                  
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1113
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
  1114
  "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
  1115
  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
  1116
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1117
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
  1118
  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
  1119
  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
  1120
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
  1121
  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
  1122
  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
  1123
    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
  1124
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
  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
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
  1127
4763aa246dbd Original files overwrite by 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
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
  1129
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
  1130
4763aa246dbd Original files overwrite by 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
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
  1132
  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
  1133
  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
  1134
    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
  1135
  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
  1136
4763aa246dbd Original files overwrite by 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
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
  1138
  "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
  1139
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
  1140
  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
  1141
  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
  1142
  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
  1143
    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
  1144
    from this(2) show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1145
      unfolding s_holding_def
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1146
      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
  1147
  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
  1148
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
  1149
4763aa246dbd Original files overwrite by 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
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
  1151
  "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
  1152
 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
  1153
 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
  1154
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1155
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
  1156
  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
  1157
  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
  1158
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
  1159
  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
  1160
  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
  1161
  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
  1162
    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
  1163
        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
  1164
  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
  1165
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
  1166
4763aa246dbd Original files overwrite by 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
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
  1168
4763aa246dbd Original files overwrite by 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
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
  1170
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
  1171
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1172
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
  1173
  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
  1174
    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
  1175
  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
  1176
4763aa246dbd Original files overwrite by 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
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
  1178
  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
  1179
  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
  1180
  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
  1181
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
  1182
4763aa246dbd Original files overwrite by 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
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
  1184
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
  1185
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
  1186
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
  1187
  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
  1188
  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
  1189
  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
  1190
  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
  1191
  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
  1192
*}
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1193
lemma wq_distinct: "distinct (wq s cs)"
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 67
diff changeset
  1194
proof(induct rule:ind)
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 67
diff changeset
  1195
  case (Cons s e)
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1196
  interpret vt_e: valid_trace_e s e using Cons by simp
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 67
diff changeset
  1197
  show ?case 
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1198
  proof(cases e)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1199
    case (Create th prio)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1200
    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
  1201
      using Create by (unfold_locales, simp)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1202
    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
  1203
  next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1204
    case (Exit th)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1205
    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
  1206
        using Exit by (unfold_locales, simp)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1207
    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
  1208
  next
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1209
    case (P th cs)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1210
    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
  1211
    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
  1212
  next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1213
    case (V th cs)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1214
    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
  1215
    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
  1216
  next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1217
    case (Set th prio)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1218
    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
  1219
        using Set by (unfold_locales, simp)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1220
    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
  1221
  qed
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 67
diff changeset
  1222
qed (unfold wq_def Let_def, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1223
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1224
end
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1225
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1226
section {* Waiting queues and threads *}
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1227
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
  1228
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
  1229
  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
  1230
  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
  1231
  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
  1232
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1233
  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
  1234
  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
  1235
  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
  1236
  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
  1237
*}
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1238
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1239
context valid_trace_create
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1240
begin
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1241
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
  1242
lemma 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1243
  th_not_in_threads: "th \<notin> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1244
proof -
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1245
  from pip_e[unfolded is_create]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1246
  show ?thesis by (cases, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1247
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1248
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
  1249
lemma 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1250
  threads_es [simp]: "threads (e#s) = threads s \<union> {th}"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1251
  by (unfold is_create, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1252
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
  1253
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
  1254
  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
  1255
  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
  1256
  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
  1257
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
  1258
  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
  1259
  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
  1260
    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
  1261
    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
  1262
    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
  1263
  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
  1264
  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
  1265
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
  1266
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1267
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
  1268
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1269
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
  1270
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
  1271
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1272
lemma threads_es [simp]: "threads (e#s) = threads s - {th}"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1273
  by (unfold is_exit, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1274
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
  1275
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
  1276
  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
  1277
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
  1278
  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
  1279
  show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1280
  apply(cases)
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1281
  unfolding holdents_def s_holding_def
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1282
  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
  1283
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
  1284
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1285
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
  1286
  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
  1287
  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
  1288
  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
  1289
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
  1290
  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
  1291
  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
  1292
    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
  1293
    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
  1294
    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
  1295
  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
  1296
  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
  1297
  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
  1298
    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
  1299
    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
  1300
    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
  1301
    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
  1302
    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
  1303
  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
  1304
  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
  1305
    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
  1306
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
  1307
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1308
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
  1309
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
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
  1311
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
  1312
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1313
lemma 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1314
  threads_es [simp]: "threads (e#s) = threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1315
  by (unfold is_v, simp)
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 
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1318
  th_not_in_rest: "th \<notin> set rest"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1319
proof
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1320
  assume otherwise: "th \<in> set rest"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1321
  have "distinct (wq s cs)" by (simp add: wq_distinct)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1322
  from this[unfolded wq_s_cs] and otherwise
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1323
  show False by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1324
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1325
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
  1326
lemma distinct_rest: "distinct rest"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1327
  by (simp add: distinct_tl rest_def wq_distinct)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1328
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
  1329
lemma
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1330
  set_wq_es_cs [simp]: "set (wq (e#s) cs) = set (wq s cs) - {th}"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1331
proof(unfold wq_es_cs wq'_def, rule someI2)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1332
  show "distinct rest \<and> set rest = set rest"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1333
    by (simp add: distinct_rest) 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1334
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1335
  fix x
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1336
  assume "distinct x \<and> set x = set rest"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1337
  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
  1338
      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
  1339
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
  1340
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1341
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
  1342
  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
  1343
  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
  1344
  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
  1345
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
  1346
  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
  1347
  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
  1348
  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
  1349
    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
  1350
    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
  1351
    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
  1352
    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
  1353
    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
  1354
  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
  1355
  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
  1356
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
  1357
    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
  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 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
  1361
      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
  1362
      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
  1363
      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
  1364
      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
  1365
      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
  1366
    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
  1367
    with threads_es show ?thesis by simp
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1368
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
  1369
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
  1370
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
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
  1372
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
  1373
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
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
  1375
  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
  1376
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
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
  1378
  using running_th_s
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1379
  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
  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 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
  1382
  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
  1383
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1384
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
  1385
  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
  1386
  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
  1387
  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
  1388
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
  1389
    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
  1390
    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
  1391
    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
  1392
    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
  1393
    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
  1394
      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
  1395
      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
  1396
      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
  1397
      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
  1398
    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
  1399
      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
  1400
      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
  1401
      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
  1402
    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
  1403
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
  1404
    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
  1405
    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
  1406
    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
  1407
      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
  1408
      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
  1409
      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
  1410
      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
  1411
      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
  1412
      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
  1413
    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
  1414
    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
  1415
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
  1416
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
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
  1418
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
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
  1420
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
  1421
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
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
  1423
  "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
  1424
  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
  1425
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
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
  1427
  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
  1428
  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
  1429
  shows "th' \<in> threads (e#s)"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1430
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
  1431
  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
  1432
     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
  1433
  with threads_kept show ?thesis by simp
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1434
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1435
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
  1436
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
  1437
129
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  1438
context valid_trace
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  1439
begin
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  1440
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
  1441
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
  1442
  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
  1443
  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
  1444
  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
  1445
  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
  1446
*}
129
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  1447
lemma wq_threads: 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1448
  assumes "th \<in> set (wq s cs)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1449
  shows "th \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1450
  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
  1451
proof(induct arbitrary:th cs rule:ind)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1452
  case (Nil)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1453
  thus ?case by (auto simp:wq_def)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1454
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1455
  case (Cons s e)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1456
  interpret vt_e: valid_trace_e s e using Cons by simp
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1457
  show ?case
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1458
  proof(cases e)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1459
    case (Create th' prio')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1460
    interpret vt: valid_trace_create s e th' prio'
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1461
      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
  1462
    show ?thesis using vt.wq_threads_kept Cons by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1463
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1464
    case (Exit th')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1465
    interpret vt: valid_trace_exit s e th'
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1466
      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
  1467
    show ?thesis using vt.wq_threads_kept Cons by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1468
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1469
    case (P th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1470
    interpret vt: valid_trace_p s e th' cs'
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1471
      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
  1472
   show ?thesis using vt.wq_threads_kept Cons by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1473
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1474
    case (V th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1475
    interpret vt: valid_trace_v s e th' cs'
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1476
      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
  1477
   show ?thesis using vt.wq_threads_kept Cons by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1478
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1479
    case (Set th' prio)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1480
    interpret vt: valid_trace_set s e th' prio
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1481
      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
  1482
   show ?thesis using vt.wq_threads_kept Cons by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1483
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1484
qed 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1485
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
  1486
subsection {* RAG and threads *}
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 67
diff changeset
  1487
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1488
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
  1489
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
  1490
  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
  1491
  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
  1492
  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
  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
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1495
lemma  dm_RAG_threads:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1496
  assumes in_dom: "(Th th) \<in> Domain (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1497
  shows "th \<in> threads s"
104
43482ab31341 A fake merge. Used to revert to 98
zhangx
parents: 103 97
diff changeset
  1498
proof -
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1499
  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
  1500
  moreover then obtain cs where "n = Cs cs" by (unfold s_RAG_def, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1501
  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
  1502
  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
  1503
    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
  1504
  then show ?thesis using wq_threads by simp
104
43482ab31341 A fake merge. Used to revert to 98
zhangx
parents: 103 97
diff changeset
  1505
qed
43482ab31341 A fake merge. Used to revert to 98
zhangx
parents: 103 97
diff changeset
  1506
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1507
lemma dm_tG_threads: 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1508
  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
  1509
  shows "th \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1510
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1511
  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
  1512
  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
  1513
  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
  1514
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1515
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1516
lemma rg_RAG_threads: 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1517
  assumes "(Th th) \<in> Range (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1518
  shows "th \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1519
  using assms
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1520
  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
  1521
  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
  1522
  apply(auto)
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1523
  using s_holding_def wq_def wq_threads by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1524
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1525
lemma rg_tG_threads: 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1526
  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
  1527
  shows "th \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1528
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1529
  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
  1530
  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
  1531
  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
  1532
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1533
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1534
lemma RAG_threads:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1535
  assumes "(Th th) \<in> Field (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1536
  shows "th \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1537
  using assms
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1538
  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
  1539
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1540
lemma tG_threads:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1541
  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
  1542
  shows "th \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1543
  using assms
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1544
  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
  1545
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  1546
lemma not_in_thread_isolated:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  1547
  assumes "th \<notin> threads s"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  1548
  shows "(Th th) \<notin> Field (RAG s)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  1549
  using RAG_threads assms by auto
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  1550
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1551
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
  1552
  assumes "th \<notin> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1553
  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
  1554
  using assms
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1555
  using tG_threads by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1556
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1557
text {*
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1558
  As a corollary, this lemma shows that @{term tRAG}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1559
  is also covered by the @{term threads}-set.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1560
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1561
lemma subtree_tRAG_thread:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1562
  assumes "th \<in> threads s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1563
  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
  1564
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1565
  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
  1566
    by (unfold tRAG_subtree_eq, simp)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1567
  also have "... \<subseteq> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1568
  proof
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1569
    fix x
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1570
    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
  1571
    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
  1572
    from this(2)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1573
    show "x \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1574
    proof(cases rule:subtreeE)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1575
      case 1
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1576
      thus ?thesis by (simp add: assms h(1)) 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1577
    next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1578
      case 2
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1579
      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
  1580
    qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1581
  qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1582
  finally show ?thesis .
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1583
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1584
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1585
lemma subtree_tG_thread:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1586
  assumes "th \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1587
  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
  1588
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1589
  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
  1590
  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
  1591
  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
  1592
  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
  1593
  thus ?thesis by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1594
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  1595
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1596
end
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1597
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
  1598
section {* The formation of @{term RAG} *}
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1599
53
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  1600
text {*
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1601
  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
  1602
  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
  1603
  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
  1604
  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
  1605
*}
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
  1606
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
  1607
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
  1608
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
  1609
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
  1610
  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
  1611
  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
  1612
  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
  1613
  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
  1614
  (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
  1615
  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
  1616
  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
  1617
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
  1618
  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
  1619
  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
  1620
  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
  1621
*}
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1622
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1623
text {*
53
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  1624
  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
  1625
  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
  1626
  events, respectively.
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  1627
*}
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  1628
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1629
lemma (in valid_trace_set) RAG_es [simp]: "(RAG (e # s)) = RAG s"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1630
   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
  1631
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1632
lemma (in valid_trace_create) RAG_es [simp]: "(RAG (e # s)) = RAG s"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1633
 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
  1634
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1635
lemma (in valid_trace_exit) RAG_es[simp]: "(RAG (e # s)) = RAG s"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1636
  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
  1637
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1638
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
  1639
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
  1640
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1641
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
  1642
  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
  1643
  shows "t = th"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1644
proof -
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1645
  from pip_e[unfolded is_v]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1646
  show ?thesis
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1647
  proof(cases)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1648
    case (thread_V)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1649
    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
  1650
    show ?thesis by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1651
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1652
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1653
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1654
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
  1655
  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
  1656
  
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1657
lemma set_wq': "set wq' = set rest"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1658
  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
  1659
    
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1660
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
  1661
  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
  1662
  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
  1663
  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
  1664
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1665
lemma running_th_s:
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1666
  shows "th \<in> running s"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1667
proof -
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1668
  from pip_e[unfolded is_v]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1669
  show ?thesis by (cases, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1670
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1671
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1672
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
  1673
  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
  1674
  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
  1675
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
  1676
  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
  1677
  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
  1678
  proof(cases "c = cs")
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1679
    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
  1680
    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
  1681
     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
  1682
     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
  1683
    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
  1684
    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
  1685
    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
  1686
  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
  1687
    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
  1688
    have "wq (e#s) c = wq s c" using False
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1689
        by simp
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1690
    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
  1691
        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
  1692
    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
  1693
    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
  1694
    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
  1695
  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
  1696
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
  1697
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1698
lemma waiting_esI1:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1699
  assumes "waiting s t c"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1700
      and "c \<noteq> cs" 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1701
  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
  1702
proof -
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1703
  have "wq (e#s) c = wq s c" 
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1704
    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
  1705
  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
  1706
    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
  1707
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
  1708
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1709
lemma holding_esI2:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1710
  assumes "c \<noteq> cs" 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1711
  and "holding s t c"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1712
  shows "holding (e#s) t c"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1713
proof -
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1714
  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
  1715
  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
  1716
                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
  1717
  show ?thesis .
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1718
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1719
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1720
lemma holding_esI1:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1721
  assumes "holding s t c"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1722
  and "t \<noteq> th"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1723
  shows "holding (e#s) t c"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1724
proof -
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1725
  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
  1726
  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
  1727
  show ?thesis .
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1728
qed
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1729
92
4763aa246dbd Original files overwrite by 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
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
  1731
4763aa246dbd Original files overwrite by 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
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
  1733
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
  1734
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1735
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
  1736
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
  1737
  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
  1738
    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
  1739
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
  1740
  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
  1741
  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
  1742
  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
  1743
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
  1744
4763aa246dbd Original files overwrite by 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
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
  1746
  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
  1747
4763aa246dbd Original files overwrite by 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
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
  1749
  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
  1750
  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
  1751
  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
  1752
4763aa246dbd Original files overwrite by 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
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
  1754
  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
  1755
  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
  1756
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
  1757
  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
  1758
  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
  1759
    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
  1760
       "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
  1761
          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
  1762
  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
  1763
  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
  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
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1766
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
  1767
  "{(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
  1768
  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
  1769
      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
  1770
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1771
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
  1772
  "{(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
  1773
  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
  1774
  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
  1775
   
4763aa246dbd Original files overwrite by 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
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
  1777
  shows "holding (e#s) taker cs"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  1778
    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
  1779
        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
  1780
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1781
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
  1782
  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
  1783
      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
  1784
  shows "waiting (e#s) t cs" 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1785
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
  1786
  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
  1787
  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
  1788
    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
  1789
          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
  1790
  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
  1791
    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
  1792
    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
  1793
    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
  1794
        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
  1795
    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
  1796
  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
  1797
  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
  1798
    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
  1799
  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
  1800
    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
  1801
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
  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 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
  1804
  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
  1805
  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
  1806
     |    "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
  1807
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
  1808
  case False
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1809
  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
  1810
  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
  1811
    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
  1812
  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
  1813
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
  1814
  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
  1815
  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
  1816
  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
  1817
  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
  1818
  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
  1819
  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
  1820
  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
  1821
    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
  1822
  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
  1823
  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
  1824
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
  1825
4763aa246dbd Original files overwrite by 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
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
  1827
  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
  1828
  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
  1829
  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
  1830
  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
  1831
4763aa246dbd Original files overwrite by 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
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
  1833
  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
  1834
  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
  1835
      | "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
  1836
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
  1837
  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
  1838
  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
  1839
             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
  1840
  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
  1841
  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
  1842
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
  1843
  case False
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1844
  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
  1845
  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
  1846
             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
  1847
  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
  1848
  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
  1849
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
  1850
4763aa246dbd Original files overwrite by 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
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
  1852
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1853
4763aa246dbd Original files overwrite by 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
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
  1855
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
  1856
4763aa246dbd Original files overwrite by 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
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
  1858
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
  1859
  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
  1860
    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
  1861
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
  1862
  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
  1863
  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
  1864
  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
  1865
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
  1866
4763aa246dbd Original files overwrite by 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
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
  1868
  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
  1869
  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
  1870
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
  1871
  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
  1872
  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
  1873
    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
  1874
  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
  1875
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
  1876
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1877
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
  1878
  "{(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
  1879
  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
  1880
4763aa246dbd Original files overwrite by 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
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
  1882
  "{(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
  1883
  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
  1884
   
4763aa246dbd Original files overwrite by 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
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
  1886
  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
  1887
  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
  1888
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
  1889
  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
  1890
  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
  1891
  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
  1892
  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
  1893
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
  1894
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1895
lemma no_waiter_before: "\<not> waiting s t cs"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1896
proof
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1897
  assume otherwise: "waiting s t cs"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1898
  from this[unfolded s_waiting_def, folded wq_def, 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1899
            unfolded wq_s_cs rest_nil]
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1900
  show False by simp
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1901
qed
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1902
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1903
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
  1904
  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
  1905
  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
  1906
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
  1907
  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
  1908
  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
  1909
  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
  1910
  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
  1911
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
  1912
4763aa246dbd Original files overwrite by 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
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
  1914
  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
  1915
  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
  1916
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
  1917
  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
  1918
    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
  1919
  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
  1920
  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
  1921
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
  1922
4763aa246dbd Original files overwrite by 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
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
  1924
  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
  1925
  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
  1926
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
  1927
  case False
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1928
  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
  1929
  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
  1930
    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
  1931
  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
  1932
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
  1933
  case True
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1934
  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
  1935
  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
  1936
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
  1937
4763aa246dbd Original files overwrite by 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
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
  1939
  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
  1940
  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
  1941
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
  1942
  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
  1943
  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
  1944
  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
  1945
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
  1946
  case False
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1947
  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
  1948
  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
  1949
             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
  1950
  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
  1951
  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
  1952
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
  1953
4763aa246dbd Original files overwrite by 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
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
  1955
4763aa246dbd Original files overwrite by 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
  
4763aa246dbd Original files overwrite by 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
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
  1958
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
  1959
4763aa246dbd Original files overwrite by 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
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
  1961
  "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
  1962
   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
  1963
     {(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
  1964
     {(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
  1965
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
  1966
  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
  1967
  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
  1968
  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
  1969
  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
  1970
    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
  1971
    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
  1972
    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
  1973
      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
  1974
      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
  1975
        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
  1976
      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
  1977
      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
  1978
      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
  1979
        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
  1980
        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
  1981
        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
  1982
        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
  1983
             fold s_waiting_abv, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1984
      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
  1985
        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
  1986
        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
  1987
        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
  1988
         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
  1989
             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
  1990
      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
  1991
    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
  1992
      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
  1993
      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
  1994
        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
  1995
      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
  1996
      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
  1997
      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
  1998
        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
  1999
        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
  2000
        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
  2001
        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
  2002
             fold s_waiting_abv, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2003
      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
  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
  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
  2006
    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
  2007
    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
  2008
    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
  2009
      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
  2010
      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
  2011
        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
  2012
      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
  2013
      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
  2014
      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
  2015
        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
  2016
        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
  2017
        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
  2018
        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
  2019
             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
  2020
      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
  2021
        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
  2022
        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
  2023
        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
  2024
         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
  2025
             fold s_holding_abv, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2026
      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
  2027
    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
  2028
      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
  2029
      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
  2030
        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
  2031
      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
  2032
      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
  2033
      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
  2034
        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
  2035
        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
  2036
        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
  2037
        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
  2038
             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
  2039
      qed
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2040
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2041
  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
  2042
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
  2043
  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
  2044
  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
  2045
  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
  2046
  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
  2047
    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
  2048
    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
  2049
        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
  2050
    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
  2051
    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
  2052
                            \<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
  2053
          (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
  2054
      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
  2055
   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
  2056
   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
  2057
      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
  2058
      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
  2059
      show ?thesis 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2060
        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
  2061
   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
  2062
    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
  2063
        (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
  2064
    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
  2065
    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
  2066
    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
  2067
      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
  2068
      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
  2069
      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
  2070
      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
  2071
      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
  2072
        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
  2073
        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
  2074
        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
  2075
      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
  2076
        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
  2077
        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
  2078
        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
  2079
          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
  2080
          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
  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
        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
  2083
          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
  2084
          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
  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
        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
  2087
      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
  2088
      thus ?thesis using waiting(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2089
        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
  2090
    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
  2091
      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
  2092
      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
  2093
      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
  2094
      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
  2095
      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
  2096
        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
  2097
        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
  2098
        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
  2099
      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
  2100
        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
  2101
        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
  2102
        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
  2103
      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
  2104
      thus ?thesis using holding(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2105
        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
  2106
    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
  2107
   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
  2108
 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
  2109
   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
  2110
   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
  2111
        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
  2112
   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
  2113
   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
  2114
      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
  2115
   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
  2116
   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
  2117
   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
  2118
    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
  2119
    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
  2120
    show ?thesis using waiting(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2121
      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
  2122
   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
  2123
    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
  2124
    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
  2125
    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
  2126
    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
  2127
    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
  2128
      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
  2129
      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
  2130
      show ?thesis using holding(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2131
        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
  2132
    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
  2133
      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
  2134
      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
  2135
      show ?thesis using holding(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2136
        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
  2137
    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
  2138
   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
  2139
 qed
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2140
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2141
92
4763aa246dbd Original files overwrite by 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
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
  2143
4763aa246dbd Original files overwrite by 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
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
  2145
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
  2146
4763aa246dbd Original files overwrite by 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
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
  2148
  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
  2149
  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
  2150
  using assms
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  2151
    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
  2152
        in_set_butlastD s_waiting_def wq_def wq_es_cs wq_neq_simp)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2153
92
4763aa246dbd Original files overwrite by 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
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
  2155
  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
  2156
  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
  2157
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
  2158
  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
  2159
  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
  2160
  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
  2161
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
  2162
  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
  2163
  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
  2164
  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
  2165
    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
  2166
  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
  2167
    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
  2168
  thus ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2169
    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
  2170
qed
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2171
end 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2172
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2173
lemma (in valid_trace_p) th_not_waiting: "\<not> waiting s th c"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2174
proof -
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2175
  have "th \<in> readys s"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  2176
    using running_ready running_th_s by blast 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2177
  thus ?thesis
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2178
    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
  2179
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
  2180
4763aa246dbd Original files overwrite by 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
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
  2182
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
  2183
4763aa246dbd Original files overwrite by 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
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
  2185
  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
  2186
4763aa246dbd Original files overwrite by 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
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
  2188
  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
  2189
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
  2190
  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
  2191
  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
  2192
  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
  2193
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
  2194
4763aa246dbd Original files overwrite by 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
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
  2196
  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
  2197
4763aa246dbd Original files overwrite by 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
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
  2199
  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
  2200
  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
  2201
  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
  2202
  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
  2203
      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
  2204
  
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2205
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
  2206
  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
  2207
  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
  2208
    | "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
  2209
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
  2210
  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
  2211
  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
  2212
  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
  2213
  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
  2214
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
  2215
  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
  2216
  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
  2217
    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
  2218
  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
  2219
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
  2220
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2221
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
  2222
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
  2223
  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
  2224
  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
  2225
  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
  2226
  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
  2227
    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
  2228
    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
  2229
    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
  2230
    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
  2231
      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
  2232
      thus ?thesis using waiting(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2233
        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
  2234
    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
  2235
  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
  2236
    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
  2237
    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
  2238
    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
  2239
    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
  2240
      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
  2241
      with holding(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2242
      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
  2243
    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
  2244
      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
  2245
      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
  2246
    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
  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
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
  2249
  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
  2250
  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
  2251
  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
  2252
  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
  2253
  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
  2254
    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
  2255
    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
  2256
    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
  2257
      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
  2258
      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
  2259
      show ?thesis using waiting(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2260
         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
  2261
    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
  2262
      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
  2263
      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
  2264
      show ?thesis using holding(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2265
         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
  2266
    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
  2267
  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
  2268
    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
  2269
    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
  2270
    show ?thesis 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2271
      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
  2272
  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
  2273
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
  2274
4763aa246dbd Original files overwrite by 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
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
  2276
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2277
context valid_trace_p_w
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2278
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2279
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2280
lemma wq_s_cs: "wq s cs = holder#waiters"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2281
    by (simp add: holder_def waiters_def wne)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2282
    
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2283
lemma wq_es_cs': "wq (e#s) cs = holder#waiters@[th]"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2284
  by (simp add: wq_es_cs wq_s_cs)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2285
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2286
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
  2287
  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
  2288
  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
  2289
   set_append wq_def wq_es_cs by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2290
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2291
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
  2292
   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
  2293
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2294
lemma holding_esE:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2295
  assumes "holding (e#s) th' cs'"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2296
  obtains "holding s th' cs'"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2297
  using assms 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2298
proof(cases "cs' = cs")
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2299
  case False
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2300
  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
  2301
  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
  2302
    using s_holding_def wq_def by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2303
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2304
  case True
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2305
  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
  2306
    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
  2307
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2308
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2309
lemma waiting_esE:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2310
  assumes "waiting (e#s) th' cs'"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2311
  obtains "th' \<noteq> th" "waiting s th' cs'"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2312
     |  "th' = th" "cs' = cs"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2313
proof(cases "waiting s th' cs'")
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2314
  case True
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2315
  have "th' \<noteq> th"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2316
  proof
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2317
    assume otherwise: "th' = th"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2318
    from True[unfolded this]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2319
    show False by (simp add: th_not_waiting)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2320
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2321
  from that(1)[OF this True] show ?thesis .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2322
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2323
  case False
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2324
  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
  2325
      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
  2326
          s_waiting_def set_rotate1 wne wq_def wq_es_cs wq_neq_simp)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2327
  with that(2) show ?thesis by metis
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2328
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2329
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2330
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
  2331
proof(rule rel_eqI)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2332
  fix n1 n2
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2333
  assume "(n1, n2) \<in> ?L"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2334
  thus "(n1, n2) \<in> ?R" 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2335
  proof(cases rule:in_RAG_E)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2336
    case (waiting th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2337
    from this(3)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2338
    show ?thesis
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2339
    proof(cases rule:waiting_esE)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2340
      case 1
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2341
      thus ?thesis using waiting(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2342
        by (unfold s_RAG_def, fold s_waiting_abv, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2343
    next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2344
      case 2
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2345
      thus ?thesis using waiting(1,2) by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2346
    qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2347
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2348
    case (holding th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2349
    from this(3)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2350
    show ?thesis
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2351
    proof(cases rule:holding_esE)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2352
      case 1
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2353
      with holding(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2354
      show ?thesis by (unfold s_RAG_def, fold s_holding_abv, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2355
    qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2356
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2357
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2358
  fix n1 n2
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2359
  assume "(n1, n2) \<in> ?R"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2360
  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
  2361
  thus "(n1, n2) \<in> ?L"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2362
  proof
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2363
    assume "(n1, n2) \<in> RAG s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2364
    thus ?thesis
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2365
    proof(cases rule:in_RAG_E)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2366
      case (waiting th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2367
      from waiting_kept[OF this(3)]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2368
      show ?thesis using waiting(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2369
         by (unfold s_RAG_def, fold s_waiting_abv, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2370
    next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2371
      case (holding th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2372
      from holding_kept[OF this(3)]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2373
      show ?thesis using holding(1,2)
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2374
         by (unfold s_RAG_def, fold s_holding_abv, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2375
    qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2376
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2377
    assume "n1 = Th th \<and> n2 = Cs cs"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2378
    thus ?thesis using RAG_edge by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2379
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2380
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2381
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2382
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2383
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2384
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
  2385
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
  2386
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2387
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
  2388
                                                  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
  2389
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
  2390
  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
  2391
  interpret vt_p: valid_trace_p_h using True
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  2392
    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
  2393
  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
  2394
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
  2395
  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
  2396
  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
  2397
    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
  2398
  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
  2399
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
  2400
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2401
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
  2402
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
  2403
subsection {* RAG is finite *}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2404
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2405
context valid_trace_v
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2406
begin
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2407
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2408
lemma 
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2409
  finite_RAG_kept:
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2410
  assumes "finite (RAG s)"
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2411
  shows "finite (RAG (e#s))"
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2412
proof(cases "rest = []")
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2413
  case True
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2414
  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
  2415
    by (unfold_locales, simp)
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2416
  show ?thesis using assms
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2417
    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
  2418
next
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2419
  case False
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2420
  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
  2421
    by (unfold_locales, simp)
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2422
  show ?thesis using assms
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2423
    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
  2424
qed
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2425
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2426
end
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2427
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2428
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2429
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2430
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2431
lemma finite_RAG:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2432
  shows "finite (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2433
proof(induct rule:ind)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2434
  case Nil
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2435
  show ?case 
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  2436
  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
  2437
                   holding_raw_def wq_def acyclic_def)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2438
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2439
  case (Cons s e)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2440
  interpret vt_e: valid_trace_e s e using Cons by simp
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2441
  show ?case
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2442
  proof(cases e)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2443
    case (Create th prio)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2444
    interpret vt: valid_trace_create s e th prio using Create
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2445
      by (unfold_locales, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2446
    show ?thesis using Cons by simp
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2447
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2448
    case (Exit th)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2449
    interpret vt: valid_trace_exit s e th using Exit
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2450
      by (unfold_locales, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2451
    show ?thesis using Cons by simp
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2452
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2453
    case (P th cs)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2454
    interpret vt: valid_trace_p s e th cs using P
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2455
      by (unfold_locales, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2456
    show ?thesis using Cons using vt.RAG_es by auto 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2457
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2458
    case (V th cs)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2459
    interpret vt: valid_trace_v s e th cs using V
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2460
      by (unfold_locales, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2461
    show ?thesis using Cons by (simp add: vt.finite_RAG_kept) 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2462
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2463
    case (Set th prio)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2464
    interpret vt: valid_trace_set s e th prio using Set
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2465
      by (unfold_locales, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2466
    show ?thesis using Cons by simp
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2467
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2468
qed
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2469
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2470
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
  2471
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2472
  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
  2473
  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
  2474
  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
  2475
  show ?thesis by simp
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2476
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2477
179
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  2478
find_theorems inj finite "_ ` _"
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  2479
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  2480
find_theorems tG tRAG
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  2481
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  2482
thm tRAG_def_tG
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  2483
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  2484
find_theorems "finite (?f ` ?A)" "finite ?A"
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  2485
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2486
lemma finite_tG: "finite (tG s)"
179
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  2487
proof(rule finite_imageD)
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  2488
  from finite_tRAG[unfolded tRAG_def_tG]
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  2489
  show "finite (map_prod Th Th ` tG s)" .
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  2490
next
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  2491
  show "inj_on (map_prod Th Th) (tG s)"
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  2492
    using inj_on_def by fastforce
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  2493
qed
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  2494
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2495
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2496
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2497
subsection {* Uniqueness of waiting *}
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2498
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2499
text {*
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2500
  {\em Uniqueness of waiting} means that 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2501
  a thread can only be blocked on one resource.
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2502
  This property is needed in order to prove that @{term RAG}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2503
  is acyclic. Therefore, we need to prove it first in the following
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2504
  lemma @{text "waiting_unqiue"}, all lemmas before it are auxiliary. 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2505
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2506
  The property is expressed by the following predicate over system 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2507
  state (or event trace), which is also named @{text "waiting_unqiue"}.
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2508
*}
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2509
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2510
definition 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2511
  "waiting_unique (ss::state) = 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2512
     (\<forall> th cs1 cs2. waiting ss th cs1 \<longrightarrow> 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2513
                    waiting ss th cs2 \<longrightarrow> cs1 = cs2)"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2514
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2515
text {*
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2516
  We are going to show (in the 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2517
  lemma named @{text waiting_unique}) that
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2518
  this property holds on any valid trace (or system state).
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2519
*}
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2520
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2521
text {*
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2522
  As a first step to prove lemma @{text "waiting_unqiue"}, 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2523
  we need to understand how 
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2524
  a thread is get blocked. 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2525
  We show in the following lemmas 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2526
  (all named @{text "waiting_inv"}) that 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2527
  @{term P}-operation is the only cause. 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2528
*}
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2529
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2530
context valid_trace_create
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2531
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2532
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2533
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2534
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2535
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2536
  using assms 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2537
  by (unfold s_waiting_def, fold wq_def, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2538
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2539
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2540
context valid_trace_set
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2541
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2542
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2543
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2544
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2545
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2546
  using assms 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2547
  by (unfold s_waiting_def, fold wq_def, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2548
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2549
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2550
context valid_trace_exit
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2551
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2552
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2553
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2554
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2555
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2556
  using assms 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2557
  by (unfold s_waiting_def, fold wq_def, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2558
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2559
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2560
context valid_trace_p
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2561
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2562
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2563
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2564
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2565
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2566
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2567
proof(cases "cs' = cs")
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2568
  case True
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2569
  moreover have "th' = th"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2570
  proof(rule ccontr)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2571
    assume otherwise: "th' \<noteq> th"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2572
    have "waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2573
    proof -
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2574
      from assms(2)[unfolded True s_waiting_def, 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2575
              folded wq_def, unfolded wq_es_cs]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2576
      have h: "th' \<in> set (wq s cs @ [th])"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2577
              "th' \<noteq> hd (wq s cs @ [th])" by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2578
      from h(1) and otherwise
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2579
      have "th' \<in> set (wq s cs)" by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2580
      hence "wq s cs \<noteq> []" by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2581
      hence "hd (wq s cs @ [th]) = hd (wq s cs)" by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2582
      with h otherwise
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2583
      have "waiting s th' cs" 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2584
        by (unfold s_waiting_def, fold wq_def, auto)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2585
      from this[folded True] show ?thesis .
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2586
    qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2587
    with assms(1) show False by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2588
  qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2589
  ultimately show ?thesis using is_p by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2590
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2591
  case False
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2592
  hence "wq (e#s) cs' = wq s cs'" by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2593
  from assms[unfolded s_waiting_def, folded wq_def, 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2594
            unfolded this]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2595
  show ?thesis by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2596
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2597
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2598
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2599
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2600
context valid_trace_v_n
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2601
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2602
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2603
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2604
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2605
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2606
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2607
proof -
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2608
  from assms(2)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2609
  show ?thesis
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2610
  by (cases rule:waiting_esE, insert assms, auto)
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2611
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2612
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2613
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2614
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2615
context valid_trace_v_e
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2616
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2617
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2618
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2619
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2620
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2621
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2622
proof -
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2623
  from assms(2)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2624
  show ?thesis
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2625
  by (cases rule:waiting_esE, insert assms, auto)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2626
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2627
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2628
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2629
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2630
context valid_trace_e
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2631
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2632
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2633
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2634
  assumes "\<not> waiting s th cs"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2635
  and "waiting (e#s) th cs"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2636
  shows "e = P th cs"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2637
proof(cases e)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2638
  case (Create th' prio')
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2639
  then interpret vt: valid_trace_create s e th' prio'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2640
    by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2641
  show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2642
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2643
  case (Exit th')
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2644
  then interpret vt: valid_trace_exit s e th'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2645
    by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2646
  show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2647
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2648
  case (Set th' prio')
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2649
  then interpret vt: valid_trace_set s e th' prio'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2650
    by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2651
  show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2652
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2653
  case (P th' cs')
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2654
  then interpret vt: valid_trace_p s e th' cs'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2655
    by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2656
  show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2657
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2658
  case (V th' cs')
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2659
  then interpret vt_e: valid_trace_v s e th' cs'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2660
    by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2661
  show ?thesis
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2662
  proof(cases "vt_e.rest = []")
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2663
    case True
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2664
    then interpret vt: valid_trace_v_e s e th' cs'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2665
      by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2666
    show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2667
  next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2668
    case False
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2669
    then interpret vt: valid_trace_v_n s e th' cs'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2670
      by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2671
    show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2672
  qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2673
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2674
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2675
text {* 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2676
  Now, with @{thm waiting_inv} in place, the following lemma
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2677
  shows the uniqueness of waiting is kept by every operation 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2678
  in the PIP protocol. This lemma constitutes the main part
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2679
  in the proof of lemma @{text "waiting_unique"}.
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2680
*}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2681
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2682
lemma waiting_unique_kept:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2683
  assumes "waiting_unique s"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2684
  shows "waiting_unique (e#s)"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2685
proof -
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2686
  note h = assms[unfolded waiting_unique_def, rule_format]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2687
  { fix th cs1 cs2
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2688
    assume w1: "waiting (e#s) th cs1"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2689
       and w2: "waiting (e#s) th cs2"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2690
    have "cs1 = cs2"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2691
    proof(rule ccontr)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2692
      assume otherwise: "cs1 \<noteq> cs2"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2693
      show False
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2694
      proof(cases "waiting s th cs1")
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2695
        case True
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2696
        from h[OF this] and otherwise
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2697
        have "\<not> waiting s th cs2" by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2698
        from waiting_inv[OF this w2]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2699
        have "e = P th cs2" .
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2700
        then interpret vt: valid_trace_p  s e th cs2
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2701
          by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2702
        from vt.th_not_waiting and True
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2703
        show ?thesis by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2704
      next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2705
        case False 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2706
        from waiting_inv[OF this w1]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2707
        have "e = P th cs1" .
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2708
        then interpret vt: valid_trace_p s e th cs1
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
        have "wq (e # s) cs2 = wq s cs2" 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2711
          using otherwise by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2712
        from w2[unfolded s_waiting_def, folded wq_def, 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2713
                  unfolded this]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2714
        have "waiting s th cs2" 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2715
          by (unfold s_waiting_def, fold wq_def, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2716
        thus ?thesis by (simp add: vt.th_not_waiting) 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2717
      qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2718
    qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2719
  } thus ?thesis by (unfold waiting_unique_def, auto)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2720
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2721
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2722
end
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2723
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2724
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2725
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2726
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2727
text {*
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2728
  With @{thm valid_trace_e.waiting_unique_kept} in place,
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2729
  the proof of the following lemma @{text "waiting_unique"} 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2730
  needs only a very simple induction.
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2731
*}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2732
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2733
lemma waiting_unique 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2734
  [unfolded waiting_unique_def, rule_format]:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2735
  shows "waiting_unique s"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2736
proof(induct rule:ind)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2737
  case Nil
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2738
  show ?case 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2739
    by (unfold waiting_unique_def s_waiting_def, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2740
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2741
  case (Cons s e)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2742
  then interpret vt: valid_trace_e s e by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2743
  show ?case using Cons(2) vt.waiting_unique_kept
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2744
    by simp
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2745
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2746
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2747
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2748
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2749
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2750
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
  2751
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2752
text {*
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2753
  To prove that @{term RAG} is acyclic, we need to show the acyclic property 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2754
  is preserved by all system operations. There are only two non-trivial cases, 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2755
  the @{term P} and @{term V} operation, where are treated in the following
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2756
  locales, under the name @{text "acylic_RAG_kept"}:
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2757
*}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2758
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2759
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
  2760
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
  2761
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2762
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
  2763
  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
  2764
  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
  2765
  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
  2766
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
  2767
  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
  2768
      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
  2769
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
  2770
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2771
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
  2772
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2773
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
  2774
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
  2775
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2776
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
  2777
  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
  2778
  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
  2779
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2780
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
  2781
  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
  2782
  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
  2783
  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
  2784
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
  2785
  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
  2786
                 {(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
  2787
  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
  2788
    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
  2789
    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
  2790
       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
  2791
    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
  2792
    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
  2793
      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
  2794
      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
  2795
        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
  2796
      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
  2797
      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
  2798
                          "(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
  2799
        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
  2800
      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
  2801
        by (unfold s_RAG_def, fold s_waiting_abv, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2802
      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
  2803
      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
  2804
      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
  2805
    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
  2806
    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
  2807
  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
  2808
  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
  2809
    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
  2810
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
  2811
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2812
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
  2813
4763aa246dbd Original files overwrite by 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
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
  2815
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
  2816
4763aa246dbd Original files overwrite by 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
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
  2818
  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
  2819
  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
  2820
  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
  2821
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
  2822
  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
  2823
  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
  2824
    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
  2825
    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
  2826
       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
  2827
    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
  2828
    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
  2829
      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
  2830
      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
  2831
        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
  2832
      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
  2833
      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
  2834
        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
  2835
      hence "waiting s th cs'" 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  2836
        by (unfold s_RAG_def, fold s_waiting_abv, auto)
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  2837
      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
  2838
    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
  2839
    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
  2840
  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
  2841
  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
  2842
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
  2843
4763aa246dbd Original files overwrite by 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
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
  2845
4763aa246dbd Original files overwrite by 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
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
  2847
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
  2848
4763aa246dbd Original files overwrite by 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
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
  2850
  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
  2851
  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
  2852
  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
  2853
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
  2854
  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
  2855
  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
  2856
    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
  2857
    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
  2858
       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
  2859
    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
  2860
    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
  2861
      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
  2862
      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
  2863
      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
  2864
      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
  2865
        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
  2866
        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
  2867
            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
  2868
        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
  2869
      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
  2870
    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
  2871
    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
  2872
  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
  2873
  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
  2874
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
  2875
4763aa246dbd Original files overwrite by 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
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
  2877
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
  2878
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
  2879
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
  2880
92
4763aa246dbd Original files overwrite by 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
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
  2882
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
  2883
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2884
text {* 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2885
  With these @{text "acylic_RAG_kept"}-lemmas proved, 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2886
  the proof of the following @{text "acyclic_RAG"} is
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2887
  straight forward. 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2888
 *}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2889
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2890
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
  2891
  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
  2892
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
  2893
  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
  2894
  show ?case 
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  2895
  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
  2896
                   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
  2897
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
  2898
  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
  2899
  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
  2900
  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
  2901
  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
  2902
    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
  2903
    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
  2904
      by (unfold_locales, simp)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2905
    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
  2906
  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
  2907
    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
  2908
    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
  2909
      by (unfold_locales, simp)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2910
    show ?thesis using Cons by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2911
  next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2912
    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
  2913
    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
  2914
      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
  2915
    show ?thesis
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2916
    proof(cases "wq s cs = []")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2917
      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
  2918
      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
  2919
        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
  2920
      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
  2921
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2922
      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
  2923
      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
  2924
        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
  2925
      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
  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
  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
  2928
    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
  2929
    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
  2930
      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
  2931
    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
  2932
    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
  2933
      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
  2934
      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
  2935
        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
  2936
      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
  2937
    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
  2938
      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
  2939
      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
  2940
        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
  2941
      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
  2942
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2943
  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
  2944
    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
  2945
    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
  2946
      by (unfold_locales, simp)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2947
    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
  2948
  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
  2949
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
  2950
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2951
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2952
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
  2953
subsection {* RAG is single-valued *}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2954
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2955
text {*
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2956
  The proof that @{term RAG} is single-valued makes use of 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2957
  @{text "unique_waiting"} and @{thm held_unique} and the
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2958
  proof itself is very simple:
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2959
*}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2960
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2961
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2962
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2963
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2964
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
  2965
  apply(unfold s_RAG_def, auto, fold s_waiting_abv s_holding_abv)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2966
  by(auto elim:waiting_unique held_unique)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2967
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2968
lemma sgv_RAG: "single_valued (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2969
  using unique_RAG by (auto simp:single_valued_def)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2970
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2971
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2972
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
  2973
subsection {* RAG is well-founded *}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2974
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2975
text {*
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2976
  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
  2977
  its converse @{term "(RAG s)^-1"} are well-founded.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2978
  The proof is very simple with the help of
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2979
  already proved fact that @{term RAG} is finite.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2980
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2981
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2982
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2983
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2984
92
4763aa246dbd Original files overwrite by 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
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
  2986
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
  2987
  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
  2988
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
  2989
  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
  2990
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
  2991
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2992
lemma wf_RAG_converse: 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2993
  shows "wf ((RAG s)^-1)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2994
proof(rule finite_acyclic_wf_converse)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2995
  from finite_RAG 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2996
  show "finite (RAG s)" .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2997
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2998
  from acyclic_RAG
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2999
  show "acyclic (RAG s)" .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3000
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3001
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3002
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3003
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
  3004
subsection {* RAG forms a finite-branching forest (or tree) *}
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3005
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3006
text {*
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3007
  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
  3008
  it is easy to show.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3009
*}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3010
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3011
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3012
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3013
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3014
lemma forest_RAG: "forest (RAG s)"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3015
  using sgv_RAG acyclic_RAG
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3016
  by (unfold forest_def, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3017
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3018
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3019
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3020
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
  3021
  using forest_RAG .
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3022
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3023
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
  3024
proof
133
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3025
  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
  3026
    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
  3027
    (*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
  3028
next
d9974794436a added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 131
diff changeset
  3029
  show "wf (RAG s)" using wf_RAG .
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3030
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3031
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
  3032
subsection {* Derived properties for sub-graphs of RAG *}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3033
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3034
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3035
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3036
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3037
lemma acyclic_tRAG: "acyclic (tRAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3038
proof(unfold tRAG_def, rule acyclic_compose)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3039
  show "acyclic (RAG s)" using acyclic_RAG .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3040
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3041
  show "wRAG s \<subseteq> RAG s" unfolding RAG_split by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3042
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3043
  show "hRAG s \<subseteq> RAG s" unfolding RAG_split by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3044
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3045
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3046
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
  3047
  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
  3048
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3049
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
  3050
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3051
  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
  3052
  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
  3053
    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
  3054
      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
  3055
  qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3056
  thus ?thesis
179
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  3057
  by (unfold tG_def_tRAG, fold rel_map_alt_def, simp) 
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3058
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3059
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3060
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
  3061
  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
  3062
  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
  3063
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3064
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
  3065
  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
  3066
  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
  3067
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3068
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
  3069
  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
  3070
              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
  3071
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3072
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
  3073
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3074
  { fix x y z
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3075
    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
  3076
    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
  3077
    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
  3078
    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
  3079
    have "y = z" by simp
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3080
  } 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
  3081
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3082
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3083
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
  3084
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  3085
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  3086
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3087
text {*
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3088
  It can be shown that @{term tRAG} is also a 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3089
  finite-branch relational tree (or forest):  
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3090
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  3091
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3092
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
  3093
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
  3094
  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
  3095
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
  3096
  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
  3097
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
  3098
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3099
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
  3100
proof(unfold_locales)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3101
  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
  3102
next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3103
  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
  3104
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3105
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3106
context valid_trace
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3107
begin
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3108
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3109
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
  3110
proof(rule wf_subset)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3111
      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
  3112
        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
  3113
next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3114
      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
  3115
        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
  3116
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3117
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3118
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
  3119
proof(rule finite_acyclic_wf)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3120
  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
  3121
next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3122
  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
  3123
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3124
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3125
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
  3126
  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
  3127
    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
  3128
    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
  3129
      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
  3130
    qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3131
  next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3132
    fix x
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3133
    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
  3134
    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
  3135
      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
  3136
    qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3137
  qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3138
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3139
lemma children_map_prod: 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3140
  assumes "inj f"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3141
  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
  3142
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3143
  { fix e
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3144
    assume "e \<in> ?L"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3145
    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
  3146
      by (auto simp:children_def)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3147
    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
  3148
    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
  3149
    with h
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3150
    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
  3151
  } moreover {
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3152
    fix e
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3153
    assume "e \<in> ?R"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3154
    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
  3155
  } ultimately show ?thesis by auto
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
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
  3159
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3160
  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
  3161
    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
  3162
  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
  3163
  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
  3164
  from finite_imageD[OF this]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3165
  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
  3166
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3167
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3168
end
133
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3169
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3170
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
  3171
proof
133
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3172
  fix x
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3173
  show "finite (children (tRAG s) x)"
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3174
  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
  3175
    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
  3176
    proof(rule finite_fbranchI1[rule_format])
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3177
      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
  3178
    qed
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3179
  next
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3180
    fix x
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3181
    show "finite (children (hRAG s) x)"
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3182
    proof(rule finite_fbranchI1[rule_format])
4b717aa162fa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
  3183
      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
  3184
    qed
132
d9974794436a added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 131
diff changeset
  3185
  qed
d9974794436a added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 131
diff changeset
  3186
next
d9974794436a added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 131
diff changeset
  3187
  show "wf (tRAG s)"
d9974794436a added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 131
diff changeset
  3188
  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
  3189
      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
  3190
        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
  3191
  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
  3192
      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
  3193
        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
  3194
  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
  3195
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
  3196
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3197
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
  3198
proof
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3199
  fix x
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3200
  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
  3201
    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
  3202
next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3203
  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
  3204
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3205
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3206
section {* Chain to readys *}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3207
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3208
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
  3209
  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
  3210
  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
  3211
  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
  3212
  between threads is established.
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3213
*}
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3214
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3215
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
  3216
begin
53
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  3217
138
20c1d3a14143 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 137
diff changeset
  3218
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
  3219
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
  3220
node), there is a path leading to a ready thread.
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3221
*}
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3222
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3223
lemma chain_building:
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3224
  assumes "node \<in> Domain (RAG s)"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3225
  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
  3226
proof -
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3227
  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
  3228
  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
  3229
  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
  3230
  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
  3231
  proof(cases b)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3232
    case (Cs cs)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3233
    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
  3234
    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
  3235
    from tranclE[OF this]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3236
    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
  3237
    from this[unfolded Cs]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3238
    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
  3239
      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
  3240
    from waiting_holding[OF this]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3241
    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
  3242
    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
  3243
      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
  3244
    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
  3245
    have False by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3246
    thus ?thesis by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3247
  qed auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3248
  have "th' \<in> readys s" 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3249
  proof -
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3250
    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
  3251
    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
  3252
      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
  3253
    moreover have "th' \<in> threads s"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3254
    proof(rule rg_RAG_threads)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3255
      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
  3256
      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
  3257
      thus "Th th' \<in> Range (RAG s)" by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3258
    qed
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3259
    ultimately show ?thesis by (auto simp:readys_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3260
  qed
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3261
  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
  3262
    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
  3263
  ultimately show ?thesis using that by metis
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3264
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3265
53
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  3266
text {* \noindent
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3267
  The following lemma says for any living thread, 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3268
  either it is ready or there is a path in @{term RAG}
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3269
  leading from it to a ready thread. The lemma is proved easily
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3270
  by instantiating @{thm "chain_building"}.
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3271
*}                    
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3272
lemma th_chain_to_ready:
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  3273
  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
  3274
  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
  3275
proof(cases "th \<in> readys s")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3276
  case True
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3277
  thus ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3278
next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3279
  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
  3280
  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
  3281
    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
  3282
 Domain_def)
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  3283
  from chain_building [rule_format, OF this]
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3284
  show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3285
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3286
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3287
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
  3288
  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
  3289
  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
  3290
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3291
  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
  3292
  show ?thesis
179
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  3293
  proof
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  3294
    assume "th \<in> readys s"
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  3295
    thus ?thesis by (unfold nancestors_def, auto)
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  3296
  next
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  3297
    assume "\<exists>th'. th' \<in> readys s \<and> (Th th, Th th') \<in> (RAG s)\<^sup>+"
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  3298
    then obtain th' where h: "th' \<in> readys s" "(Th th, Th th') \<in> (RAG s)\<^sup>+" by auto
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  3299
    from h(2) tRAG_trancl_eq
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  3300
    have "(Th th, Th th') \<in> (tRAG s)^+" by auto
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  3301
    hence "(th, th') \<in> (tG s)^+"
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  3302
      by (metis the_thread.simps trancl_tRAG_tG)
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  3303
    with h(1)
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  3304
    show ?thesis
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  3305
      using ancestors_def mem_Collect_eq nancestors2 by fastforce
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  3306
  qed
138
20c1d3a14143 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 137
diff changeset
  3307
qed
20c1d3a14143 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 137
diff changeset
  3308
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3309
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3310
text {*
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3311
  The following lemma is a technical one to show 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3312
  that the set of threads in the subtree of any thread
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3313
  is finite.
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3314
*}
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3315
lemma finite_subtree_threads:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3316
    "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
  3317
proof -
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3318
  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
  3319
        by (auto, insert image_iff, fastforce)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3320
  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
  3321
        (is "finite ?B")
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3322
  proof -
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3323
     have "?B = (subtree (RAG s) (Th th)) \<inter> {Th th' | th'. True}"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3324
      by auto
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3325
     moreover have "... \<subseteq> (subtree (RAG s) (Th th))" by auto
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3326
     moreover have "finite ..." by (simp add: fsbtRAGs.finite_subtree) 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3327
     ultimately show ?thesis by auto
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3328
  qed
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3329
  ultimately show ?thesis by auto
104
43482ab31341 A fake merge. Used to revert to 98
zhangx
parents: 103 97
diff changeset
  3330
qed
43482ab31341 A fake merge. Used to revert to 98
zhangx
parents: 103 97
diff changeset
  3331
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3332
(* ccc *)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3333
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3334
lemma readys_no_tRAG_chain:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3335
  assumes "th1 \<in> readys s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3336
  and "th2 \<in> readys s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3337
  and "th1 \<noteq> th2"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3338
  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
  3339
proof
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3340
  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
  3341
  from rtranclD[OF this]
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3342
  show False
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3343
  proof
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3344
    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
  3345
  next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3346
    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
  3347
    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
  3348
    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
  3349
      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
  3350
    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
  3351
    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
  3352
  qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3353
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3354
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3355
lemma root_readys:
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3356
  assumes "th \<in> readys s"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3357
  shows "root (tRAG s) (Th th)"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3358
proof -
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3359
  { assume "\<not> root (tRAG s) (Th th)"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3360
    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
  3361
      unfolding root_def ancestors_def by auto
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3362
    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
  3363
      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
  3364
    then have "th \<notin> readys s" 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3365
      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
  3366
    with assms have False by simp
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3367
  } 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
  3368
qed
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3369
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3370
lemma root_readys_tG:
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3371
  assumes "th \<in> readys s"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3372
  shows "root (tG s) th"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3373
proof -
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3374
  { assume "\<not> root (tG s) th"
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3375
    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
  3376
      unfolding root_def ancestors_def by auto
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3377
    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
  3378
      using trancl_tG_tRAG by simp
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3379
    with root_readys assms 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3380
    have False 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3381
      unfolding root_def ancestors_def by auto
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3382
  } 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
  3383
qed  
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3384
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3385
lemma readys_indep:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3386
  assumes "th1 \<in> readys s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3387
  and "th2 \<in> readys s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3388
  and "th1 \<noteq> th2"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3389
  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
  3390
  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
  3391
  unfolding indep_def by blast
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3392
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3393
lemma readys_indep_tG:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3394
  assumes "th1 \<in> readys s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3395
  and "th2 \<in> readys s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3396
  and "th1 \<noteq> th2"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3397
  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
  3398
  using assms
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3399
  unfolding indep_def
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3400
  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
  3401
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3402
text {*
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3403
  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
  3404
  not necessarily a running one. 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3405
*}
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3406
lemma thread_chain:
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3407
  assumes "th \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3408
  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
  3409
                    "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
  3410
proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3411
  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
  3412
  proof(rule Max_in)
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3413
    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
  3414
        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
  3415
  next
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3416
    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
  3417
  qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3418
  then obtain th' where 
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3419
       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
  3420
                    "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
  3421
  by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3422
  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
  3423
  proof -
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3424
    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
  3425
    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
  3426
    show ?thesis by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3427
  qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3428
  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
  3429
qed
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3430
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3431
text {*
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3432
  The following two lemmas shows there is at most one running thread 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3433
  in the system.
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3434
*}
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3435
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3436
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3437
lemma running_unique:
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3438
  assumes running_1: "th1 \<in> running s"
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3439
  and running_2: "th2 \<in> running s"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3440
  shows "th1 = th2"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3441
proof -
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3442
  -- {* 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3443
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3444
  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
  3445
  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
  3446
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3447
  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
  3448
  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
  3449
  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
  3450
  
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3451
  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
  3452
    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
  3453
  with thread_chain
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3454
  obtain th1' where 
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3455
      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
  3456
          "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
  3457
          "th1' \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3458
      by auto
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3459
  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
  3460
    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
  3461
  with thread_chain
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3462
  obtain th2' where 
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3463
      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
  3464
          "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
  3465
          "th2' \<in> threads s"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3466
      by auto
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3467
  -- {* 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
  3468
        @{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
  3469
        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
  3470
     *}
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3471
  have eq_th': "th1' = th2'"
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  3472
  proof -
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3473
    -- {* 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
  3474
          cp-value is the same *}
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3475
    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
  3476
      unfolding running_def by auto
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3477
    -- {* 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
  3478
          must be the same *}
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3479
    then 
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3480
    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
  3481
                  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
  3482
      unfolding cp_alt_def2 .
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3483
    with chain1(2) chain2(2)
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3484
    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
  3485
    -- {* 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
  3486
          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
  3487
    with preced_unique chain1(3) chain2(3)
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3488
    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
  3489
  qed
137
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3490
  moreover
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3491
  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
  3492
    using assms root_readys_tG
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3493
    unfolding running_def by auto
785c0f6b8184 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 136
diff changeset
  3494
  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
  3495
     by fastforce
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3496
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3497
129
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  3498
lemma card_running: 
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  3499
  shows "card (running s) \<le> 1"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3500
proof(cases "running s = {}")
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3501
  case True
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3502
  thus ?thesis by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3503
next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3504
  case False
129
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  3505
  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
  3506
  with running_unique
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3507
  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
  3508
  thus ?thesis by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3509
qed
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  3510
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3511
text {*
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3512
  The following two lemmas show that the set of living threads
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3513
  in the system can be partitioned into subtrees of those 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3514
  threads in the @{term readys} set. The first lemma
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3515
  @{text threads_alt_def} shows the union of 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3516
  these subtrees equals to the set of living threads
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3517
  and the second lemma @{text "readys_subtree_disjoint"} shows 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3518
  subtrees of different threads in @{term readys}-set
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3519
  are disjoint.
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3520
*}
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3521
140
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3522
lemma subtree_RAG_tG: 
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3523
  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
  3524
  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
  3525
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3526
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3527
lemma threads_alt_def:
140
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3528
  "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
  3529
    (is "?L = ?R")
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3530
proof -
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3531
  { fix th1
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3532
    assume "th1 \<in> ?L"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3533
    from th_chain_to_ready[OF this]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3534
    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
  3535
    hence "th1 \<in> ?R" by (auto simp:subtree_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3536
  } moreover 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3537
  { fix th'
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3538
    assume "th' \<in> ?R"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3539
    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
  3540
      by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3541
    from this(2)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3542
    have "th' \<in> ?L" 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3543
    proof(cases rule:subtreeE)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3544
      case 1
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3545
      with h(1) show ?thesis by (auto simp:readys_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3546
    next
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3547
      case 2
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3548
      from tranclD[OF this(2)[unfolded ancestors_def, simplified]]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3549
      have "Th th' \<in> Domain (RAG s)" by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3550
      from dm_RAG_threads[OF this]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3551
      show ?thesis .
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3552
    qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3553
  } ultimately show ?thesis by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3554
qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3555
140
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3556
lemma threads_alt_def1:
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3557
  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
  3558
unfolding threads_alt_def subtree_RAG_tG  ..
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3559
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3560
lemma readys_subtree_disjoint:
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3561
  assumes "th1 \<in> readys s"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3562
  and "th2 \<in> readys s"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3563
  and "th1 \<noteq> th2"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3564
  shows "subtree (RAG s) (Th th1) \<inter> subtree (RAG s) (Th th2) = {}"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3565
proof -
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3566
  { fix n
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3567
    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
  3568
    hence "(n, Th th1) \<in> (RAG s)^*" "(n, Th th2) \<in> (RAG s)^*"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3569
      by (auto simp:subtree_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3570
    from star_rpath[OF this(1)] star_rpath[OF this(2)]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3571
    obtain xs1 xs2 where "rpath (RAG s) n xs1 (Th th1)"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3572
                         "rpath (RAG s) n xs2 (Th th2)" by metis
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3573
    hence False
134
8a13b37b4d95 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3574
    proof(cases rule:forest_RAG.rpath_overlap')
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3575
      case (less_1 xs3)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3576
      from rpath_star[OF this(3)]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3577
      have "Th th1 \<in> subtree (RAG s) (Th th2)"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3578
        by (auto simp:subtree_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3579
      thus ?thesis
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3580
      proof(cases rule:subtreeE)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3581
        case 1
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3582
        with assms(3) show ?thesis by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3583
      next
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3584
        case 2
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3585
        hence "(Th th1, Th th2) \<in> (RAG s)^+" by (auto simp:ancestors_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3586
        from tranclD[OF this]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3587
        obtain z where "(Th th1, z) \<in> RAG s" by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3588
        from this[unfolded s_RAG_def, folded wq_def]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3589
        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
  3590
          by (auto simp:s_waiting_abv)
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3591
        with assms(1) show False by (auto simp:readys_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3592
      qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3593
    next
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3594
      case (less_2 xs3)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3595
      from rpath_star[OF this(3)]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3596
      have "Th th2 \<in> subtree (RAG s) (Th th1)"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3597
        by (auto simp:subtree_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3598
      thus ?thesis
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3599
      proof(cases rule:subtreeE)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3600
        case 1
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3601
        with assms(3) show ?thesis by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3602
      next
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3603
        case 2
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3604
        hence "(Th th2, Th th1) \<in> (RAG s)^+" by (auto simp:ancestors_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3605
        from tranclD[OF this]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3606
        obtain z where "(Th th2, z) \<in> RAG s" by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3607
        from this[unfolded s_RAG_def, folded wq_def]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3608
        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
  3609
          by (auto simp:s_waiting_abv)
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3610
        with assms(2) show False by (auto simp:readys_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3611
      qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3612
    qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3613
  } thus ?thesis by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3614
qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3615
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  3616
end
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  3617
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3618
section {* Relating @{term cp} and @{term the_preced} and @{term preced} *}
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3619
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
  3620
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
  3621
 @{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
  3622
 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
  3623
 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
  3624
 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
  3625
 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
  3626
 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
  3627
*}
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
  3628
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3629
context valid_trace
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3630
begin
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3631
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
  3632
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
  3633
  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
  3634
  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
  3635
  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
  3636
  @{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
  3637
*}
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3638
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3639
lemma le_cp:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3640
  shows "preced th s \<le> cp s th"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3641
  proof(unfold cp_alt_def, rule Max_ge)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3642
    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
  3643
      by (simp add: finite_subtree_threads)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3644
  next
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3645
    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
  3646
      by (simp add: subtree_def the_preced_def)   
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3647
  qed
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3648
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
  3649
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
  3650
  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
  3651
  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
  3652
  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
  3653
  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
  3654
*}
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
  3655
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3656
lemma cp_le:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3657
  assumes th_in: "th \<in> threads s"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3658
  shows "cp s th \<le> Max (the_preced s ` threads s)"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3659
proof(unfold cp_alt_def, rule Max_f_mono)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3660
  show "finite (threads s)" by (simp add: finite_threads) 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3661
next
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3662
  show " {th'. Th th' \<in> subtree (RAG s) (Th th)} \<noteq> {}"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3663
    using subtree_def by fastforce
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3664
next
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3665
  show "{th'. Th th' \<in> subtree (RAG s) (Th th)} \<subseteq> threads s"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3666
    using assms
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3667
    by (smt Domain.DomainI dm_RAG_threads mem_Collect_eq 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3668
        node.inject(1) rtranclD subsetI subtree_def trancl_domain) 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3669
qed
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3670
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
  3671
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
  3672
  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
  3673
  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
  3674
  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
  3675
  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
  3676
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
  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
  3678
  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
  3679
  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
  3680
  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
  3681
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
  3682
  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
  3683
  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
  3684
*}
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
  3685
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3686
lemma max_cp_eq: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3687
  shows "Max ((cp s) ` threads s) = Max (the_preced s ` threads s)"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3688
  (is "?L = ?R")
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3689
proof -
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3690
  have "?L \<le> ?R" 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3691
  proof(cases "threads s = {}")
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3692
    case False
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3693
    show ?thesis 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3694
      by (rule Max.boundedI, 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3695
          insert cp_le, 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3696
          auto simp:finite_threads False)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3697
  qed auto
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3698
  moreover have "?R \<le> ?L"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3699
    by (rule Max_fg_mono, 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3700
        simp add: finite_threads,
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3701
        simp add: le_cp the_preced_def)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3702
  ultimately show ?thesis by auto
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3703
qed
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3704
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3705
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
  3706
  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
  3707
  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
  3708
  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
  3709
  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
  3710
  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
  3711
  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
  3712
*}
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
  3713
141
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3714
lemma cp_alt_def3:
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3715
  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
  3716
unfolding cp_alt_def2
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3717
unfolding image_def
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3718
unfolding the_preced_def
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3719
by meson
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3720
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3721
lemma KK:
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3722
  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
  3723
(*  and "\<Union>" *)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3724
by (simp_all add: Setcompr_eq_image)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3725
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3726
lemma Max_Segments: 
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3727
  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
  3728
  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
  3729
using assms
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3730
apply(subst KK(1))
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3731
apply(subst Max_Union)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3732
apply(auto)[3]
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3733
apply(simp add: Setcompr_eq_image)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3734
apply(simp add: image_eq_UN)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3735
done 
140
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3736
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3737
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
  3738
  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
  3739
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
  3740
  case False
141
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3741
  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
  3742
    unfolding threads_alt_def1 by simp
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3743
  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
  3744
    apply(subst Max_Segments[symmetric])
142
10c16b85a839 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 141
diff changeset
  3745
    apply (simp add: finite_readys)
10c16b85a839 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 141
diff changeset
  3746
    apply (simp add: fsbttGs.finite_subtree)
10c16b85a839 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 141
diff changeset
  3747
    apply blast
10c16b85a839 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 141
diff changeset
  3748
    using False apply blast
141
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3749
    apply(rule arg_cong)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3750
    back
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3751
    apply(blast)
142
10c16b85a839 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 141
diff changeset
  3752
    done 
141
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3753
  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
  3754
    unfolding cp_alt_def3 ..
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3755
  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
  3756
   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
  3757
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
  3758
140
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3759
141
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3760
lemma LL:
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3761
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
  3762
using the_preced_def by auto
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3763
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3764
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
  3765
text {*
140
389ef8b1959c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 138
diff changeset
  3766
  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
  3767
  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
  3768
*}
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
  3769
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
  3770
  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
  3771
    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
  3772
    apply(simp add: max_cp_eq)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3773
    apply(simp add: LL)
f70344294e99 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 140
diff changeset
  3774
    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
  3775
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3776
end
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3777
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
  3778
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3779
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
  3780
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
  3781
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
  3782
  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
  3783
  @{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
  3784
  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
  3785
  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
  3786
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
  3787
  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
  3788
  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
  3789
  @{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
  3790
  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
  3791
  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
  3792
  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
  3793
  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
  3794
  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
  3795
  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
  3796
*}
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
  3797
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3798
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
  3799
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
  3800
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3801
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
  3802
  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
  3803
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3804
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
  3805
  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
  3806
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3807
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
  3808
  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
  3809
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
  3810
  { 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
  3811
    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
  3812
    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
  3813
    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
  3814
    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
  3815
      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
  3816
      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
  3817
      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
  3818
      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
  3819
        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
  3820
    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
  3821
      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
  3822
      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
  3823
      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
  3824
      show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  3825
       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
  3826
    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
  3827
    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
  3828
  } 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
  3829
    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
  3830
    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
  3831
    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
  3832
    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
  3833
    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
  3834
      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
  3835
      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
  3836
      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
  3837
      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
  3838
        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
  3839
    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
  3840
      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
  3841
      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
  3842
      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
  3843
      show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  3844
       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
  3845
    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
  3846
    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
  3847
  } 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
  3848
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
  3849
4763aa246dbd Original files overwrite by 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
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
  3851
 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
  3852
4763aa246dbd Original files overwrite by 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
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
  3854
  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
  3855
  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
  3856
  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
  3857
4763aa246dbd Original files overwrite by 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
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
  3859
  
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3860
lemma (in valid_trace) finite_holdents: "finite (holdents s th)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3861
  by (unfold holdents_alt_def, insert fsbtRAGs.finite_children, auto)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3862
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3863
context valid_trace_p 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3864
begin
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3865
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3866
lemma live_th_es: "th \<in> threads (e#s)"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3867
  using live_th_s 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3868
  by (unfold is_p, simp)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3869
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3870
lemma waiting_neq_th: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3871
  assumes "waiting s t c"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3872
  shows "t \<noteq> th"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3873
  using assms using th_not_waiting by blast 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3874
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3875
end
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3876
92
4763aa246dbd Original files overwrite by 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
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
  3878
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
  3879
4763aa246dbd Original files overwrite by 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
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
  3881
  "\<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
  3882
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
  3883
  case True
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3884
  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
  3885
    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
  3886
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
  3887
  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
  3888
  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
  3889
  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
  3890
    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
  3891
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
  3892
4763aa246dbd Original files overwrite by 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
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
  3894
  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
  3895
  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
  3896
  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
  3897
4763aa246dbd Original files overwrite by 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
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
  3899
  "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
  3900
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
  3901
  { 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
  3902
    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
  3903
    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
  3904
      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
  3905
    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
  3906
     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
  3907
  } 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
  3908
    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
  3909
    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
  3910
    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
  3911
      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
  3912
    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
  3913
    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
  3914
      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
  3915
      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
  3916
      show ?thesis by (auto simp:holdents_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3917
    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
  3918
      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
  3919
      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
  3920
        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
  3921
    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
  3922
  } 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
  3923
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
  3924
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3925
lemma not_holding_s_th_cs: "\<not> holding s th cs"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3926
proof
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3927
  assume otherwise: "holding s th cs"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3928
  from pip_e[unfolded is_p]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3929
  show False
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3930
  proof(cases)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3931
    case (thread_P)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3932
    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
  3933
      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
  3934
      using s_holding_def wq_def by auto
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3935
    ultimately show ?thesis by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3936
  qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3937
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3938
92
4763aa246dbd Original files overwrite by 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
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
  3940
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
  3941
  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
  3942
  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
  3943
    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
  3944
      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
  3945
  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
  3946
  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
  3947
   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
  3948
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
  3949
4763aa246dbd Original files overwrite by 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
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
  3951
  "\<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
  3952
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
  3953
  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
  3954
  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
  3955
  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
  3956
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
  3957
4763aa246dbd Original files overwrite by 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
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
  3959
  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
  3960
  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
  3961
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
  3962
  { 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
  3963
    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
  3964
    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
  3965
    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
  3966
    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
  3967
      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
  3968
      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
  3969
      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
  3970
      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
  3971
    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
  3972
    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
  3973
    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
  3974
    hence "cs' \<in> ?R" 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  3975
      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
  3976
  } 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
  3977
    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
  3978
    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
  3979
    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
  3980
    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
  3981
    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
  3982
    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
  3983
      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
  3984
  } 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
  3985
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
  3986
4763aa246dbd Original files overwrite by 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
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
  3988
  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
  3989
  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
  3990
  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
  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
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
  3993
4763aa246dbd Original files overwrite by 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
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
  3995
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
  3996
4763aa246dbd Original files overwrite by 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
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
  3998
  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
  3999
  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
  4000
  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
  4001
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
  4002
  { 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
  4003
    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
  4004
    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
  4005
        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
  4006
    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
  4007
    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
  4008
      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
  4009
      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
  4010
      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
  4011
        by (unfold s_waiting_def, fold wq_def, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4012
    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
  4013
      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
  4014
      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
  4015
      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
  4016
        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
  4017
        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
  4018
          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
  4019
        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
  4020
      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
  4021
        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
  4022
        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
  4023
        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
  4024
      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
  4025
    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
  4026
  } 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
  4027
    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
  4028
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
  4029
4763aa246dbd Original files overwrite by 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
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
  4031
  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
  4032
  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
  4033
  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
  4034
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
  4035
  { 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
  4036
    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
  4037
    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
  4038
        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
  4039
    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
  4040
    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
  4041
      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
  4042
      with n_wait wait
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4043
      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
  4044
        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
  4045
    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
  4046
      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
  4047
      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
  4048
      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
  4049
        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
  4050
        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
  4051
          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
  4052
        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
  4053
      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
  4054
        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
  4055
        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
  4056
        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
  4057
      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
  4058
    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
  4059
  } 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
  4060
    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
  4061
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
  4062
4763aa246dbd Original files overwrite by 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
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
  4064
  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
  4065
  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
  4066
  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
  4067
  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
  4068
4763aa246dbd Original files overwrite by 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
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
  4070
  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
  4071
  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
  4072
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
  4073
  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
  4074
  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
  4075
  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
  4076
  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
  4077
    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
  4078
    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
  4079
    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
  4080
      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
  4081
  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
  4082
    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
  4083
    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
  4084
    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
  4085
      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
  4086
            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
  4087
      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
  4088
      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
  4089
  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
  4090
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
  4091
  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
  4092
  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
  4093
  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
  4094
  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
  4095
    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
  4096
    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
  4097
    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
  4098
      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
  4099
  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
  4100
    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
  4101
    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
  4102
    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
  4103
      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
  4104
  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
  4105
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
  4106
4763aa246dbd Original files overwrite by 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
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
  4108
4763aa246dbd Original files overwrite by 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
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  4110
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
  4111
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
  4112
4763aa246dbd Original files overwrite by 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
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
  4114
  "holding s th cs" 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4115
 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
  4116
4763aa246dbd Original files overwrite by 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
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
  4118
  using running_th_s
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4119
  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
  4120
4763aa246dbd Original files overwrite by 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
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
  4122
  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
  4123
4763aa246dbd Original files overwrite by 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
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
  4125
  using running_th_s neq_t_th
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4126
  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
  4127
4763aa246dbd Original files overwrite by 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
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
  4129
  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
  4130
4763aa246dbd Original files overwrite by 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
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
  4132
  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
  4133
4763aa246dbd Original files overwrite by 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
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
  4135
  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
  4136
4763aa246dbd Original files overwrite by 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
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
  4138
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
  4139
  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
  4140
    by (unfold holdents_def, simp)
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4141
  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
  4142
    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
  4143
  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
  4144
    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
  4145
        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
  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
4763aa246dbd Original files overwrite by 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
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
  4149
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4150
context valid_trace_v
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4151
begin
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4152
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4153
lemma th_not_waiting: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4154
  "\<not> waiting s th c"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4155
proof -
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4156
  have "th \<in> readys s"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4157
    using running_ready running_th_s by blast 
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4158
  thus ?thesis
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4159
    by (unfold readys_def, auto)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4160
qed
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4161
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4162
lemma waiting_neq_th: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4163
  assumes "waiting s t c"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4164
  shows "t \<noteq> th"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4165
  using assms using th_not_waiting by blast 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4166
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4167
end
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4168
92
4763aa246dbd Original files overwrite by 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
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
  4170
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
  4171
4763aa246dbd Original files overwrite by 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
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
  4173
  "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
  4174
  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
  4175
  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
  4176
4763aa246dbd Original files overwrite by 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
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
  4178
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
  4179
  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
  4180
  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
  4181
  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
  4182
  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
  4183
  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
  4184
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
  4185
4763aa246dbd Original files overwrite by 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
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
  4187
  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
  4188
4763aa246dbd Original files overwrite by 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
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
  4190
  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
  4191
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
  4192
  { 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
  4193
    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
  4194
    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
  4195
    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
  4196
      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
  4197
      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
  4198
    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
  4199
  } 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
  4200
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
  4201
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4202
lemma neq_taker_th: "taker \<noteq> th"
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4203
  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
  4204
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4205
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
  4206
  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
  4207
  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
  4208
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4209
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
  4210
  "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
  4211
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
  4212
  { 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
  4213
    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
  4214
    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
  4215
    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
  4216
    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
  4217
      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
  4218
      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
  4219
    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
  4220
  } 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
  4221
    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
  4222
    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
  4223
    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
  4224
    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
  4225
    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
  4226
      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
  4227
      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
  4228
          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
  4229
      thus ?thesis by (auto simp:holdents_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4230
    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
  4231
      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
  4232
      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
  4233
      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
  4234
    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
  4235
  } 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
  4236
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
  4237
4763aa246dbd Original files overwrite by 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
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
  4239
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
  4240
  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
  4241
  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
  4242
    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
  4243
      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
  4244
  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
  4245
  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
  4246
    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
  4247
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
  4248
4763aa246dbd Original files overwrite by 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
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
  4250
  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
  4251
4763aa246dbd Original files overwrite by 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
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
  4253
  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
  4254
4763aa246dbd Original files overwrite by 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
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
  4256
  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
  4257
4763aa246dbd Original files overwrite by 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
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
  4259
  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
  4260
4763aa246dbd Original files overwrite by 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
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
  4262
  "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
  4263
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
  4264
  { 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
  4265
    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
  4266
    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
  4267
    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
  4268
    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
  4269
      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
  4270
      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
  4271
    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
  4272
  } 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
  4273
    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
  4274
    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
  4275
    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
  4276
    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
  4277
    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
  4278
  } 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
  4279
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
  4280
4763aa246dbd Original files overwrite by 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
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
  4282
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
  4283
  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
  4284
  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
  4285
    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
  4286
      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
  4287
    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
  4288
        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
  4289
    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
  4290
  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
  4291
  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
  4292
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
  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 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
  4295
  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
  4296
  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
  4297
  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
  4298
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
  4299
  { 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
  4300
    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
  4301
    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
  4302
    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
  4303
      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
  4304
      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
  4305
      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
  4306
      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
  4307
      show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4308
        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
  4309
    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
  4310
      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
  4311
      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
  4312
      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
  4313
      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
  4314
      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
  4315
      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
  4316
    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
  4317
  } 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
  4318
    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
  4319
    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
  4320
    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
  4321
    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
  4322
      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
  4323
      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
  4324
      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
  4325
      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
  4326
      show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4327
        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
  4328
    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
  4329
      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
  4330
      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
  4331
      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
  4332
      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
  4333
      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
  4334
      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
  4335
    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
  4336
  } 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
  4337
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
  4338
4763aa246dbd Original files overwrite by 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
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
  4340
  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
  4341
  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
  4342
  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
  4343
  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
  4344
4763aa246dbd Original files overwrite by 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
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
  4346
  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
  4347
  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
  4348
  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
  4349
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
  4350
  { 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
  4351
    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
  4352
    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
  4353
        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
  4354
    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
  4355
    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
  4356
      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
  4357
      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
  4358
      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
  4359
        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
  4360
    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
  4361
      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
  4362
      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
  4363
        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
  4364
      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
  4365
        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
  4366
                    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
  4367
      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
  4368
      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
  4369
      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
  4370
    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
  4371
  } 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
  4372
    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
  4373
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
  4374
4763aa246dbd Original files overwrite by 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
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
  4376
  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
  4377
  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
  4378
  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
  4379
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
  4380
  { 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
  4381
    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
  4382
    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
  4383
        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
  4384
    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
  4385
    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
  4386
      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
  4387
      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
  4388
      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
  4389
        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
  4390
    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
  4391
      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
  4392
      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
  4393
          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
  4394
                    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
  4395
      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
  4396
          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
  4397
      ultimately have "th' = taker" using th_not_in_rest by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  4398
      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
  4399
      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
  4400
      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
  4401
    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
  4402
  } 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
  4403
    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
  4404
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
  4405
4763aa246dbd Original files overwrite by 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
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
  4407
  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
  4408
  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
  4409
  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
  4410
  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
  4411
4763aa246dbd Original files overwrite by 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
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
  4413
  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
  4414
  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
  4415
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
  4416
  { 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
  4417
    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
  4418
      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
  4419
      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
  4420
  } 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
  4421
    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
  4422
    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
  4423
      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
  4424
      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
  4425
  } 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
  4426
    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
  4427
    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
  4428
      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
  4429
      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
  4430
  } 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
  4431
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
  4432
4763aa246dbd Original files overwrite by 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
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
  4434
4763aa246dbd Original files overwrite by 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
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
  4436
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
  4437
4763aa246dbd Original files overwrite by 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
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
  4439
  "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
  4440
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
  4441
  { 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
  4442
    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
  4443
    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
  4444
    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
  4445
    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
  4446
      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
  4447
      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
  4448
    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
  4449
  } 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
  4450
    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
  4451
    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
  4452
    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
  4453
    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
  4454
    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
  4455
  } 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
  4456
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
  4457
4763aa246dbd Original files overwrite by 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
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
  4459
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
  4460
  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
  4461
  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
  4462
    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
  4463
      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
  4464
    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
  4465
        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
  4466
    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
  4467
  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
  4468
  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
  4469
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
  4470
4763aa246dbd Original files overwrite by 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
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
  4472
  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
  4473
  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
  4474
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
  4475
  { 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
  4476
    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
  4477
    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
  4478
    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
  4479
      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
  4480
      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
  4481
      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
  4482
      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
  4483
      show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4484
        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
  4485
    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
  4486
      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
  4487
      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
  4488
      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
  4489
      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
  4490
            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
  4491
      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
  4492
    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
  4493
  } 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
  4494
    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
  4495
    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
  4496
    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
  4497
    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
  4498
      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
  4499
      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
  4500
      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
  4501
      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
  4502
      show ?thesis
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4503
        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
  4504
    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
  4505
      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
  4506
      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
  4507
      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
  4508
      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
  4509
      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
  4510
      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
  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
  } 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
  4513
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
  4514
4763aa246dbd Original files overwrite by 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
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
  4516
  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
  4517
  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
  4518
  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
  4519
4763aa246dbd Original files overwrite by 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
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
  4521
  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
  4522
  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
  4523
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
  4524
  { 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
  4525
    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
  4526
    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
  4527
        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
  4528
    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
  4529
    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
  4530
      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
  4531
      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
  4532
      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
  4533
        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
  4534
    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
  4535
      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
  4536
      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
  4537
        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
  4538
      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
  4539
      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
  4540
      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
  4541
    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
  4542
  } 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
  4543
    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
  4544
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
  4545
4763aa246dbd Original files overwrite by 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
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
  4547
  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
  4548
  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
  4549
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
  4550
  { 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
  4551
    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
  4552
    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
  4553
        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
  4554
    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
  4555
    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
  4556
      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
  4557
      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
  4558
      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
  4559
        by (unfold s_waiting_def, fold wq_def, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4560
    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
  4561
      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
  4562
      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
  4563
        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
  4564
              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
  4565
      thus ?thesis by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4566
    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
  4567
  } 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
  4568
    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
  4569
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
  4570
4763aa246dbd Original files overwrite by 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
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
  4572
  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
  4573
  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
  4574
  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
  4575
4763aa246dbd Original files overwrite by 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
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
  4577
  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
  4578
  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
  4579
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
  4580
  {
4763aa246dbd Original files overwrite by 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
    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
  4582
    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
  4583
      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
  4584
      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
  4585
  } 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
  4586
    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
  4587
    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
  4588
      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
  4589
      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
  4590
  } 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
  4591
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
  4592
4763aa246dbd Original files overwrite by 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
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
  4594
4763aa246dbd Original files overwrite by 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
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
  4596
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
  4597
4763aa246dbd Original files overwrite by 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
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
  4599
  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
  4600
  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
  4601
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
  4602
  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
  4603
  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
  4604
  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
  4605
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
  4606
  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
  4607
  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
  4608
  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
  4609
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
  4610
4763aa246dbd Original files overwrite by 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
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
  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
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
  4614
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
  4615
4763aa246dbd Original files overwrite by 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
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
  4617
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
  4618
  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
  4619
  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
  4620
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
  4621
4763aa246dbd Original files overwrite by 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
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
  4623
  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
  4624
4763aa246dbd Original files overwrite by 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
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
  4626
  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
  4627
4763aa246dbd Original files overwrite by 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
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
  4629
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
  4630
  assume "waiting s th cs'"
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4631
  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
  4632
  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
  4633
  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
  4634
  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
  4635
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
  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
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
  4638
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
  4639
  assume "holding s th cs'"
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4640
  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
  4641
  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
  4642
  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
  4643
  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
  4644
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
  4645
4763aa246dbd Original files overwrite by 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
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
  4647
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
  4648
  assume "waiting (e # s) th cs'"
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4649
  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
  4650
  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
  4651
  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
  4652
  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
  4653
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
  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
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
  4656
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
  4657
  assume "holding (e # s) th cs'"
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4658
  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
  4659
  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
  4660
  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
  4661
  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
  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 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
  4665
  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
  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 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
  4668
  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
  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 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
  4671
  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
  4672
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4673
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
  4674
  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
  4675
4763aa246dbd Original files overwrite by 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
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
  4677
  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
  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 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
  4680
  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
  4681
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4682
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
  4683
  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
  4684
4763aa246dbd Original files overwrite by 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
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
  4686
  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
  4687
  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
  4688
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
  4689
  { 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
  4690
    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
  4691
    hence "cs' \<in> ?R"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4692
      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
  4693
  } 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
  4694
    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
  4695
    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
  4696
    hence "cs' \<in> ?L"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4697
      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
  4698
  } 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
  4699
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
  4700
4763aa246dbd Original files overwrite by 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
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
  4702
  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
  4703
  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
  4704
  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
  4705
  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
  4706
4763aa246dbd Original files overwrite by 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
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
  4708
  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
  4709
  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
  4710
  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
  4711
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
  4712
  { 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
  4713
    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
  4714
    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
  4715
      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
  4716
    from wait[unfolded s_waiting_def, folded wq_def]
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4717
         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
  4718
    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
  4719
  } 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
  4720
    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
  4721
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
  4722
4763aa246dbd Original files overwrite by 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
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
  4724
  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
  4725
  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
  4726
  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
  4727
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
  4728
  { 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
  4729
    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
  4730
    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
  4731
      using assms(2) by (auto simp:readys_def)
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4732
    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
  4733
         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
  4734
    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
  4735
  } 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
  4736
    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
  4737
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
  4738
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4739
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
  4740
  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
  4741
  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
  4742
  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
  4743
  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
  4744
4763aa246dbd Original files overwrite by 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
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
  4746
  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
  4747
  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
  4748
  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
  4749
  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
  4750
4763aa246dbd Original files overwrite by 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
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
  4752
  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
  4753
  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
  4754
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
  4755
  {
4763aa246dbd Original files overwrite by 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
    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
  4757
    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
  4758
      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
  4759
  } 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
  4760
    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
  4761
    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
  4762
      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
  4763
  } 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
  4764
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
  4765
4763aa246dbd Original files overwrite by 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
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
  4767
4763aa246dbd Original files overwrite by 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
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
  4769
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
  4770
4763aa246dbd Original files overwrite by 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
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
  4772
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
  4773
  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
  4774
  show ?thesis
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4775
  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
  4776
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
  4777
4763aa246dbd Original files overwrite by 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
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
  4779
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
  4780
  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
  4781
  show ?thesis
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4782
  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
  4783
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
  4784
4763aa246dbd Original files overwrite by 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
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
  4786
  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
  4787
4763aa246dbd Original files overwrite by 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
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
  4789
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
  4790
  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
  4791
  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
  4792
   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
  4793
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
  4794
4763aa246dbd Original files overwrite by 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
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
  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
  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
  4798
  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
  4799
   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
  4800
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
  4801
4763aa246dbd Original files overwrite by 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
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
  4803
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
  4804
  assume "holding (e # s) th cs'"
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4805
  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
  4806
  have "holding s th cs'" 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4807
    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
  4808
  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
  4809
  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
  4810
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
  4811
4763aa246dbd Original files overwrite by 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
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
  4813
  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
  4814
4763aa246dbd Original files overwrite by 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
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
  4816
  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
  4817
4763aa246dbd Original files overwrite by 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
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
  4819
  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
  4820
4763aa246dbd Original files overwrite by 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
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
  4822
  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
  4823
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4824
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
  4825
  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
  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 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
  4828
  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
  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 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
  4831
  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
  4832
  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
  4833
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
  4834
  { 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
  4835
    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
  4836
    hence "cs' \<in> ?R"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4837
      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
  4838
  } 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
  4839
    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
  4840
    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
  4841
    hence "cs' \<in> ?L"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4842
      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
  4843
  } 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
  4844
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
  4845
4763aa246dbd Original files overwrite by 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
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
  4847
  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
  4848
  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
  4849
  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
  4850
  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
  4851
4763aa246dbd Original files overwrite by 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
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
  4853
  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
  4854
  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
  4855
  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
  4856
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
  4857
  { 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
  4858
    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
  4859
    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
  4860
      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
  4861
    from wait[unfolded s_waiting_def, folded wq_def]
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4862
         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
  4863
    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
  4864
  } 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
  4865
    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
  4866
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
  4867
4763aa246dbd Original files overwrite by 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
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
  4869
  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
  4870
  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
  4871
  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
  4872
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
  4873
  { 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
  4874
    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
  4875
    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
  4876
      using assms(2) by (auto simp:readys_def)
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4877
    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
  4878
         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
  4879
    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
  4880
  } 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
  4881
    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
  4882
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
  4883
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4884
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
  4885
  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
  4886
  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
  4887
  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
  4888
  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
  4889
4763aa246dbd Original files overwrite by 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
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
  4891
  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
  4892
  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
  4893
  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
  4894
  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
  4895
4763aa246dbd Original files overwrite by 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
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
  4897
  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
  4898
  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
  4899
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
  4900
  {
4763aa246dbd Original files overwrite by 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
    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
  4902
    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
  4903
      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
  4904
  } 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
  4905
    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
  4906
    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
  4907
      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
  4908
  } 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
  4909
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
  4910
4763aa246dbd Original files overwrite by 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
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
  4912
4763aa246dbd Original files overwrite by 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
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
  4914
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
  4915
4763aa246dbd Original files overwrite by 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
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
  4917
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
  4918
  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
  4919
  show ?thesis
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4920
  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
  4921
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
  4922
4763aa246dbd Original files overwrite by 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
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
  4924
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
  4925
  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
  4926
  show ?thesis
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4927
  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
  4928
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
  4929
4763aa246dbd Original files overwrite by 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
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
  4931
  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
  4932
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4935
  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
  4936
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
  4937
  { 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
  4938
    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
  4939
    hence "cs' \<in> ?R"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4940
      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
  4941
  } 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
  4942
    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
  4943
    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
  4944
    hence "cs' \<in> ?L"
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  4945
      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
  4946
  } 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
  4947
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
  4948
4763aa246dbd Original files overwrite by 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
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
  4950
  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
  4951
  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
  4952
  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
  4953
4763aa246dbd Original files overwrite by 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
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
  4955
  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
  4956
  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
  4957
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
  4958
  { 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
  4959
    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
  4960
    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
  4961
      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
  4962
    from wait[unfolded s_waiting_def, folded wq_def]
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4963
         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
  4964
    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
  4965
  } 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
  4966
    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
  4967
  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
  4968
    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
  4969
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
  4970
4763aa246dbd Original files overwrite by 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
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
  4972
  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
  4973
  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
  4974
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
  4975
  { 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
  4976
    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
  4977
    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
  4978
      using assms by (auto simp:readys_def)
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4979
    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
  4980
         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
  4981
    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
  4982
  } 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
  4983
    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
  4984
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
  4985
4763aa246dbd Original files overwrite by 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
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
  4987
  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
  4988
  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
  4989
  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
  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 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
  4992
  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
  4993
  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
  4994
4763aa246dbd Original files overwrite by 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
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
  4996
  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
  4997
  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
  4998
  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
  4999
  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
  5000
4763aa246dbd Original files overwrite by 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
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
  5002
4763aa246dbd Original files overwrite by 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
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
  5004
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
  5005
4763aa246dbd Original files overwrite by 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
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
  5007
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
  5008
  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
  5009
  thus ?case 
130
0f124691c191 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 129
diff changeset
  5010
    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
  5011
    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
  5012
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
  5013
  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
  5014
  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
  5015
  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
  5016
  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
  5017
    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
  5018
    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
  5019
      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
  5020
    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
  5021
  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
  5022
    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
  5023
    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
  5024
        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
  5025
   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
  5026
  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
  5027
    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
  5028
    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
  5029
    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
  5030
  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
  5031
    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
  5032
    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
  5033
    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
  5034
  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
  5035
    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
  5036
    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
  5037
        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
  5038
    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
  5039
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5040
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5041
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  5042
end
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  5043
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  5044
section {* Corollaries of @{thm valid_trace.cnp_cnv_cncs} *}
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  5045
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  5046
context valid_trace
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  5047
begin
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  5048
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
  5049
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
  5050
  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
  5051
  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
  5052
*}
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5053
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
  5054
  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
  5055
  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
  5056
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
  5057
  { 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
  5058
    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
  5059
    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
  5060
    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
  5061
    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
  5062
    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
  5063
    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
  5064
    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
  5065
  } 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
  5066
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
  5067
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5068
lemma not_thread_cncs:
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5069
  assumes not_in: "th \<notin> threads s" 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5070
  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
  5071
  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
  5072
  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
  5073
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
  5074
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
  5075
  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
  5076
  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
  5077
  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
  5078
  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
  5079
  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
  5080
*}
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
  5081
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5082
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
  5083
  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
  5084
  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
  5085
  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
  5086
  by (auto)
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5087
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5088
lemma eq_pv_children:
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5089
  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
  5090
  shows "children (RAG s) (Th th) = {}"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5091
proof -
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5092
    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
  5093
    have "cntCS s th = 0" 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5094
      by (auto split:if_splits)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5095
    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
  5096
    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
  5097
    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
  5098
      by (simp add: fsbtRAGs.finite_children)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5099
    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
  5100
    show ?thesis by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5101
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5102
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5103
lemma eq_pv_holdents:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5104
  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
  5105
  shows "holdents s th = {}"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5106
  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
  5107
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5108
lemma eq_pv_subtree:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5109
  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
  5110
  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
  5111
  using eq_pv_children[OF assms]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5112
    by (unfold subtree_children, simp)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5113
92
4763aa246dbd Original files overwrite by 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
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
  5115
  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
  5116
  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
  5117
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
  5118
    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
  5119
    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
  5120
    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
  5121
    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
  5122
      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
  5123
    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
  5124
    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
  5125
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
  5126
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
  5127
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
  5128
  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
  5129
  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
  5130
  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
  5131
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5132
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5133
lemma count_eq_tRAG_plus:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5134
  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
  5135
  shows "{th'. (Th th', Th th) \<in> (tRAG s)^+} = {}"
179
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  5136
  using count_eq_RAG_plus_Th[OF assms]
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  5137
  using tRAG_trancl_eq by auto
f9e6c4166476 updated
Christian Urban <urbanc@in.tum.de>
parents: 178
diff changeset
  5138
  
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5139
lemma count_eq_tRAG_plus_Th:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  5140
  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
  5141
  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
  5142
   using count_eq_tRAG_plus[OF assms] by auto
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5143
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5144
end
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5145
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
  5146
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
  5147
  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
  5148
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5149
definition detached :: "state \<Rightarrow> thread \<Rightarrow> bool"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5150
  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
  5151
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
  5152
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
  5153
  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
  5154
  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
  5155
*}
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
  5156
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5157
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
  5158
  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
  5159
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
  5160
apply(simp add: s_RAG_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5161
apply(simp add: s_holding_abv s_waiting_abv)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5162
apply(simp add: Domain_iff Range_iff)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5163
apply(simp add: wq_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5164
apply(auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5165
done
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5166
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5167
lemma detached_cp_the_preced:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5168
  assumes "detached s th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5169
  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
  5170
proof -
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5171
  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
  5172
      by (unfold cp_alt_def, simp)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5173
  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
  5174
  proof -
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5175
    { fix n
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5176
      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
  5177
      hence "n = Th th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5178
      proof(cases rule:subtreeE)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5179
        case 2
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5180
        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
  5181
          by (elim ancestors_Field, simp)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5182
        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
  5183
        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
  5184
        thus ?thesis by simp
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5185
      qed simp
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5186
    } thus ?thesis by auto
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5187
  qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5188
  ultimately show ?thesis by auto
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5189
qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5190
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5191
lemma detached_cp_preced:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5192
  assumes "detached s th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5193
  shows "cp s th = preced th s" 
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5194
  using detached_cp_the_preced[OF assms] 
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5195
  by (simp add:the_preced_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5196
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5197
context valid_trace
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5198
begin
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5199
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5200
lemma detached_intro:
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  5201
  assumes eq_pv: "cntP s th = cntV s th"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5202
  shows "detached s th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  5203
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
  5204
  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
  5205
  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
  5206
  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
  5207
  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
  5208
    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
  5209
    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
  5210
    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
  5211
      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
  5212
              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
  5213
  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
  5214
    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
  5215
    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
  5216
    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
  5217
      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
  5218
      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
  5219
      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
  5220
      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
  5221
    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
  5222
    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
  5223
      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
  5224
              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
  5225
  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
  5226
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
  5227
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  5228
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
  5229
  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
  5230
  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
  5231
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
  5232
  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
  5233
  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
  5234
    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
  5235
      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
  5236
      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
  5237
    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
  5238
  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
  5239
  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
  5240
  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
  5241
    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
  5242
    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
  5243
    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
  5244
      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
  5245
           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
  5246
    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
  5247
  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
  5248
    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
  5249
    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
  5250
  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
  5251
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
  5252
4763aa246dbd Original files overwrite by 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
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
  5254
  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
  5255
  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
  5256
4763aa246dbd Original files overwrite by 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
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
  5258
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5259
section {* Recursive calculation of @{term "cp"} *}
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5260
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5261
text {*
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5262
  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
  5263
  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
  5264
  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
  5265
  a @{term cp}-value, one needs to traverse a whole subtree. 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5266
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5267
  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
  5268
  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
  5269
  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
  5270
  the @{term cp}-values of its children in @{term RAG}. 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5271
  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
  5272
  changed by an execution step, there is no need to recalculate. This
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5273
  is particularly useful to in Implementation.thy to speed up the 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5274
  recalculation of @{term cp}-values. 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5275
*}
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5276
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5277
text {*
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5278
  The following function @{text "cp_gen"} is a generalization 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5279
  of @{term cp}. Unlike @{term cp} which returns a precedence 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5280
  for a thread, @{text "cp_gen"} returns precedence for a node
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5281
  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
  5282
  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
  5283
  and this is the only meaningful use of @{text cp_gen}. 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5284
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5285
  The introduction of @{text cp_gen} is purely technical to easy some
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5286
  of the proofs leading to the finally lemma @{text cp_rec}.
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5287
*}
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5288
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5289
definition "cp_gen s x =
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5290
                  Max ((the_preced s \<circ> the_thread) ` subtree (tRAG s) x)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5291
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5292
lemma cp_gen_alt_def:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5293
  "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
  5294
    by (auto simp:cp_gen_def)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5295
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5296
lemma cp_gen_def_cond: 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5297
  assumes "x = Th th"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5298
  shows "cp s th = cp_gen s (Th th)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5299
by (unfold cp_alt_def1 cp_gen_def, simp)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5300
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5301
lemma cp_gen_over_set:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5302
  assumes "\<forall> x \<in> A. \<exists> th. x = Th th"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5303
  shows "cp_gen s ` A = (cp s \<circ> the_thread) ` A"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5304
proof(rule f_image_eq)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5305
  fix a
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5306
  assume "a \<in> A"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5307
  from assms[rule_format, OF this]
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5308
  obtain th where eq_a: "a = Th th" by auto
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5309
  show "cp_gen s a = (cp s \<circ> the_thread) a"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5310
    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
  5311
qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5312
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 77
diff changeset
  5313
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 101
diff changeset
  5314
context valid_trace
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 101
diff changeset
  5315
begin
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5316
(* ddd *)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5317
lemma cp_gen_rec:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5318
  assumes "x = Th th"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5319
  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
  5320
proof(cases "children (tRAG s) x = {}")
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5321
  case True
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5322
  show ?thesis
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5323
    by (unfold True cp_gen_def subtree_children, simp add:assms)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5324
next
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5325
  case False
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5326
  hence [simp]: "children (tRAG s) x \<noteq> {}" by auto
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5327
  note fsbttRAGs.finite_subtree[simp]
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5328
  have [simp]: "finite (children (tRAG s) x)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5329
     by (intro rev_finite_subset[OF fsbttRAGs.finite_subtree], 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5330
            rule children_subtree)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5331
  { fix r x
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5332
    have "subtree r x \<noteq> {}" by (auto simp:subtree_def)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5333
  } note this[simp]
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5334
  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
  5335
  proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5336
    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
  5337
    moreover have "subtree (tRAG s) q \<noteq> {}" by simp
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5338
    ultimately show ?thesis by blast
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5339
  qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5340
  have h: "Max ((the_preced s \<circ> the_thread) `
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5341
                ({x} \<union> \<Union>(subtree (tRAG s) ` children (tRAG s) x))) =
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5342
        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
  5343
                     (is "?L = ?R")
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5344
  proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5345
    let "Max (?f ` (?A \<union> \<Union> (?g ` ?B)))" = ?L
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5346
    let "Max (_ \<union> (?h ` ?B))" = ?R
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5347
    let ?L1 = "?f ` \<Union>(?g ` ?B)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5348
    have eq_Max_L1: "Max ?L1 = Max (?h ` ?B)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5349
    proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5350
      have "?L1 = ?f ` (\<Union> x \<in> ?B.(?g x))" by simp
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5351
      also have "... =  (\<Union> x \<in> ?B. ?f ` (?g x))" by auto
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5352
      finally have "Max ?L1 = Max ..." by simp
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5353
      also have "... = Max (Max ` (\<lambda>x. ?f ` subtree (tRAG s) x) ` ?B)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5354
        by (subst Max_UNION, simp+)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5355
      also have "... = Max (cp_gen s ` children (tRAG s) x)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5356
          by (unfold image_comp cp_gen_alt_def, simp)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5357
      finally show ?thesis .
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5358
    qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5359
    show ?thesis
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5360
    proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5361
      have "?L = Max (?f ` ?A \<union> ?L1)" by simp
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5362
      also have "... = max (the_preced s (the_thread x)) (Max ?L1)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5363
            by (subst Max_Un, simp+)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5364
      also have "... = max (?f x) (Max (?h ` ?B))"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5365
        by (unfold eq_Max_L1, simp)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5366
      also have "... =?R"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5367
        by (rule max_Max_eq, (simp)+, unfold assms, simp)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5368
      finally show ?thesis .
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5369
    qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5370
  qed  thus ?thesis 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5371
          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
  5372
qed
65
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5373
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5374
lemma cp_rec:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5375
  "cp s th = Max ({the_preced s th} \<union> 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5376
                     (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
  5377
proof -
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5378
  have "Th th = Th th" by simp
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5379
  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
  5380
  show ?thesis 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5381
  proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5382
    have "cp_gen s ` children (tRAG s) (Th th) = 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5383
                (cp s \<circ> the_thread) ` children (tRAG s) (Th th)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5384
    proof(rule cp_gen_over_set)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5385
      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
  5386
        by (unfold tRAG_alt_def, auto simp:children_def)
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
    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
  5389
  qed
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5390
qed
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5391
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5392
end
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5393
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5394
lemma PIP_actorE:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5395
  assumes "PIP s e"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5396
  and "actor e = th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5397
  and "\<not> isCreate e"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  5398
  shows "th \<in> running s"
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5399
  using assms
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5400
  by (cases, auto)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5401
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5402
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5403
lemma holdents_RAG:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5404
  assumes "holdents s th = {}"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5405
  shows "Th th \<notin> Range (RAG s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5406
proof
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5407
  assume "Th th \<in> Range (RAG s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5408
  thus False
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5409
  proof(rule RangeE)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5410
    fix a
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5411
    assume "(a, Th th) \<in> RAG s"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5412
    with assms[unfolded holdents_test]
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5413
    show False
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  5414
    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
  5415
  qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5416
qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5417
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5418
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5419
lemma readys_RAG:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5420
  assumes "th \<in> readys s"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5421
  shows "Th th \<notin> Domain (RAG s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5422
proof
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5423
  assume "Th th \<in> Domain (RAG s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5424
  thus False
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5425
  proof(rule DomainE)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5426
    fix b
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5427
    assume "(Th th, b) \<in> RAG s"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5428
    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
  5429
    show False
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  5430
      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
  5431
  qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5432
qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5433
178
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5434
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5435
text {*
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5436
  The following two lemmas are general about any valid system state, 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5437
  but are used in the derivation in more specific system operations. 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5438
*}
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5439
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5440
lemma readys_root:
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5441
  assumes "th \<in> readys s"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5442
  shows "root (RAG s) (Th th)"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5443
  unfolding root_def ancestors_def
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5444
  using readys_RAG assms
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5445
by (metis Collect_empty_eq Domain.DomainI trancl_domain)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5446
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5447
lemma readys_in_no_subtree:
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5448
  assumes "th \<in> readys s"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5449
  and "th' \<noteq> th"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5450
  shows "Th th \<notin> subtree (RAG s) (Th th')" 
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5451
proof
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5452
   assume "Th th \<in> subtree (RAG s) (Th th')"
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5453
   thus False
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5454
   proof(cases rule:subtreeE)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5455
      case 1
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5456
      with assms show ?thesis by auto
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5457
   next
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5458
      case 2
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5459
      with readys_root[OF assms(1)]
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5460
      show ?thesis by (auto simp:root_def)
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5461
   qed
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5462
qed
da27bece9575 updated
Christian Urban <urbanc@in.tum.de>
parents: 142
diff changeset
  5463
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5464
lemma readys_holdents_detached:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5465
  assumes "th \<in> readys s"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5466
  and "holdents s th = {}"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5467
  shows "detached s th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5468
proof -
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5469
  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
  5470
  show ?thesis
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5471
    by (unfold detached_test Field_def, auto)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5472
qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5473
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5474
lemma len_actions_of_sigma:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5475
  assumes "finite A"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5476
  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
  5477
proof(induct t)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5478
  case h: (Cons e t)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5479
  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
  5480
  proof(cases "actor e \<in> A")
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5481
    case True
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5482
    have "?L = 1 + ?T t"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5483
      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
  5484
    moreover have "?R = 1 + ?T t"
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
      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
  5487
                 (\<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
  5488
            (is "_ = ?F (e#t) + ?G (e#t)")
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5489
            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
  5490
                OF assms True], simp)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5491
      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
  5492
          by  (simp add:actions_of_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5493
      moreover have "?G (e#t) = ?G t"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5494
        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
  5495
      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
  5496
        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
  5497
              OF assms True], simp)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5498
      ultimately show ?thesis by simp
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5499
    qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5500
    ultimately show ?thesis by simp
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5501
  next
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5502
    case False
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5503
    hence "?L = length (actions_of A t)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5504
      by (simp add:actions_of_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5505
    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
  5506
    also have "... = ?R"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5507
      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
  5508
    finally show ?thesis .
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5509
  qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5510
qed (auto simp:actions_of_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5511
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5512
lemma threads_Exit:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5513
    assumes "th \<in> threads s"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5514
    and "th \<notin> threads (e#s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5515
    shows "e = Exit th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5516
    using assms
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5517
    by (cases e, auto)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5518
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  5519
end
136
fb3f52fe99d1 updated tG definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 134
diff changeset
  5520