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