PIPBasics.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Tue, 14 Jun 2016 15:06:16 +0100
changeset 129 e3cf792db636
parent 128 5d8ec128518b
child 130 0f124691c191
permissions -rw-r--r--
removed some files to attic
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
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
     2
imports PIPDefs
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
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    36
lemma Max_fg_mono:
4763aa246dbd Original files overwrite by 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
  assumes "finite 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
    38
  and "\<forall> a \<in> A. f a \<le> 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
    39
  shows "Max (f ` A) \<le> Max (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
    40
proof(cases "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
    41
  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
    42
  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
    43
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
    44
  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
    45
  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
    46
  proof(rule Max.boundedI)
4763aa246dbd Original files overwrite by 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
    from assms show "finite (f ` A)" 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
    48
  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
    49
    from False show "f ` A \<noteq> {}" 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
    50
  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
    51
    fix fa
4763aa246dbd Original files overwrite by 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
    assume "fa \<in> 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
    53
    then obtain a where h_fa: "a \<in> A" "fa = f a" 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
    54
    show "fa \<le> Max (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
    55
    proof(rule Max_ge_iff[THEN iffD2])
4763aa246dbd Original files overwrite by 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
      from assms show "finite (g ` A)" 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
    57
    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
    58
      from False show "g ` A \<noteq> {}" 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
    59
    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
    60
      from h_fa have "g a \<in> g ` A" 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
    61
      moreover have "fa \<le> g a" using h_fa assms(2) 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
    62
      ultimately show "\<exists>a\<in>g ` A. fa \<le> a" 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
    63
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    64
  qed
4763aa246dbd Original files overwrite by 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
qed 
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
lemma Max_f_mono:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    68
  assumes seq: "A \<subseteq> B"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    69
  and np: "A \<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
    70
  and fnt: "finite B"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    71
  shows "Max (f ` A) \<le> Max (f ` B)"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    72
proof(rule Max_mono)
4763aa246dbd Original files overwrite by 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
  from seq show "f ` A \<subseteq> f ` B" 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
    74
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
    75
  from np show "f ` A \<noteq> {}" 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
    76
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
    77
  from fnt and seq show "finite (f ` B)" 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
    78
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
lemma Max_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
    81
  assumes "finite 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
    82
  and "A \<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
    83
  and "\<forall> M \<in> f ` A. finite M"
4763aa246dbd Original files overwrite by 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
  and "\<forall> M \<in> f ` A. M \<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
    85
  shows "Max (\<Union>x\<in> A. f x) = Max (Max ` f ` A)" (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
    86
  using 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
    87
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
    88
  have "?L = Max (\<Union>(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
    89
    by (fold Union_image_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
    90
  also have "... = ?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
    91
    by (subst Max_Union, simp+)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    92
  finally 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
    93
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    94
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    95
lemma max_Max_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
    96
  assumes "finite 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
    97
    and "A \<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
    98
    and "x = y"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
    99
  shows "max x (Max A) = Max ({y} \<union> A)" (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
   100
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
   101
  have "?R = Max (insert y A)" 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
   102
  also from assms have "... = ?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
   103
      by (subst Max.insert, simp+)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   104
  finally 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
   105
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   106
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   107
section {* Lemmas do not depend on trace validity *}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   108
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   109
text {* The following lemma serves to proof @{text "preced_tm_lt"} *}
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   110
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   111
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
   112
  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
   113
  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
   114
  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
   115
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
   116
  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
   117
  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
   118
  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
   119
    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
   120
    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
   121
      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
   122
  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
   123
    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
   124
    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
   125
      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
   126
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   127
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
   128
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   129
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
   130
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
   131
  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
   132
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   133
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
   134
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
   135
  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
   136
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   137
text {*
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   138
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   139
  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
   140
  by someone else. *}
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   141
92
4763aa246dbd Original files overwrite by 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
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
   143
  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
   144
  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
   145
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
   146
  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
   147
  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
   148
    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
   149
  hence "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
   150
    by (unfold s_holding_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
   151
  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
   152
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   153
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   154
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   155
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   156
  The following @{text "children_RAG_alt_def"} relates
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   157
  @{term children} in @{term RAG} to the notion of @{term holding}.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   158
  It is a technical lemmas used to prove the two following lemmas.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   159
*}
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   160
lemma children_RAG_alt_def:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   161
  "children (RAG (s::state)) (Th th) = Cs ` {cs. holding s th cs}"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   162
  by (unfold s_RAG_def, auto simp:children_def holding_eq)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   163
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   164
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   165
  The following two lemmas relate @{term holdents} and @{term cntCS}
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   166
  to @{term children} in @{term RAG}, so that proofs about
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   167
  @{term holdents} and @{term cntCS} can be carried out under 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   168
  the support of the abstract theory of {\em relational graph}
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   169
  (and specifically {\em relational tree} and {\em relational forest}).
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   170
*}
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   171
lemma holdents_alt_def:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   172
  "holdents s th = the_cs ` (children (RAG (s::state)) (Th th))"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   173
  by (unfold children_RAG_alt_def holdents_def, simp add: image_image)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   174
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   175
lemma cntCS_alt_def:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   176
  "cntCS s th = card (children (RAG s) (Th th))"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   177
  apply (unfold children_RAG_alt_def cntCS_def holdents_def)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   178
  by (rule card_image[symmetric], auto simp:inj_on_def)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   179
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   180
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   181
  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
   182
  among three key sets, namely @{term running}, @{term readys}
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   183
  and @{term threads}.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   184
*}
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   185
lemma running_ready: 
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   186
  shows "running s \<subseteq> readys s"
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   187
  unfolding running_def readys_def
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   188
  by auto 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   189
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   190
lemma readys_threads:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   191
  shows "readys s \<subseteq> threads s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   192
  unfolding readys_def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   193
  by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   194
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   195
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   196
  The following lemma says that if a thread is running, 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   197
  it must be the head of every waiting queue it is in. 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   198
  In other words, a running thread must have got every 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   199
  resource it has requested.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   200
*}
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   201
lemma running_wqE:
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   202
  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
   203
  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
   204
  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
   205
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
   206
  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
   207
    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
   208
  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
   209
  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
   210
    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
   211
    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
   212
    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
   213
    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
   214
      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
   215
    with assms show False 
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   216
      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
   217
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   218
  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
   219
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   220
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   221
text {*
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   222
  Every thread can only be blocked on one critical resource, 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   223
  symmetrically, every critical resource can only be held by one thread. 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   224
  This fact is much more easier according to our definition. 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   225
*}
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   226
lemma held_unique:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   227
  assumes "holding (s::event list) th1 cs"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   228
  and "holding s th2 cs"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   229
  shows "th1 = th2"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   230
 by (insert assms, unfold s_holding_def, auto)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   231
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   232
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   233
  The following three lemmas establishes the uniqueness of
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   234
  precedence, a key property about precedence.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   235
  The first two are just technical lemmas to assist the proof
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   236
  of the third.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   237
*}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   238
lemma last_set_lt: "th \<in> threads s \<Longrightarrow> last_set th s < length s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   239
  apply (induct s, auto)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   240
  by (case_tac a, auto split:if_splits)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   241
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   242
lemma last_set_unique: 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   243
  "\<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
   244
          \<Longrightarrow> th1 = th2"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   245
  apply (induct s, auto)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   246
  by (case_tac a, auto split:if_splits dest:last_set_lt)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   247
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   248
lemma preced_unique : 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   249
  assumes pcd_eq: "preced th1 s = preced th2 s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   250
  and th_in1: "th1 \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   251
  and th_in2: " th2 \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   252
  shows "th1 = th2"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   253
proof -
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   254
  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
   255
  from last_set_unique [OF this th_in1 th_in2]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   256
  show ?thesis .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   257
qed
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   258
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   259
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   260
  The following lemma shows that there exits a linear order
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   261
  on precedences, which is crucial for the notion of 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   262
  @{term Max} to be applicable.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   263
*}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   264
lemma preced_linorder: 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   265
  assumes neq_12: "th1 \<noteq> th2"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   266
  and th_in1: "th1 \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   267
  and th_in2: " th2 \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   268
  shows "preced th1 s < preced th2 s \<or> preced th1 s > preced th2 s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   269
proof -
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   270
  from preced_unique [OF _ th_in1 th_in2] and neq_12 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   271
  have "preced th1 s \<noteq> preced th2 s" by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   272
  thus ?thesis by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   273
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   274
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   275
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   276
  The following lemma case analysis the situations when
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   277
  two nodes are in @{term RAG}.
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   278
*}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   279
lemma in_RAG_E:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   280
  assumes "(n1, n2) \<in> RAG (s::state)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   281
  obtains (waiting) th cs where "n1 = Th th" "n2 = Cs cs" "waiting s th cs"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   282
      | (holding) th cs where "n1 = Cs cs" "n2 = Th th" "holding s th cs"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   283
  using assms[unfolded s_RAG_def, folded waiting_eq holding_eq]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   284
  by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   285
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   286
text {*
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   287
  The following lemmas are the simplification rules 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   288
  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
   289
  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
   290
  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
   291
  the number of resources occupied by one thread.
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   292
*}
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   293
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   294
lemma count_rec1 [simp]: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   295
  assumes "Q e"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   296
  shows "count Q (e#es) = Suc (count Q es)"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   297
  using assms
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   298
  by (unfold count_def, auto)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   299
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   300
lemma count_rec2 [simp]: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   301
  assumes "\<not>Q e"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   302
  shows "count Q (e#es) = (count Q es)"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   303
  using assms
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   304
  by (unfold count_def, auto)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   305
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   306
lemma count_rec3 [simp]: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   307
  shows "count Q [] =  0"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   308
  by (unfold count_def, auto)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   309
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   310
lemma cntP_simp1[simp]:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   311
  "cntP (P th cs'#s) th = cntP s th + 1"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   312
  by (unfold cntP_def, simp)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   313
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   314
lemma cntP_simp2[simp]:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   315
  assumes "th' \<noteq> th"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   316
  shows "cntP (P th cs'#s) th' = cntP s th'"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   317
  using assms
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   318
  by (unfold cntP_def, simp)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   319
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   320
lemma cntP_simp3[simp]:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   321
  assumes "\<not> isP e"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   322
  shows "cntP (e#s) th' = cntP s th'"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   323
  using assms
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   324
  by (unfold cntP_def, cases e, simp+)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   325
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   326
lemma cntV_simp1[simp]:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   327
  "cntV (V th cs'#s) th = cntV s th + 1"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   328
  by (unfold cntV_def, simp)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   329
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   330
lemma cntV_simp2[simp]:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   331
  assumes "th' \<noteq> th"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   332
  shows "cntV (V th cs'#s) th' = cntV s th'"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   333
  using assms
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   334
  by (unfold cntV_def, simp)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   335
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   336
lemma cntV_simp3[simp]:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   337
  assumes "\<not> isV e"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   338
  shows "cntV (e#s) th' = cntV s th'"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   339
  using assms
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   340
  by (unfold cntV_def, cases e, simp+)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   341
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
   342
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
   343
  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
   344
  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
   345
  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
   346
  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
   347
*}
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   348
lemma cntP_diff_inv:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   349
  assumes "cntP (e#s) th \<noteq> cntP s th"
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
   350
  obtains cs where "e = P th cs"
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   351
proof(cases e)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   352
  case (P th' pty)
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
   353
  show ?thesis using that
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   354
  by (cases "(\<lambda>e. \<exists>cs. e = P th cs) (P th' pty)", 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   355
        insert assms P, auto simp:cntP_def)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   356
qed (insert assms, auto simp:cntP_def)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   357
  
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   358
lemma cntV_diff_inv:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   359
  assumes "cntV (e#s) th \<noteq> cntV s th"
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
   360
  obtains cs' where "e = V th cs'"
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   361
proof(cases e)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   362
  case (V th' pty)
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
   363
  show ?thesis using that
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   364
  by (cases "(\<lambda>e. \<exists>cs. e = V th cs) (V th' pty)", 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   365
        insert assms V, auto simp:cntV_def)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   366
qed (insert assms, auto simp:cntV_def)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
   367
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   368
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   369
text {* 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   370
  The following three lemmas shows the shape
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   371
  of nodes in @{term tRAG}.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   372
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   373
lemma tRAG_nodeE:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   374
  assumes "(n1, n2) \<in> tRAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   375
  obtains th1 th2 where "n1 = Th th1" "n2 = Th th2"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   376
  using assms
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   377
  by (auto simp: tRAG_def wRAG_def hRAG_def)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   378
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   379
lemma tRAG_ancestorsE:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   380
  assumes "x \<in> ancestors (tRAG s) u"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   381
  obtains th where "x = Th th"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   382
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   383
  from assms have "(u, x) \<in> (tRAG s)^+" 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   384
      by (unfold ancestors_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   385
  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
   386
  then obtain th where "x = Th th"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   387
    by (unfold tRAG_alt_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   388
  from that[OF this] show ?thesis .
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   389
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   390
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   391
lemma subtree_nodeE:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   392
  assumes "n \<in> subtree (tRAG s) (Th th)"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   393
  obtains th1 where "n = Th th1"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   394
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   395
  show ?thesis
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   396
  proof(rule subtreeE[OF assms])
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   397
    assume "n = Th th"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   398
    from that[OF this] show ?thesis .
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   399
  next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   400
    assume "Th th \<in> ancestors (tRAG s) n"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   401
    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
   402
    hence "\<exists> th1. n = Th th1"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   403
    proof(induct)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   404
      case (base y)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   405
      from tRAG_nodeE[OF this] show ?case by metis
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   406
    next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   407
      case (step y z)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   408
      thus ?case by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   409
    qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   410
    with that show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   411
  qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   412
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   413
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   414
text {*
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   415
  The following lemmas relate @{term tRAG} with 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   416
  @{term RAG} from different perspectives. 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   417
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   418
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   419
lemma tRAG_star_RAG: "(tRAG s)^* \<subseteq> (RAG s)^*"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   420
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   421
  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
   422
    by (rule rtrancl_mono, auto simp:RAG_split)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   423
  also have "... \<subseteq> ((RAG s)^*)^*"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   424
    by (rule rtrancl_mono, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   425
  also have "... = (RAG s)^*" by simp
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   426
  finally show ?thesis by (unfold tRAG_def, simp)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   427
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   428
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   429
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
   430
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   431
  { fix a
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   432
    assume "a \<in> subtree (tRAG s) x"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   433
    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
   434
    with tRAG_star_RAG
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   435
    have "(a, x) \<in> (RAG s)^*" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   436
    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
   437
  } thus ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   438
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   439
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   440
lemma tRAG_trancl_eq:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   441
   "{th'. (Th th', Th th)  \<in> (tRAG s)^+} = 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   442
    {th'. (Th th', Th th)  \<in> (RAG s)^+}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   443
   (is "?L = ?R")
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   444
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   445
  { fix th'
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   446
    assume "th' \<in> ?L"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   447
    hence "(Th th', Th th) \<in> (tRAG s)^+" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   448
    from tranclD[OF this]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   449
    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
   450
    from tRAG_subtree_RAG and this(2)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   451
    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
   452
    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
   453
    ultimately have "th' \<in> ?R"  by auto 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   454
  } moreover 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   455
  { fix th'
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   456
    assume "th' \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   457
    hence "(Th th', Th th) \<in> (RAG s)^+" by (auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   458
    from plus_rpath[OF this]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   459
    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
   460
    hence "(Th th', Th th) \<in> (tRAG s)^+"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   461
    proof(induct xs arbitrary:th' th rule:length_induct)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   462
      case (1 xs th' th)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   463
      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
   464
      show ?case
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   465
      proof(cases "xs1")
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   466
        case Nil
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   467
        from 1(2)[unfolded Cons1 Nil]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   468
        have rp: "rpath (RAG s) (Th th') [x1] (Th th)" .
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   469
        hence "(Th th', x1) \<in> (RAG s)" 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   470
          by (cases, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   471
        then obtain cs where "x1 = Cs cs" 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   472
              by (unfold s_RAG_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   473
        from rpath_nnl_lastE[OF rp[unfolded this]]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   474
        show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   475
      next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   476
        case (Cons x2 xs2)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   477
        from 1(2)[unfolded Cons1[unfolded this]]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   478
        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
   479
        from rpath_edges_on[OF this]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   480
        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
   481
        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
   482
            by (simp add: edges_on_unfold)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   483
        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
   484
        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
   485
        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
   486
            by (simp add: edges_on_unfold)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   487
        from this eds
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   488
        have rg2: "(x1, x2) \<in> RAG s" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   489
        from this[unfolded eq_x1] 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   490
        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
   491
        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
   492
        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
   493
        from rp have "rpath (RAG s) x2 xs2 (Th th)"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   494
           by  (elim rpath_ConsE, simp)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   495
        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
   496
        show ?thesis
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   497
        proof(cases "xs2 = []")
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   498
          case True
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   499
          from rpath_nilE[OF rp'[unfolded this]]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   500
          have "th1 = th" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   501
          from rt1[unfolded this] show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   502
        next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   503
          case False
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   504
          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
   505
          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
   506
          with rt1 show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   507
        qed
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
    hence "th' \<in> ?L" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   511
  } ultimately show ?thesis by blast
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   512
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   513
129
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
   514
(*
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   515
lemma image_eq:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   516
  assumes "A = B"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   517
  shows "f ` A = f ` B"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   518
  using assms by auto
129
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
   519
*)
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   520
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   521
lemma tRAG_trancl_eq_Th:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   522
   "{Th th' | th'. (Th th', Th th)  \<in> (tRAG s)^+} = 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   523
    {Th th' | th'. (Th th', Th th)  \<in> (RAG s)^+}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   524
    using tRAG_trancl_eq by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   525
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   526
lemma tRAG_Field:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   527
  "Field (tRAG s) \<subseteq> Field (RAG s)"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   528
  by (unfold tRAG_alt_def Field_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   529
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   530
lemma tRAG_mono:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   531
  assumes "RAG s' \<subseteq> RAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   532
  shows "tRAG s' \<subseteq> tRAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   533
  using assms 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   534
  by (unfold tRAG_alt_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   535
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   536
lemma tRAG_subtree_eq: 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   537
   "(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
   538
   (is "?L = ?R")
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   539
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   540
  { fix n 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   541
    assume h: "n \<in> ?L"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   542
    hence "n \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   543
    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
   544
  } moreover {
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   545
    fix n
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   546
    assume "n \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   547
    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
   548
      by (auto simp:subtree_def)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   549
    from rtranclD[OF this(2)]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   550
    have "n \<in> ?L"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   551
    proof
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   552
      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
   553
      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
   554
      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
   555
        by fastforce (* ccc *)
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   556
    qed (insert h, auto simp:subtree_def)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   557
  } ultimately show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   558
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   559
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   560
lemma threads_set_eq: 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   561
   "the_thread ` (subtree (tRAG s) (Th th)) = 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   562
                  {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
   563
   by (auto intro:rev_image_eqI simp:tRAG_subtree_eq)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   564
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
   565
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
   566
  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
   567
  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
   568
  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
   569
  (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
   570
  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
   571
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   572
lemma cp_alt_def:
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   573
  "cp s th =  Max ((the_preced s) ` {th'. Th th' \<in> (subtree (RAG s) (Th th))})"
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   574
proof -
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   575
  have "Max (the_preced s ` ({th} \<union> dependants s th)) =
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   576
        Max (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)})" 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   577
          (is "Max (_ ` ?L) = Max (_ ` ?R)")
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   578
  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
   579
    have "?L = ?R" 
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   580
    unfolding subtree_def
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   581
    apply(auto)
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   582
    apply (simp add: s_RAG_abv s_dependants_def wq_def)
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   583
    by (simp add: rtrancl_eq_or_trancl s_RAG_abv s_dependants_def wq_def)
115
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   584
    thus ?thesis by simp
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   585
  qed
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   586
  thus ?thesis
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   587
  by (metis (no_types, lifting) cp_eq cpreced_def eq_dependants 
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   588
      f_image_eq 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
   589
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
   590
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   591
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
   592
  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
   593
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   594
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
   595
  "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
   596
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
   597
  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
   598
       ((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
   599
       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
   600
  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
   601
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
   602
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   603
lemma RAG_tRAG_transfer:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   604
  assumes  "RAG s' = RAG s \<union> {(Th th, Cs cs)}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   605
  and "(Cs cs, Th th'') \<in> RAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   606
  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
   607
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   608
  { fix n1 n2
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   609
    assume "(n1, n2) \<in> ?L"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   610
    from this[unfolded tRAG_alt_def]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   611
    obtain th1 th2 cs' where 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   612
      h: "n1 = Th th1" "n2 = Th th2" 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   613
         "(Th th1, Cs cs') \<in> RAG s'"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   614
         "(Cs cs', Th th2) \<in> RAG s'" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   615
    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
   616
    from h(3) and assms(1) 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   617
    have "(Th th1, Cs cs') = (Th th, Cs cs) \<or> 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   618
          (Th th1, Cs cs') \<in> RAG s" by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   619
    hence "(n1, n2) \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   620
    proof
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   621
      assume h1: "(Th th1, Cs cs') = (Th th, Cs cs)"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   622
      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
   623
      moreover have "th2 = th''"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   624
      proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   625
        from h1 have "cs' = cs" by simp
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   626
        from assms(2) cs_in[unfolded this]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   627
        have "holding s th'' cs" "holding s th2 cs"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   628
          by (unfold s_RAG_def, fold holding_eq, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   629
        from held_unique[OF this]
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   630
        show ?thesis by simp 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   631
      qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   632
      ultimately show ?thesis using h(1,2) h1 by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   633
    next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   634
      assume "(Th th1, Cs cs') \<in> RAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   635
      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
   636
        by (unfold tRAG_alt_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   637
      from this[folded h(1, 2)] show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   638
    qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   639
  } moreover {
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   640
    fix n1 n2
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   641
    assume "(n1, n2) \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   642
    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
   643
    hence "(n1, n2) \<in> ?L" 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   644
    proof
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   645
      assume "(n1, n2) \<in> tRAG s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   646
      moreover have "... \<subseteq> ?L"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   647
      proof(rule tRAG_mono)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   648
        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
   649
      qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   650
      ultimately show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   651
    next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   652
      assume eq_n: "(n1, n2) = (Th th, Th th'')"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   653
      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
   654
      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
   655
      ultimately show ?thesis 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   656
        by (unfold eq_n tRAG_alt_def, auto)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   657
    qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   658
  } ultimately show ?thesis by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   659
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   660
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   661
text {* 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   662
  The following lemmas gives an alternative definition @{term dependants}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   663
  in terms of @{term tRAG}.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   664
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   665
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   666
lemma dependants_alt_def:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   667
  "dependants s th = {th'. (Th th', Th th) \<in> (tRAG s)^+}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   668
  by (metis eq_RAG s_dependants_def tRAG_trancl_eq)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   669
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   670
text {* 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   671
  The following lemmas gives another alternative definition @{term dependants}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   672
  in terms of @{term RAG}.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   673
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   674
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   675
lemma dependants_alt_def1:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   676
  "dependants (s::state) th = {th'. (Th th', Th th) \<in> (RAG s)^+}"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   677
  using dependants_alt_def tRAG_trancl_eq by auto
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
   678
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   679
section {* Locales used to investigate the execution of PIP *}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   680
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   681
text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   682
  The following locale @{text valid_trace} is used to constrain the 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   683
  trace to be valid. All properties hold for valid traces are 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   684
  derived under this locale. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   685
*}
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   686
locale valid_trace = 
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   687
  fixes s
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   688
  assumes vt : "vt s"
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   689
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   690
text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   691
  The following locale @{text valid_trace_e} describes 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   692
  the valid extension of a valid trace. The event @{text "e"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   693
  represents an event in the system, which corresponds 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   694
  to a one step operation of the PIP protocol. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   695
  It is required that @{text "e"} is an event eligible to happen
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   696
  under state @{text "s"}, which is already required to be valid
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   697
  by the parent locale @{text "valid_trace"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   698
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   699
  This locale is used to investigate one step execution of PIP, 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   700
  properties concerning the effects of @{text "e"}'s execution, 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   701
  for example, how the values of observation functions are changed, 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   702
  or how desirable properties are kept invariant, are derived
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   703
  under this locale. The state before execution is @{text "s"}, while
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   704
  the state after execution is @{text "e#s"}. Therefore, the lemmas 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   705
  derived usually relate observations on @{text "e#s"} to those 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   706
  on @{text "s"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   707
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   708
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   709
locale valid_trace_e = valid_trace +
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   710
  fixes e
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   711
  assumes vt_e: "vt (e#s)"
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   712
begin
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   713
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   714
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   715
  The following lemma shows that @{text "e"} must be a 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   716
  eligible event (or a valid step) to be taken under
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   717
  the state represented by @{text "s"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   718
*}
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   719
lemma pip_e: "PIP s e"
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   720
  using vt_e by (cases, simp)  
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   721
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   722
end
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
   723
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   724
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   725
  Because @{term "e#s"} is also a valid trace, properties 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   726
  derived for valid trace @{term s} also hold on @{term "e#s"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   727
*}
120
b3b8735c7c02 updated to Isabelle 2016
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 119
diff changeset
   728
sublocale valid_trace_e < vat_es: valid_trace "e#s" 
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   729
  using vt_e
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   730
  by (unfold_locales, simp)
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   731
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   732
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   733
  For each specific event (or operation), there is a sublocale
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   734
  further constraining that the event @{text e} to be that 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   735
  particular event. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   736
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   737
  For example, the following 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   738
  locale @{text "valid_trace_create"} is the sublocale for 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   739
  event @{term "Create"}:
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   740
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   741
locale valid_trace_create = valid_trace_e + 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   742
  fixes th prio
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   743
  assumes is_create: "e = Create th prio"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   744
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   745
locale valid_trace_exit = valid_trace_e + 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   746
  fixes th
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   747
  assumes is_exit: "e = Exit th"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   748
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   749
locale valid_trace_p = valid_trace_e + 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   750
  fixes th cs
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   751
  assumes is_p: "e = P th cs"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   752
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   753
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   754
  locale @{text "valid_trace_p"} is divided further into two 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   755
  sublocales, namely, @{text "valid_trace_p_h"} 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   756
  and @{text "valid_trace_p_w"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   757
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   758
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   759
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   760
  The following two sublocales @{text "valid_trace_p_h"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   761
  and @{text "valid_trace_p_w"} represent two complementary 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   762
  cases under @{text "valid_trace_p"}, where
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   763
  @{text "valid_trace_p_h"} further constraints that
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   764
  @{text "wq s cs = []"}, which means the waiting queue of 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   765
  the requested resource @{text "cs"} is empty, in which
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   766
  case,  the requesting thread @{text "th"} 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   767
  will take hold of @{text "cs"}. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   768
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   769
  Opposite to @{text "valid_trace_p_h"},
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   770
  @{text "valid_trace_p_w"} constraints that
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   771
  @{text "wq s cs \<noteq> []"}, which means the waiting queue of 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   772
  the requested resource @{text "cs"} is nonempty, in which
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   773
  case,  the requesting thread @{text "th"} will be blocked
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   774
  on @{text "cs"}: 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   775
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   776
  Peculiar properties will be derived under respective 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   777
  locales.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   778
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   779
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   780
locale valid_trace_p_h = valid_trace_p +
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   781
  assumes we: "wq s cs = []"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   782
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   783
locale valid_trace_p_w = valid_trace_p +
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   784
  assumes wne: "wq s cs \<noteq> []"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   785
begin
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   786
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   787
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   788
  The following @{text "holder"} designates
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   789
  the holder of @{text "cs"} before the @{text "P"}-operation.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   790
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   791
definition "holder = hd (wq s cs)"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   792
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   793
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   794
  The following @{text "waiters"} designates
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   795
  the list of threads waiting for @{text "cs"} 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   796
  before the @{text "P"}-operation.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   797
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   798
definition "waiters = tl (wq s cs)"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   799
end
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   800
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   801
text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   802
  @{text "valid_trace_v"} is set for the @{term V}-operation.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   803
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   804
locale valid_trace_v = valid_trace_e + 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   805
  fixes th cs
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   806
  assumes is_v: "e = V th cs"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   807
begin
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   808
  -- {* The following @{text "rest"} is the tail of 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   809
        waiting queue of the resource @{text "cs"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   810
        to be released by this @{text "V"}-operation.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   811
     *}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   812
  definition "rest = tl (wq s cs)"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   813
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   814
  text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   815
    The following @{text "wq'"} is the waiting
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   816
    queue of @{term "cs"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   817
    after the @{text "V"}-operation, which
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   818
    is simply a reordering of @{term "rest"}. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   819
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   820
    The effect of this reordering needs to be 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   821
    understood by two cases:
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   822
    \begin{enumerate}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   823
    \item When @{text "rest = []"},
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   824
    the reordering gives rise to an empty list as well, 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   825
    which means there is no thread holding or waiting 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   826
    for resource @{term "cs"}, therefore, it is free.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   827
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   828
    \item When @{text "rest \<noteq> []"}, the effect of 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   829
    this reordering is to arbitrarily 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   830
    switch one thread in @{term "rest"} to the 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   831
    head, which, by definition take over the hold
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   832
    of @{term "cs"} and is designated by @{text "taker"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   833
    in the following sublocale @{text "valid_trace_v_n"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   834
  *}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   835
  definition "wq' = (SOME q. distinct q \<and> set q = set rest)"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   836
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   837
  text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   838
  The following @{text "rest'"} is the tail of the 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   839
  waiting queue after the @{text "V"}-operation. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   840
  It plays only auxiliary role to ease reasoning. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   841
  *}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   842
  definition "rest' = tl wq'"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   843
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   844
end
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   845
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   846
text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   847
  In the following, @{text "valid_trace_v"} is also 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   848
  divided into two 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   849
  sublocales: when @{text "rest"} is empty (represented
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   850
  by @{text "valid_trace_v_e"}), which means, there is no thread waiting 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   851
  for @{text "cs"}, therefore, after the @{text "V"}-operation, 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   852
  it will become free; otherwise (represented 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   853
  by @{text "valid_trace_v_n"}), one thread 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   854
  will be picked from those in @{text "rest"} to take 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   855
  over @{text "cs"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   856
*}
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_v_e = valid_trace_v +
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   859
  assumes rest_nil: "rest = []"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   860
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   861
locale valid_trace_v_n = valid_trace_v +
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   862
  assumes rest_nnl: "rest \<noteq> []"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   863
begin
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   864
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   865
text {* 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   866
  The following @{text "taker"} is the thread to 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   867
  take over @{text "cs"}. 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   868
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   869
  definition "taker = hd wq'"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   870
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   871
end
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   872
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   873
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   874
locale valid_trace_set = valid_trace_e + 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   875
  fixes th prio
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   876
  assumes is_set: "e = Set th prio"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   877
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   878
context valid_trace
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   879
begin
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   880
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   881
text {*
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   882
  Induction rule introduced to easy the 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   883
  derivation of properties for valid trace @{term "s"}.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   884
  One more premises, namely @{term "valid_trace_e s e"}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   885
  is added, so that an interpretation of 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   886
  @{text "valid_trace_e"} can be instantiated 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   887
  so that all properties derived so far becomes 
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   888
  available in the proof of induction step.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   889
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   890
  You will see its use in the proofs that follows.
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   891
*}
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   892
lemma ind [consumes 0, case_names Nil Cons, induct type]:
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   893
  assumes "PP []"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   894
     and "(\<And>s e. valid_trace_e s e \<Longrightarrow>
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   895
                   PP s \<Longrightarrow> PIP s e \<Longrightarrow> PP (e # s))"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   896
     shows "PP s"
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   897
proof(induct rule:vt.induct[OF vt, case_names Init Step])
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   898
  case Init
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   899
  from assms(1) show ?case .
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   900
next
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   901
  case (Step s e)
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   902
  show ?case
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   903
  proof(rule assms(2))
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   904
    show "valid_trace_e s e" using Step by (unfold_locales, auto)
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   905
  next
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   906
    show "PP s" using Step by simp
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   907
  next
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   908
    show "PIP s e" using Step by simp
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   909
  qed
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   910
qed
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   911
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
   912
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   913
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
   914
  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
   915
  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
   916
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
   917
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
   918
  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
   919
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   920
end
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   921
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   922
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
   923
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
   924
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
   925
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
   926
  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
   927
  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
   928
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
   929
  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
   930
  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
   931
  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
   932
  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
   933
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
   934
  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
   935
  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
   936
  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
   937
  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
   938
  
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
   939
*}
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
   940
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   941
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
   942
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
   943
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   944
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
   945
  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
   946
    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
   947
  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
   948
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   949
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
   950
  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
   951
  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
   952
  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
   953
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
   954
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   955
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
   956
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
   957
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
   958
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
   959
  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
   960
    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
   961
  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
   962
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   963
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
   964
  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
   965
  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
   966
  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
   967
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
   968
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
   969
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
   970
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
   971
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   972
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
   973
  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
   974
  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
   975
    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
   976
  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
   977
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   978
lemma running_th_s:
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
   979
  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
   980
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
   981
  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
   982
  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
   983
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   984
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
   985
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
   986
  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
   987
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
   988
  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
   989
  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
   990
  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
   991
  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
   992
  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
   993
    by (unfold s_holding_def, fold wq_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
   994
  hence cs_th_RAG: "(Cs cs, 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
   995
    by (unfold s_RAG_def, fold holding_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
   996
  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
   997
  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
   998
  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
   999
    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
  1000
    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
  1001
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1002
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
  1003
                  
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1004
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
  1005
  "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
  1006
  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
  1007
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1008
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
  1009
  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
  1010
  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
  1011
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
  1012
  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
  1013
  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
  1014
    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
  1015
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
  1016
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1017
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
  1018
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1019
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
  1020
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
  1021
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1022
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
  1023
  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
  1024
  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
  1025
    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
  1026
  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
  1027
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1028
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
  1029
  "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
  1030
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
  1031
  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
  1032
  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
  1033
  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
  1034
    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
  1035
    from this(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
  1036
      by (unfold rest_def s_holding_def, fold 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
  1037
                 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
  1038
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1039
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1040
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1041
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
  1042
  "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
  1043
 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
  1044
 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
  1045
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1046
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
  1047
  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
  1048
  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
  1049
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
  1050
  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
  1051
  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
  1052
  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
  1053
    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
  1054
        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
  1055
  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
  1056
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
  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
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
  1059
4763aa246dbd Original files overwrite by 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
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
  1061
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
  1062
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  1063
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
  1064
  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
  1065
    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
  1066
  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
  1067
4763aa246dbd Original files overwrite by 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
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
  1069
  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
  1070
  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
  1071
  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
  1072
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
  1073
4763aa246dbd Original files overwrite by 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
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
  1075
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
  1076
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
  1077
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
  1078
  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
  1079
  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
  1080
  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
  1081
  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
  1082
  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
  1083
*}
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1084
lemma wq_distinct: "distinct (wq s cs)"
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 67
diff changeset
  1085
proof(induct rule:ind)
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 67
diff changeset
  1086
  case (Cons s e)
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1087
  interpret vt_e: valid_trace_e s e using Cons by simp
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 67
diff changeset
  1088
  show ?case 
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1089
  proof(cases e)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1090
    case (Create th prio)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1091
    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
  1092
      using Create by (unfold_locales, simp)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1093
    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
  1094
  next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1095
    case (Exit th)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1096
    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
  1097
        using Exit by (unfold_locales, simp)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1098
    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
  1099
  next
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1100
    case (P th cs)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1101
    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
  1102
    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
  1103
  next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1104
    case (V th cs)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1105
    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
  1106
    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
  1107
  next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1108
    case (Set th prio)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1109
    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
  1110
        using Set by (unfold_locales, simp)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1111
    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
  1112
  qed
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 67
diff changeset
  1113
qed (unfold wq_def Let_def, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1114
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1115
end
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1116
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1117
section {* Waiting queues and threads *}
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1118
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
  1119
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
  1120
  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
  1121
  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
  1122
  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
  1123
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1124
  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
  1125
  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
  1126
  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
  1127
  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
  1128
*}
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1129
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1130
context valid_trace_create
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1131
begin
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1132
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
  1133
lemma 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1134
  th_not_in_threads: "th \<notin> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1135
proof -
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1136
  from pip_e[unfolded is_create]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1137
  show ?thesis by (cases, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1138
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1139
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
  1140
lemma 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1141
  threads_es [simp]: "threads (e#s) = threads s \<union> {th}"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1142
  by (unfold is_create, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1143
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
  1144
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
  1145
  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
  1146
  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
  1147
  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
  1148
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
  1149
  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
  1150
  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
  1151
    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
  1152
    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
  1153
    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
  1154
  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
  1155
  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
  1156
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
  1157
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1158
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
  1159
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1160
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
  1161
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
  1162
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1163
lemma threads_es [simp]: "threads (e#s) = threads s - {th}"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1164
  by (unfold is_exit, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1165
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
  1166
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
  1167
  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
  1168
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
  1169
  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
  1170
  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
  1171
  by (cases, unfold holdents_def s_holding_def, fold wq_def, 
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1172
             auto elim!: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
  1173
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
  1174
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1175
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
  1176
  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
  1177
  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
  1178
  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
  1179
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
  1180
  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
  1181
  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
  1182
    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
  1183
    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
  1184
    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
  1185
  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
  1186
  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
  1187
  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
  1188
    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
  1189
    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
  1190
    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
  1191
    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
  1192
    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
  1193
  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
  1194
  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
  1195
    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
  1196
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
  1197
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1198
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
  1199
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1200
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
  1201
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
  1202
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1203
lemma 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1204
  threads_es [simp]: "threads (e#s) = threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1205
  by (unfold is_v, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1206
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
  1207
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
  1208
  th_not_in_rest: "th \<notin> set rest"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1209
proof
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1210
  assume otherwise: "th \<in> set rest"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1211
  have "distinct (wq s cs)" by (simp add: wq_distinct)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1212
  from this[unfolded wq_s_cs] and otherwise
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1213
  show False by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1214
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1215
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
  1216
lemma distinct_rest: "distinct rest"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1217
  by (simp add: distinct_tl rest_def wq_distinct)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1218
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
  1219
lemma
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1220
  set_wq_es_cs [simp]: "set (wq (e#s) cs) = set (wq s cs) - {th}"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1221
proof(unfold wq_es_cs wq'_def, rule someI2)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1222
  show "distinct rest \<and> set rest = set rest"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1223
    by (simp add: distinct_rest) 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1224
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1225
  fix x
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1226
  assume "distinct x \<and> set x = set rest"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1227
  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
  1228
      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
  1229
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
  1230
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
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
  1232
  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
  1233
  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
  1234
  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
  1235
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
  1236
  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
  1237
  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
  1238
  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
  1239
    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
  1240
    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
  1241
    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
  1242
    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
  1243
    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
  1244
  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
  1245
  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
  1246
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
  1247
    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
  1248
    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
  1249
    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
  1250
      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
  1251
      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
  1252
      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
  1253
      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
  1254
      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
  1255
      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
  1256
    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
  1257
    with threads_es show ?thesis by simp
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1258
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
  1259
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
  1260
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
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
  1262
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
  1263
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
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
  1265
  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
  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
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
  1268
  using running_th_s
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1269
  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
  1270
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
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
  1272
  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
  1273
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1274
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
  1275
  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
  1276
  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
  1277
  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
  1278
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
  1279
    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
  1280
    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
  1281
    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
  1282
    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
  1283
    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
  1284
      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
  1285
      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
  1286
      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
  1287
      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
  1288
    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
  1289
      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
  1290
      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
  1291
      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
  1292
    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
  1293
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
  1294
    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
  1295
    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
  1296
    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
  1297
      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
  1298
      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
  1299
      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
  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
      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
  1302
      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
  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
    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
  1305
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
  1306
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1307
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
  1308
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
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
  1310
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
  1311
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
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
  1313
  "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
  1314
  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
  1315
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 108
diff changeset
  1316
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
  1317
  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
  1318
  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
  1319
  shows "th' \<in> threads (e#s)"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1320
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
  1321
  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
  1322
     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
  1323
  with threads_kept show ?thesis by simp
100
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
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
  1327
129
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  1328
context valid_trace
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  1329
begin
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  1330
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
  1331
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
  1332
  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
  1333
  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
  1334
  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
  1335
  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
  1336
*}
129
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  1337
lemma wq_threads: 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1338
  assumes "th \<in> set (wq s cs)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1339
  shows "th \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1340
  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
  1341
proof(induct arbitrary:th cs rule:ind)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1342
  case (Nil)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1343
  thus ?case by (auto simp:wq_def)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1344
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1345
  case (Cons s e)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1346
  interpret vt_e: valid_trace_e s e using Cons by simp
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1347
  show ?case
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1348
  proof(cases e)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1349
    case (Create th' prio')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1350
    interpret vt: valid_trace_create s e th' prio'
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1351
      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
  1352
    show ?thesis using vt.wq_threads_kept Cons by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1353
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1354
    case (Exit th')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1355
    interpret vt: valid_trace_exit s e th'
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1356
      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
  1357
    show ?thesis using vt.wq_threads_kept Cons by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1358
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1359
    case (P th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1360
    interpret vt: valid_trace_p s e th' cs'
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1361
      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
  1362
   show ?thesis using vt.wq_threads_kept Cons by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1363
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1364
    case (V th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1365
    interpret vt: valid_trace_v s e th' cs'
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1366
      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
  1367
   show ?thesis using vt.wq_threads_kept Cons by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1368
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1369
    case (Set th' prio)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1370
    interpret vt: valid_trace_set s e th' prio
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1371
      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
  1372
   show ?thesis using vt.wq_threads_kept Cons by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1373
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1374
qed 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1375
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
  1376
subsection {* RAG and threads *}
68
db196b066b97 Before retrofiting PIPBasics.thy
zhangx
parents: 67
diff changeset
  1377
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1378
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
  1379
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
  1380
  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
  1381
  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
  1382
  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
  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
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1385
lemma  dm_RAG_threads:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1386
  assumes in_dom: "(Th th) \<in> Domain (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1387
  shows "th \<in> threads s"
104
43482ab31341 A fake merge. Used to revert to 98
zhangx
parents: 103 97
diff changeset
  1388
proof -
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1389
  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
  1390
  moreover then obtain cs where "n = Cs cs" by (unfold s_RAG_def, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1391
  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
  1392
  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
  1393
    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
  1394
  then show ?thesis using wq_threads by simp
104
43482ab31341 A fake merge. Used to revert to 98
zhangx
parents: 103 97
diff changeset
  1395
qed
43482ab31341 A fake merge. Used to revert to 98
zhangx
parents: 103 97
diff changeset
  1396
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1397
lemma rg_RAG_threads: 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1398
  assumes "(Th th) \<in> Range (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1399
  shows "th \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1400
  using assms
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1401
  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
  1402
  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
  1403
  apply(auto)
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1404
  using s_holding_def wq_def wq_threads by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1405
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1406
lemma RAG_threads:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1407
  assumes "(Th th) \<in> Field (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1408
  shows "th \<in> threads s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1409
  using assms
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1410
  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
  1411
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  1412
lemma not_in_thread_isolated:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  1413
  assumes "th \<notin> threads s"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  1414
  shows "(Th th) \<notin> Field (RAG s)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  1415
  using RAG_threads assms by auto
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  1416
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1417
text {*
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1418
  As a corollary, this lemma shows that @{term tRAG}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1419
  is also covered by the @{term threads}-set.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1420
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1421
lemma subtree_tRAG_thread:
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1422
  assumes "th \<in> threads s"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1423
  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
  1424
proof -
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1425
  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
  1426
    by (unfold tRAG_subtree_eq, simp)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1427
  also have "... \<subseteq> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1428
  proof
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1429
    fix x
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1430
    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
  1431
    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
  1432
    from this(2)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1433
    show "x \<in> ?R"
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1434
    proof(cases rule:subtreeE)
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1435
      case 1
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1436
      thus ?thesis by (simp add: assms h(1)) 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1437
    next
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1438
      case 2
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1439
      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
  1440
    qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1441
  qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1442
  finally show ?thesis .
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1443
qed
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  1444
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1445
end
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1446
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
  1447
section {* The formation of @{term RAG} *}
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1448
53
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  1449
text {*
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1450
  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
  1451
  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
  1452
  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
  1453
  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
  1454
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1455
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1456
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
  1457
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  1458
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
  1459
  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
  1460
  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
  1461
  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
  1462
  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
  1463
  (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
  1464
  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
  1465
  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
  1466
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
  1467
  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
  1468
  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
  1469
  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
  1470
*}
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1471
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1472
text {*
53
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  1473
  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
  1474
  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
  1475
  events, respectively.
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  1476
*}
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  1477
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1478
lemma (in valid_trace_set) RAG_es [simp]: "(RAG (e # s)) = RAG s"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1479
   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
  1480
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1481
lemma (in valid_trace_create) RAG_es [simp]: "(RAG (e # s)) = RAG s"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1482
 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
  1483
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  1484
lemma (in valid_trace_exit) RAG_es[simp]: "(RAG (e # s)) = RAG s"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1485
  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
  1486
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1487
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
  1488
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
  1489
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1490
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
  1491
  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
  1492
  shows "t = th"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1493
proof -
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1494
  from pip_e[unfolded is_v]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1495
  show ?thesis
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1496
  proof(cases)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1497
    case (thread_V)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1498
    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
  1499
    show ?thesis by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1500
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1501
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1502
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1503
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
  1504
  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
  1505
  
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1506
lemma set_wq': "set wq' = set rest"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1507
  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
  1508
    
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1509
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
  1510
  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
  1511
  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
  1512
  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
  1513
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1514
lemma running_th_s:
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  1515
  shows "th \<in> running s"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1516
proof -
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1517
  from pip_e[unfolded is_v]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1518
  show ?thesis by (cases, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1519
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  1520
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1521
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
  1522
  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
  1523
  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
  1524
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
  1525
  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
  1526
  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
  1527
  proof(cases "c = cs")
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1528
    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
  1529
    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
  1530
     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
  1531
     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
  1532
    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
  1533
    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
  1534
    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
  1535
  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
  1536
    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
  1537
    have "wq (e#s) c = wq s c" using False
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1538
        by simp
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1539
    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
  1540
        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
  1541
    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
  1542
    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
  1543
    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
  1544
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1545
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1546
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1547
lemma waiting_esI1:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1548
  assumes "waiting s t c"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1549
      and "c \<noteq> cs" 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1550
  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
  1551
proof -
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1552
  have "wq (e#s) c = wq s c" 
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1553
    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
  1554
  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
  1555
    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
  1556
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1557
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1558
lemma holding_esI2:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1559
  assumes "c \<noteq> cs" 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1560
  and "holding s t c"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1561
  shows "holding (e#s) t c"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1562
proof -
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1563
  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
  1564
  from assms(2)[unfolded s_holding_def, folded wq_def, 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1565
                folded this, unfolded wq_def, folded s_holding_def]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1566
  show ?thesis .
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1567
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1568
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1569
lemma holding_esI1:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1570
  assumes "holding s t c"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1571
  and "t \<noteq> th"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1572
  shows "holding (e#s) t c"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1573
proof -
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1574
  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
  1575
  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
  1576
  show ?thesis .
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1577
qed
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1578
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1579
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
  1580
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1581
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
  1582
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
  1583
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1584
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
  1585
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
  1586
  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
  1587
    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
  1588
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
  1589
  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
  1590
  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
  1591
  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
  1592
qed 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1593
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1594
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
  1595
  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
  1596
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1597
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
  1598
  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
  1599
  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
  1600
  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
  1601
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1602
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
  1603
  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
  1604
  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
  1605
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
  1606
  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
  1607
  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
  1608
    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
  1609
       "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
  1610
          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
  1611
  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
  1612
  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
  1613
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1614
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1615
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
  1616
  "{(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
  1617
  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
  1618
      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
  1619
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1620
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
  1621
  "{(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
  1622
  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
  1623
  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
  1624
   
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1625
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
  1626
  shows "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
  1627
    by (unfold s_holding_def, fold wq_def, unfold 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
  1628
        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
  1629
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1630
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
  1631
  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
  1632
      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
  1633
  shows "waiting (e#s) t cs" 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1634
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
  1635
  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
  1636
  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
  1637
    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
  1638
          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
  1639
  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
  1640
    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
  1641
    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
  1642
    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
  1643
        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
  1644
    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
  1645
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1646
  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
  1647
    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
  1648
  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
  1649
    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
  1650
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1651
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1652
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
  1653
  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
  1654
  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
  1655
     |    "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
  1656
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
  1657
  case False
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1658
  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
  1659
  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
  1660
    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
  1661
  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
  1662
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
  1663
  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
  1664
  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
  1665
  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
  1666
  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
  1667
  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
  1668
  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
  1669
  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
  1670
    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
  1671
  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
  1672
  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
  1673
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  1676
  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
  1677
  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
  1678
  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
  1679
  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
  1680
4763aa246dbd Original files overwrite by 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
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
  1682
  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
  1683
  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
  1684
      | "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
  1685
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
  1686
  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
  1687
  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
  1688
             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
  1689
  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
  1690
  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
  1691
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
  1692
  case False
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1693
  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
  1694
  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
  1695
             unfolded this, unfolded wq_def, folded 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
  1696
  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
  1697
  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
  1698
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1699
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1700
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
  1701
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1703
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
  1704
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
  1705
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1706
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
  1707
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
  1708
  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
  1709
    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
  1710
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
  1711
  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
  1712
  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
  1713
  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
  1714
qed 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1715
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1716
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
  1717
  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
  1718
  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
  1719
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
  1720
  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
  1721
  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
  1722
    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
  1723
  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
  1724
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1725
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1726
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
  1727
  "{(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
  1728
  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
  1729
4763aa246dbd Original files overwrite by 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
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
  1731
  "{(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
  1732
  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
  1733
   
4763aa246dbd Original files overwrite by 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
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
  1735
  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
  1736
  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
  1737
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
  1738
  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
  1739
  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
  1740
  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
  1741
  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
  1742
qed
4763aa246dbd Original files overwrite by 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
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1744
lemma no_waiter_before: "\<not> waiting s t cs"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1745
proof
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1746
  assume otherwise: "waiting s t cs"
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1747
  from this[unfolded s_waiting_def, folded wq_def, 
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1748
            unfolded wq_s_cs rest_nil]
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1749
  show False by simp
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1750
qed
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1751
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1752
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
  1753
  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
  1754
  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
  1755
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
  1756
  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
  1757
  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
  1758
  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
  1759
  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
  1760
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  1763
  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
  1764
  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
  1765
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
  1766
  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
  1767
    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
  1768
  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
  1769
  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
  1770
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  1773
  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
  1774
  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
  1775
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
  1776
  case False
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1777
  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
  1778
  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
  1779
    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
  1780
  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
  1781
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
  1782
  case True
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1783
  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
  1784
  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
  1785
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  1788
  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
  1789
  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
  1790
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
  1791
  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
  1792
  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
  1793
  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
  1794
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
  1795
  case False
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  1796
  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
  1797
  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
  1798
             unfolded this, unfolded wq_def, folded 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
  1799
  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
  1800
  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
  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
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
  1804
4763aa246dbd Original files overwrite by 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
  
4763aa246dbd Original files overwrite by 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
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
  1807
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
  1808
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1809
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
  1810
  "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
  1811
   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
  1812
     {(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
  1813
     {(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
  1814
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
  1815
  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
  1816
  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
  1817
  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
  1818
  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
  1819
    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
  1820
    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
  1821
    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
  1822
      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
  1823
      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
  1824
        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
  1825
      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
  1826
      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
  1827
      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
  1828
        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
  1829
        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
  1830
        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
  1831
        by (unfold h_n.waiting_set_eq h_n.holding_set_eq 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
  1832
             fold waiting_eq, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1833
      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
  1834
        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
  1835
        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
  1836
        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
  1837
         by (unfold h_n.waiting_set_eq h_n.holding_set_eq 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
  1838
             fold waiting_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
  1839
      qed
4763aa246dbd Original files overwrite by 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
    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
  1841
      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
  1842
      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
  1843
        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
  1844
      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
  1845
      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
  1846
      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
  1847
        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
  1848
        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
  1849
        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
  1850
        by (unfold h_e.waiting_set_eq h_e.holding_set_eq 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
  1851
             fold waiting_eq, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1852
      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
  1853
    qed
4763aa246dbd Original files overwrite by 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
  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
  1855
    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
  1856
    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
  1857
    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
  1858
      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
  1859
      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
  1860
        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
  1861
      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
  1862
      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
  1863
      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
  1864
        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
  1865
        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
  1866
        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
  1867
        by (unfold h_n.waiting_set_eq h_n.holding_set_eq 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
  1868
             fold waiting_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
  1869
      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
  1870
        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
  1871
        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
  1872
        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
  1873
         by (unfold h_n.waiting_set_eq h_n.holding_set_eq 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
  1874
             fold holding_eq, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1875
      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
  1876
    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
  1877
      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
  1878
      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
  1879
        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
  1880
      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
  1881
      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
  1882
      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
  1883
        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
  1884
        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
  1885
        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
  1886
        by (unfold h_e.waiting_set_eq h_e.holding_set_eq 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
  1887
             fold holding_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
  1888
      qed
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1889
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1890
  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
  1891
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
  1892
  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
  1893
  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
  1894
  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
  1895
  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
  1896
    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
  1897
    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
  1898
        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
  1899
    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
  1900
    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
  1901
                            \<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
  1902
          (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
  1903
      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
  1904
   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
  1905
   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
  1906
      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
  1907
      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
  1908
      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
  1909
        by (unfold s_RAG_def, fold holding_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
  1910
   next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  1911
    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
  1912
        (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
  1913
    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
  1914
    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
  1915
    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
  1916
      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
  1917
      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
  1918
      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
  1919
      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
  1920
      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
  1921
        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
  1922
        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
  1923
        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
  1924
      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
  1925
        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
  1926
        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
  1927
        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
  1928
          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
  1929
          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
  1930
          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
  1931
        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
  1932
          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
  1933
          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
  1934
          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
  1935
        qed
4763aa246dbd Original files overwrite by 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
      thus ?thesis using 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
  1938
        by (unfold s_RAG_def, fold waiting_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
  1939
    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
  1940
      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
  1941
      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
  1942
      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
  1943
      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
  1944
      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
  1945
        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
  1946
        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
  1947
        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
  1948
      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
  1949
        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
  1950
        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
  1951
        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
      thus ?thesis using 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
  1954
        by (unfold s_RAG_def, fold holding_eq, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1955
    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
  1956
   qed
4763aa246dbd Original files overwrite by 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
 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
  1958
   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
  1959
   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
  1960
        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
  1961
   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
  1962
   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
  1963
      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
  1964
   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
  1965
   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
  1966
   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
  1967
    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
  1968
    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
  1969
    show ?thesis using 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
  1970
      by (unfold s_RAG_def, fold waiting_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
  1971
   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
  1972
    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
  1973
    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
  1974
    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
  1975
    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
  1976
    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
  1977
      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
  1978
      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
  1979
      show ?thesis using 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
  1980
        by (unfold s_RAG_def, fold holding_eq, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1981
    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
  1982
      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
  1983
      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
  1984
      show ?thesis using 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
  1985
        by (unfold s_RAG_def, fold holding_eq, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1986
    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
  1987
   qed
4763aa246dbd Original files overwrite by 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
 qed
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1989
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1990
92
4763aa246dbd Original files overwrite by 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
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
  1992
4763aa246dbd Original files overwrite by 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
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
  1994
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
  1995
4763aa246dbd Original files overwrite by 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
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
  1997
  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
  1998
  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
  1999
  using assms
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  2000
    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
  2001
        in_set_butlastD s_waiting_def wq_def wq_es_cs wq_neq_simp)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2002
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2003
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
  2004
  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
  2005
  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
  2006
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
  2007
  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
  2008
  hence "wq (e#s) cs' = wq s cs'" by simp
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  2009
  with assms show ?thesis unfolding holding_raw_def holding_eq 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
  2010
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
  2011
  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
  2012
  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
  2013
  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
  2014
    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
  2015
  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
  2016
    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
  2017
  thus ?thesis
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  2018
    by (simp add: holding_raw_def holding_eq) 
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2019
qed
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2020
end 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2021
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2022
lemma (in valid_trace_p) th_not_waiting: "\<not> waiting s th c"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2023
proof -
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2024
  have "th \<in> readys s"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  2025
    using running_ready running_th_s by blast 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2026
  thus ?thesis
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2027
    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
  2028
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  2031
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
  2032
4763aa246dbd Original files overwrite by 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
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
  2034
  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
  2035
4763aa246dbd Original files overwrite by 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
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
  2037
  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
  2038
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
  2039
  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
  2040
  have "th \<in> set (wq (e#s) cs)" "th = hd (wq (e#s) cs)" by auto
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  2041
  thus ?thesis unfolding holding_raw_def holding_eq 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
  2042
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
lemma RAG_edge: "(Cs cs, Th th) \<in> 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
  2045
  by (unfold s_RAG_def, fold holding_eq, insert holding_es_th_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
  2046
4763aa246dbd Original files overwrite by 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
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
  2048
  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
  2049
  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
  2050
  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
  2051
  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
  2052
      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
  2053
  
4763aa246dbd Original files overwrite by 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
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
  2055
  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
  2056
  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
  2057
    | "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
  2058
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
  2059
  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
  2060
  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
  2061
  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
  2062
  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
  2063
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
  2064
  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
  2065
  have "holding s th' cs'" using assms
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  2066
    using False unfolding holding_raw_def holding_eq 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
  2067
  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
  2068
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  2071
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
  2072
  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
  2073
  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
  2074
  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
  2075
  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
  2076
    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
  2077
    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
  2078
    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
  2079
    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
  2080
      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
  2081
      thus ?thesis using 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
  2082
        by (unfold s_RAG_def, fold waiting_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
  2083
    qed
4763aa246dbd Original files overwrite by 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
  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
  2085
    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
  2086
    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
  2087
    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
  2088
    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
  2089
      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
  2090
      with holding(1,2)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2091
      show ?thesis by (unfold s_RAG_def, fold holding_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
  2092
    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
  2093
      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
  2094
      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
  2095
    qed
4763aa246dbd Original files overwrite by 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
  qed
4763aa246dbd Original files overwrite by 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
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
  2098
  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
  2099
  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
  2100
  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
  2101
  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
  2102
  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
  2103
    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
  2104
    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
  2105
    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
  2106
      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
  2107
      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
  2108
      show ?thesis using 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
  2109
         by (unfold s_RAG_def, fold waiting_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
  2110
    next
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2111
      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
  2112
      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
  2113
      show ?thesis using 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
  2114
         by (unfold s_RAG_def, fold holding_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
  2115
    qed
4763aa246dbd Original files overwrite by 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
  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
  2117
    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
  2118
    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
  2119
    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
  2120
      by (unfold s_RAG_def, fold holding_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
  2121
  qed
4763aa246dbd Original files overwrite by 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
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  2125
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2126
context valid_trace_p_w
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2127
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2128
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2129
lemma wq_s_cs: "wq s cs = holder#waiters"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2130
    by (simp add: holder_def waiters_def wne)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2131
    
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2132
lemma wq_es_cs': "wq (e#s) cs = holder#waiters@[th]"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2133
  by (simp add: wq_es_cs wq_s_cs)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2134
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2135
lemma waiting_es_th_cs: "waiting (e#s) th cs"
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  2136
  using th_not_in_wq waiting_eq wq_es_cs' wq_s_cs
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  2137
  by (simp add: s_waiting_def wq_def wq_es_cs)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2138
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2139
lemma RAG_edge: "(Th th, Cs cs) \<in> RAG (e#s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2140
   by (unfold s_RAG_def, fold waiting_eq, insert waiting_es_th_cs, auto)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2141
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2142
lemma holding_esE:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2143
  assumes "holding (e#s) th' cs'"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2144
  obtains "holding s th' cs'"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2145
  using assms 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2146
proof(cases "cs' = cs")
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2147
  case False
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2148
  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
  2149
  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
  2150
    using s_holding_def wq_def by auto
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2151
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2152
  case True
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2153
  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
  2154
    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
  2155
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2156
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2157
lemma waiting_esE:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2158
  assumes "waiting (e#s) th' cs'"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2159
  obtains "th' \<noteq> th" "waiting s th' cs'"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2160
     |  "th' = th" "cs' = cs"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2161
proof(cases "waiting s th' cs'")
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2162
  case True
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2163
  have "th' \<noteq> th"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2164
  proof
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2165
    assume otherwise: "th' = th"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2166
    from True[unfolded this]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2167
    show False by (simp add: th_not_waiting)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2168
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2169
  from that(1)[OF this True] show ?thesis .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2170
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2171
  case False
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2172
  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
  2173
      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
  2174
          s_waiting_def set_rotate1 wne wq_def wq_es_cs wq_neq_simp)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2175
  with that(2) show ?thesis by metis
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2176
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2177
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2178
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
  2179
proof(rule rel_eqI)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2180
  fix n1 n2
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2181
  assume "(n1, n2) \<in> ?L"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2182
  thus "(n1, n2) \<in> ?R" 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2183
  proof(cases rule:in_RAG_E)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2184
    case (waiting th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2185
    from this(3)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2186
    show ?thesis
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2187
    proof(cases rule:waiting_esE)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2188
      case 1
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2189
      thus ?thesis using waiting(1,2)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2190
        by (unfold s_RAG_def, fold waiting_eq, auto)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2191
    next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2192
      case 2
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2193
      thus ?thesis using waiting(1,2) by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2194
    qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2195
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2196
    case (holding th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2197
    from this(3)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2198
    show ?thesis
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2199
    proof(cases rule:holding_esE)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2200
      case 1
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2201
      with holding(1,2)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2202
      show ?thesis by (unfold s_RAG_def, fold holding_eq, auto)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2203
    qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2204
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2205
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2206
  fix n1 n2
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2207
  assume "(n1, n2) \<in> ?R"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2208
  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
  2209
  thus "(n1, n2) \<in> ?L"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2210
  proof
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2211
    assume "(n1, n2) \<in> RAG s"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2212
    thus ?thesis
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2213
    proof(cases rule:in_RAG_E)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2214
      case (waiting th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2215
      from waiting_kept[OF this(3)]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2216
      show ?thesis using waiting(1,2)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2217
         by (unfold s_RAG_def, fold waiting_eq, auto)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2218
    next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2219
      case (holding th' cs')
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2220
      from holding_kept[OF this(3)]
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2221
      show ?thesis using holding(1,2)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2222
         by (unfold s_RAG_def, fold holding_eq, auto)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2223
    qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2224
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2225
    assume "n1 = Th th \<and> n2 = Cs cs"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2226
    thus ?thesis using RAG_edge by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2227
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2228
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2229
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2230
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2231
92
4763aa246dbd Original files overwrite by 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
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
  2233
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
  2234
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2235
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
  2236
                                                  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
  2237
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
  2238
  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
  2239
  interpret vt_p: valid_trace_p_h using True
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  2240
    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
  2241
  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
  2242
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
  2243
  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
  2244
  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
  2245
    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
  2246
  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
  2247
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2248
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2249
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
  2250
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
  2251
subsection {* RAG is finite *}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2252
110
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2253
context valid_trace_v
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2254
begin
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2255
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2256
lemma 
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2257
  finite_RAG_kept:
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2258
  assumes "finite (RAG s)"
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2259
  shows "finite (RAG (e#s))"
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2260
proof(cases "rest = []")
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2261
  case True
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2262
  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
  2263
    by (unfold_locales, simp)
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2264
  show ?thesis using assms
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2265
    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
  2266
next
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2267
  case False
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2268
  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
  2269
    by (unfold_locales, simp)
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2270
  show ?thesis using assms
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2271
    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
  2272
qed
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2273
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2274
end
4782d82c3ae9 About to change the proof of waiting_unique_pre and waiting_unqie.
zhangx
parents: 109
diff changeset
  2275
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2276
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2277
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2278
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2279
lemma finite_RAG:
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2280
  shows "finite (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2281
proof(induct rule:ind)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2282
  case Nil
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2283
  show ?case 
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  2284
  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
  2285
                   holding_raw_def wq_def acyclic_def)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2286
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2287
  case (Cons s e)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2288
  interpret vt_e: valid_trace_e s e using Cons by simp
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2289
  show ?case
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2290
  proof(cases e)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2291
    case (Create th prio)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2292
    interpret vt: valid_trace_create s e th prio using Create
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2293
      by (unfold_locales, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2294
    show ?thesis using Cons by simp
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2295
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2296
    case (Exit th)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2297
    interpret vt: valid_trace_exit s e th using Exit
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2298
      by (unfold_locales, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2299
    show ?thesis using Cons by simp
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2300
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2301
    case (P th cs)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2302
    interpret vt: valid_trace_p s e th cs using P
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2303
      by (unfold_locales, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2304
    show ?thesis using Cons using vt.RAG_es by auto 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2305
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2306
    case (V th cs)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2307
    interpret vt: valid_trace_v s e th cs using V
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2308
      by (unfold_locales, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2309
    show ?thesis using Cons by (simp add: vt.finite_RAG_kept) 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2310
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2311
    case (Set th prio)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2312
    interpret vt: valid_trace_set s e th prio using Set
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2313
      by (unfold_locales, simp)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2314
    show ?thesis using Cons by simp
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2315
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2316
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2317
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2318
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2319
subsection {* Uniqueness of waiting *}
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2320
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2321
text {*
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2322
  {\em Uniqueness of waiting} means that 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2323
  a thread can only be blocked on one resource.
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2324
  This property is needed in order to prove that @{term RAG}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2325
  is acyclic. Therefore, we need to prove it first in the following
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2326
  lemma @{text "waiting_unqiue"}, all lemmas before it are auxiliary. 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2327
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2328
  The property is expressed by the following predicate over system 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2329
  state (or event trace), which is also named @{text "waiting_unqiue"}.
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2330
*}
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2331
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2332
definition 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2333
  "waiting_unique (ss::state) = 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2334
     (\<forall> th cs1 cs2. waiting ss th cs1 \<longrightarrow> 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2335
                    waiting ss th cs2 \<longrightarrow> cs1 = cs2)"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2336
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2337
text {*
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2338
  We are going to show (in the 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2339
  lemma named @{text waiting_unique}) that
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2340
  this property holds on any valid trace (or system state).
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2341
*}
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2342
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2343
text {*
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2344
  As a first step to prove lemma @{text "waiting_unqiue"}, 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2345
  we need to understand how 
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2346
  a thread is get blocked. 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2347
  We show in the following lemmas 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2348
  (all named @{text "waiting_inv"}) that 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2349
  @{term P}-operation is the only cause. 
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2350
*}
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2351
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2352
context valid_trace_create
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2353
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2354
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2355
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2356
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2357
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2358
  using assms 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2359
  by (unfold s_waiting_def, fold wq_def, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2360
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2361
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2362
context valid_trace_set
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2363
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2364
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2365
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2366
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2367
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2368
  using assms 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2369
  by (unfold s_waiting_def, fold wq_def, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2370
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2371
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2372
context valid_trace_exit
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2373
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2374
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2375
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2376
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2377
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2378
  using assms 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2379
  by (unfold s_waiting_def, fold wq_def, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2380
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2381
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2382
context valid_trace_p
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2383
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2384
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2385
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2386
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2387
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2388
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2389
proof(cases "cs' = cs")
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2390
  case True
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2391
  moreover have "th' = th"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2392
  proof(rule ccontr)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2393
    assume otherwise: "th' \<noteq> th"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2394
    have "waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2395
    proof -
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2396
      from assms(2)[unfolded True s_waiting_def, 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2397
              folded wq_def, unfolded wq_es_cs]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2398
      have h: "th' \<in> set (wq s cs @ [th])"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2399
              "th' \<noteq> hd (wq s cs @ [th])" by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2400
      from h(1) and otherwise
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2401
      have "th' \<in> set (wq s cs)" by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2402
      hence "wq s cs \<noteq> []" by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2403
      hence "hd (wq s cs @ [th]) = hd (wq s cs)" by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2404
      with h otherwise
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2405
      have "waiting s th' cs" 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2406
        by (unfold s_waiting_def, fold wq_def, auto)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2407
      from this[folded True] show ?thesis .
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2408
    qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2409
    with assms(1) show False by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2410
  qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2411
  ultimately show ?thesis using is_p by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2412
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2413
  case False
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2414
  hence "wq (e#s) cs' = wq s cs'" by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2415
  from assms[unfolded s_waiting_def, folded wq_def, 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2416
            unfolded this]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2417
  show ?thesis by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2418
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2419
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2420
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2421
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2422
context valid_trace_v_n
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2423
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2424
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2425
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2426
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2427
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2428
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2429
proof -
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2430
  from assms(2)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2431
  show ?thesis
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2432
  by (cases rule:waiting_esE, insert assms, auto)
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2433
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2434
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2435
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2436
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2437
context valid_trace_v_e
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2438
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2439
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2440
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2441
  assumes "\<not> waiting s th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2442
  and "waiting (e#s) th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2443
  shows "e = P th' cs'"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2444
proof -
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2445
  from assms(2)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2446
  show ?thesis
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2447
  by (cases rule:waiting_esE, insert assms, auto)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2448
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2449
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2450
end
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2451
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2452
context valid_trace_e
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2453
begin
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2454
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2455
lemma waiting_inv:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2456
  assumes "\<not> waiting s th cs"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2457
  and "waiting (e#s) th cs"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2458
  shows "e = P th cs"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2459
proof(cases e)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2460
  case (Create th' prio')
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2461
  then interpret vt: valid_trace_create s e th' prio'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2462
    by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2463
  show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2464
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2465
  case (Exit th')
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2466
  then interpret vt: valid_trace_exit s e th'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2467
    by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2468
  show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2469
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2470
  case (Set th' prio')
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2471
  then interpret vt: valid_trace_set s e th' prio'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2472
    by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2473
  show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2474
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2475
  case (P th' cs')
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2476
  then interpret vt: valid_trace_p s e th' cs'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2477
    by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2478
  show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2479
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2480
  case (V th' cs')
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2481
  then interpret vt_e: valid_trace_v s e th' cs'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2482
    by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2483
  show ?thesis
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2484
  proof(cases "vt_e.rest = []")
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2485
    case True
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2486
    then interpret vt: valid_trace_v_e s e th' cs'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2487
      by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2488
    show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2489
  next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2490
    case False
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2491
    then interpret vt: valid_trace_v_n s e th' cs'
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2492
      by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2493
    show ?thesis using vt.waiting_inv[OF assms] by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2494
  qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2495
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2496
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2497
text {* 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2498
  Now, with @{thm waiting_inv} in place, the following lemma
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2499
  shows the uniqueness of waiting is kept by every operation 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2500
  in the PIP protocol. This lemma constitutes the main part
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2501
  in the proof of lemma @{text "waiting_unique"}.
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2502
*}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2503
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2504
lemma waiting_unique_kept:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2505
  assumes "waiting_unique s"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2506
  shows "waiting_unique (e#s)"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2507
proof -
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2508
  note h = assms[unfolded waiting_unique_def, rule_format]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2509
  { fix th cs1 cs2
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2510
    assume w1: "waiting (e#s) th cs1"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2511
       and w2: "waiting (e#s) th cs2"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2512
    have "cs1 = cs2"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2513
    proof(rule ccontr)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2514
      assume otherwise: "cs1 \<noteq> cs2"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2515
      show False
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2516
      proof(cases "waiting s th cs1")
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2517
        case True
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2518
        from h[OF this] and otherwise
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2519
        have "\<not> waiting s th cs2" by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2520
        from waiting_inv[OF this w2]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2521
        have "e = P th cs2" .
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2522
        then interpret vt: valid_trace_p  s e th cs2
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2523
          by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2524
        from vt.th_not_waiting and True
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2525
        show ?thesis by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2526
      next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2527
        case False 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2528
        from waiting_inv[OF this w1]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2529
        have "e = P th cs1" .
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2530
        then interpret vt: valid_trace_p s e th cs1
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2531
          by (unfold_locales, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2532
        have "wq (e # s) cs2 = wq s cs2" 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2533
          using otherwise by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2534
        from w2[unfolded s_waiting_def, folded wq_def, 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2535
                  unfolded this]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2536
        have "waiting s th cs2" 
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
        thus ?thesis by (simp add: vt.th_not_waiting) 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2539
      qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2540
    qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2541
  } thus ?thesis by (unfold waiting_unique_def, auto)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2542
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2543
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2544
end
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2545
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2546
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2547
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2548
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2549
text {*
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2550
  With @{thm valid_trace_e.waiting_unique_kept} in place,
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2551
  the proof of the following lemma @{text "waiting_unique"} 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2552
  needs only a very simple induction.
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2553
*}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2554
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2555
lemma waiting_unique 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2556
  [unfolded waiting_unique_def, rule_format]:
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2557
  shows "waiting_unique s"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2558
proof(induct rule:ind)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2559
  case Nil
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2560
  show ?case 
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2561
    by (unfold waiting_unique_def s_waiting_def, simp)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2562
next
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2563
  case (Cons s e)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2564
  then interpret vt: valid_trace_e s e by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2565
  show ?case using Cons(2) vt.waiting_unique_kept
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2566
    by simp
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2567
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2568
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2569
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2570
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2571
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  2572
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
  2573
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2574
text {*
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2575
  To prove that @{term RAG} is acyclic, we need to show the acyclic property 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2576
  is preserved by all system operations. There are only two non-trivial cases, 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2577
  the @{term P} and @{term V} operation, where are treated in the following
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2578
  locales, under the name @{text "acylic_RAG_kept"}:
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2579
*}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2580
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2581
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
  2582
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
  2583
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2584
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
  2585
  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
  2586
  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
  2587
  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
  2588
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
  2589
  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
  2590
      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
  2591
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2592
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2593
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
  2594
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2595
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
  2596
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
  2597
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2598
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
  2599
  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
  2600
  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
  2601
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2602
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
  2603
  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
  2604
  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
  2605
  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
  2606
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
  2607
  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
  2608
                 {(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
  2609
  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
  2610
    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
  2611
    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
  2612
       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
  2613
    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
  2614
    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
  2615
      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
  2616
      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
  2617
        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
  2618
      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
  2619
      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
  2620
                          "(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
  2621
        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
  2622
      from this(2) have "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
  2623
        by (unfold s_RAG_def, fold waiting_eq, auto)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2624
      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
  2625
      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
  2626
      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
  2627
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2628
    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
  2629
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2630
  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
  2631
    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
  2632
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2633
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2634
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
  2635
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2636
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
  2637
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
  2638
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2639
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
  2640
  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
  2641
  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
  2642
  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
  2643
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
  2644
  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
  2645
  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
  2646
    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
  2647
    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
  2648
       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
  2649
    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
  2650
    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
  2651
      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
  2652
      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
  2653
        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
  2654
      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
  2655
      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
  2656
        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
  2657
      hence "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
  2658
        by (unfold s_RAG_def, fold waiting_eq, auto)
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  2659
      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
  2660
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2661
    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
  2662
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2663
  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
  2664
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2665
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2666
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
  2667
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2668
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
  2669
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
  2670
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2671
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
  2672
  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
  2673
  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
  2674
  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
  2675
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
  2676
  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
  2677
  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
  2678
    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
  2679
    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
  2680
       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
  2681
    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
  2682
    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
  2683
      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
  2684
      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
  2685
      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
  2686
      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
  2687
        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
  2688
        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
  2689
            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
  2690
        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
  2691
      qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2692
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2693
    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
  2694
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2695
  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
  2696
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2697
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2698
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
  2699
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
  2700
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  2701
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
  2702
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2703
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
  2704
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
  2705
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2706
text {* 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2707
  With these @{text "acylic_RAG_kept"}-lemmas proved, 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2708
  the proof of the following @{text "acyclic_RAG"} is
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2709
  straight forward. 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2710
 *}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2711
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2712
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
  2713
  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
  2714
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
  2715
  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
  2716
  show ?case 
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  2717
  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
  2718
                   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
  2719
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
  2720
  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
  2721
  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
  2722
  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
  2723
  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
  2724
    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
  2725
    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
  2726
      by (unfold_locales, simp)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2727
    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
  2728
  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
  2729
    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
  2730
    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
  2731
      by (unfold_locales, simp)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2732
    show ?thesis using Cons by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2733
  next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2734
    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
  2735
    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
  2736
      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
  2737
    show ?thesis
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2738
    proof(cases "wq s cs = []")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2739
      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
  2740
      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
  2741
        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
  2742
      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
  2743
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2744
      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
  2745
      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
  2746
        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
  2747
      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
  2748
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2749
  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
  2750
    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
  2751
    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
  2752
      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
  2753
    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
  2754
    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
  2755
      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
  2756
      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
  2757
        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
  2758
      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
  2759
    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
  2760
      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
  2761
      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
  2762
        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
  2763
      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
  2764
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2765
  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
  2766
    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
  2767
    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
  2768
      by (unfold_locales, simp)
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2769
    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
  2770
  qed
4763aa246dbd Original files overwrite by 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
qed
4763aa246dbd Original files overwrite by 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
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2773
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2774
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
  2775
subsection {* RAG is single-valued *}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2776
112
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2777
text {*
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2778
  The proof that @{term RAG} is single-valued makes use of 
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2779
  @{text "unique_waiting"} and @{thm held_unique} and the
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2780
  proof itself is very simple:
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2781
*}
b3795b1f030b Small improvements.
zhangx
parents: 111
diff changeset
  2782
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2783
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2784
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2785
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2786
lemma unique_RAG: "\<lbrakk>(n, n1) \<in> RAG s; (n, n2) \<in> RAG s\<rbrakk> \<Longrightarrow> n1 = n2"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2787
  apply(unfold s_RAG_def, auto, fold waiting_eq holding_eq)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2788
  by(auto elim:waiting_unique held_unique)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2789
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2790
lemma sgv_RAG: "single_valued (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2791
  using unique_RAG by (auto simp:single_valued_def)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2792
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2793
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2794
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
  2795
subsection {* RAG is well-founded *}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2796
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2797
text {*
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2798
  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
  2799
  its converse @{term "(RAG s)^-1"} are well-founded.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2800
  The proof is very simple with the help of
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2801
  already proved fact that @{term RAG} is finite.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2802
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2803
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2804
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2805
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2806
92
4763aa246dbd Original files overwrite by 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
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
  2808
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
  2809
  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
  2810
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
  2811
  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
  2812
qed
4763aa246dbd Original files overwrite by 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
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2814
lemma wf_RAG_converse: 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2815
  shows "wf ((RAG s)^-1)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2816
proof(rule finite_acyclic_wf_converse)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2817
  from finite_RAG 
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2818
  show "finite (RAG s)" .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2819
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2820
  from acyclic_RAG
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2821
  show "acyclic (RAG s)" .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2822
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2823
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2824
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2825
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
  2826
subsection {* RAG forms a finite-branching forest (or tree) *}
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2827
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2828
text {*
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2829
  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
  2830
  it is easy to show.
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2831
*}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2832
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2833
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2834
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2835
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2836
lemma rtree_RAG: "rtree (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2837
  using sgv_RAG acyclic_RAG
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2838
  by (unfold rtree_def rtree_axioms_def sgv_def, auto)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2839
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2840
end
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2841
121
c80a08ff2a85 added ? to PIPBasics
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  2842
sublocale valid_trace < rtree_RAG?: rtree "RAG s"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2843
  using rtree_RAG .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2844
121
c80a08ff2a85 added ? to PIPBasics
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  2845
sublocale valid_trace < fsbtRAGs?: fsubtree "RAG s"
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2846
proof -
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2847
  show "fsubtree (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2848
  proof(intro_locales)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2849
    show "fbranch (RAG s)" using finite_fbranchI[OF finite_RAG] .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2850
  next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2851
    show "fsubtree_axioms (RAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2852
    proof(unfold fsubtree_axioms_def)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2853
      from wf_RAG show "wf (RAG s)" .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2854
    qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2855
  qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2856
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2857
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
  2858
subsection {* Derived properties for sub-graphs of RAG *}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2859
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2860
context valid_trace
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2861
begin
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2862
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2863
lemma acyclic_tRAG: "acyclic (tRAG s)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2864
proof(unfold tRAG_def, rule acyclic_compose)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2865
  show "acyclic (RAG s)" using acyclic_RAG .
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2866
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2867
  show "wRAG s \<subseteq> RAG s" unfolding RAG_split by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2868
next
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2869
  show "hRAG s \<subseteq> RAG s" unfolding RAG_split by auto
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2870
qed
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2871
92
4763aa246dbd Original files overwrite by 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
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
  2873
  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
  2874
  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
  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
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
  2877
  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
  2878
  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
  2879
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2880
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
  2881
  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
  2882
              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
  2883
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2884
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
  2885
113
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2886
text {*
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2887
  It can be shown that @{term tRAG} is also a 
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2888
  finite-branch relational tree (or forest):  
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2889
*}
ce85c3c4e5bf More improvements in PIPBasics.thy and Implemenation.thy.
zhangx
parents: 112
diff changeset
  2890
121
c80a08ff2a85 added ? to PIPBasics
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  2891
sublocale valid_trace < rtree_s?: rtree "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
  2892
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
  2893
  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
  2894
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
  2895
  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
  2896
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2897
121
c80a08ff2a85 added ? to PIPBasics
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  2898
sublocale valid_trace < fsbttRAGs?: fsubtree "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
  2899
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
  2900
  have "fsubtree (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
  2901
  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
  2902
    have "fbranch (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
  2903
    proof(unfold tRAG_def, rule fbranch_compose)
4763aa246dbd Original files overwrite by 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
        show "fbranch (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
  2905
        proof(rule finite_fbranchI)
4763aa246dbd Original files overwrite by 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
           from finite_RAG show "finite (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
  2907
           by (unfold RAG_split, auto)
4763aa246dbd Original files overwrite by 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
        qed
4763aa246dbd Original files overwrite by 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
    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
  2910
        show "fbranch (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
  2911
        proof(rule finite_fbranchI)
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2912
           from finite_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
  2913
           show "finite (hRAG s)" by (unfold RAG_split, auto)
4763aa246dbd Original files overwrite by 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
        qed
4763aa246dbd Original files overwrite by 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
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2916
    moreover have "wf (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
  2917
    proof(rule wf_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
  2918
      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
  2919
        by (fold wf_comp_self, simp)
4763aa246dbd Original files overwrite by 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
    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
  2921
      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
  2922
        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
  2923
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2924
    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
  2925
      by (unfold fsubtree_def fsubtree_axioms_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
  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
  from this[folded tRAG_def] show "fsubtree (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
  2928
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  2929
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  2930
section {* Chain to readys *}
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2931
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  2932
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
  2933
  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
  2934
  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
  2935
  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
  2936
  between threads is established.
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  2937
*}
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  2938
92
4763aa246dbd Original files overwrite by 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
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
  2940
begin
53
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  2941
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  2942
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
  2943
  The first lemma is technical, which says out of any node 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  2944
  in the domain 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
  2945
  (no matter whether it is thread node or resource node)  
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  2946
  there is a path leading to a ready thread.
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  2947
*}
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  2948
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2949
lemma chain_building:
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2950
  assumes "node \<in> Domain (RAG s)"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2951
  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
  2952
proof -
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2953
  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
  2954
  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
  2955
  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
  2956
  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
  2957
  proof(cases b)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2958
    case (Cs cs)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2959
    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
  2960
    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
  2961
    from tranclE[OF this]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2962
    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
  2963
    from this[unfolded Cs]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2964
    obtain th1 where "waiting s th1 cs"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2965
      by (unfold s_RAG_def, fold waiting_eq, auto)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2966
    from waiting_holding[OF this]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2967
    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
  2968
    hence "(Cs cs, Th th2) \<in> RAG s"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2969
      by (unfold s_RAG_def, fold holding_eq, auto)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2970
    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
  2971
    have False by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2972
    thus ?thesis by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2973
  qed auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2974
  have "th' \<in> readys s" 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2975
  proof -
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2976
    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
  2977
    have "\<forall>cs. \<not> waiting s th' cs"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2978
      by (unfold s_RAG_def, fold waiting_eq, auto)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2979
    moreover have "th' \<in> threads s"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2980
    proof(rule rg_RAG_threads)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2981
      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
  2982
      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
  2983
      thus "Th th' \<in> Range (RAG s)" by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2984
    qed
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2985
    ultimately show ?thesis by (auto simp:readys_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2986
  qed
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  2987
  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
  2988
    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
  2989
  ultimately show ?thesis using that by metis
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2990
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2991
53
8142e80f5d58 Finished comments on PrioGDef.thy
xingyuan zhang <xingyuanzhang@126.com>
parents: 44
diff changeset
  2992
text {* \noindent
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  2993
  The following lemma says for any living thread, 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  2994
  either it is ready or there is a path in @{term RAG}
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  2995
  leading from it to a ready thread. The lemma is proved easily
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  2996
  by instantiating @{thm "chain_building"}.
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  2997
*}                    
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2998
lemma th_chain_to_ready:
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  2999
  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
  3000
  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
  3001
proof(cases "th \<in> readys s")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3002
  case True
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3003
  thus ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3004
next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3005
  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
  3006
  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
  3007
    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
  3008
 Domain_def)
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  3009
  from chain_building [rule_format, OF this]
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3010
  show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3011
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3012
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3013
text {*
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3014
  The following lemma is a technical one to show 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3015
  that the set of threads in the subtree of any thread
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3016
  is finite.
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3017
*}
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3018
lemma finite_subtree_threads:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3019
    "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
  3020
proof -
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3021
  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
  3022
        by (auto, insert image_iff, fastforce)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3023
  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
  3024
        (is "finite ?B")
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3025
  proof -
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3026
     have "?B = (subtree (RAG s) (Th th)) \<inter> {Th th' | th'. True}"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3027
      by auto
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3028
     moreover have "... \<subseteq> (subtree (RAG s) (Th th))" by auto
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3029
     moreover have "finite ..." by (simp add: fsbtRAGs.finite_subtree) 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3030
     ultimately show ?thesis by auto
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3031
  qed
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3032
  ultimately show ?thesis by auto
104
43482ab31341 A fake merge. Used to revert to 98
zhangx
parents: 103 97
diff changeset
  3033
qed
43482ab31341 A fake merge. Used to revert to 98
zhangx
parents: 103 97
diff changeset
  3034
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3035
text {*
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3036
  The following two lemmas shows there is at most one running thread 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3037
  in the system.
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3038
*}
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3039
lemma running_unique:
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3040
  assumes running_1: "th1 \<in> running s"
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3041
  and running_2: "th2 \<in> running s"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3042
  shows "th1 = th2"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3043
proof -
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3044
  from running_1 and running_2 have "cp s th1 = cp s th2"
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3045
    unfolding running_def by auto
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3046
  from this[unfolded cp_alt_def]
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3047
  have eq_max: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3048
    "Max (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th1)}) =
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3049
     Max (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th2)})" 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3050
        (is "Max ?L = Max ?R") .
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3051
  have "Max ?L \<in> ?L"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3052
  proof(rule Max_in)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3053
    show "finite ?L" by (simp add: finite_subtree_threads) 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3054
  next
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3055
    show "?L \<noteq> {}" using subtree_def by fastforce 
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3056
  qed
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3057
  then obtain th1' where 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3058
    h_1: "Th th1' \<in> subtree (RAG s) (Th th1)" "the_preced s th1' = Max ?L"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3059
    by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3060
  have "Max ?R \<in> ?R"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3061
  proof(rule Max_in)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3062
    show "finite ?R" by (simp add: finite_subtree_threads)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3063
  next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3064
    show "?R \<noteq> {}" using subtree_def by fastforce 
92
4763aa246dbd Original files overwrite by 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
  qed
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3066
  then obtain th2' where 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3067
    h_2: "Th th2' \<in> subtree (RAG s) (Th th2)" "the_preced s th2' = Max ?R"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3068
    by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3069
  have "th1' = th2'"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3070
  proof(rule preced_unique)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3071
    from h_1(1)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3072
    show "th1' \<in> threads s"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3073
    proof(cases rule:subtreeE)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3074
      case 1
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3075
      hence "th1' = th1" by simp
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3076
      with running_1 show ?thesis by (auto simp:running_def readys_def)
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3077
    next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3078
      case 2
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3079
      from this(2)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3080
      have "(Th th1', Th th1) \<in> (RAG s)^+" by (auto simp:ancestors_def)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3081
      from tranclD[OF this]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3082
      have "(Th th1') \<in> Domain (RAG s)" by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3083
      from dm_RAG_threads[OF this] show ?thesis .
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3084
    qed
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3085
  next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3086
    from h_2(1)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3087
    show "th2' \<in> threads s"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3088
    proof(cases rule:subtreeE)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3089
      case 1
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3090
      hence "th2' = th2" by simp
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3091
      with running_2 show ?thesis by (auto simp:running_def readys_def)
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3092
    next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3093
      case 2
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3094
      from this(2)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3095
      have "(Th th2', Th th2) \<in> (RAG s)^+" by (auto simp:ancestors_def)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3096
      from tranclD[OF this]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3097
      have "(Th th2') \<in> Domain (RAG s)" by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3098
      from dm_RAG_threads[OF this] show ?thesis .
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3099
    qed
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3100
  next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3101
    have "the_preced s th1' = the_preced s th2'" 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3102
     using eq_max h_1(2) h_2(2) by metis
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3103
    thus "preced th1' s = preced th2' s" by (simp add:the_preced_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3104
  qed
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3105
  from h_1(1)[unfolded this]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3106
  have star1: "(Th th2', Th th1) \<in> (RAG s)^*" by (auto simp:subtree_def)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3107
  from h_2(1)[unfolded this]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3108
  have star2: "(Th th2', Th th2) \<in> (RAG s)^*" by (auto simp:subtree_def)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3109
  from star_rpath[OF star1] obtain xs1 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3110
    where rp1: "rpath (RAG s) (Th th2') xs1 (Th th1)"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3111
    by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3112
  from star_rpath[OF star2] obtain xs2 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3113
    where rp2: "rpath (RAG s) (Th th2') xs2 (Th th2)"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3114
    by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3115
  from rp1 rp2
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3116
  show ?thesis
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3117
  proof(cases)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3118
    case (less_1 xs')
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3119
    moreover have "xs' = []"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3120
    proof(rule ccontr)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3121
      assume otherwise: "xs' \<noteq> []"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3122
      from rpath_plus[OF less_1(3) this]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3123
      have "(Th th1, Th th2) \<in> (RAG s)\<^sup>+" .
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3124
      from tranclD[OF this]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3125
      obtain cs where "waiting s th1 cs"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3126
        by (unfold s_RAG_def, fold waiting_eq, auto)
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3127
      with running_1 show False
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3128
        by (unfold running_def readys_def, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3129
    qed
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3130
    ultimately have "xs2 = xs1" by simp
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3131
    from rpath_dest_eq[OF rp1 rp2[unfolded this]]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3132
    show ?thesis 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
  3133
  next
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3134
    case (less_2 xs')
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3135
    moreover have "xs' = []"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3136
    proof(rule ccontr)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3137
      assume otherwise: "xs' \<noteq> []"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3138
      from rpath_plus[OF less_2(3) this]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3139
      have "(Th th2, Th th1) \<in> (RAG s)\<^sup>+" .
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3140
      from tranclD[OF this]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3141
      obtain cs where "waiting s th2 cs"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3142
        by (unfold s_RAG_def, fold waiting_eq, auto)
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3143
      with running_2 show False
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3144
        by (unfold running_def readys_def, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3145
    qed
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3146
    ultimately have "xs2 = xs1" by simp
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3147
    from rpath_dest_eq[OF rp1 rp2[unfolded this]]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3148
    show ?thesis by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3149
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3150
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3151
129
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  3152
lemma card_running: 
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  3153
  shows "card (running s) \<le> 1"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3154
proof(cases "running s = {}")
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3155
  case True
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3156
  thus ?thesis by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3157
next
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3158
  case False
129
e3cf792db636 removed some files to attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 128
diff changeset
  3159
  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
  3160
  with running_unique
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3161
  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
  3162
  thus ?thesis by auto
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  3163
qed
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  3164
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3165
text {*
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3166
  The following two lemmas show that the set of living threads
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3167
  in the system can be partitioned into subtrees of those 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3168
  threads in the @{term readys} set. The first lemma
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3169
  @{text threads_alt_def} shows the union of 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3170
  these subtrees equals to the set of living threads
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3171
  and the second lemma @{text "readys_subtree_disjoint"} shows 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3172
  subtrees of different threads in @{term readys}-set
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3173
  are disjoint.
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3174
*}
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3175
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3176
lemma threads_alt_def:
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3177
  "(threads s) = (\<Union> th \<in> readys s. {th'. Th th' \<in> subtree (RAG s) (Th th)})"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3178
    (is "?L = ?R")
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3179
proof -
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3180
  { fix th1
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3181
    assume "th1 \<in> ?L"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3182
    from th_chain_to_ready[OF this]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3183
    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
  3184
    hence "th1 \<in> ?R" by (auto simp:subtree_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3185
  } moreover 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3186
  { fix th'
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3187
    assume "th' \<in> ?R"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3188
    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
  3189
      by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3190
    from this(2)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3191
    have "th' \<in> ?L" 
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3192
    proof(cases rule:subtreeE)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3193
      case 1
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3194
      with h(1) show ?thesis by (auto simp:readys_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3195
    next
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3196
      case 2
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3197
      from tranclD[OF this(2)[unfolded ancestors_def, simplified]]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3198
      have "Th th' \<in> Domain (RAG s)" by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3199
      from dm_RAG_threads[OF this]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3200
      show ?thesis .
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3201
    qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3202
  } ultimately show ?thesis by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3203
qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3204
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3205
lemma readys_subtree_disjoint:
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3206
  assumes "th1 \<in> readys s"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3207
  and "th2 \<in> readys s"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3208
  and "th1 \<noteq> th2"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3209
  shows "subtree (RAG s) (Th th1) \<inter> subtree (RAG s) (Th th2) = {}"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3210
proof -
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3211
  { fix n
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3212
    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
  3213
    hence "(n, Th th1) \<in> (RAG s)^*" "(n, Th th2) \<in> (RAG s)^*"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3214
      by (auto simp:subtree_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3215
    from star_rpath[OF this(1)] star_rpath[OF this(2)]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3216
    obtain xs1 xs2 where "rpath (RAG s) n xs1 (Th th1)"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3217
                         "rpath (RAG s) n xs2 (Th th2)" by metis
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3218
    hence False
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3219
    proof(cases rule:rtree_RAG.rpath_overlap')
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3220
      case (less_1 xs3)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3221
      from rpath_star[OF this(3)]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3222
      have "Th th1 \<in> subtree (RAG s) (Th th2)"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3223
        by (auto simp:subtree_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3224
      thus ?thesis
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3225
      proof(cases rule:subtreeE)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3226
        case 1
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3227
        with assms(3) show ?thesis by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3228
      next
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3229
        case 2
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3230
        hence "(Th th1, Th th2) \<in> (RAG s)^+" by (auto simp:ancestors_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3231
        from tranclD[OF this]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3232
        obtain z where "(Th th1, z) \<in> RAG s" by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3233
        from this[unfolded s_RAG_def, folded wq_def]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3234
        obtain cs' where "waiting s th1 cs'"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3235
          by (auto simp:waiting_eq)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3236
        with assms(1) show False by (auto simp:readys_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3237
      qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3238
    next
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3239
      case (less_2 xs3)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3240
      from rpath_star[OF this(3)]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3241
      have "Th th2 \<in> subtree (RAG s) (Th th1)"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3242
        by (auto simp:subtree_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3243
      thus ?thesis
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3244
      proof(cases rule:subtreeE)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3245
        case 1
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3246
        with assms(3) show ?thesis by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3247
      next
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3248
        case 2
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3249
        hence "(Th th2, Th th1) \<in> (RAG s)^+" by (auto simp:ancestors_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3250
        from tranclD[OF this]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3251
        obtain z where "(Th th2, z) \<in> RAG s" by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3252
        from this[unfolded s_RAG_def, folded wq_def]
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3253
        obtain cs' where "waiting s th2 cs'"
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3254
          by (auto simp:waiting_eq)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3255
        with assms(2) show False by (auto simp:readys_def)
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3256
      qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3257
    qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3258
  } thus ?thesis by auto
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3259
qed
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3260
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  3261
end
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  3262
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3263
section {* Relating @{term cp} and @{term the_preced} and @{term preced} *}
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3264
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
  3265
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
  3266
 @{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
  3267
 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
  3268
 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
  3269
 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
  3270
 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
  3271
 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
  3272
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3273
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3274
context valid_trace
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3275
begin
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3276
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
  3277
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
  3278
  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
  3279
  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
  3280
  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
  3281
  @{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
  3282
*}
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3283
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3284
lemma le_cp:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3285
  shows "preced th s \<le> cp s th"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3286
  proof(unfold cp_alt_def, rule Max_ge)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3287
    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
  3288
      by (simp add: finite_subtree_threads)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3289
  next
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3290
    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
  3291
      by (simp add: subtree_def the_preced_def)   
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3292
  qed
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3293
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
  3294
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
  3295
  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
  3296
  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
  3297
  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
  3298
  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
  3299
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3300
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3301
lemma cp_le:
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3302
  assumes th_in: "th \<in> threads s"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3303
  shows "cp s th \<le> Max (the_preced s ` threads s)"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3304
proof(unfold cp_alt_def, rule Max_f_mono)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3305
  show "finite (threads s)" by (simp add: finite_threads) 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3306
next
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3307
  show " {th'. Th th' \<in> subtree (RAG s) (Th th)} \<noteq> {}"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3308
    using subtree_def by fastforce
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3309
next
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3310
  show "{th'. Th th' \<in> subtree (RAG s) (Th th)} \<subseteq> threads s"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3311
    using assms
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3312
    by (smt Domain.DomainI dm_RAG_threads mem_Collect_eq 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3313
        node.inject(1) rtranclD subsetI subtree_def trancl_domain) 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3314
qed
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3315
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
  3316
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
  3317
  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
  3318
  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
  3319
  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
  3320
  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
  3321
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3322
  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
  3323
  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
  3324
  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
  3325
  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
  3326
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3327
  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
  3328
  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
  3329
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3330
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3331
lemma max_cp_eq: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3332
  shows "Max ((cp s) ` threads s) = Max (the_preced s ` threads s)"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3333
  (is "?L = ?R")
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3334
proof -
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3335
  have "?L \<le> ?R" 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3336
  proof(cases "threads s = {}")
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3337
    case False
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3338
    show ?thesis 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3339
      by (rule Max.boundedI, 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3340
          insert cp_le, 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3341
          auto simp:finite_threads False)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3342
  qed auto
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3343
  moreover have "?R \<le> ?L"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3344
    by (rule Max_fg_mono, 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3345
        simp add: finite_threads,
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3346
        simp add: le_cp the_preced_def)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3347
  ultimately show ?thesis by auto
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3348
qed
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3349
114
81c6ede5cd11 More refinements in PIPBasics.thy.
zhangx
parents: 113
diff changeset
  3350
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
  3351
  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
  3352
  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
  3353
  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
  3354
  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
  3355
  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
  3356
  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
  3357
*}
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
  3358
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3359
lemma max_cp_readys_max_preced:
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3360
  shows "Max (cp s ` readys s) = Max (the_preced s ` threads 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
  3361
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
  3362
  case False
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
  3363
  have "?R = 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3364
    Max (the_preced s ` (\<Union>th\<in>readys s. {th'. Th th' \<in> subtree (RAG s) (Th th)}))"
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3365
    by (simp add: threads_alt_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
  3366
  also have "... = 
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3367
    Max ((\<Union>th\<in>readys s. the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)}))"
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3368
          by (unfold image_UN, simp)
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3369
  also have "... = 
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3370
    Max (Max ` (\<lambda>th. the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)}) ` 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
  3371
  proof(rule Max_UNION)
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3372
    show "\<forall>M\<in>(\<lambda>x. the_preced 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
  3373
                    {th'. Th th' \<in> subtree (RAG s) (Th x)}) ` readys s. finite M"
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3374
                        using finite_subtree_threads by 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
  3375
  qed (auto simp:False subtree_def finite_readys)
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
  3376
  also have "... = 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3377
     Max ((Max \<circ> (\<lambda>th. the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)})) ` 
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3378
                        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
  3379
      by (simp add: image_comp)
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
  3380
  also have "... = ?L" (is "Max (?f ` ?A) = Max (?g ` ?A)")
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3381
  proof -
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3382
    have "(?f ` ?A) = (?g ` ?A)"
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3383
    proof(rule f_image_eq)
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3384
      fix th1 
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3385
      assume "th1 \<in> ?A"
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3386
      thus "?f th1 = ?g th1"
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3387
        by (unfold cp_alt_def, simp)
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3388
    qed
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3389
    thus ?thesis by simp
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3390
  qed
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3391
  finally show ?thesis by simp
d5e9653fbf19 PIPBasics.thy reorganized into sections. The structure is now stable. Next step is to put in more comments.
zhangx
parents: 102
diff changeset
  3392
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
  3393
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
  3394
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
  3395
  The following lemma is simply a corollary of @{thm max_cp_readys_max_preced}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3396
  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
  3397
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3398
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
  3399
  shows "Max (cp s ` readys s) = Max (cp s ` 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
  3400
    using max_cp_readys_max_preced max_cp_eq 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
  3401
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3402
end
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3403
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
  3404
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3405
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
  3406
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
  3407
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
  3408
  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
  3409
  @{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
  3410
  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
  3411
  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
  3412
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3413
  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
  3414
  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
  3415
  @{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
  3416
  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
  3417
  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
  3418
  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
  3419
  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
  3420
  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
  3421
  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
  3422
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  3423
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3424
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
  3425
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
  3426
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3427
lemma holding_s_holder: "holding s holder cs"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3428
  by (unfold s_holding_def, fold wq_def, unfold wq_s_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
  3429
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3430
lemma holding_es_holder: "holding (e#s) holder cs"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3431
  by (unfold s_holding_def, fold wq_def, unfold wq_es_cs wq_s_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
  3432
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3433
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
  3434
  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
  3435
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
  3436
  { 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
  3437
    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
  3438
    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
  3439
    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
  3440
    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
  3441
      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
  3442
      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
  3443
      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
  3444
      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
  3445
        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
  3446
    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
  3447
      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
  3448
      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
  3449
      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
  3450
      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
  3451
       by (unfold s_holding_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
  3452
    qed 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3453
    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
  3454
  } 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
  3455
    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
  3456
    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
  3457
    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
  3458
    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
  3459
    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
  3460
      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
  3461
      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
  3462
      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
  3463
      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
  3464
        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
  3465
    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
  3466
      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
  3467
      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
  3468
      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
  3469
      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
  3470
       by (unfold s_holding_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
  3471
    qed 
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3472
    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
  3473
  } 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
  3474
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3475
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3476
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
  3477
 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
  3478
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3479
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
  3480
  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
  3481
  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
  3482
  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
  3483
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3484
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
  3485
  
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3486
lemma (in valid_trace) finite_holdents: "finite (holdents s th)"
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3487
  by (unfold holdents_alt_def, insert fsbtRAGs.finite_children, auto)
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3488
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3489
context valid_trace_p 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3490
begin
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3491
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3492
lemma live_th_es: "th \<in> threads (e#s)"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3493
  using live_th_s 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3494
  by (unfold is_p, simp)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3495
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3496
lemma waiting_neq_th: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3497
  assumes "waiting s t c"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3498
  shows "t \<noteq> th"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3499
  using assms using th_not_waiting by blast 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3500
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3501
end
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3502
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3503
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
  3504
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
  3505
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3506
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
  3507
  "\<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
  3508
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
  3509
  case True
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3510
  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
  3511
    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
  3512
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
  3513
  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
  3514
  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
  3515
  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
  3516
    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
  3517
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3518
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3519
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
  3520
  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
  3521
  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
  3522
  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
  3523
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3524
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
  3525
  "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
  3526
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
  3527
  { 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
  3528
    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
  3529
    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
  3530
      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
  3531
    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
  3532
     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
  3533
  } 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
  3534
    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
  3535
    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
  3536
    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
  3537
      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
  3538
    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
  3539
    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
  3540
      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
  3541
      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
  3542
      show ?thesis by (auto simp:holdents_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3543
    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
  3544
      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
  3545
      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
  3546
        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
  3547
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3548
  } 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
  3549
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3550
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3551
lemma not_holding_s_th_cs: "\<not> holding s th cs"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3552
proof
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3553
  assume otherwise: "holding s th cs"
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3554
  from pip_e[unfolded is_p]
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3555
  show False
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3556
  proof(cases)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3557
    case (thread_P)
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3558
    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
  3559
      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
  3560
      using s_holding_def wq_def by auto
111
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3561
    ultimately show ?thesis by auto
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3562
  qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3563
qed
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  3564
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3565
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
  3566
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
  3567
  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
  3568
  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
  3569
    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
  3570
      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
  3571
  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
  3572
  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
  3573
   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
  3574
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3575
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3576
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
  3577
  "\<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
  3578
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
  3579
  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
  3580
  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
  3581
  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
  3582
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3583
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3584
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
  3585
  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
  3586
  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
  3587
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
  3588
  { 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
  3589
    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
  3590
    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
  3591
    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
  3592
    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
  3593
      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
  3594
      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
  3595
      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
  3596
      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
  3597
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3598
    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
  3599
    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
  3600
    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
  3601
      by (unfold holdents_def s_holding_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
  3602
  } 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
  3603
    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
  3604
    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
  3605
    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
  3606
    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
  3607
    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
  3608
    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
  3609
      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
  3610
  } 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
  3611
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3612
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3613
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
  3614
  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
  3615
  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
  3616
  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
  3617
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3618
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
  3619
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3620
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
  3621
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
  3622
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3623
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
  3624
  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
  3625
  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
  3626
  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
  3627
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
  3628
  { 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
  3629
    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
  3630
    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
  3631
        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
  3632
    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
  3633
    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
  3634
      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
  3635
      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
  3636
      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
  3637
        by (unfold s_waiting_def, fold wq_def, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3638
    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
  3639
      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
  3640
      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
  3641
      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
  3642
        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
  3643
        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
  3644
          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
  3645
        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
  3646
      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
  3647
        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
  3648
        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
  3649
        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
  3650
      qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3651
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3652
  } 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
  3653
    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
  3654
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3655
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3656
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
  3657
  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
  3658
  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
  3659
  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
  3660
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
  3661
  { 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
  3662
    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
  3663
    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
  3664
        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
  3665
    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
  3666
    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
  3667
      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
  3668
      with n_wait wait
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3669
      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
  3670
        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
  3671
    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
  3672
      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
  3673
      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
  3674
      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
  3675
        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
  3676
        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
  3677
          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
  3678
        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
  3679
      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
  3680
        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
  3681
        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
  3682
        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
  3683
      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
  3684
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3685
  } 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
  3686
    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
  3687
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3688
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3689
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
  3690
  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
  3691
  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
  3692
  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
  3693
  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
  3694
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3695
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
  3696
  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
  3697
  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
  3698
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
  3699
  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
  3700
  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
  3701
  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
  3702
  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
  3703
    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
  3704
    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
  3705
    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
  3706
      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
  3707
  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
  3708
    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
  3709
    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
  3710
    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
  3711
      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
  3712
            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
  3713
      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
  3714
      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
  3715
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3716
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
  3717
  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
  3718
  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
  3719
  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
  3720
  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
  3721
    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
  3722
    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
  3723
    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
  3724
      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
  3725
  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
  3726
    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
  3727
    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
  3728
    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
  3729
      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
  3730
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3731
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3732
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3733
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
  3734
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3735
100
3d2b59f15f26 Reorganizing PIPBasics.thy
zhangx
parents: 99
diff changeset
  3736
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
  3737
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
  3738
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3739
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
  3740
  "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
  3741
 by  (unfold s_holding_def, fold wq_def, unfold wq_s_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
  3742
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3743
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
  3744
  using running_th_s
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3745
  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
  3746
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3747
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
  3748
  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
  3749
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3750
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
  3751
  using running_th_s neq_t_th
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3752
  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
  3753
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3754
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
  3755
  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
  3756
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3757
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
  3758
  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
  3759
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3760
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
  3761
  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
  3762
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3763
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
  3764
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
  3765
  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
  3766
    by (unfold holdents_def, simp)
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3767
  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
  3768
    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
  3769
  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
  3770
    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
  3771
        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
  3772
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3773
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3774
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
  3775
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3776
context valid_trace_v
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3777
begin
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3778
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3779
lemma th_not_waiting: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3780
  "\<not> waiting s th c"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3781
proof -
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3782
  have "th \<in> readys s"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  3783
    using running_ready running_th_s by blast 
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3784
  thus ?thesis
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3785
    by (unfold readys_def, auto)
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3786
qed
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3787
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3788
lemma waiting_neq_th: 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3789
  assumes "waiting s t c"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3790
  shows "t \<noteq> th"
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3791
  using assms using th_not_waiting by blast 
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3792
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3793
end
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3794
92
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3795
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
  3796
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
  3797
4763aa246dbd Original files overwrite by 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
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
  3799
  "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
  3800
  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
  3801
  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
  3802
4763aa246dbd Original files overwrite by 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
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
  3804
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
  3805
  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
  3806
  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
  3807
  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
  3808
  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
  3809
  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
  3810
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  3813
  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
  3814
4763aa246dbd Original files overwrite by 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
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
  3816
  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
  3817
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
  3818
  { 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
  3819
    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
  3820
    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
  3821
    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
  3822
      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
  3823
      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
  3824
    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
  3825
  } 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
  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
4763aa246dbd Original files overwrite by 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
lemma neq_taker_th: "taker \<noteq> th"
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  3829
  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
  3830
4763aa246dbd Original files overwrite by 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
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
  3832
  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
  3833
  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
  3834
4763aa246dbd Original files overwrite by 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
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
  3836
  "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
  3837
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
  3838
  { 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
  3839
    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
  3840
    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
  3841
    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
  3842
    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
  3843
      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
  3844
      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
  3845
    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
  3846
  } 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
  3847
    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
  3848
    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
  3849
    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
  3850
    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
  3851
    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
  3852
      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
  3853
      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
  3854
          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
  3855
      thus ?thesis by (auto simp:holdents_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3856
    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
  3857
      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
  3858
      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
  3859
      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
  3860
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3861
  } 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
  3862
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3863
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3864
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
  3865
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
  3866
  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
  3867
  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
  3868
    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
  3869
      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
  3870
  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
  3871
  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
  3872
    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
  3873
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3874
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3875
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
  3876
  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
  3877
4763aa246dbd Original files overwrite by 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
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
  3879
  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
  3880
4763aa246dbd Original files overwrite by 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
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
  3882
  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
  3883
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3884
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
  3885
  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
  3886
4763aa246dbd Original files overwrite by 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
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
  3888
  "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
  3889
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
  3890
  { 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
  3891
    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
  3892
    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
  3893
    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
  3894
    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
  3895
      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
  3896
      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
  3897
    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
  3898
  } 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
  3899
    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
  3900
    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
  3901
    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
  3902
    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
  3903
    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
  3904
  } 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
  3905
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  3908
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
  3909
  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
  3910
  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
  3911
    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
  3912
      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
  3913
    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
  3914
        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
  3915
    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
  3916
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3917
  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
  3918
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  3921
  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
  3922
  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
  3923
  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
  3924
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
  3925
  { 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
  3926
    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
  3927
    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
  3928
    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
  3929
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3930
      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
  3931
      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
  3932
      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
  3933
      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
  3934
        by (unfold holdents_def s_holding_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
  3935
    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
  3936
      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
  3937
      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
  3938
      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
  3939
      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
  3940
      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
  3941
      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
  3942
    qed
4763aa246dbd Original files overwrite by 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
  } 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
  3944
    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
  3945
    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
  3946
    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
  3947
    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
  3948
      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
  3949
      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
  3950
      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
  3951
      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
  3952
      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
  3953
        by (unfold holdents_def s_holding_def, fold wq_def, insert eq_wq, simp)
4763aa246dbd Original files overwrite by 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
    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
  3955
      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
  3956
      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
  3957
      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
  3958
      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
  3959
      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
  3960
      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
  3961
    qed
4763aa246dbd Original files overwrite by 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
  } 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
  3963
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  3964
4763aa246dbd Original files overwrite by 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
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
  3966
  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
  3967
  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
  3968
  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
  3969
  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
  3970
4763aa246dbd Original files overwrite by 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
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
  3972
  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
  3973
  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
  3974
  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
  3975
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
  3976
  { 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
  3977
    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
  3978
    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
  3979
        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
  3980
    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
  3981
    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
  3982
      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
  3983
      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
  3984
      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
  3985
        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
  3986
    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
  3987
      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
  3988
      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
  3989
        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
  3990
      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
  3991
        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
  3992
                    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
  3993
      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
  3994
      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
  3995
      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
  3996
    qed
4763aa246dbd Original files overwrite by 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
  } 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
  3998
    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
  3999
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4002
  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
  4003
  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
  4004
  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
  4005
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
  4006
  { 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
  4007
    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
  4008
    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
  4009
        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
  4010
    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
  4011
    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
  4012
      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
  4013
      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
  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
        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
  4016
    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
  4017
      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
  4018
      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
  4019
          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
  4020
                    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
  4021
      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
  4022
          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
  4023
      ultimately have "th' = taker" using th_not_in_rest by simp
4b416723a616 More redundant lemmas are reomved.
zhangx
parents: 110
diff changeset
  4024
      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
  4025
      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
  4026
      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
  4027
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4028
  } 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
  4029
    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
  4030
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4033
  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
  4034
  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
  4035
  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
  4036
  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
  4037
4763aa246dbd Original files overwrite by 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
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
  4039
  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
  4040
  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
  4041
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
  4042
  { 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
  4043
    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
  4044
      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
  4045
      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
  4046
  } 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
  4047
    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
  4048
    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
  4049
      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
  4050
      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
  4051
  } 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
  4052
    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
  4053
    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
  4054
      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
  4055
      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
  4056
  } 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
  4057
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4060
4763aa246dbd Original files overwrite by 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
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
  4062
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
  4063
4763aa246dbd Original files overwrite by 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
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
  4065
  "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
  4066
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
  4067
  { 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
  4068
    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
  4069
    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
  4070
    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
  4071
    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
  4072
      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
  4073
      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
  4074
    qed 
4763aa246dbd Original files overwrite by 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
  } 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
  4076
    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
  4077
    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
  4078
    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
  4079
    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
  4080
    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
  4081
  } 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
  4082
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4085
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
  4086
  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
  4087
  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
  4088
    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
  4089
      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
  4090
    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
  4091
        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
  4092
    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
  4093
  qed
4763aa246dbd Original files overwrite by 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
  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
  4095
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4098
  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
  4099
  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
  4100
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
  4101
  { 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
  4102
    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
  4103
    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
  4104
    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
  4105
      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
  4106
      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
  4107
      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
  4108
      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
  4109
      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
  4110
        by (unfold holdents_def s_holding_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
  4111
    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
  4112
      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
  4113
      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
  4114
      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
  4115
      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
  4116
            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
  4117
      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
  4118
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4119
  } 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
  4120
    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
  4121
    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
  4122
    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
  4123
    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
  4124
      case False
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4125
      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
  4126
      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
  4127
      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
  4128
      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
  4129
        by (unfold holdents_def s_holding_def, fold wq_def, insert eq_wq, simp)
4763aa246dbd Original files overwrite by 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
    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
  4131
      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
  4132
      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
  4133
      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
  4134
      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
  4135
      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
  4136
      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
  4137
    qed
4763aa246dbd Original files overwrite by 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
  } 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
  4139
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4141
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
  4142
  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
  4143
  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
  4144
  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
  4145
4763aa246dbd Original files overwrite by 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
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
  4147
  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
  4148
  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
  4149
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
  4150
  { 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
  4151
    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
  4152
    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
  4153
        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
  4154
    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
  4155
    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
  4156
      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
  4157
      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
  4158
      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
  4159
        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
  4160
    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
  4161
      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
  4162
      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
  4163
        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
  4164
      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
  4165
      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
  4166
      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
  4167
    qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4168
  } 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
  4169
    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
  4170
qed
4763aa246dbd Original files overwrite by 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 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
  4173
  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
  4174
  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
  4175
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
  4176
  { 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
  4177
    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
  4178
    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
  4179
        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
  4180
    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
  4181
    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
  4182
      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
  4183
      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
  4184
      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
  4185
        by (unfold s_waiting_def, fold wq_def, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4186
    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
  4187
      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
  4188
      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
  4189
        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
  4190
              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
  4191
      thus ?thesis by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4192
    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
  4193
  } 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
  4194
    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
  4195
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4198
  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
  4199
  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
  4200
  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
  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 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
  4203
  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
  4204
  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
  4205
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
  4206
  {
4763aa246dbd Original files overwrite by 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
    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
  4208
    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
  4209
      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
  4210
      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
  4211
  } 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
  4212
    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
  4213
    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
  4214
      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
  4215
      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
  4216
  } 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
  4217
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4218
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4219
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
  4220
4763aa246dbd Original files overwrite by 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
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
  4222
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
  4223
4763aa246dbd Original files overwrite by 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
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
  4225
  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
  4226
  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
  4227
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
  4228
  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
  4229
  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
  4230
  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
  4231
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
  4232
  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
  4233
  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
  4234
  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
  4235
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4238
4763aa246dbd Original files overwrite by 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
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
  4240
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
  4241
4763aa246dbd Original files overwrite by 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
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
  4243
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
  4244
  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
  4245
  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
  4246
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4249
  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
  4250
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4251
lemma 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
  4252
  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
  4253
4763aa246dbd Original files overwrite by 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
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
  4255
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
  4256
  assume "waiting s th cs'"
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4257
  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
  4258
  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
  4259
  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
  4260
  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
  4261
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4264
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
  4265
  assume "holding s th cs'"
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4266
  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
  4267
  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
  4268
  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
  4269
  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
  4270
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4273
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
  4274
  assume "waiting (e # s) th cs'"
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4275
  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
  4276
  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
  4277
  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
  4278
  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
  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 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
  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
  assume "holding (e # s) th cs'"
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4284
  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
  4285
  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
  4286
  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
  4287
  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
  4288
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4291
  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
  4292
4763aa246dbd Original files overwrite by 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
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
  4294
  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
  4295
4763aa246dbd Original files overwrite by 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
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
  4297
  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
  4298
4763aa246dbd Original files overwrite by 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
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
  4300
  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
  4301
4763aa246dbd Original files overwrite by 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
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
  4303
  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
  4304
4763aa246dbd Original files overwrite by 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
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
  4306
  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
  4307
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4308
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
  4309
  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
  4310
4763aa246dbd Original files overwrite by 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
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
  4312
  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
  4313
  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
  4314
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
  4315
  { fix cs'
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4316
    assume 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
  4317
    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
  4318
      by (unfold holdents_def s_holding_def, fold wq_def, 
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4319
             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
  4320
  } 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
  4321
    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
  4322
    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
  4323
    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
  4324
      by (unfold holdents_def s_holding_def, fold wq_def, 
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4325
             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
  4326
  } 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
  4327
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4330
  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
  4331
  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
  4332
  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
  4333
  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
  4334
4763aa246dbd Original files overwrite by 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
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
  4336
  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
  4337
  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
  4338
  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
  4339
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
  4340
  { 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
  4341
    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
  4342
    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
  4343
      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
  4344
    from wait[unfolded s_waiting_def, folded wq_def]
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4345
         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
  4346
    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
  4347
  } 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
  4348
    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
  4349
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4352
  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
  4353
  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
  4354
  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
  4355
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
  4356
  { 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
  4357
    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
  4358
    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
  4359
      using assms(2) by (auto simp:readys_def)
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4360
    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
  4361
         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
  4362
    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
  4363
  } 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
  4364
    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
  4365
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4368
  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
  4369
  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
  4370
  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
  4371
  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
  4372
4763aa246dbd Original files overwrite by 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
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
  4374
  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
  4375
  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
  4376
  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
  4377
  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
  4378
4763aa246dbd Original files overwrite by 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
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
  4380
  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
  4381
  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
  4382
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
  4383
  {
4763aa246dbd Original files overwrite by 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
    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
  4385
    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
  4386
      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
  4387
  } 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
  4388
    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
  4389
    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
  4390
      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
  4391
  } 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
  4392
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4395
4763aa246dbd Original files overwrite by 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
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
  4397
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
  4398
4763aa246dbd Original files overwrite by 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
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
  4400
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
  4401
  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
  4402
  show ?thesis
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4403
  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
  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 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
  4407
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
  4408
  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
  4409
  show ?thesis
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4410
  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
  4411
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4414
  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
  4415
4763aa246dbd Original files overwrite by 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
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
  4417
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
  4418
  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
  4419
  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
  4420
   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
  4421
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4424
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
  4425
  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
  4426
  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
  4427
   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
  4428
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4431
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
  4432
  assume "holding (e # s) th cs'"
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4433
  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
  4434
  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
  4435
    by (unfold s_holding_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
  4436
  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
  4437
  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
  4438
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4441
  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
  4442
4763aa246dbd Original files overwrite by 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
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
  4444
  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
  4445
4763aa246dbd Original files overwrite by 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
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
  4447
  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
  4448
4763aa246dbd Original files overwrite by 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
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
  4450
  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
  4451
4763aa246dbd Original files overwrite by 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
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
  4453
  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
  4454
4763aa246dbd Original files overwrite by 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
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
  4456
  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
  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 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
  4459
  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
  4460
  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
  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
  { 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
  4463
    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
  4464
    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
  4465
      by (unfold holdents_def s_holding_def, fold wq_def, 
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4466
             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
  4467
  } moreover {
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4468
    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
  4469
    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
  4470
    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
  4471
      by (unfold holdents_def s_holding_def, fold wq_def, 
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4472
             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
  4473
  } 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
  4474
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4477
  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
  4478
  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
  4479
  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
  4480
  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
  4481
4763aa246dbd Original files overwrite by 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
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
  4483
  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
  4484
  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
  4485
  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
  4486
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
  4487
  { 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
  4488
    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
  4489
    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
  4490
      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
  4491
    from wait[unfolded s_waiting_def, folded wq_def]
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4492
         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
  4493
    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
  4494
  } 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
  4495
    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
  4496
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4499
  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
  4500
  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
  4501
  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
  4502
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
  4503
  { 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
  4504
    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
  4505
    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
  4506
      using assms(2) by (auto simp:readys_def)
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4507
    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
  4508
         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
  4509
    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
  4510
  } 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
  4511
    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
  4512
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4515
  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
  4516
  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
  4517
  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
  4518
  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
  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 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
  4521
  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
  4522
  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
  4523
  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
  4524
  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
  4525
4763aa246dbd Original files overwrite by 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
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
  4527
  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
  4528
  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
  4529
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
  4530
  {
4763aa246dbd Original files overwrite by 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
    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
  4532
    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
  4533
      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
  4534
  } 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
  4535
    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
  4536
    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
  4537
      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
  4538
  } 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
  4539
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4542
4763aa246dbd Original files overwrite by 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
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
  4544
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
  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 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
  4547
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
  4548
  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
  4549
  show ?thesis
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4550
  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
  4551
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4554
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
  4555
  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
  4556
  show ?thesis
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  4557
  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
  4558
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4560
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
  4561
  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
  4562
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4565
  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
  4566
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
  4567
  { 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
  4568
    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
  4569
    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
  4570
      by (unfold holdents_def s_holding_def, fold wq_def, 
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4571
             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
  4572
  } 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
  4573
    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
  4574
    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
  4575
    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
  4576
      by (unfold holdents_def s_holding_def, fold wq_def, 
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4577
             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
  4578
  } 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
  4579
qed
4763aa246dbd Original files overwrite by 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
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
  4582
  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
  4583
  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
  4584
  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
  4585
4763aa246dbd Original files overwrite by 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
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
  4587
  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
  4588
  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
  4589
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
  4590
  { 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
  4591
    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
  4592
    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
  4593
      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
  4594
    from wait[unfolded s_waiting_def, folded wq_def]
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4595
         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
  4596
    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
  4597
  } 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
  4598
    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
  4599
  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
  4600
    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
  4601
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4604
  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
  4605
  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
  4606
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
  4607
  { 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
  4608
    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
  4609
    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
  4610
      using assms by (auto simp:readys_def)
99
f7b33c633b96 Small improvemnts in PIPBasis.thy
zhangx
parents: 93
diff changeset
  4611
    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
  4612
         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
  4613
    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
  4614
  } 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
  4615
    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
  4616
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4617
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4618
lemma 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
  4619
  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
  4620
  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
  4621
  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
  4622
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4623
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
  4624
  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
  4625
  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
  4626
4763aa246dbd Original files overwrite by 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
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
  4628
  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
  4629
  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
  4630
  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
  4631
  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
  4632
4763aa246dbd Original files overwrite by 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
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
  4634
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4635
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
  4636
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
  4637
4763aa246dbd Original files overwrite by 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
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
  4639
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
  4640
  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
  4641
  thus ?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
  4642
    by (unfold cntP_def cntV_def pvD_def cntCS_def 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
  4643
              s_holding_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
  4644
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
  4645
  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
  4646
  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
  4647
  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
  4648
  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
  4649
    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
  4650
    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
  4651
      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
  4652
    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
  4653
  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
  4654
    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
  4655
    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
  4656
        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
  4657
   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
  4658
  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
  4659
    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
  4660
    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
  4661
    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
  4662
  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
  4663
    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
  4664
    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
  4665
    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
  4666
  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
  4667
    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
  4668
    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
  4669
        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
  4670
    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
  4671
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4672
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4673
101
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4674
end
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4675
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4676
section {* Corollaries of @{thm valid_trace.cnp_cnv_cncs} *}
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4677
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4678
context valid_trace
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4679
begin
c7db2ccba18a Reorganzing PIPBasics.thy intro sections.
zhangx
parents: 100
diff changeset
  4680
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
  4681
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
  4682
  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
  4683
  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
  4684
*}
92
4763aa246dbd Original files overwrite by 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 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
  4686
  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
  4687
  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
  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 "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
  4691
    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
  4692
    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
  4693
    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
  4694
    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
  4695
    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
  4696
    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
  4697
  } 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
  4698
qed
4763aa246dbd Original files overwrite by 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
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4700
lemma not_thread_cncs:
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  4701
  assumes not_in: "th \<notin> threads s" 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4702
  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
  4703
  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
  4704
  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
  4705
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
  4706
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
  4707
  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
  4708
  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
  4709
  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
  4710
  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
  4711
  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
  4712
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  4713
92
4763aa246dbd Original files overwrite by 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
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
  4715
  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
  4716
  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
  4717
  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
  4718
  by (auto)
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  4719
92
4763aa246dbd Original files overwrite by 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
lemma eq_pv_children:
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  4721
  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
  4722
  shows "children (RAG s) (Th th) = {}"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4723
proof -
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4724
    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
  4725
    have "cntCS s th = 0" 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4726
      by (auto split:if_splits)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4727
    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
  4728
    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
  4729
    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
  4730
      by (simp add: fsbtRAGs.finite_children)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4731
    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
  4732
    show ?thesis by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4733
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4734
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4735
lemma eq_pv_holdents:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4736
  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
  4737
  shows "holdents s th = {}"
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4738
  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
  4739
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4740
lemma eq_pv_subtree:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4741
  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
  4742
  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
  4743
  using eq_pv_children[OF assms]
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4744
    by (unfold subtree_children, simp)
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4745
92
4763aa246dbd Original files overwrite by 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
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
  4747
  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
  4748
  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
  4749
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
  4750
    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
  4751
    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
  4752
    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
  4753
    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
  4754
      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
  4755
    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
  4756
    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
  4757
qed
4763aa246dbd Original files overwrite by 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
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
  4759
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
  4760
  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
  4761
  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
  4762
  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
  4763
92
4763aa246dbd Original files overwrite by 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
lemma eq_pv_dependants:
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4765
  assumes eq_pv: "cntP s th = cntV s th"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4766
  shows "dependants s th = {}"
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4767
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
  4768
  from count_eq_RAG_plus[OF assms, folded dependants_alt_def1]
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4769
  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
  4770
qed
4763aa246dbd Original files overwrite by 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
106
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4772
lemma count_eq_tRAG_plus:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4773
  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
  4774
  shows "{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
  4775
  using assms eq_pv_dependants dependants_alt_def eq_dependants by auto 
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4776
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4777
lemma count_eq_tRAG_plus_Th:
5454387e42ce updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  4778
  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
  4779
  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
  4780
   using count_eq_tRAG_plus[OF assms] by auto
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  4781
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  4782
end
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4783
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
  4784
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
  4785
  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
  4786
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4787
definition detached :: "state \<Rightarrow> thread \<Rightarrow> bool"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4788
  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
  4789
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
  4790
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
  4791
  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
  4792
  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
  4793
*}
74fc1eae4605 Commenting of PIPBasics.thy almost completed. The last section needs to be distributed to Correctness.thy and Implementation.thy
zhangx
parents: 114
diff changeset
  4794
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4795
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
  4796
  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
  4797
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
  4798
apply(simp add: s_RAG_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4799
apply(simp add: s_holding_abv s_waiting_abv)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4800
apply(simp add: Domain_iff Range_iff)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4801
apply(simp add: wq_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4802
apply(auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4803
done
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4804
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4805
lemma detached_cp_the_preced:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4806
  assumes "detached s th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4807
  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
  4808
proof -
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4809
  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
  4810
      by (unfold cp_alt_def, simp)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4811
  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
  4812
  proof -
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4813
    { fix n
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4814
      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
  4815
      hence "n = Th th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4816
      proof(cases rule:subtreeE)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4817
        case 2
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4818
        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
  4819
          by (elim ancestors_Field, simp)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4820
        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
  4821
        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
  4822
        thus ?thesis by simp
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4823
      qed simp
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4824
    } thus ?thesis by auto
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4825
  qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4826
  ultimately show ?thesis by auto
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4827
qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4828
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4829
lemma detached_cp_preced:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4830
  assumes "detached s th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4831
  shows "cp s th = preced th s" 
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4832
  using detached_cp_the_preced[OF assms] 
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4833
  by (simp add:the_preced_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  4834
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  4835
context valid_trace
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  4836
begin
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  4837
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4838
lemma detached_intro:
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  4839
  assumes eq_pv: "cntP s th = cntV s th"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4840
  shows "detached s th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4841
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
  4842
  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
  4843
  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
  4844
  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
  4845
  proof
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4846
    assume "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
  4847
    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
  4848
    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
  4849
      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
  4850
              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
  4851
  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
  4852
    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
  4853
    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
  4854
    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
  4855
      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
  4856
      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
  4857
      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
  4858
      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
  4859
    qed
4763aa246dbd Original files overwrite by 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
    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
  4861
      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
  4862
              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
  4863
  qed
4763aa246dbd Original files overwrite by 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
qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4865
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4866
lemma 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
  4867
  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
  4868
  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
  4869
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
  4870
  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
  4871
  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
  4872
    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
  4873
      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
  4874
      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
  4875
    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
  4876
  qed
4763aa246dbd Original files overwrite by their parallels (Correctness.thy v.s. PrioG.thy, PIPBasics.thy v.s. CpsG.thy, Implementation v.s. ExtGG.thy).
zhangx
parents: 90
diff changeset
  4877
  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
  4878
  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
  4879
    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
  4880
    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
  4881
    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
  4882
      by (unfold readys_def detached_def Field_def Domain_def Range_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
  4883
           auto simp:waiting_eq 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
  4884
    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
  4885
  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
  4886
    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
  4887
    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
  4888
  qed
4763aa246dbd Original files overwrite by 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
qed
4763aa246dbd Original files overwrite by 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
4763aa246dbd Original files overwrite by 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
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
  4892
  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
  4893
  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
  4894
4763aa246dbd Original files overwrite by 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
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
  4896
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4897
section {* Recursive calculation of @{term "cp"} *}
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4898
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4899
text {*
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4900
  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
  4901
  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
  4902
  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
  4903
  a @{term cp}-value, one needs to traverse a whole subtree. 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4904
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4905
  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
  4906
  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
  4907
  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
  4908
  the @{term cp}-values of its children in @{term RAG}. 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4909
  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
  4910
  changed by an execution step, there is no need to recalculate. This
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4911
  is particularly useful to in Implementation.thy to speed up the 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4912
  recalculation of @{term cp}-values. 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4913
*}
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4914
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4915
text {*
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4916
  The following function @{text "cp_gen"} is a generalization 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4917
  of @{term cp}. Unlike @{term cp} which returns a precedence 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4918
  for a thread, @{text "cp_gen"} returns precedence for a node
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4919
  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
  4920
  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
  4921
  and this is the only meaningful use of @{text cp_gen}. 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4922
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4923
  The introduction of @{text cp_gen} is purely technical to easy some
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4924
  of the proofs leading to the finally lemma @{text cp_rec}.
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4925
*}
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4926
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4927
definition "cp_gen s x =
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4928
                  Max ((the_preced s \<circ> the_thread) ` subtree (tRAG s) x)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4929
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4930
lemma cp_gen_alt_def:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4931
  "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
  4932
    by (auto simp:cp_gen_def)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4933
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4934
lemma cp_gen_def_cond: 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4935
  assumes "x = Th th"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4936
  shows "cp s th = cp_gen s (Th th)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4937
by (unfold cp_alt_def1 cp_gen_def, simp)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4938
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4939
lemma cp_gen_over_set:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4940
  assumes "\<forall> x \<in> A. \<exists> th. x = Th th"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4941
  shows "cp_gen s ` A = (cp s \<circ> the_thread) ` A"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4942
proof(rule f_image_eq)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4943
  fix a
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4944
  assume "a \<in> A"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4945
  from assms[rule_format, OF this]
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4946
  obtain th where eq_a: "a = Th th" by auto
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4947
  show "cp_gen s a = (cp s \<circ> the_thread) a"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4948
    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
  4949
qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4950
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 77
diff changeset
  4951
102
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 101
diff changeset
  4952
context valid_trace
3a801bbd2687 Reorganizing PIPBasics.thy and making small changes to Implementation.thy and Correctness.thy.
zhangx
parents: 101
diff changeset
  4953
begin
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4954
(* ddd *)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4955
lemma cp_gen_rec:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4956
  assumes "x = Th th"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4957
  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
  4958
proof(cases "children (tRAG s) x = {}")
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4959
  case True
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4960
  show ?thesis
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4961
    by (unfold True cp_gen_def subtree_children, simp add:assms)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4962
next
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4963
  case False
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4964
  hence [simp]: "children (tRAG s) x \<noteq> {}" by auto
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4965
  note fsbttRAGs.finite_subtree[simp]
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4966
  have [simp]: "finite (children (tRAG s) x)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4967
     by (intro rev_finite_subset[OF fsbttRAGs.finite_subtree], 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4968
            rule children_subtree)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4969
  { fix r x
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4970
    have "subtree r x \<noteq> {}" by (auto simp:subtree_def)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4971
  } note this[simp]
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4972
  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
  4973
  proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4974
    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
  4975
    moreover have "subtree (tRAG s) q \<noteq> {}" by simp
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4976
    ultimately show ?thesis by blast
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4977
  qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4978
  have h: "Max ((the_preced s \<circ> the_thread) `
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4979
                ({x} \<union> \<Union>(subtree (tRAG s) ` children (tRAG s) x))) =
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4980
        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
  4981
                     (is "?L = ?R")
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4982
  proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4983
    let "Max (?f ` (?A \<union> \<Union> (?g ` ?B)))" = ?L
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4984
    let "Max (_ \<union> (?h ` ?B))" = ?R
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4985
    let ?L1 = "?f ` \<Union>(?g ` ?B)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4986
    have eq_Max_L1: "Max ?L1 = Max (?h ` ?B)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4987
    proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4988
      have "?L1 = ?f ` (\<Union> x \<in> ?B.(?g x))" by simp
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4989
      also have "... =  (\<Union> x \<in> ?B. ?f ` (?g x))" by auto
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4990
      finally have "Max ?L1 = Max ..." by simp
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4991
      also have "... = Max (Max ` (\<lambda>x. ?f ` subtree (tRAG s) x) ` ?B)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4992
        by (subst Max_UNION, simp+)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4993
      also have "... = Max (cp_gen s ` children (tRAG s) x)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4994
          by (unfold image_comp cp_gen_alt_def, simp)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4995
      finally show ?thesis .
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4996
    qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4997
    show ?thesis
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4998
    proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  4999
      have "?L = Max (?f ` ?A \<union> ?L1)" by simp
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5000
      also have "... = max (the_preced s (the_thread x)) (Max ?L1)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5001
            by (subst Max_Un, simp+)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5002
      also have "... = max (?f x) (Max (?h ` ?B))"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5003
        by (unfold eq_Max_L1, simp)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5004
      also have "... =?R"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5005
        by (rule max_Max_eq, (simp)+, unfold assms, simp)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5006
      finally show ?thesis .
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5007
    qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5008
  qed  thus ?thesis 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5009
          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
  5010
qed
65
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5011
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5012
lemma cp_rec:
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5013
  "cp s th = Max ({the_preced s th} \<union> 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5014
                     (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
  5015
proof -
116
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5016
  have "Th th = Th th" by simp
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5017
  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
  5018
  show ?thesis 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5019
  proof -
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5020
    have "cp_gen s ` children (tRAG s) (Th th) = 
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5021
                (cp s \<circ> the_thread) ` children (tRAG s) (Th th)"
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5022
    proof(rule cp_gen_over_set)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5023
      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
  5024
        by (unfold tRAG_alt_def, auto simp:children_def)
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5025
    qed
a7441db6f4e1 PIPBasics.thy is tidied up now.
zhangx
parents: 115
diff changeset
  5026
    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
  5027
  qed
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5028
qed
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5029
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5030
end
633b1fc8631b Reorganization completed, added "scripts_structure.pdf" and "scirpts_structure.pptx".
zhangx
parents: 64
diff changeset
  5031
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5032
lemma PIP_actorE:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5033
  assumes "PIP s e"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5034
  and "actor e = th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5035
  and "\<not> isCreate e"
127
38c6acf03f68 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 125
diff changeset
  5036
  shows "th \<in> running s"
125
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5037
  using assms
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5038
  by (cases, auto)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5039
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5040
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5041
lemma holdents_RAG:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5042
  assumes "holdents s th = {}"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5043
  shows "Th th \<notin> Range (RAG s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5044
proof
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5045
  assume "Th th \<in> Range (RAG s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5046
  thus False
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5047
  proof(rule RangeE)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5048
    fix a
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5049
    assume "(a, Th th) \<in> RAG s"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5050
    with assms[unfolded holdents_test]
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5051
    show False
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  5052
    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
  5053
  qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5054
qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5055
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5056
lemma readys_RAG:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5057
  assumes "th \<in> readys s"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5058
  shows "Th th \<notin> Domain (RAG s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5059
proof
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5060
  assume "Th th \<in> Domain (RAG s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5061
  thus False
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5062
  proof(rule DomainE)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5063
    fix b
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5064
    assume "(Th th, b) \<in> RAG s"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5065
    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
  5066
    show False
128
5d8ec128518b removed most instances of raw
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  5067
      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
  5068
  qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5069
qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5070
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5071
lemma readys_holdents_detached:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5072
  assumes "th \<in> readys s"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5073
  and "holdents s th = {}"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5074
  shows "detached s th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5075
proof -
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5076
  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
  5077
  show ?thesis
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5078
    by (unfold detached_test Field_def, auto)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5079
qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5080
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5081
lemma len_actions_of_sigma:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5082
  assumes "finite A"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5083
  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
  5084
proof(induct t)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5085
  case h: (Cons e t)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5086
  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
  5087
  proof(cases "actor e \<in> A")
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5088
    case True
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5089
    have "?L = 1 + ?T t"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5090
      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
  5091
    moreover have "?R = 1 + ?T t"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5092
    proof -
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5093
      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
  5094
                 (\<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
  5095
            (is "_ = ?F (e#t) + ?G (e#t)")
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5096
            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
  5097
                OF assms True], simp)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5098
      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
  5099
          by  (simp add:actions_of_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5100
      moreover have "?G (e#t) = ?G t"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5101
        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
  5102
      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
  5103
        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
  5104
              OF assms True], simp)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5105
      ultimately show ?thesis by simp
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5106
    qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5107
    ultimately show ?thesis by simp
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5108
  next
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5109
    case False
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5110
    hence "?L = length (actions_of A t)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5111
      by (simp add:actions_of_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5112
    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
  5113
    also have "... = ?R"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5114
      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
  5115
    finally show ?thesis .
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5116
  qed
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5117
qed (auto simp:actions_of_def)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5118
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5119
lemma threads_Exit:
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5120
    assumes "th \<in> threads s"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5121
    and "th \<notin> threads (e#s)"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5122
    shows "e = Exit th"
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5123
    using assms
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5124
    by (cases e, auto)
95e7933968f8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
  5125
108
b769f43deb30 Several redundant lemmas removed.
zhangx
parents: 107
diff changeset
  5126
end