CpsG.thy~
author zhangx
Thu, 28 Jan 2016 16:33:49 +0800
changeset 88 83dd5345d5d0
parent 80 17305a85493d
child 90 ed938e2246b9
permissions -rw-r--r--
Merged back ExtGG.thy and PrioG.thy.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
     1
theory CpsG
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
     2
imports PIPDefs
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
     3
begin
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
     4
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
     5
lemma Max_fg_mono:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
     6
  assumes "finite A"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
     7
  and "\<forall> a \<in> A. f a \<le> g a"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
     8
  shows "Max (f ` A) \<le> Max (g ` A)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
     9
proof(cases "A = {}")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    10
  case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    11
  thus ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    12
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    13
  case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    14
  show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    15
  proof(rule Max.boundedI)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    16
    from assms show "finite (f ` A)" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    17
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    18
    from False show "f ` A \<noteq> {}" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    19
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    20
    fix fa
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    21
    assume "fa \<in> f ` A"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    22
    then obtain a where h_fa: "a \<in> A" "fa = f a" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    23
    show "fa \<le> Max (g ` A)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    24
    proof(rule Max_ge_iff[THEN iffD2])
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    25
      from assms show "finite (g ` A)" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    26
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    27
      from False show "g ` A \<noteq> {}" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    28
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    29
      from h_fa have "g a \<in> g ` A" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    30
      moreover have "fa \<le> g a" using h_fa assms(2) by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    31
      ultimately show "\<exists>a\<in>g ` A. fa \<le> a" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    32
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    33
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    34
qed 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    35
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    36
lemma Max_f_mono:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    37
  assumes seq: "A \<subseteq> B"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    38
  and np: "A \<noteq> {}"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    39
  and fnt: "finite B"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    40
  shows "Max (f ` A) \<le> Max (f ` B)"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    41
proof(rule Max_mono)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    42
  from seq show "f ` A \<subseteq> f ` B" by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    43
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    44
  from np show "f ` A \<noteq> {}" by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    45
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    46
  from fnt and seq show "finite (f ` B)" by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    47
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    48
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    49
lemma eq_RAG: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    50
  "RAG (wq s) = RAG s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    51
  by (unfold cs_RAG_def s_RAG_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    52
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    53
lemma waiting_holding:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    54
  assumes "waiting (s::state) th cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    55
  obtains th' where "holding s th' cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    56
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    57
  from assms[unfolded s_waiting_def, folded wq_def]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    58
  obtain th' where "th' \<in> set (wq s cs)" "th' = hd (wq s cs)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    59
    by (metis empty_iff hd_in_set list.set(1))
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    60
  hence "holding s th' cs" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    61
    by (unfold s_holding_def, fold wq_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    62
  from that[OF this] show ?thesis .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    63
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    64
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    65
lemma cp_eq_cpreced: "cp s th = cpreced (wq s) s th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    66
unfolding cp_def wq_def
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    67
apply(induct s rule: schs.induct)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    68
apply(simp add: Let_def cpreced_initial)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    69
apply(simp add: Let_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    70
apply(simp add: Let_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    71
apply(simp add: Let_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    72
apply(subst (2) schs.simps)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    73
apply(simp add: Let_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    74
apply(subst (2) schs.simps)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    75
apply(simp add: Let_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    76
done
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    77
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    78
lemma cp_alt_def:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    79
  "cp s th =  
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    80
           Max ((the_preced s) ` {th'. Th th' \<in> (subtree (RAG s) (Th th))})"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    81
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    82
  have "Max (the_preced s ` ({th} \<union> dependants (wq s) th)) =
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    83
        Max (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)})" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    84
          (is "Max (_ ` ?L) = Max (_ ` ?R)")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    85
  proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    86
    have "?L = ?R" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    87
    by (auto dest:rtranclD simp:cs_dependants_def cs_RAG_def s_RAG_def subtree_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    88
    thus ?thesis by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    89
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    90
  thus ?thesis by (unfold cp_eq_cpreced cpreced_def, fold the_preced_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    91
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    92
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    93
(* ccc *)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
    94
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    95
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    96
locale valid_trace = 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    97
  fixes s
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    98
  assumes vt : "vt s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    99
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   100
locale valid_trace_e = valid_trace +
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   101
  fixes e
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   102
  assumes vt_e: "vt (e#s)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   103
begin
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   104
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   105
lemma pip_e: "PIP s e"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   106
  using vt_e by (cases, simp)  
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   107
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   108
end
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   109
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   110
locale valid_trace_create = valid_trace_e + 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   111
  fixes th prio
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   112
  assumes is_create: "e = Create th prio"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   113
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   114
locale valid_trace_exit = valid_trace_e + 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   115
  fixes th
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   116
  assumes is_exit: "e = Exit th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   117
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   118
locale valid_trace_p = valid_trace_e + 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   119
  fixes th cs
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   120
  assumes is_p: "e = P th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   121
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   122
locale valid_trace_v = valid_trace_e + 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   123
  fixes th cs
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   124
  assumes is_v: "e = V th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   125
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   126
  definition "rest = tl (wq s cs)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   127
  definition "wq' = (SOME q. distinct q \<and> set q = set rest)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   128
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   129
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   130
locale valid_trace_v_n = valid_trace_v +
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   131
  assumes rest_nnl: "rest \<noteq> []"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   132
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   133
locale valid_trace_v_e = valid_trace_v +
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   134
  assumes rest_nil: "rest = []"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   135
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   136
locale valid_trace_set= valid_trace_e + 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   137
  fixes th prio
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   138
  assumes is_set: "e = Set th prio"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   139
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   140
context valid_trace
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   141
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   142
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   143
lemma ind [consumes 0, case_names Nil Cons, induct type]:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   144
  assumes "PP []"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   145
     and "(\<And>s e. valid_trace_e s e \<Longrightarrow>
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   146
                   PP s \<Longrightarrow> PIP s e \<Longrightarrow> PP (e # s))"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   147
     shows "PP s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   148
proof(induct rule:vt.induct[OF vt, case_names Init Step])
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   149
  case Init
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   150
  from assms(1) show ?case .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   151
next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   152
  case (Step s e)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   153
  show ?case
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   154
  proof(rule assms(2))
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   155
    show "valid_trace_e s e" using Step by (unfold_locales, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   156
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   157
    show "PP s" using Step by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   158
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   159
    show "PIP s e" using Step by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   160
  qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   161
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   162
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   163
lemma  vt_moment: "\<And> t. vt (moment t s)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   164
proof(induct rule:ind)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   165
  case Nil
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   166
  thus ?case by (simp add:vt_nil)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   167
next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   168
  case (Cons s e t)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   169
  show ?case
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   170
  proof(cases "t \<ge> length (e#s)")
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   171
    case True
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   172
    from True have "moment t (e#s) = e#s" by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   173
    thus ?thesis using Cons
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   174
      by (simp add:valid_trace_def valid_trace_e_def, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   175
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   176
    case False
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   177
    from Cons have "vt (moment t s)" by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   178
    moreover have "moment t (e#s) = moment t s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   179
    proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   180
      from False have "t \<le> length s" by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   181
      from moment_app [OF this, of "[e]"] 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   182
      show ?thesis by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   183
    qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   184
    ultimately show ?thesis by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   185
  qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   186
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   187
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   188
lemma finite_threads:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   189
  shows "finite (threads s)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   190
using vt by (induct) (auto elim: step.cases)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   191
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   192
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   193
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   194
lemma RAG_target_th: "(Th th, x) \<in> RAG (s::state) \<Longrightarrow> \<exists> cs. x = Cs cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   195
  by (unfold s_RAG_def, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   196
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   197
locale valid_moment = valid_trace + 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   198
  fixes i :: nat
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   199
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   200
sublocale valid_moment < vat_moment: valid_trace "(moment i s)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   201
  by (unfold_locales, insert vt_moment, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   202
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   203
lemma waiting_eq: "waiting s th cs = waiting (wq s) th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   204
  by  (unfold s_waiting_def cs_waiting_def wq_def, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   205
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   206
lemma holding_eq: "holding (s::state) th cs = holding (wq s) th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   207
  by (unfold s_holding_def wq_def cs_holding_def, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   208
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   209
lemma runing_ready: 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   210
  shows "runing s \<subseteq> readys s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   211
  unfolding runing_def readys_def
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   212
  by auto 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   213
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   214
lemma readys_threads:
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   215
  shows "readys s \<subseteq> threads s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   216
  unfolding readys_def
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   217
  by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   218
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   219
lemma wq_v_neq [simp]:
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   220
   "cs \<noteq> cs' \<Longrightarrow> wq (V thread cs#s) cs' = wq s cs'"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   221
  by (auto simp:wq_def Let_def cp_def split:list.splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   222
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   223
lemma runing_head:
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   224
  assumes "th \<in> runing s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   225
  and "th \<in> set (wq_fun (schs s) cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   226
  shows "th = hd (wq_fun (schs s) cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   227
  using assms
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   228
  by (simp add:runing_def readys_def s_waiting_def wq_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   229
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   230
context valid_trace
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   231
begin
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   232
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   233
lemma runing_wqE:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   234
  assumes "th \<in> runing s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   235
  and "th \<in> set (wq s cs)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   236
  obtains rest where "wq s cs = th#rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   237
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   238
  from assms(2) obtain th' rest where eq_wq: "wq s cs = th'#rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   239
    by (meson list.set_cases)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   240
  have "th' = th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   241
  proof(rule ccontr)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   242
    assume "th' \<noteq> th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   243
    hence "th \<noteq> hd (wq s cs)" using eq_wq by auto 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   244
    with assms(2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   245
    have "waiting s th cs" 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   246
      by (unfold s_waiting_def, fold wq_def, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   247
    with assms show False 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   248
      by (unfold runing_def readys_def, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   249
  qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   250
  with eq_wq that show ?thesis by metis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   251
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   252
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   253
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   254
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   255
context valid_trace_create
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   256
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   257
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   258
lemma wq_neq_simp [simp]:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   259
  shows "wq (e#s) cs' = wq s cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   260
    using assms unfolding is_create wq_def
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   261
  by (auto simp:Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   262
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   263
lemma wq_distinct_kept:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   264
  assumes "distinct (wq s cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   265
  shows "distinct (wq (e#s) cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   266
  using assms by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   267
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   268
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   269
context valid_trace_exit
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   270
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   271
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   272
lemma wq_neq_simp [simp]:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   273
  shows "wq (e#s) cs' = wq s cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   274
    using assms unfolding is_exit wq_def
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   275
  by (auto simp:Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   276
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   277
lemma wq_distinct_kept:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   278
  assumes "distinct (wq s cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   279
  shows "distinct (wq (e#s) cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   280
  using assms by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   281
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   282
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   283
context valid_trace_p
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   284
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   285
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   286
lemma wq_neq_simp [simp]:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   287
  assumes "cs' \<noteq> cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   288
  shows "wq (e#s) cs' = wq s cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   289
    using assms unfolding is_p wq_def
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   290
  by (auto simp:Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   291
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   292
lemma runing_th_s:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   293
  shows "th \<in> runing s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   294
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   295
  from pip_e[unfolded is_p]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   296
  show ?thesis by (cases, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   297
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   298
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   299
lemma ready_th_s: "th \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   300
  using runing_th_s
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   301
  by (unfold runing_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   302
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   303
lemma live_th_s: "th \<in> threads s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   304
  using readys_threads ready_th_s by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   305
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   306
lemma live_th_es: "th \<in> threads (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   307
  using live_th_s 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   308
  by (unfold is_p, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   309
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   310
lemma th_not_waiting: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   311
  "\<not> waiting s th c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   312
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   313
  have "th \<in> readys s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   314
    using runing_ready runing_th_s by blast 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   315
  thus ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   316
    by (unfold readys_def, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   317
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   318
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   319
lemma waiting_neq_th: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   320
  assumes "waiting s t c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   321
  shows "t \<noteq> th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   322
  using assms using th_not_waiting by blast 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   323
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   324
lemma th_not_in_wq: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   325
  shows "th \<notin> set (wq s cs)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   326
proof
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   327
  assume otherwise: "th \<in> set (wq s cs)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   328
  from runing_wqE[OF runing_th_s this]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   329
  obtain rest where eq_wq: "wq s cs = th#rest" by blast
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   330
  with otherwise
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   331
  have "holding s th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   332
    by (unfold s_holding_def, fold wq_def, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   333
  hence cs_th_RAG: "(Cs cs, Th th) \<in> RAG s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   334
    by (unfold s_RAG_def, fold holding_eq, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   335
  from pip_e[unfolded is_p]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   336
  show False
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   337
  proof(cases)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   338
    case (thread_P)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   339
    with cs_th_RAG show ?thesis by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   340
  qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   341
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   342
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   343
lemma wq_es_cs: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   344
  "wq (e#s) cs =  wq s cs @ [th]"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   345
  by (unfold is_p wq_def, auto simp:Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   346
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   347
lemma wq_distinct_kept:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   348
  assumes "distinct (wq s cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   349
  shows "distinct (wq (e#s) cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   350
proof(cases "cs' = cs")
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   351
  case True
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   352
  show ?thesis using True assms th_not_in_wq
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   353
    by (unfold True wq_es_cs, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   354
qed (insert assms, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   355
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   356
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   357
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   358
context valid_trace_v
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   359
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   360
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   361
lemma wq_neq_simp [simp]:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   362
  assumes "cs' \<noteq> cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   363
  shows "wq (e#s) cs' = wq s cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   364
    using assms unfolding is_v wq_def
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   365
  by (auto simp:Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   366
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   367
lemma runing_th_s:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   368
  shows "th \<in> runing s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   369
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   370
  from pip_e[unfolded is_v]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   371
  show ?thesis by (cases, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   372
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   373
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   374
lemma th_not_waiting: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   375
  "\<not> waiting s th c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   376
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   377
  have "th \<in> readys s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   378
    using runing_ready runing_th_s by blast 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   379
  thus ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   380
    by (unfold readys_def, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   381
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   382
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   383
lemma waiting_neq_th: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   384
  assumes "waiting s t c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   385
  shows "t \<noteq> th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   386
  using assms using th_not_waiting by blast 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   387
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   388
lemma wq_s_cs:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   389
  "wq s cs = th#rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   390
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   391
  from pip_e[unfolded is_v]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   392
  show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   393
  proof(cases)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   394
    case (thread_V)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   395
    from this(2) show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   396
      by (unfold rest_def s_holding_def, fold wq_def,
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   397
                 metis empty_iff list.collapse list.set(1))
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   398
  qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   399
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   400
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   401
lemma wq_es_cs:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   402
  "wq (e#s) cs = wq'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   403
 using wq_s_cs[unfolded wq_def]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   404
 by (auto simp:Let_def wq_def rest_def wq'_def is_v, simp) 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   405
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   406
lemma wq_distinct_kept:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   407
  assumes "distinct (wq s cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   408
  shows "distinct (wq (e#s) cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   409
proof(cases "cs' = cs")
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   410
  case True
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   411
  show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   412
  proof(unfold True wq_es_cs wq'_def, rule someI2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   413
    show "distinct rest \<and> set rest = set rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   414
        using assms[unfolded True wq_s_cs] by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   415
  qed simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   416
qed (insert assms, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   417
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   418
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   419
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   420
context valid_trace_set
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   421
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   422
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   423
lemma wq_neq_simp [simp]:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   424
  shows "wq (e#s) cs' = wq s cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   425
    using assms unfolding is_set wq_def
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   426
  by (auto simp:Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   427
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   428
lemma wq_distinct_kept:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   429
  assumes "distinct (wq s cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   430
  shows "distinct (wq (e#s) cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   431
  using assms by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   432
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   433
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   434
context valid_trace
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   435
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   436
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   437
lemma actor_inv: 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   438
  assumes "PIP s e"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   439
  and "\<not> isCreate e"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   440
  shows "actor e \<in> runing s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   441
  using assms
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   442
  by (induct, auto)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   443
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   444
lemma isP_E:
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   445
  assumes "isP e"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   446
  obtains cs where "e = P (actor e) cs"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   447
  using assms by (cases e, auto)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   448
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   449
lemma isV_E:
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   450
  assumes "isV e"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   451
  obtains cs where "e = V (actor e) cs"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   452
  using assms by (cases e, auto) 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   453
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   454
lemma wq_distinct: "distinct (wq s cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   455
proof(induct rule:ind)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   456
  case (Cons s e)
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   457
  interpret vt_e: valid_trace_e s e using Cons by simp
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   458
  show ?case 
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   459
  proof(cases e)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   460
    case (Create th prio)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   461
    interpret vt_create: valid_trace_create s e th prio 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   462
      using Create by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   463
    show ?thesis using Cons by (simp add: vt_create.wq_distinct_kept) 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   464
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   465
    case (Exit th)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   466
    interpret vt_exit: valid_trace_exit s e th  
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   467
        using Exit by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   468
    show ?thesis using Cons by (simp add: vt_exit.wq_distinct_kept) 
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   469
  next
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   470
    case (P th cs)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   471
    interpret vt_p: valid_trace_p s e th cs using P by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   472
    show ?thesis using Cons by (simp add: vt_p.wq_distinct_kept) 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   473
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   474
    case (V th cs)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   475
    interpret vt_v: valid_trace_v s e th cs using V by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   476
    show ?thesis using Cons by (simp add: vt_v.wq_distinct_kept) 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   477
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   478
    case (Set th prio)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   479
    interpret vt_set: valid_trace_set s e th prio
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   480
        using Set by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   481
    show ?thesis using Cons by (simp add: vt_set.wq_distinct_kept) 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   482
  qed
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   483
qed (unfold wq_def Let_def, simp)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   484
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   485
end
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   486
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   487
context valid_trace_e
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   488
begin
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   489
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   490
text {*
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   491
  The following lemma shows that only the @{text "P"}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   492
  operation can add new thread into waiting queues. 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   493
  Such kind of lemmas are very obvious, but need to be checked formally.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   494
  This is a kind of confirmation that our modelling is correct.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   495
*}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   496
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   497
lemma wq_in_inv: 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   498
  assumes s_ni: "thread \<notin> set (wq s cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   499
  and s_i: "thread \<in> set (wq (e#s) cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   500
  shows "e = P thread cs"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   501
proof(cases e)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   502
  -- {* This is the only non-trivial case: *}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   503
  case (V th cs1)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   504
  have False
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   505
  proof(cases "cs1 = cs")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   506
    case True
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   507
    show ?thesis
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   508
    proof(cases "(wq s cs1)")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   509
      case (Cons w_hd w_tl)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   510
      have "set (wq (e#s) cs) \<subseteq> set (wq s cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   511
      proof -
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   512
        have "(wq (e#s) cs) = (SOME q. distinct q \<and> set q = set w_tl)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   513
          using  Cons V by (auto simp:wq_def Let_def True split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   514
        moreover have "set ... \<subseteq> set (wq s cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   515
        proof(rule someI2)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   516
          show "distinct w_tl \<and> set w_tl = set w_tl"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   517
            by (metis distinct.simps(2) local.Cons wq_distinct)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   518
        qed (insert Cons True, auto)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   519
        ultimately show ?thesis by simp
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   520
      qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   521
      with assms show ?thesis by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   522
    qed (insert assms V True, auto simp:wq_def Let_def split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   523
  qed (insert assms V, auto simp:wq_def Let_def split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   524
  thus ?thesis by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   525
qed (insert assms, auto simp:wq_def Let_def split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   526
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   527
lemma wq_out_inv: 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   528
  assumes s_in: "thread \<in> set (wq s cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   529
  and s_hd: "thread = hd (wq s cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   530
  and s_i: "thread \<noteq> hd (wq (e#s) cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   531
  shows "e = V thread cs"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   532
proof(cases e)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   533
-- {* There are only two non-trivial cases: *}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   534
  case (V th cs1)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   535
  show ?thesis
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   536
  proof(cases "cs1 = cs")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   537
    case True
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   538
    have "PIP s (V th cs)" using pip_e[unfolded V[unfolded True]] .
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   539
    thus ?thesis
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   540
    proof(cases)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   541
      case (thread_V)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   542
      moreover have "th = thread" using thread_V(2) s_hd
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   543
          by (unfold s_holding_def wq_def, simp)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   544
      ultimately show ?thesis using V True by simp
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   545
    qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   546
  qed (insert assms V, auto simp:wq_def Let_def split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   547
next
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   548
  case (P th cs1)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   549
  show ?thesis
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   550
  proof(cases "cs1 = cs")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   551
    case True
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   552
    with P have "wq (e#s) cs = wq_fun (schs s) cs @ [th]"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   553
      by (auto simp:wq_def Let_def split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   554
    with s_i s_hd s_in have False
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   555
      by (metis empty_iff hd_append2 list.set(1) wq_def) 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   556
    thus ?thesis by simp
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   557
  qed (insert assms P, auto simp:wq_def Let_def split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   558
qed (insert assms, auto simp:wq_def Let_def split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   559
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   560
end
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   561
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   562
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   563
context valid_trace
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   564
begin
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   565
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   566
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   567
text {* (* ddd *)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   568
  The nature of the work is like this: since it starts from a very simple and basic 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   569
  model, even intuitively very `basic` and `obvious` properties need to derived from scratch.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   570
  For instance, the fact 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   571
  that one thread can not be blocked by two critical resources at the same time
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   572
  is obvious, because only running threads can make new requests, if one is waiting for 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   573
  a critical resource and get blocked, it can not make another resource request and get 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   574
  blocked the second time (because it is not running). 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   575
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   576
  To derive this fact, one needs to prove by contraction and 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   577
  reason about time (or @{text "moement"}). The reasoning is based on a generic theorem
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   578
  named @{text "p_split"}, which is about status changing along the time axis. It says if 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   579
  a condition @{text "Q"} is @{text "True"} at a state @{text "s"},
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   580
  but it was @{text "False"} at the very beginning, then there must exits a moment @{text "t"} 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   581
  in the history of @{text "s"} (notice that @{text "s"} itself is essentially the history 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   582
  of events leading to it), such that @{text "Q"} switched 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   583
  from being @{text "False"} to @{text "True"} and kept being @{text "True"}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   584
  till the last moment of @{text "s"}.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   585
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   586
  Suppose a thread @{text "th"} is blocked
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   587
  on @{text "cs1"} and @{text "cs2"} in some state @{text "s"}, 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   588
  since no thread is blocked at the very beginning, by applying 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   589
  @{text "p_split"} to these two blocking facts, there exist 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   590
  two moments @{text "t1"} and @{text "t2"}  in @{text "s"}, such that 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   591
  @{text "th"} got blocked on @{text "cs1"} and @{text "cs2"} 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   592
  and kept on blocked on them respectively ever since.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   593
 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   594
  Without lost of generality, we assume @{text "t1"} is earlier than @{text "t2"}.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   595
  However, since @{text "th"} was blocked ever since memonent @{text "t1"}, so it was still
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   596
  in blocked state at moment @{text "t2"} and could not
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   597
  make any request and get blocked the second time: Contradiction.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   598
*}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   599
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   600
lemma waiting_unique_pre: (* ddd *)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   601
  assumes h11: "thread \<in> set (wq s cs1)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   602
  and h12: "thread \<noteq> hd (wq s cs1)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   603
  assumes h21: "thread \<in> set (wq s cs2)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   604
  and h22: "thread \<noteq> hd (wq s cs2)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   605
  and neq12: "cs1 \<noteq> cs2"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   606
  shows "False"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   607
proof -
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   608
  let "?Q" = "\<lambda> cs s. thread \<in> set (wq s cs) \<and> thread \<noteq> hd (wq s cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   609
  from h11 and h12 have q1: "?Q cs1 s" by simp
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   610
  from h21 and h22 have q2: "?Q cs2 s" by simp
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   611
  have nq1: "\<not> ?Q cs1 []" by (simp add:wq_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   612
  have nq2: "\<not> ?Q cs2 []" by (simp add:wq_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   613
  from p_split [of "?Q cs1", OF q1 nq1]
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   614
  obtain t1 where lt1: "t1 < length s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   615
    and np1: "\<not> ?Q cs1 (moment t1 s)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   616
    and nn1: "(\<forall>i'>t1. ?Q cs1 (moment i' s))" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   617
  from p_split [of "?Q cs2", OF q2 nq2]
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   618
  obtain t2 where lt2: "t2 < length s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   619
    and np2: "\<not> ?Q cs2 (moment t2 s)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   620
    and nn2: "(\<forall>i'>t2. ?Q cs2 (moment i' s))" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   621
  { fix s cs
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   622
    assume q: "?Q cs s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   623
    have "thread \<notin> runing s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   624
    proof
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   625
      assume "thread \<in> runing s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   626
      hence " \<forall>cs. \<not> (thread \<in> set (wq_fun (schs s) cs) \<and> 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   627
                 thread \<noteq> hd (wq_fun (schs s) cs))"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   628
        by (unfold runing_def s_waiting_def readys_def, auto)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   629
      from this[rule_format, of cs] q 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   630
      show False by (simp add: wq_def) 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   631
    qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   632
  } note q_not_runing = this
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   633
  { fix t1 t2 cs1 cs2
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   634
    assume  lt1: "t1 < length s"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   635
    and np1: "\<not> ?Q cs1 (moment t1 s)"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   636
    and nn1: "(\<forall>i'>t1. ?Q cs1 (moment i' s))"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   637
    and lt2: "t2 < length s"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   638
    and np2: "\<not> ?Q cs2 (moment t2 s)"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   639
    and nn2: "(\<forall>i'>t2. ?Q cs2 (moment i' s))"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   640
    and lt12: "t1 < t2"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   641
    let ?t3 = "Suc t2"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   642
    from lt2 have le_t3: "?t3 \<le> length s" by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   643
    from moment_plus [OF this] 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   644
    obtain e where eq_m: "moment ?t3 s = e#moment t2 s" by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   645
    have "t2 < ?t3" by simp
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   646
    from nn2 [rule_format, OF this] and eq_m
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   647
    have h1: "thread \<in> set (wq (e#moment t2 s) cs2)" and
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   648
         h2: "thread \<noteq> hd (wq (e#moment t2 s) cs2)" by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   649
    have "vt (e#moment t2 s)"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   650
    proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   651
      from vt_moment 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   652
      have "vt (moment ?t3 s)" .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   653
      with eq_m show ?thesis by simp
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   654
    qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   655
    then interpret vt_e: valid_trace_e "moment t2 s" "e"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   656
        by (unfold_locales, auto, cases, simp)
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   657
    have ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   658
    proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   659
      have "thread \<in> runing (moment t2 s)"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   660
      proof(cases "thread \<in> set (wq (moment t2 s) cs2)")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   661
        case True
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   662
        have "e = V thread cs2"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   663
        proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   664
          have eq_th: "thread = hd (wq (moment t2 s) cs2)" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   665
              using True and np2  by auto 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   666
          from vt_e.wq_out_inv[OF True this h2]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   667
          show ?thesis .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   668
        qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   669
        thus ?thesis using vt_e.actor_inv[OF vt_e.pip_e] by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   670
      next
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   671
        case False
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   672
        have "e = P thread cs2" using vt_e.wq_in_inv[OF False h1] .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   673
        with vt_e.actor_inv[OF vt_e.pip_e]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   674
        show ?thesis by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   675
      qed
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   676
      moreover have "thread \<notin> runing (moment t2 s)"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   677
        by (rule q_not_runing[OF nn1[rule_format, OF lt12]])
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   678
      ultimately show ?thesis by simp
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   679
    qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   680
  } note lt_case = this
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   681
  show ?thesis
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   682
  proof -
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   683
    { assume "t1 < t2"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   684
      from lt_case[OF lt1 np1 nn1 lt2 np2 nn2 this]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   685
      have ?thesis .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   686
    } moreover {
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   687
      assume "t2 < t1"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   688
      from lt_case[OF lt2 np2 nn2 lt1 np1 nn1 this]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   689
      have ?thesis .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   690
    } moreover {
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   691
      assume eq_12: "t1 = t2"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   692
      let ?t3 = "Suc t2"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   693
      from lt2 have le_t3: "?t3 \<le> length s" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   694
      from moment_plus [OF this] 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   695
      obtain e where eq_m: "moment ?t3 s = e#moment t2 s" by auto
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   696
      have lt_2: "t2 < ?t3" by simp
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   697
      from nn2 [rule_format, OF this] and eq_m
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   698
      have h1: "thread \<in> set (wq (e#moment t2 s) cs2)" and
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   699
           h2: "thread \<noteq> hd (wq (e#moment t2 s) cs2)" by auto
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   700
      from nn1[rule_format, OF lt_2[folded eq_12]] eq_m[folded eq_12]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   701
      have g1: "thread \<in> set (wq (e#moment t1 s) cs1)" and
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   702
           g2: "thread \<noteq> hd (wq (e#moment t1 s) cs1)" by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   703
      have "vt (e#moment t2 s)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   704
      proof -
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   705
        from vt_moment 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   706
        have "vt (moment ?t3 s)" .
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   707
        with eq_m show ?thesis by simp
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   708
      qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   709
      then interpret vt_e: valid_trace_e "moment t2 s" "e"
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   710
          by (unfold_locales, auto, cases, simp)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   711
      have "e = V thread cs2 \<or> e = P thread cs2"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   712
      proof(cases "thread \<in> set (wq (moment t2 s) cs2)")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   713
        case True
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   714
        have "e = V thread cs2"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   715
        proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   716
          have eq_th: "thread = hd (wq (moment t2 s) cs2)" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   717
              using True and np2  by auto 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   718
          from vt_e.wq_out_inv[OF True this h2]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   719
          show ?thesis .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   720
        qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   721
        thus ?thesis by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   722
      next
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   723
        case False
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   724
        have "e = P thread cs2" using vt_e.wq_in_inv[OF False h1] .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   725
        thus ?thesis by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   726
      qed
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   727
      moreover have "e = V thread cs1 \<or> e = P thread cs1"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   728
      proof(cases "thread \<in> set (wq (moment t1 s) cs1)")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   729
        case True
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   730
        have eq_th: "thread = hd (wq (moment t1 s) cs1)" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   731
              using True and np1  by auto 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   732
        from vt_e.wq_out_inv[folded eq_12, OF True this g2]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   733
        have "e = V thread cs1" .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   734
        thus ?thesis by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   735
      next
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   736
        case False
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   737
        have "e = P thread cs1" using vt_e.wq_in_inv[folded eq_12, OF False g1] .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   738
        thus ?thesis by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   739
      qed
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   740
      ultimately have ?thesis using neq12 by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   741
    } ultimately show ?thesis using nat_neq_iff by blast 
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   742
  qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   743
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   744
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   745
text {*
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   746
  This lemma is a simple corrolary of @{text "waiting_unique_pre"}.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   747
*}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   748
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   749
lemma waiting_unique:
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   750
  assumes "waiting s th cs1"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   751
  and "waiting s th cs2"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   752
  shows "cs1 = cs2"
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   753
  using waiting_unique_pre assms
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   754
  unfolding wq_def s_waiting_def
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   755
  by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   756
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   757
end
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   758
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   759
(* not used *)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   760
text {*
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   761
  Every thread can only be blocked on one critical resource, 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   762
  symmetrically, every critical resource can only be held by one thread. 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   763
  This fact is much more easier according to our definition. 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   764
*}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   765
lemma held_unique:
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   766
  assumes "holding (s::event list) th1 cs"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   767
  and "holding s th2 cs"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   768
  shows "th1 = th2"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   769
 by (insert assms, unfold s_holding_def, auto)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   770
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   771
lemma last_set_lt: "th \<in> threads s \<Longrightarrow> last_set th s < length s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   772
  apply (induct s, auto)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   773
  by (case_tac a, auto split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   774
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   775
lemma last_set_unique: 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   776
  "\<lbrakk>last_set th1 s = last_set th2 s; th1 \<in> threads s; th2 \<in> threads s\<rbrakk>
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   777
          \<Longrightarrow> th1 = th2"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   778
  apply (induct s, auto)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   779
  by (case_tac a, auto split:if_splits dest:last_set_lt)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   780
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   781
lemma preced_unique : 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   782
  assumes pcd_eq: "preced th1 s = preced th2 s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   783
  and th_in1: "th1 \<in> threads s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   784
  and th_in2: " th2 \<in> threads s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   785
  shows "th1 = th2"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   786
proof -
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   787
  from pcd_eq have "last_set th1 s = last_set th2 s" by (simp add:preced_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   788
  from last_set_unique [OF this th_in1 th_in2]
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   789
  show ?thesis .
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   790
qed
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   791
                      
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   792
lemma preced_linorder: 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   793
  assumes neq_12: "th1 \<noteq> th2"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   794
  and th_in1: "th1 \<in> threads s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   795
  and th_in2: " th2 \<in> threads s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   796
  shows "preced th1 s < preced th2 s \<or> preced th1 s > preced th2 s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   797
proof -
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   798
  from preced_unique [OF _ th_in1 th_in2] and neq_12 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   799
  have "preced th1 s \<noteq> preced th2 s" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   800
  thus ?thesis by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   801
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   802
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   803
text {*
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   804
  The following three lemmas show that @{text "RAG"} does not change
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   805
  by the happening of @{text "Set"}, @{text "Create"} and @{text "Exit"}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   806
  events, respectively.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   807
*}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   808
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   809
lemma RAG_set_unchanged: "(RAG (Set th prio # s)) = RAG s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   810
apply (unfold s_RAG_def s_waiting_def wq_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   811
by (simp add:Let_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   812
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   813
lemma (in valid_trace_set)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   814
   RAG_unchanged: "(RAG (e # s)) = RAG s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   815
   by (unfold is_set RAG_set_unchanged, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   816
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   817
lemma RAG_create_unchanged: "(RAG (Create th prio # s)) = RAG s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   818
apply (unfold s_RAG_def s_waiting_def wq_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   819
by (simp add:Let_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   820
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   821
lemma (in valid_trace_create)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   822
   RAG_unchanged: "(RAG (e # s)) = RAG s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   823
   by (unfold is_create RAG_create_unchanged, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   824
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   825
lemma RAG_exit_unchanged: "(RAG (Exit th # s)) = RAG s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   826
apply (unfold s_RAG_def s_waiting_def wq_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   827
by (simp add:Let_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   828
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   829
lemma (in valid_trace_exit)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   830
   RAG_unchanged: "(RAG (e # s)) = RAG s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   831
   by (unfold is_exit RAG_exit_unchanged, simp)
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   832
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   833
context valid_trace_v
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   834
begin
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   835
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   836
lemma distinct_rest: "distinct rest"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   837
  by (simp add: distinct_tl rest_def wq_distinct)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   838
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   839
lemma holding_cs_eq_th:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   840
  assumes "holding s t cs"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   841
  shows "t = th"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   842
proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   843
  from pip_e[unfolded is_v]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   844
  show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   845
  proof(cases)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   846
    case (thread_V)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   847
    from held_unique[OF this(2) assms]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   848
    show ?thesis by simp
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   849
  qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   850
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   851
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   852
lemma distinct_wq': "distinct wq'"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   853
  by (metis (mono_tags, lifting) distinct_rest  some_eq_ex wq'_def)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   854
  
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   855
lemma set_wq': "set wq' = set rest"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   856
  by (metis (mono_tags, lifting) distinct_rest rest_def 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   857
      some_eq_ex wq'_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   858
    
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   859
lemma th'_in_inv:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   860
  assumes "th' \<in> set wq'"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   861
  shows "th' \<in> set rest"
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
   862
  using assms set_wq' by simp
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   863
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   864
lemma neq_t_th: 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   865
  assumes "waiting (e#s) t c"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   866
  shows "t \<noteq> th"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   867
proof
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   868
  assume otherwise: "t = th"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   869
  show False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   870
  proof(cases "c = cs")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   871
    case True
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   872
    have "t \<in> set wq'" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   873
     using assms[unfolded True s_waiting_def, folded wq_def, unfolded wq_es_cs]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   874
     by simp 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   875
    from th'_in_inv[OF this] have "t \<in> set rest" .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   876
    with wq_s_cs[folded otherwise] wq_distinct[of cs]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   877
    show ?thesis by simp
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   878
  next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   879
    case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   880
    have "wq (e#s) c = wq s c" using False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   881
        by (unfold is_v, simp)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   882
    hence "waiting s t c" using assms 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   883
        by (simp add: cs_waiting_def waiting_eq)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   884
    hence "t \<notin> readys s" by (unfold readys_def, auto)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   885
    hence "t \<notin> runing s" using runing_ready by auto 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   886
    with runing_th_s[folded otherwise] show ?thesis by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   887
  qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   888
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   889
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   890
lemma waiting_esI1:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   891
  assumes "waiting s t c"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   892
      and "c \<noteq> cs" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   893
  shows "waiting (e#s) t c" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   894
proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   895
  have "wq (e#s) c = wq s c" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   896
    using assms(2) is_v by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   897
  with assms(1) show ?thesis 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   898
    using cs_waiting_def waiting_eq by auto 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   899
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   900
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   901
lemma holding_esI2:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   902
  assumes "c \<noteq> cs" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   903
  and "holding s t c"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   904
  shows "holding (e#s) t c"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   905
proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   906
  from assms(1) have "wq (e#s) c = wq s c" using is_v by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   907
  from assms(2)[unfolded s_holding_def, folded wq_def, 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   908
                folded this, unfolded wq_def, folded s_holding_def]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   909
  show ?thesis .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   910
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   911
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   912
lemma holding_esI1:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   913
  assumes "holding s t c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   914
  and "t \<noteq> th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   915
  shows "holding (e#s) t c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   916
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   917
  have "c \<noteq> cs" using assms using holding_cs_eq_th by blast 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   918
  from holding_esI2[OF this assms(1)]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   919
  show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   920
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   921
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   922
end
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   923
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   924
context valid_trace_v_n
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   925
begin
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   926
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   927
lemma neq_wq': "wq' \<noteq> []" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   928
proof (unfold wq'_def, rule someI2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   929
  show "distinct rest \<and> set rest = set rest"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   930
    by (simp add: distinct_rest) 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   931
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   932
  fix x
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   933
  assume " distinct x \<and> set x = set rest" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   934
  thus "x \<noteq> []" using rest_nnl by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   935
qed 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   936
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   937
definition "taker = hd wq'"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   938
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   939
definition "rest' = tl wq'"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   940
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   941
lemma eq_wq': "wq' = taker # rest'"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   942
  by (simp add: neq_wq' rest'_def taker_def)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   943
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   944
lemma next_th_taker: 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   945
  shows "next_th s th cs taker"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   946
  using rest_nnl taker_def wq'_def wq_s_cs 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   947
  by (auto simp:next_th_def)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   948
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   949
lemma taker_unique: 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   950
  assumes "next_th s th cs taker'"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   951
  shows "taker' = taker"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   952
proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   953
  from assms
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   954
  obtain rest' where 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   955
    h: "wq s cs = th # rest'" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   956
       "taker' = hd (SOME q. distinct q \<and> set q = set rest')"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   957
          by (unfold next_th_def, auto)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   958
  with wq_s_cs have "rest' = rest" by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   959
  thus ?thesis using h(2) taker_def wq'_def by auto 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   960
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   961
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   962
lemma waiting_set_eq:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   963
  "{(Th th', Cs cs) |th'. next_th s th cs th'} = {(Th taker, Cs cs)}"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   964
  by (smt all_not_in_conv bot.extremum insertI1 insert_subset 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   965
      mem_Collect_eq next_th_taker subsetI subset_antisym taker_def taker_unique)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   966
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   967
lemma holding_set_eq:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   968
  "{(Cs cs, Th th') |th'.  next_th s th cs th'} = {(Cs cs, Th taker)}"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   969
  using next_th_taker taker_def waiting_set_eq 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   970
  by fastforce
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   971
   
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   972
lemma holding_taker:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   973
  shows "holding (e#s) taker cs"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   974
    by (unfold s_holding_def, fold wq_def, unfold wq_es_cs, 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   975
        auto simp:neq_wq' taker_def)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   976
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   977
lemma waiting_esI2:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   978
  assumes "waiting s t cs"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   979
      and "t \<noteq> taker"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   980
  shows "waiting (e#s) t cs" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   981
proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   982
  have "t \<in> set wq'" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   983
  proof(unfold wq'_def, rule someI2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   984
    show "distinct rest \<and> set rest = set rest"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   985
          by (simp add: distinct_rest)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   986
  next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   987
    fix x
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   988
    assume "distinct x \<and> set x = set rest"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   989
    moreover have "t \<in> set rest"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   990
        using assms(1) cs_waiting_def waiting_eq wq_s_cs by auto 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   991
    ultimately show "t \<in> set x" by simp
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   992
  qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   993
  moreover have "t \<noteq> hd wq'"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   994
    using assms(2) taker_def by auto 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   995
  ultimately show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   996
    by (unfold s_waiting_def, fold wq_def, unfold wq_es_cs, simp)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   997
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   998
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   999
lemma waiting_esE:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1000
  assumes "waiting (e#s) t c" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1001
  obtains "c \<noteq> cs" "waiting s t c"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1002
     |    "c = cs" "t \<noteq> taker" "waiting s t cs" "t \<in> set rest'"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1003
proof(cases "c = cs")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1004
  case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1005
  hence "wq (e#s) c = wq s c" using is_v by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1006
  with assms have "waiting s t c" using cs_waiting_def waiting_eq by auto 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1007
  from that(1)[OF False this] show ?thesis .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1008
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1009
  case True
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1010
  from assms[unfolded s_waiting_def True, folded wq_def, unfolded wq_es_cs]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1011
  have "t \<noteq> hd wq'" "t \<in> set wq'" by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1012
  hence "t \<noteq> taker" by (simp add: taker_def) 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1013
  moreover hence "t \<noteq> th" using assms neq_t_th by blast 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1014
  moreover have "t \<in> set rest" by (simp add: `t \<in> set wq'` th'_in_inv) 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1015
  ultimately have "waiting s t cs"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1016
    by (metis cs_waiting_def list.distinct(2) list.sel(1) 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1017
                list.set_sel(2) rest_def waiting_eq wq_s_cs)  
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1018
  show ?thesis using that(2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1019
  using True `t \<in> set wq'` `t \<noteq> taker` `waiting s t cs` eq_wq' by auto   
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1020
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1021
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1022
lemma holding_esI1:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1023
  assumes "c = cs"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1024
  and "t = taker"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1025
  shows "holding (e#s) t c"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1026
  by (unfold assms, simp add: holding_taker)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1027
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1028
lemma holding_esE:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1029
  assumes "holding (e#s) t c" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1030
  obtains "c = cs" "t = taker"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1031
      | "c \<noteq> cs" "holding s t c"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1032
proof(cases "c = cs")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1033
  case True
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1034
  from assms[unfolded True, unfolded s_holding_def, 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1035
             folded wq_def, unfolded wq_es_cs]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1036
  have "t = taker" by (simp add: taker_def) 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1037
  from that(1)[OF True this] show ?thesis .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1038
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1039
  case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1040
  hence "wq (e#s) c = wq s c" using is_v by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1041
  from assms[unfolded s_holding_def, folded wq_def, 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1042
             unfolded this, unfolded wq_def, folded s_holding_def]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1043
  have "holding s t c"  .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1044
  from that(2)[OF False this] show ?thesis .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1045
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1046
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1047
end 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1048
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1049
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1050
context valid_trace_v_e
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1051
begin
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1052
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1053
lemma nil_wq': "wq' = []" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1054
proof (unfold wq'_def, rule someI2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1055
  show "distinct rest \<and> set rest = set rest"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1056
    by (simp add: distinct_rest) 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1057
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1058
  fix x
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1059
  assume " distinct x \<and> set x = set rest" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1060
  thus "x = []" using rest_nil by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1061
qed 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1062
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1063
lemma no_taker: 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1064
  assumes "next_th s th cs taker"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1065
  shows "False"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1066
proof -
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1067
  from assms[unfolded next_th_def]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1068
  obtain rest' where "wq s cs = th # rest'" "rest' \<noteq> []"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1069
    by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1070
  thus ?thesis using rest_def rest_nil by auto 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1071
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1072
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1073
lemma waiting_set_eq:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1074
  "{(Th th', Cs cs) |th'. next_th s th cs th'} = {}"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1075
  using no_taker by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1076
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1077
lemma holding_set_eq:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1078
  "{(Cs cs, Th th') |th'.  next_th s th cs th'} = {}"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1079
  using no_taker by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1080
   
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1081
lemma no_holding:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1082
  assumes "holding (e#s) taker cs"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1083
  shows False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1084
proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1085
  from wq_es_cs[unfolded nil_wq']
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1086
  have " wq (e # s) cs = []" .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1087
  from assms[unfolded s_holding_def, folded wq_def, unfolded this]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1088
  show ?thesis by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1089
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1090
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1091
lemma no_waiting:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1092
  assumes "waiting (e#s) t cs"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1093
  shows False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1094
proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1095
  from wq_es_cs[unfolded nil_wq']
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1096
  have " wq (e # s) cs = []" .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1097
  from assms[unfolded s_waiting_def, folded wq_def, unfolded this]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1098
  show ?thesis by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1099
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1100
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1101
lemma waiting_esI2:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1102
  assumes "waiting s t c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1103
  shows "waiting (e#s) t c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1104
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1105
  have "c \<noteq> cs" using assms
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1106
    using cs_waiting_def rest_nil waiting_eq wq_s_cs by auto 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1107
  from waiting_esI1[OF assms this]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1108
  show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1109
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1110
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1111
lemma waiting_esE:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1112
  assumes "waiting (e#s) t c" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1113
  obtains "c \<noteq> cs" "waiting s t c"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1114
proof(cases "c = cs")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1115
  case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1116
  hence "wq (e#s) c = wq s c" using is_v by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1117
  with assms have "waiting s t c" using cs_waiting_def waiting_eq by auto 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1118
  from that(1)[OF False this] show ?thesis .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1119
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1120
  case True
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1121
  from no_waiting[OF assms[unfolded True]]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1122
  show ?thesis by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1123
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1124
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1125
lemma holding_esE:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1126
  assumes "holding (e#s) t c" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1127
  obtains "c \<noteq> cs" "holding s t c"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1128
proof(cases "c = cs")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1129
  case True
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1130
  from no_holding[OF assms[unfolded True]] 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1131
  show ?thesis by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1132
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1133
  case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1134
  hence "wq (e#s) c = wq s c" using is_v by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1135
  from assms[unfolded s_holding_def, folded wq_def, 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1136
             unfolded this, unfolded wq_def, folded s_holding_def]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1137
  have "holding s t c"  .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1138
  from that[OF False this] show ?thesis .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1139
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1140
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1141
end 
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1142
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1143
lemma rel_eqI:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1144
  assumes "\<And> x y. (x,y) \<in> A \<Longrightarrow> (x,y) \<in> B"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1145
  and "\<And> x y. (x,y) \<in> B \<Longrightarrow> (x, y) \<in> A"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1146
  shows "A = B"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1147
  using assms by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1148
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1149
lemma in_RAG_E:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1150
  assumes "(n1, n2) \<in> RAG (s::state)"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1151
  obtains (waiting) th cs where "n1 = Th th" "n2 = Cs cs" "waiting s th cs"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1152
      | (holding) th cs where "n1 = Cs cs" "n2 = Th th" "holding s th cs"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1153
  using assms[unfolded s_RAG_def, folded waiting_eq holding_eq]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1154
  by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1155
  
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1156
context valid_trace_v
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1157
begin
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1158
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1159
lemma RAG_es:
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1160
  "RAG (e # s) =
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1161
   RAG s - {(Cs cs, Th th)} -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1162
     {(Th th', Cs cs) |th'. next_th s th cs th'} \<union>
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1163
     {(Cs cs, Th th') |th'.  next_th s th cs th'}" (is "?L = ?R")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1164
proof(rule rel_eqI)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1165
  fix n1 n2
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1166
  assume "(n1, n2) \<in> ?L"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1167
  thus "(n1, n2) \<in> ?R"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1168
  proof(cases rule:in_RAG_E)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1169
    case (waiting th' cs')
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1170
    show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1171
    proof(cases "rest = []")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1172
      case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1173
      interpret h_n: valid_trace_v_n s e th cs
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1174
        by (unfold_locales, insert False, simp)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1175
      from waiting(3)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1176
      show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1177
      proof(cases rule:h_n.waiting_esE)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1178
        case 1
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1179
        with waiting(1,2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1180
        show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1181
        by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1182
             fold waiting_eq, auto)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1183
      next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1184
        case 2
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1185
        with waiting(1,2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1186
        show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1187
         by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1188
             fold waiting_eq, auto)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1189
      qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1190
    next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1191
      case True
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1192
      interpret h_e: valid_trace_v_e s e th cs
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1193
        by (unfold_locales, insert True, simp)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1194
      from waiting(3)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1195
      show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1196
      proof(cases rule:h_e.waiting_esE)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1197
        case 1
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1198
        with waiting(1,2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1199
        show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1200
        by (unfold h_e.waiting_set_eq h_e.holding_set_eq s_RAG_def, 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1201
             fold waiting_eq, auto)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1202
      qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1203
    qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1204
  next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1205
    case (holding th' cs')
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1206
    show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1207
    proof(cases "rest = []")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1208
      case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1209
      interpret h_n: valid_trace_v_n s e th cs
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1210
        by (unfold_locales, insert False, simp)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1211
      from holding(3)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1212
      show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1213
      proof(cases rule:h_n.holding_esE)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1214
        case 1
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1215
        with holding(1,2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1216
        show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1217
        by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1218
             fold waiting_eq, auto)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1219
      next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1220
        case 2
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1221
        with holding(1,2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1222
        show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1223
         by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1224
             fold holding_eq, auto)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1225
      qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1226
    next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1227
      case True
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1228
      interpret h_e: valid_trace_v_e s e th cs
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1229
        by (unfold_locales, insert True, simp)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1230
      from holding(3)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1231
      show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1232
      proof(cases rule:h_e.holding_esE)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1233
        case 1
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1234
        with holding(1,2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1235
        show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1236
        by (unfold h_e.waiting_set_eq h_e.holding_set_eq s_RAG_def, 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1237
             fold holding_eq, auto)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1238
      qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1239
    qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1240
  qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1241
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1242
  fix n1 n2
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1243
  assume h: "(n1, n2) \<in> ?R"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1244
  show "(n1, n2) \<in> ?L"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1245
  proof(cases "rest = []")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1246
    case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1247
    interpret h_n: valid_trace_v_n s e th cs
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1248
        by (unfold_locales, insert False, simp)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1249
    from h[unfolded h_n.waiting_set_eq h_n.holding_set_eq]
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1250
    have "((n1, n2) \<in> RAG s \<and> (n1 \<noteq> Cs cs \<or> n2 \<noteq> Th th)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1251
                            \<and> (n1 \<noteq> Th h_n.taker \<or> n2 \<noteq> Cs cs)) \<or> 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1252
          (n2 = Th h_n.taker \<and> n1 = Cs cs)" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1253
      by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1254
   thus ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1255
   proof
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1256
      assume "n2 = Th h_n.taker \<and> n1 = Cs cs"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1257
      with h_n.holding_taker
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1258
      show ?thesis 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1259
        by (unfold s_RAG_def, fold holding_eq, auto)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1260
   next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1261
    assume h: "(n1, n2) \<in> RAG s \<and>
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1262
        (n1 \<noteq> Cs cs \<or> n2 \<noteq> Th th) \<and> (n1 \<noteq> Th h_n.taker \<or> n2 \<noteq> Cs cs)"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1263
    hence "(n1, n2) \<in> RAG s" by simp
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1264
    thus ?thesis
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1265
    proof(cases rule:in_RAG_E)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1266
      case (waiting th' cs')
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1267
      from h and this(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1268
      have "th' \<noteq> h_n.taker \<or> cs' \<noteq> cs" by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1269
      hence "waiting (e#s) th' cs'" 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1270
      proof
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1271
        assume "cs' \<noteq> cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1272
        from waiting_esI1[OF waiting(3) this] 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1273
        show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1274
      next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1275
        assume neq_th': "th' \<noteq> h_n.taker"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1276
        show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1277
        proof(cases "cs' = cs")
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1278
          case False
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1279
          from waiting_esI1[OF waiting(3) this] 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1280
          show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1281
        next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1282
          case True
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1283
          from h_n.waiting_esI2[OF waiting(3)[unfolded True] neq_th', folded True]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1284
          show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1285
        qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1286
      qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1287
      thus ?thesis using waiting(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1288
        by (unfold s_RAG_def, fold waiting_eq, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1289
    next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1290
      case (holding th' cs')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1291
      from h this(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1292
      have "cs' \<noteq> cs \<or> th' \<noteq> th" by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1293
      hence "holding (e#s) th' cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1294
      proof
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1295
        assume "cs' \<noteq> cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1296
        from holding_esI2[OF this holding(3)] 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1297
        show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1298
      next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1299
        assume "th' \<noteq> th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1300
        from holding_esI1[OF holding(3) this]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1301
        show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1302
      qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1303
      thus ?thesis using holding(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1304
        by (unfold s_RAG_def, fold holding_eq, auto)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1305
    qed
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1306
   qed
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1307
 next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1308
   case True
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1309
   interpret h_e: valid_trace_v_e s e th cs
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1310
        by (unfold_locales, insert True, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1311
   from h[unfolded h_e.waiting_set_eq h_e.holding_set_eq]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1312
   have h_s: "(n1, n2) \<in> RAG s" "(n1, n2) \<noteq> (Cs cs, Th th)" 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1313
      by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1314
   from h_s(1)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1315
   show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1316
   proof(cases rule:in_RAG_E)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1317
    case (waiting th' cs')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1318
    from h_e.waiting_esI2[OF this(3)]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1319
    show ?thesis using waiting(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1320
      by (unfold s_RAG_def, fold waiting_eq, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1321
   next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1322
    case (holding th' cs')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1323
    with h_s(2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1324
    have "cs' \<noteq> cs \<or> th' \<noteq> th" by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1325
    thus ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1326
    proof
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1327
      assume neq_cs: "cs' \<noteq> cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1328
      from holding_esI2[OF this holding(3)]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1329
      show ?thesis using holding(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1330
        by (unfold s_RAG_def, fold holding_eq, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1331
    next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1332
      assume "th' \<noteq> th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1333
      from holding_esI1[OF holding(3) this]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1334
      show ?thesis using holding(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1335
        by (unfold s_RAG_def, fold holding_eq, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1336
    qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1337
   qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1338
 qed
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1339
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1340
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1341
end
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1342
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1343
lemma step_RAG_v: 
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1344
assumes vt:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1345
  "vt (V th cs#s)"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1346
shows "
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1347
  RAG (V th cs # s) =
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1348
  RAG s - {(Cs cs, Th th)} -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1349
  {(Th th', Cs cs) |th'. next_th s th cs th'} \<union>
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1350
  {(Cs cs, Th th') |th'.  next_th s th cs th'}" (is "?L = ?R")
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1351
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1352
  interpret vt_v: valid_trace_v s "V th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1353
    using assms step_back_vt by (unfold_locales, auto) 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1354
  show ?thesis using vt_v.RAG_es .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1355
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1356
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1357
lemma (in valid_trace_create)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1358
  th_not_in_threads: "th \<notin> threads s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1359
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1360
  from pip_e[unfolded is_create]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1361
  show ?thesis by (cases, simp)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1362
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1363
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1364
lemma (in valid_trace_create)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1365
  threads_es [simp]: "threads (e#s) = threads s \<union> {th}"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1366
  by (unfold is_create, simp)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1367
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1368
lemma (in valid_trace_exit)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1369
  threads_es [simp]: "threads (e#s) = threads s - {th}"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1370
  by (unfold is_exit, simp)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1371
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1372
lemma (in valid_trace_p)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1373
  threads_es [simp]: "threads (e#s) = threads s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1374
  by (unfold is_p, simp)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1375
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1376
lemma (in valid_trace_v)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1377
  threads_es [simp]: "threads (e#s) = threads s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1378
  by (unfold is_v, simp)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1379
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1380
lemma (in valid_trace_v)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1381
  th_not_in_rest[simp]: "th \<notin> set rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1382
proof
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1383
  assume otherwise: "th \<in> set rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1384
  have "distinct (wq s cs)" by (simp add: wq_distinct)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1385
  from this[unfolded wq_s_cs] and otherwise
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1386
  show False by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1387
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1388
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1389
lemma (in valid_trace_v)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1390
  set_wq_es_cs [simp]: "set (wq (e#s) cs) = set (wq s cs) - {th}"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1391
proof(unfold wq_es_cs wq'_def, rule someI2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1392
  show "distinct rest \<and> set rest = set rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1393
    by (simp add: distinct_rest)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1394
next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1395
  fix x
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1396
  assume "distinct x \<and> set x = set rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1397
  thus "set x = set (wq s cs) - {th}" 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1398
      by (unfold wq_s_cs, simp)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1399
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1400
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1401
lemma (in valid_trace_exit)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1402
  th_not_in_wq: "th \<notin> set (wq s cs)"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1403
proof -
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1404
  from pip_e[unfolded is_exit]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1405
  show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1406
  by (cases, unfold holdents_def s_holding_def, fold wq_def, 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1407
             auto elim!:runing_wqE)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1408
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1409
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1410
lemma (in valid_trace) wq_threads: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1411
  assumes "th \<in> set (wq s cs)"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1412
  shows "th \<in> threads s"
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1413
  using assms
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1414
proof(induct rule:ind)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1415
  case (Nil)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1416
  thus ?case by (auto simp:wq_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1417
next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1418
  case (Cons s e)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1419
  interpret vt_e: valid_trace_e s e using Cons by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1420
  show ?case
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1421
  proof(cases e)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1422
    case (Create th' prio')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1423
    interpret vt: valid_trace_create s e th' prio'
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1424
      using Create by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1425
    show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1426
      using Cons.hyps(2) Cons.prems by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1427
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1428
    case (Exit th')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1429
    interpret vt: valid_trace_exit s e th'
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1430
      using Exit by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1431
    show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1432
      using Cons.hyps(2) Cons.prems vt.th_not_in_wq by auto 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1433
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1434
    case (P th' cs')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1435
    interpret vt: valid_trace_p s e th' cs'
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1436
      using P by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1437
    show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1438
      using Cons.hyps(2) Cons.prems readys_threads 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1439
        runing_ready vt.is_p vt.runing_th_s vt_e.wq_in_inv 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1440
        by fastforce 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1441
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1442
    case (V th' cs')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1443
    interpret vt: valid_trace_v s e th' cs'
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1444
      using V by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1445
    show ?thesis using Cons
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1446
      using vt.is_v vt.threads_es vt_e.wq_in_inv by blast
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1447
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1448
    case (Set th' prio)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1449
    interpret vt: valid_trace_set s e th' prio
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1450
      using Set by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1451
    show ?thesis using Cons.hyps(2) Cons.prems vt.is_set 
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1452
        by (auto simp:wq_def Let_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1453
  qed
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1454
qed 
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1455
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1456
context valid_trace
57
f1b39d77db00 Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff changeset
  1457
begin
f1b39d77db00 Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff changeset
  1458
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1459
lemma  dm_RAG_threads:
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1460
  assumes in_dom: "(Th th) \<in> Domain (RAG s)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1461
  shows "th \<in> threads s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1462
proof -
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1463
  from in_dom obtain n where "(Th th, n) \<in> RAG s" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1464
  moreover from RAG_target_th[OF this] obtain cs where "n = Cs cs" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1465
  ultimately have "(Th th, Cs cs) \<in> RAG s" by simp
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1466
  hence "th \<in> set (wq s cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1467
    by (unfold s_RAG_def, auto simp:cs_waiting_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1468
  from wq_threads [OF this] show ?thesis .
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1469
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1470
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1471
lemma rg_RAG_threads: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1472
  assumes "(Th th) \<in> Range (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1473
  shows "th \<in> threads s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1474
  using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1475
  by (unfold s_RAG_def cs_waiting_def cs_holding_def, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1476
       auto intro:wq_threads)
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1477
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1478
end
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1479
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1480
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1481
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1482
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1483
lemma preced_v [simp]: "preced th' (V th cs#s) = preced th' s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1484
  by (unfold preced_def, simp)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1485
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1486
lemma (in valid_trace_v)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1487
  preced_es: "preced th (e#s) = preced th s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1488
  by (unfold is_v preced_def, simp)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1489
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1490
lemma the_preced_v[simp]: "the_preced (V th cs#s) = the_preced s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1491
proof
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1492
  fix th'
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1493
  show "the_preced (V th cs # s) th' = the_preced s th'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1494
    by (unfold the_preced_def preced_def, simp)
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
  1495
qed
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
  1496
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1497
lemma (in valid_trace_v)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1498
  the_preced_es: "the_preced (e#s) = the_preced s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1499
  by (unfold is_v preced_def, simp)
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1500
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1501
context valid_trace_p
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1502
begin
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1503
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1504
lemma not_holding_s_th_cs: "\<not> holding s th cs"
62
031d2ae9c9b8 In the middle of retrofiting ExtGG.thy.
zhangx
parents: 61
diff changeset
  1505
proof
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1506
  assume otherwise: "holding s th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1507
  from pip_e[unfolded is_p]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1508
  show False
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1509
  proof(cases)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1510
    case (thread_P)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1511
    moreover have "(Cs cs, Th th) \<in> RAG s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1512
      using otherwise cs_holding_def 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1513
            holding_eq th_not_in_wq by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1514
    ultimately show ?thesis by auto
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1515
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1516
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1517
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1518
lemma waiting_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1519
  assumes "waiting s th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1520
  shows "waiting (e#s) th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1521
  using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1522
  by (metis cs_waiting_def hd_append2 list.sel(1) list.set_intros(2) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1523
      rotate1.simps(2) self_append_conv2 set_rotate1 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1524
        th_not_in_wq waiting_eq wq_es_cs wq_neq_simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1525
  
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1526
lemma holding_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1527
  assumes "holding s th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1528
  shows "holding (e#s) th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1529
proof(cases "cs' = cs")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1530
  case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1531
  hence "wq (e#s) cs' = wq s cs'" by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1532
  with assms show ?thesis using cs_holding_def holding_eq by auto 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1533
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1534
  case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1535
  from assms[unfolded s_holding_def, folded wq_def]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1536
  obtain rest where eq_wq: "wq s cs' = th'#rest"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1537
    by (metis empty_iff list.collapse list.set(1)) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1538
  hence "wq (e#s) cs' = th'#(rest@[th])"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1539
    by (simp add: True wq_es_cs) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1540
  thus ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1541
    by (simp add: cs_holding_def holding_eq) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1542
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1543
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1544
end
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1545
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1546
locale valid_trace_p_h = valid_trace_p +
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1547
  assumes we: "wq s cs = []"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1548
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1549
locale valid_trace_p_w = valid_trace_p +
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1550
  assumes wne: "wq s cs \<noteq> []"
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1551
begin
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1552
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1553
definition "holder = hd (wq s cs)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1554
definition "waiters = tl (wq s cs)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1555
definition "waiters' = waiters @ [th]"
57
f1b39d77db00 Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff changeset
  1556
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1557
lemma wq_s_cs: "wq s cs = holder#waiters"
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1558
    by (simp add: holder_def waiters_def wne)
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1559
    
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1560
lemma wq_es_cs': "wq (e#s) cs = holder#waiters@[th]"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1561
  by (simp add: wq_es_cs wq_s_cs)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1562
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1563
lemma waiting_es_th_cs: "waiting (e#s) th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1564
  using cs_waiting_def th_not_in_wq waiting_eq wq_es_cs' wq_s_cs by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1565
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1566
lemma RAG_edge: "(Th th, Cs cs) \<in> RAG (e#s)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1567
   by (unfold s_RAG_def, fold waiting_eq, insert waiting_es_th_cs, auto)
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1568
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1569
lemma holding_esE:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1570
  assumes "holding (e#s) th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1571
  obtains "holding s th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1572
  using assms 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1573
proof(cases "cs' = cs")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1574
  case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1575
  hence "wq (e#s) cs' = wq s cs'" by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1576
  with assms show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1577
    using cs_holding_def holding_eq that by auto 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1578
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1579
  case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1580
  with assms show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1581
  by (metis cs_holding_def holding_eq list.sel(1) list.set_intros(1) that 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1582
        wq_es_cs' wq_s_cs) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1583
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1584
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1585
lemma waiting_esE:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1586
  assumes "waiting (e#s) th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1587
  obtains "th' \<noteq> th" "waiting s th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1588
     |  "th' = th" "cs' = cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1589
proof(cases "waiting s th' cs'")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1590
  case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1591
  have "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1592
  proof
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1593
    assume otherwise: "th' = th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1594
    from True[unfolded this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1595
    show False by (simp add: th_not_waiting) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1596
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1597
  from that(1)[OF this True] show ?thesis .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1598
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1599
  case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1600
  hence "th' = th \<and> cs' = cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1601
      by (metis assms cs_waiting_def holder_def list.sel(1) rotate1.simps(2) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1602
        set_ConsD set_rotate1 waiting_eq wq_es_cs wq_es_cs' wq_neq_simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1603
  with that(2) show ?thesis by metis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1604
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1605
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1606
lemma RAG_es: "RAG (e # s) =  RAG s \<union> {(Th th, Cs cs)}" (is "?L = ?R")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1607
proof(rule rel_eqI)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1608
  fix n1 n2
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1609
  assume "(n1, n2) \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1610
  thus "(n1, n2) \<in> ?R" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1611
  proof(cases rule:in_RAG_E)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1612
    case (waiting th' cs')
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1613
    from this(3)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1614
    show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1615
    proof(cases rule:waiting_esE)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1616
      case 1
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1617
      thus ?thesis using waiting(1,2)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1618
        by (unfold s_RAG_def, fold waiting_eq, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1619
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1620
      case 2
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1621
      thus ?thesis using waiting(1,2) by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1622
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1623
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1624
    case (holding th' cs')
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1625
    from this(3)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1626
    show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1627
    proof(cases rule:holding_esE)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1628
      case 1
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1629
      with holding(1,2)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1630
      show ?thesis by (unfold s_RAG_def, fold holding_eq, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1631
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1632
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1633
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1634
  fix n1 n2
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1635
  assume "(n1, n2) \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1636
  hence "(n1, n2) \<in> RAG s \<or> (n1 = Th th \<and> n2 = Cs cs)" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1637
  thus "(n1, n2) \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1638
  proof
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1639
    assume "(n1, n2) \<in> RAG s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1640
    thus ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1641
    proof(cases rule:in_RAG_E)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1642
      case (waiting th' cs')
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1643
      from waiting_kept[OF this(3)]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1644
      show ?thesis using waiting(1,2)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1645
         by (unfold s_RAG_def, fold waiting_eq, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1646
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1647
      case (holding th' cs')
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1648
      from holding_kept[OF this(3)]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1649
      show ?thesis using holding(1,2)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1650
         by (unfold s_RAG_def, fold holding_eq, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1651
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1652
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1653
    assume "n1 = Th th \<and> n2 = Cs cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1654
    thus ?thesis using RAG_edge by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1655
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1656
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1657
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1658
end
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1659
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1660
context valid_trace_p_h
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1661
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1662
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1663
lemma wq_es_cs': "wq (e#s) cs = [th]"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1664
  using wq_es_cs[unfolded we] by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1665
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1666
lemma holding_es_th_cs: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1667
  shows "holding (e#s) th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1668
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1669
  from wq_es_cs'
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1670
  have "th \<in> set (wq (e#s) cs)" "th = hd (wq (e#s) cs)" by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1671
  thus ?thesis using cs_holding_def holding_eq by blast 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1672
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1673
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1674
lemma RAG_edge: "(Cs cs, Th th) \<in> RAG (e#s)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1675
  by (unfold s_RAG_def, fold holding_eq, insert holding_es_th_cs, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1676
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1677
lemma waiting_esE:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1678
  assumes "waiting (e#s) th' cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1679
  obtains "waiting s th' cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1680
  using assms
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1681
  by (metis cs_waiting_def event.distinct(15) is_p list.sel(1) 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1682
        set_ConsD waiting_eq we wq_es_cs' wq_neq_simp wq_out_inv)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1683
  
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1684
lemma holding_esE:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1685
  assumes "holding (e#s) th' cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1686
  obtains "cs' \<noteq> cs" "holding s th' cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1687
    | "cs' = cs" "th' = th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1688
proof(cases "cs' = cs")
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1689
  case True
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1690
  from held_unique[OF holding_es_th_cs assms[unfolded True]]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1691
  have "th' = th" by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1692
  from that(2)[OF True this] show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1693
next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1694
  case False
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1695
  have "holding s th' cs'" using assms
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1696
    using False cs_holding_def holding_eq by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1697
  from that(1)[OF False this] show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1698
qed
57
f1b39d77db00 Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff changeset
  1699
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1700
lemma RAG_es: "RAG (e # s) =  RAG s \<union> {(Cs cs, Th th)}" (is "?L = ?R")
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1701
proof(rule rel_eqI)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1702
  fix n1 n2
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1703
  assume "(n1, n2) \<in> ?L"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1704
  thus "(n1, n2) \<in> ?R" 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1705
  proof(cases rule:in_RAG_E)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1706
    case (waiting th' cs')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1707
    from this(3)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1708
    show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1709
    proof(cases rule:waiting_esE)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1710
      case 1
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1711
      thus ?thesis using waiting(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1712
        by (unfold s_RAG_def, fold waiting_eq, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1713
    qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1714
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1715
    case (holding th' cs')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1716
    from this(3)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1717
    show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1718
    proof(cases rule:holding_esE)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1719
      case 1
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1720
      with holding(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1721
      show ?thesis by (unfold s_RAG_def, fold holding_eq, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1722
    next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1723
      case 2
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1724
      with holding(1,2) show ?thesis by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1725
    qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1726
  qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1727
next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1728
  fix n1 n2
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1729
  assume "(n1, n2) \<in> ?R"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1730
  hence "(n1, n2) \<in> RAG s \<or> (n1 = Cs cs \<and> n2 = Th th)" by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1731
  thus "(n1, n2) \<in> ?L"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1732
  proof
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1733
    assume "(n1, n2) \<in> RAG s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1734
    thus ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1735
    proof(cases rule:in_RAG_E)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1736
      case (waiting th' cs')
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1737
      from waiting_kept[OF this(3)]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1738
      show ?thesis using waiting(1,2)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1739
         by (unfold s_RAG_def, fold waiting_eq, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1740
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1741
      case (holding th' cs')
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1742
      from holding_kept[OF this(3)]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1743
      show ?thesis using holding(1,2)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1744
         by (unfold s_RAG_def, fold holding_eq, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1745
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1746
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1747
    assume "n1 = Cs cs \<and> n2 = Th th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1748
    with holding_es_th_cs
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1749
    show ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1750
      by (unfold s_RAG_def, fold holding_eq, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1751
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1752
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1753
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1754
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1755
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1756
context valid_trace_p
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1757
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1758
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1759
lemma RAG_es': "RAG (e # s) =  (if (wq s cs = []) then RAG s \<union> {(Cs cs, Th th)}
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1760
                                                  else RAG s \<union> {(Th th, Cs cs)})"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1761
proof(cases "wq s cs = []")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1762
  case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1763
  interpret vt_p: valid_trace_p_h using True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1764
    by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1765
  show ?thesis by (simp add: vt_p.RAG_es vt_p.we) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1766
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1767
  case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1768
  interpret vt_p: valid_trace_p_w using False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1769
    by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1770
  show ?thesis by (simp add: vt_p.RAG_es vt_p.wne) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1771
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1772
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1773
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1774
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1775
lemma (in valid_trace_v_n) finite_waiting_set:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1776
  "finite {(Th th', Cs cs) |th'. next_th s th cs th'}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1777
    by (simp add: waiting_set_eq)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1778
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1779
lemma (in valid_trace_v_n) finite_holding_set:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1780
  "finite {(Cs cs, Th th') |th'. next_th s th cs th'}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1781
    by (simp add: holding_set_eq)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1782
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1783
lemma (in valid_trace_v_e) finite_waiting_set:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1784
  "finite {(Th th', Cs cs) |th'. next_th s th cs th'}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1785
    by (simp add: waiting_set_eq)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1786
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1787
lemma (in valid_trace_v_e) finite_holding_set:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1788
  "finite {(Cs cs, Th th') |th'. next_th s th cs th'}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1789
    by (simp add: holding_set_eq)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1790
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1791
context valid_trace_v
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1792
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1793
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1794
lemma 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1795
  finite_RAG_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1796
  assumes "finite (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1797
  shows "finite (RAG (e#s))"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1798
proof(cases "rest = []")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1799
  case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1800
  interpret vt: valid_trace_v_e using True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1801
    by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1802
  show ?thesis using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1803
    by  (unfold RAG_es vt.waiting_set_eq vt.holding_set_eq, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1804
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1805
  case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1806
  interpret vt: valid_trace_v_n using False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1807
    by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1808
  show ?thesis using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1809
    by  (unfold RAG_es vt.waiting_set_eq vt.holding_set_eq, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1810
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1811
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1812
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1813
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1814
context valid_trace_v_e
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1815
begin 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1816
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1817
lemma 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1818
  acylic_RAG_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1819
  assumes "acyclic (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1820
  shows "acyclic (RAG (e#s))"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1821
proof(rule acyclic_subset[OF assms])
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1822
  show "RAG (e # s) \<subseteq> RAG s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1823
      by (unfold RAG_es waiting_set_eq holding_set_eq, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1824
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1825
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1826
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1827
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1828
context valid_trace_v_n
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1829
begin 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1830
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1831
lemma waiting_taker: "waiting s taker cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1832
  apply (unfold s_waiting_def, fold wq_def, unfold wq_s_cs taker_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1833
  using eq_wq' th'_in_inv wq'_def by fastforce
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1834
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1835
lemma 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1836
  acylic_RAG_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1837
  assumes "acyclic (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1838
  shows "acyclic (RAG (e#s))"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1839
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1840
  have "acyclic ((RAG s - {(Cs cs, Th th)} - {(Th taker, Cs cs)}) \<union> 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1841
                 {(Cs cs, Th taker)})" (is "acyclic (?A \<union> _)")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1842
  proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1843
    from assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1844
    have "acyclic ?A"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1845
       by (rule acyclic_subset, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1846
    moreover have "(Th taker, Cs cs) \<notin> ?A^*"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1847
    proof
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1848
      assume otherwise: "(Th taker, Cs cs) \<in> ?A^*"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1849
      hence "(Th taker, Cs cs) \<in> ?A^+"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1850
        by (unfold rtrancl_eq_or_trancl, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1851
      from tranclD[OF this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1852
      obtain cs' where h: "(Th taker, Cs cs') \<in> ?A" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1853
                          "(Th taker, Cs cs') \<in> RAG s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1854
        by (unfold s_RAG_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1855
      from this(2) have "waiting s taker cs'" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1856
        by (unfold s_RAG_def, fold waiting_eq, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1857
      from waiting_unique[OF this waiting_taker]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1858
      have "cs' = cs" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1859
      from h(1)[unfolded this] show False by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1860
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1861
    ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1862
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1863
  thus ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1864
    by (unfold RAG_es waiting_set_eq holding_set_eq, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1865
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1866
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1867
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1868
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1869
context valid_trace_p_h
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1870
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1871
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1872
lemma 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1873
  acylic_RAG_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1874
  assumes "acyclic (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1875
  shows "acyclic (RAG (e#s))"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1876
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1877
  have "acyclic (RAG s \<union> {(Cs cs, Th th)})" (is "acyclic (?A \<union> _)") 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1878
  proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1879
    from assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1880
    have "acyclic ?A"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1881
       by (rule acyclic_subset, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1882
    moreover have "(Th th, Cs cs) \<notin> ?A^*"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1883
    proof
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1884
      assume otherwise: "(Th th, Cs cs) \<in> ?A^*"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1885
      hence "(Th th, Cs cs) \<in> ?A^+"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1886
        by (unfold rtrancl_eq_or_trancl, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1887
      from tranclD[OF this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1888
      obtain cs' where h: "(Th th, Cs cs') \<in> RAG s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1889
        by (unfold s_RAG_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1890
      hence "waiting s th cs'" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1891
        by (unfold s_RAG_def, fold waiting_eq, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1892
      with th_not_waiting show False by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1893
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1894
    ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1895
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1896
  thus ?thesis by (unfold RAG_es, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1897
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1898
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1899
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1900
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1901
context valid_trace_p_w
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1902
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1903
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1904
lemma 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1905
  acylic_RAG_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1906
  assumes "acyclic (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1907
  shows "acyclic (RAG (e#s))"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1908
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1909
  have "acyclic (RAG s \<union> {(Th th, Cs cs)})" (is "acyclic (?A \<union> _)") 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1910
  proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1911
    from assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1912
    have "acyclic ?A"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1913
       by (rule acyclic_subset, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1914
    moreover have "(Cs cs, Th th) \<notin> ?A^*"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1915
    proof
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1916
      assume otherwise: "(Cs cs, Th th) \<in> ?A^*"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1917
      from pip_e[unfolded is_p]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1918
      show False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1919
      proof(cases)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1920
        case (thread_P)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1921
        moreover from otherwise have "(Cs cs, Th th) \<in> ?A^+"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1922
            by (unfold rtrancl_eq_or_trancl, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1923
        ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1924
      qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1925
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1926
    ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1927
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1928
  thus ?thesis by (unfold RAG_es, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1929
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1930
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1931
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1932
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1933
context valid_trace
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1934
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1935
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1936
lemma finite_RAG:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1937
  shows "finite (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1938
proof(induct rule:ind)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1939
  case Nil
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1940
  show ?case 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1941
  by (auto simp: s_RAG_def cs_waiting_def 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1942
                   cs_holding_def wq_def acyclic_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1943
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1944
  case (Cons s e)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1945
  interpret vt_e: valid_trace_e s e using Cons by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1946
  show ?case
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1947
  proof(cases e)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1948
    case (Create th prio)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1949
    interpret vt: valid_trace_create s e th prio using Create
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1950
      by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1951
    show ?thesis using Cons by (simp add: vt.RAG_unchanged) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1952
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1953
    case (Exit th)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1954
    interpret vt: valid_trace_exit s e th using Exit
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1955
      by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1956
    show ?thesis using Cons by (simp add: vt.RAG_unchanged)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1957
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1958
    case (P th cs)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1959
    interpret vt: valid_trace_p s e th cs using P
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1960
      by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1961
    show ?thesis using Cons using vt.RAG_es' by auto 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1962
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1963
    case (V th cs)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1964
    interpret vt: valid_trace_v s e th cs using V
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1965
      by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1966
    show ?thesis using Cons by (simp add: vt.finite_RAG_kept) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1967
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1968
    case (Set th prio)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1969
    interpret vt: valid_trace_set s e th prio using Set
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1970
      by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1971
    show ?thesis using Cons by (simp add: vt.RAG_unchanged) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1972
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1973
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1974
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1975
lemma acyclic_RAG:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1976
  shows "acyclic (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1977
proof(induct rule:ind)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1978
  case Nil
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1979
  show ?case 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1980
  by (auto simp: s_RAG_def cs_waiting_def 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1981
                   cs_holding_def wq_def acyclic_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1982
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1983
  case (Cons s e)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1984
  interpret vt_e: valid_trace_e s e using Cons by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1985
  show ?case
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1986
  proof(cases e)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1987
    case (Create th prio)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1988
    interpret vt: valid_trace_create s e th prio using Create
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1989
      by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1990
    show ?thesis using Cons by (simp add: vt.RAG_unchanged) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1991
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1992
    case (Exit th)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1993
    interpret vt: valid_trace_exit s e th using Exit
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1994
      by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1995
    show ?thesis using Cons by (simp add: vt.RAG_unchanged)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1996
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1997
    case (P th cs)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1998
    interpret vt: valid_trace_p s e th cs using P
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  1999
      by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2000
    show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2001
    proof(cases "wq s cs = []")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2002
      case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2003
      then interpret vt_h: valid_trace_p_h s e th cs
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2004
        by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2005
      show ?thesis using Cons by (simp add: vt_h.acylic_RAG_kept) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2006
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2007
      case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2008
      then interpret vt_w: valid_trace_p_w s e th cs
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2009
        by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2010
      show ?thesis using Cons by (simp add: vt_w.acylic_RAG_kept) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2011
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2012
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2013
    case (V th cs)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2014
    interpret vt: valid_trace_v s e th cs using V
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2015
      by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2016
    show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2017
    proof(cases "vt.rest = []")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2018
      case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2019
      then interpret vt_e: valid_trace_v_e s e th cs
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2020
        by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2021
      show ?thesis by (simp add: Cons.hyps(2) vt_e.acylic_RAG_kept) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2022
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2023
      case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2024
      then interpret vt_n: valid_trace_v_n s e th cs
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2025
        by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2026
      show ?thesis by (simp add: Cons.hyps(2) vt_n.acylic_RAG_kept) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2027
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2028
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2029
    case (Set th prio)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2030
    interpret vt: valid_trace_set s e th prio using Set
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2031
      by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2032
    show ?thesis using Cons by (simp add: vt.RAG_unchanged) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2033
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2034
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2035
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2036
lemma wf_RAG: "wf (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2037
proof(rule finite_acyclic_wf)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2038
  from finite_RAG show "finite (RAG s)" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2039
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2040
  from acyclic_RAG show "acyclic (RAG s)" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2041
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2042
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2043
lemma sgv_wRAG: "single_valued (wRAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2044
  using waiting_unique
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2045
  by (unfold single_valued_def wRAG_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2046
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2047
lemma sgv_hRAG: "single_valued (hRAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2048
  using held_unique 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2049
  by (unfold single_valued_def hRAG_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2050
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2051
lemma sgv_tRAG: "single_valued (tRAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2052
  by (unfold tRAG_def, rule single_valued_relcomp, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2053
              insert sgv_wRAG sgv_hRAG, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2054
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2055
lemma acyclic_tRAG: "acyclic (tRAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2056
proof(unfold tRAG_def, rule acyclic_compose)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2057
  show "acyclic (RAG s)" using acyclic_RAG .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2058
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2059
  show "wRAG s \<subseteq> RAG s" unfolding RAG_split by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2060
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2061
  show "hRAG s \<subseteq> RAG s" unfolding RAG_split by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2062
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2063
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2064
lemma unique_RAG: "\<lbrakk>(n, n1) \<in> RAG s; (n, n2) \<in> RAG s\<rbrakk> \<Longrightarrow> n1 = n2"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2065
  apply(unfold s_RAG_def, auto, fold waiting_eq holding_eq)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2066
  by(auto elim:waiting_unique held_unique)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2067
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2068
lemma sgv_RAG: "single_valued (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2069
  using unique_RAG by (auto simp:single_valued_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2070
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2071
lemma rtree_RAG: "rtree (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2072
  using sgv_RAG acyclic_RAG
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2073
  by (unfold rtree_def rtree_axioms_def sgv_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2074
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2075
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2076
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2077
sublocale valid_trace < rtree_RAG: rtree "RAG s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2078
proof
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2079
  show "single_valued (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2080
  apply (intro_locales)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2081
    by (unfold single_valued_def, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2082
        auto intro:unique_RAG)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2083
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2084
  show "acyclic (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2085
     by (rule acyclic_RAG)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2086
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2087
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2088
sublocale valid_trace < rtree_s: rtree "tRAG s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2089
proof(unfold_locales)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2090
  from sgv_tRAG show "single_valued (tRAG s)" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2091
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2092
  from acyclic_tRAG show "acyclic (tRAG s)" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2093
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2094
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2095
sublocale valid_trace < fsbtRAGs : fsubtree "RAG s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2096
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2097
  show "fsubtree (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2098
  proof(intro_locales)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2099
    show "fbranch (RAG s)" using finite_fbranchI[OF finite_RAG] .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2100
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2101
    show "fsubtree_axioms (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2102
    proof(unfold fsubtree_axioms_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2103
      from wf_RAG show "wf (RAG s)" .
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  2104
    qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  2105
  qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  2106
qed
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  2107
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2108
context valid_trace
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2109
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2110
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2111
lemma finite_subtree_threads:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2112
    "finite {th'. Th th' \<in> subtree (RAG s) (Th th)}" (is "finite ?A")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2113
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2114
  have "?A = the_thread ` {Th th' | th' . Th th' \<in> subtree (RAG s) (Th th)}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2115
        by (auto, insert image_iff, fastforce)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2116
  moreover have "finite {Th th' | th' . Th th' \<in> subtree (RAG s) (Th th)}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2117
        (is "finite ?B")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2118
  proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2119
     have "?B = (subtree (RAG s) (Th th)) \<inter> {Th th' | th'. True}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2120
      by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2121
     moreover have "... \<subseteq> (subtree (RAG s) (Th th))" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2122
     moreover have "finite ..." by (simp add: finite_subtree) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2123
     ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2124
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2125
  ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2126
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2127
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2128
lemma le_cp:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2129
  shows "preced th s \<le> cp s th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2130
  proof(unfold cp_alt_def, rule Max_ge)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2131
    show "finite (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)})"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2132
      by (simp add: finite_subtree_threads)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2133
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2134
    show "preced th s \<in> the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2135
      by (simp add: subtree_def the_preced_def)   
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2136
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2137
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2138
lemma cp_le:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2139
  assumes th_in: "th \<in> threads s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2140
  shows "cp s th \<le> Max (the_preced s ` threads s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2141
proof(unfold cp_alt_def, rule Max_f_mono)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2142
  show "finite (threads s)" by (simp add: finite_threads) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2143
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2144
  show " {th'. Th th' \<in> subtree (RAG s) (Th th)} \<noteq> {}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2145
    using subtree_def by fastforce
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2146
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2147
  show "{th'. Th th' \<in> subtree (RAG s) (Th th)} \<subseteq> threads s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2148
    using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2149
    by (smt Domain.DomainI dm_RAG_threads mem_Collect_eq 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2150
        node.inject(1) rtranclD subsetI subtree_def trancl_domain) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2151
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2152
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2153
lemma max_cp_eq: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2154
  shows "Max ((cp s) ` threads s) = Max (the_preced s ` threads s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2155
  (is "?L = ?R")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2156
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2157
  have "?L \<le> ?R" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2158
  proof(cases "threads s = {}")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2159
    case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2160
    show ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2161
      by (rule Max.boundedI, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2162
          insert cp_le, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2163
          auto simp:finite_threads False)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2164
  qed auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2165
  moreover have "?R \<le> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2166
    by (rule Max_fg_mono, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2167
        simp add: finite_threads,
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2168
        simp add: le_cp the_preced_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2169
  ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2170
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2171
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2172
lemma max_cp_eq_the_preced:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2173
  shows "Max ((cp s) ` threads s) = Max (the_preced s ` threads s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2174
  using max_cp_eq using the_preced_def by presburger 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2175
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2176
lemma wf_RAG_converse: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2177
  shows "wf ((RAG s)^-1)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2178
proof(rule finite_acyclic_wf_converse)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2179
  from finite_RAG 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2180
  show "finite (RAG s)" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2181
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2182
  from acyclic_RAG
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2183
  show "acyclic (RAG s)" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2184
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2185
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2186
lemma chain_building:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2187
  assumes "node \<in> Domain (RAG s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2188
  obtains th' where "th' \<in> readys s" "(node, Th th') \<in> (RAG s)^+"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2189
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2190
  from assms have "node \<in> Range ((RAG s)^-1)" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2191
  from wf_base[OF wf_RAG_converse this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2192
  obtain b where h_b: "(b, node) \<in> ((RAG s)\<inverse>)\<^sup>+" "\<forall>c. (c, b) \<notin> (RAG s)\<inverse>" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2193
  obtain th' where eq_b: "b = Th th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2194
  proof(cases b)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2195
    case (Cs cs)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2196
    from h_b(1)[unfolded trancl_converse] 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2197
    have "(node, b) \<in> ((RAG s)\<^sup>+)" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2198
    from tranclE[OF this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2199
    obtain n where "(n, b) \<in> RAG s" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2200
    from this[unfolded Cs]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2201
    obtain th1 where "waiting s th1 cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2202
      by (unfold s_RAG_def, fold waiting_eq, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2203
    from waiting_holding[OF this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2204
    obtain th2 where "holding s th2 cs" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2205
    hence "(Cs cs, Th th2) \<in> RAG s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2206
      by (unfold s_RAG_def, fold holding_eq, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2207
    with h_b(2)[unfolded Cs, rule_format]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2208
    have False by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2209
    thus ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2210
  qed auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2211
  have "th' \<in> readys s" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2212
  proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2213
    from h_b(2)[unfolded eq_b]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2214
    have "\<forall>cs. \<not> waiting s th' cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2215
      by (unfold s_RAG_def, fold waiting_eq, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2216
    moreover have "th' \<in> threads s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2217
    proof(rule rg_RAG_threads)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2218
      from tranclD[OF h_b(1), unfolded eq_b]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2219
      obtain z where "(z, Th th') \<in> (RAG s)" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2220
      thus "Th th' \<in> Range (RAG s)" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2221
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2222
    ultimately show ?thesis by (auto simp:readys_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2223
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2224
  moreover have "(node, Th th') \<in> (RAG s)^+" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2225
    using h_b(1)[unfolded trancl_converse] eq_b by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2226
  ultimately show ?thesis using that by metis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2227
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2228
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2229
text {* \noindent
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2230
  The following is just an instance of @{text "chain_building"}.
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2231
*}
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2232
lemma th_chain_to_ready:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2233
  assumes th_in: "th \<in> threads s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2234
  shows "th \<in> readys s \<or> (\<exists> th'. th' \<in> readys s \<and> (Th th, Th th') \<in> (RAG s)^+)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2235
proof(cases "th \<in> readys s")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2236
  case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2237
  thus ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2238
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2239
  case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2240
  from False and th_in have "Th th \<in> Domain (RAG s)" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2241
    by (auto simp:readys_def s_waiting_def s_RAG_def wq_def cs_waiting_def Domain_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2242
  from chain_building [rule_format, OF this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2243
  show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2244
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2245
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2246
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2247
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2248
lemma count_rec1 [simp]: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2249
  assumes "Q e"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2250
  shows "count Q (e#es) = Suc (count Q es)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2251
  using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2252
  by (unfold count_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2253
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2254
lemma count_rec2 [simp]: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2255
  assumes "\<not>Q e"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2256
  shows "count Q (e#es) = (count Q es)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2257
  using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2258
  by (unfold count_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2259
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2260
lemma count_rec3 [simp]: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2261
  shows "count Q [] =  0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2262
  by (unfold count_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2263
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2264
lemma cntP_simp1[simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2265
  "cntP (P th cs'#s) th = cntP s th + 1"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2266
  by (unfold cntP_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2267
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2268
lemma cntP_simp2[simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2269
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2270
  shows "cntP (P th cs'#s) th' = cntP s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2271
  using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2272
  by (unfold cntP_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2273
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2274
lemma cntP_simp3[simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2275
  assumes "\<not> isP e"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2276
  shows "cntP (e#s) th' = cntP s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2277
  using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2278
  by (unfold cntP_def, cases e, simp+)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2279
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2280
lemma cntV_simp1[simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2281
  "cntV (V th cs'#s) th = cntV s th + 1"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2282
  by (unfold cntV_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2283
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2284
lemma cntV_simp2[simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2285
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2286
  shows "cntV (V th cs'#s) th' = cntV s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2287
  using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2288
  by (unfold cntV_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2289
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2290
lemma cntV_simp3[simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2291
  assumes "\<not> isV e"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2292
  shows "cntV (e#s) th' = cntV s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2293
  using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2294
  by (unfold cntV_def, cases e, simp+)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2295
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2296
lemma cntP_diff_inv:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2297
  assumes "cntP (e#s) th \<noteq> cntP s th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2298
  shows "isP e \<and> actor e = th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2299
proof(cases e)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2300
  case (P th' pty)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2301
  show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2302
  by (cases "(\<lambda>e. \<exists>cs. e = P th cs) (P th' pty)", 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2303
        insert assms P, auto simp:cntP_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2304
qed (insert assms, auto simp:cntP_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2305
  
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2306
lemma cntV_diff_inv:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2307
  assumes "cntV (e#s) th \<noteq> cntV s th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2308
  shows "isV e \<and> actor e = th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2309
proof(cases e)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2310
  case (V th' pty)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2311
  show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2312
  by (cases "(\<lambda>e. \<exists>cs. e = V th cs) (V th' pty)", 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2313
        insert assms V, auto simp:cntV_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2314
qed (insert assms, auto simp:cntV_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2315
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2316
lemma children_RAG_alt_def:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2317
  "children (RAG (s::state)) (Th th) = Cs ` {cs. holding s th cs}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2318
  by (unfold s_RAG_def, auto simp:children_def holding_eq)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2319
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2320
fun the_cs :: "node \<Rightarrow> cs" where
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2321
  "the_cs (Cs cs) = cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2322
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2323
lemma holdents_alt_def:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2324
  "holdents s th = the_cs ` (children (RAG (s::state)) (Th th))"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2325
  by (unfold children_RAG_alt_def holdents_def, simp add: image_image)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2326
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2327
lemma cntCS_alt_def:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2328
  "cntCS s th = card (children (RAG s) (Th th))"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2329
  apply (unfold children_RAG_alt_def cntCS_def holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2330
  by (rule card_image[symmetric], auto simp:inj_on_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2331
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2332
context valid_trace
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2333
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2334
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2335
lemma finite_holdents: "finite (holdents s th)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2336
  by (unfold holdents_alt_def, insert finite_children, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2337
  
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2338
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2339
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2340
context valid_trace_p_w
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2341
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2342
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2343
lemma holding_s_holder: "holding s holder cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2344
  by (unfold s_holding_def, fold wq_def, unfold wq_s_cs, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2345
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2346
lemma holding_es_holder: "holding (e#s) holder cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2347
  by (unfold s_holding_def, fold wq_def, unfold wq_es_cs wq_s_cs, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2348
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2349
lemma holdents_es:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2350
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R") 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2351
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2352
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2353
    assume "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2354
    hence h: "holding (e#s) th' cs'" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2355
    have "holding s th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2356
    proof(cases "cs' = cs")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2357
      case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2358
      from held_unique[OF h[unfolded True] holding_es_holder]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2359
      have "th' = holder" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2360
      thus ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2361
        by (unfold True holdents_def, insert holding_s_holder, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2362
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2363
      case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2364
      hence "wq (e#s) cs' = wq s cs'" by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2365
      from h[unfolded s_holding_def, folded wq_def, unfolded this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2366
      show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2367
       by (unfold s_holding_def, fold wq_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2368
    qed 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2369
    hence "cs' \<in> ?R" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2370
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2371
    fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2372
    assume "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2373
    hence h: "holding s th' cs'" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2374
    have "holding (e#s) th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2375
    proof(cases "cs' = cs")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2376
      case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2377
      from held_unique[OF h[unfolded True] holding_s_holder]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2378
      have "th' = holder" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2379
      thus ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2380
        by (unfold True holdents_def, insert holding_es_holder, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2381
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2382
      case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2383
      hence "wq s cs' = wq (e#s) cs'" by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2384
      from h[unfolded s_holding_def, folded wq_def, unfolded this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2385
      show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2386
       by (unfold s_holding_def, fold wq_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2387
    qed 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2388
    hence "cs' \<in> ?L" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2389
  } ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2390
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2391
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2392
lemma cntCS_es_th[simp]: "cntCS (e#s) th' = cntCS s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2393
 by (unfold cntCS_def holdents_es, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2394
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2395
lemma th_not_ready_es: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2396
  shows "th \<notin> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2397
  using waiting_es_th_cs 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2398
  by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2399
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2400
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2401
  
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2402
context valid_trace_p_h
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2403
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2404
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2405
lemma th_not_waiting':
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2406
  "\<not> waiting (e#s) th cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2407
proof(cases "cs' = cs")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2408
  case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2409
  show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2410
    by (unfold True s_waiting_def, fold wq_def, unfold wq_es_cs', auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2411
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2412
  case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2413
  from th_not_waiting[of cs', unfolded s_waiting_def, folded wq_def]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2414
  show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2415
    by (unfold s_waiting_def, fold wq_def, insert False, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2416
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2417
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2418
lemma ready_th_es: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2419
  shows "th \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2420
  using th_not_waiting'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2421
  by (unfold readys_def, insert live_th_es, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2422
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2423
lemma holdents_es_th:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2424
  "holdents (e#s) th = (holdents s th) \<union> {cs}" (is "?L = ?R")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2425
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2426
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2427
    assume "cs' \<in> ?L" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2428
    hence "holding (e#s) th cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2429
      by (unfold holdents_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2430
    hence "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2431
     by (cases rule:holding_esE, auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2432
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2433
    fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2434
    assume "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2435
    hence "holding s th cs' \<or> cs' = cs" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2436
      by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2437
    hence "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2438
    proof
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2439
      assume "holding s th cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2440
      from holding_kept[OF this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2441
      show ?thesis by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2442
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2443
      assume "cs' = cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2444
      thus ?thesis using holding_es_th_cs
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2445
        by (unfold holdents_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2446
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2447
  } ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2448
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2449
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2450
lemma cntCS_es_th: "cntCS (e#s) th = cntCS s th + 1"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2451
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2452
  have "card (holdents s th \<union> {cs}) = card (holdents s th) + 1"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2453
  proof(subst card_Un_disjoint)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2454
    show "holdents s th \<inter> {cs} = {}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2455
      using not_holding_s_th_cs by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2456
  qed (auto simp:finite_holdents)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2457
  thus ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2458
   by (unfold cntCS_def holdents_es_th, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2459
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2460
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2461
lemma no_holder: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2462
  "\<not> holding s th' cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2463
proof
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2464
  assume otherwise: "holding s th' cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2465
  from this[unfolded s_holding_def, folded wq_def, unfolded we]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2466
  show False by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2467
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2468
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2469
lemma holdents_es_th':
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2470
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2471
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2472
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2473
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2474
    assume "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2475
    hence h_e: "holding (e#s) th' cs'" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2476
    have "cs' \<noteq> cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2477
    proof
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2478
      assume "cs' = cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2479
      from held_unique[OF h_e[unfolded this] holding_es_th_cs]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2480
      have "th' = th" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2481
      with assms show False by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2482
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2483
    from h_e[unfolded s_holding_def, folded wq_def, unfolded wq_neq_simp[OF this]]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2484
    have "th' \<in> set (wq s cs') \<and> th' = hd (wq s cs')" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2485
    hence "cs' \<in> ?R" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2486
      by (unfold holdents_def s_holding_def, fold wq_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2487
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2488
    fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2489
    assume "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2490
    hence "holding s th' cs'" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2491
    from holding_kept[OF this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2492
    have "holding (e # s) th' cs'" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2493
    hence "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2494
      by (unfold holdents_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2495
  } ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2496
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2497
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2498
lemma cntCS_es_th'[simp]: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2499
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2500
  shows "cntCS (e#s) th' = cntCS s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2501
  by (unfold cntCS_def holdents_es_th'[OF assms], simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2502
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2503
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2504
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2505
context valid_trace_p
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2506
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2507
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2508
lemma readys_kept1: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2509
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2510
  and "th' \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2511
  shows "th' \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2512
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2513
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2514
    assume wait: "waiting s th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2515
    have n_wait: "\<not> waiting (e#s) th' cs'" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2516
        using assms(2)[unfolded readys_def] by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2517
    have False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2518
    proof(cases "cs' = cs")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2519
      case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2520
      with n_wait wait
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2521
      show ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2522
        by (unfold s_waiting_def, fold wq_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2523
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2524
      case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2525
      show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2526
      proof(cases "wq s cs = []")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2527
        case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2528
        then interpret vt: valid_trace_p_h
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2529
          by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2530
        show ?thesis using n_wait wait waiting_kept by auto 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2531
      next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2532
        case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2533
        then interpret vt: valid_trace_p_w by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2534
        show ?thesis using n_wait wait waiting_kept by blast 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2535
      qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2536
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2537
  } with assms(2) show ?thesis  
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2538
    by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2539
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2540
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2541
lemma readys_kept2: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2542
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2543
  and "th' \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2544
  shows "th' \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2545
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2546
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2547
    assume wait: "waiting (e#s) th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2548
    have n_wait: "\<not> waiting s th' cs'" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2549
        using assms(2)[unfolded readys_def] by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2550
    have False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2551
    proof(cases "cs' = cs")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2552
      case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2553
      with n_wait wait
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2554
      show ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2555
        by (unfold s_waiting_def, fold wq_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2556
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2557
      case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2558
      show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2559
      proof(cases "wq s cs = []")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2560
        case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2561
        then interpret vt: valid_trace_p_h
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2562
          by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2563
        show ?thesis using n_wait vt.waiting_esE wait by blast 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2564
      next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2565
        case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2566
        then interpret vt: valid_trace_p_w by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2567
        show ?thesis using assms(1) n_wait vt.waiting_esE wait by auto 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2568
      qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2569
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2570
  } with assms(2) show ?thesis  
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2571
    by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2572
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2573
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2574
lemma readys_simp [simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2575
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2576
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2577
  using readys_kept1[OF assms] readys_kept2[OF assms]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2578
  by metis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2579
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2580
lemma cnp_cnv_cncs_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2581
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2582
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#s) th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2583
proof(cases "th' = th")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2584
  case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2585
  note eq_th' = this
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2586
  show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2587
  proof(cases "wq s cs = []")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2588
    case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2589
    then interpret vt: valid_trace_p_h by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2590
    show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2591
      using assms eq_th' is_p ready_th_s vt.cntCS_es_th vt.ready_th_es pvD_def by auto 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2592
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2593
    case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2594
    then interpret vt: valid_trace_p_w by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2595
    show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2596
      using add.commute add.left_commute assms eq_th' is_p live_th_s 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2597
            ready_th_s vt.th_not_ready_es pvD_def
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2598
      apply (auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2599
      by (fold is_p, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2600
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2601
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2602
  case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2603
  note h_False = False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2604
  thus ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2605
  proof(cases "wq s cs = []")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2606
    case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2607
    then interpret vt: valid_trace_p_h by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2608
    show ?thesis using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2609
      by (insert True h_False pvD_def, auto split:if_splits,unfold is_p, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2610
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2611
    case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2612
    then interpret vt: valid_trace_p_w by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2613
    show ?thesis using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2614
      by (insert False h_False pvD_def, auto split:if_splits,unfold is_p, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2615
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2616
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2617
57
f1b39d77db00 Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff changeset
  2618
end
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  2619
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  2620
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2621
context valid_trace_v (* ccc *)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2622
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2623
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2624
lemma holding_th_cs_s: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2625
  "holding s th cs" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2626
 by  (unfold s_holding_def, fold wq_def, unfold wq_s_cs, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2627
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2628
lemma th_ready_s [simp]: "th \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2629
  using runing_th_s
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2630
  by (unfold runing_def readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2631
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2632
lemma th_live_s [simp]: "th \<in> threads s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2633
  using th_ready_s by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2634
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2635
lemma th_ready_es [simp]: "th \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2636
  using runing_th_s neq_t_th
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2637
  by (unfold is_v runing_def readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2638
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2639
lemma th_live_es [simp]: "th \<in> threads (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2640
  using th_ready_es by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2641
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2642
lemma pvD_th_s[simp]: "pvD s th = 0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2643
  by (unfold pvD_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2644
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2645
lemma pvD_th_es[simp]: "pvD (e#s) th = 0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2646
  by (unfold pvD_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2647
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2648
lemma cntCS_s_th [simp]: "cntCS s th > 0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2649
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2650
  have "cs \<in> holdents s th" using holding_th_cs_s
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2651
    by (unfold holdents_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2652
  moreover have "finite (holdents s th)" using finite_holdents
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2653
    by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2654
  ultimately show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2655
    by (unfold cntCS_def, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2656
        auto intro!:card_gt_0_iff[symmetric, THEN iffD1])
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2657
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2658
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2659
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2660
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2661
context valid_trace_v_n
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2662
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2663
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2664
lemma not_ready_taker_s[simp]: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2665
  "taker \<notin> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2666
  using waiting_taker
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2667
  by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2668
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2669
lemma taker_live_s [simp]: "taker \<in> threads s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2670
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2671
  have "taker \<in> set wq'" by (simp add: eq_wq') 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2672
  from th'_in_inv[OF this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2673
  have "taker \<in> set rest" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2674
  hence "taker \<in> set (wq s cs)" by (simp add: wq_s_cs) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2675
  thus ?thesis using wq_threads by auto 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2676
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2677
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2678
lemma taker_live_es [simp]: "taker \<in> threads (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2679
  using taker_live_s threads_es by blast
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2680
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2681
lemma taker_ready_es [simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2682
  shows "taker \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2683
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2684
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2685
    assume "waiting (e#s) taker cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2686
    hence False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2687
    proof(cases rule:waiting_esE)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2688
      case 1
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2689
      thus ?thesis using waiting_taker waiting_unique by auto 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2690
    qed simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2691
  } thus ?thesis by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2692
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2693
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2694
lemma neq_taker_th: "taker \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2695
  using th_not_waiting waiting_taker by blast
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2696
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2697
lemma not_holding_taker_s_cs:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2698
  shows "\<not> holding s taker cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2699
  using holding_cs_eq_th neq_taker_th by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2700
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2701
lemma holdents_es_taker:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2702
  "holdents (e#s) taker = holdents s taker \<union> {cs}" (is "?L = ?R")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2703
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2704
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2705
    assume "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2706
    hence "holding (e#s) taker cs'" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2707
    hence "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2708
    proof(cases rule:holding_esE)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2709
      case 2
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2710
      thus ?thesis by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2711
    qed auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2712
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2713
    fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2714
    assume "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2715
    hence "holding s taker cs' \<or> cs' = cs" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2716
    hence "cs' \<in> ?L" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2717
    proof
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2718
      assume "holding s taker cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2719
      hence "holding (e#s) taker cs'" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2720
          using holding_esI2 holding_taker by fastforce 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2721
      thus ?thesis by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2722
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2723
      assume "cs' = cs"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2724
      with holding_taker
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2725
      show ?thesis by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2726
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2727
  } ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2728
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2729
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2730
lemma cntCS_es_taker [simp]: "cntCS (e#s) taker = cntCS s taker + 1"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2731
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2732
  have "card (holdents s taker \<union> {cs}) = card (holdents s taker) + 1"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2733
  proof(subst card_Un_disjoint)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2734
    show "holdents s taker \<inter> {cs} = {}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2735
      using not_holding_taker_s_cs by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2736
  qed (auto simp:finite_holdents)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2737
  thus ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2738
    by (unfold cntCS_def, insert holdents_es_taker, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2739
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2740
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2741
lemma pvD_taker_s[simp]: "pvD s taker = 1"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2742
  by (unfold pvD_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2743
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2744
lemma pvD_taker_es[simp]: "pvD (e#s) taker = 0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2745
  by (unfold pvD_def, simp)  
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2746
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2747
lemma pvD_th_s[simp]: "pvD s th = 0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2748
  by (unfold pvD_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2749
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2750
lemma pvD_th_es[simp]: "pvD (e#s) th = 0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2751
  by (unfold pvD_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2752
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2753
lemma holdents_es_th:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2754
  "holdents (e#s) th = holdents s th - {cs}" (is "?L = ?R")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2755
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2756
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2757
    assume "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2758
    hence "holding (e#s) th cs'" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2759
    hence "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2760
    proof(cases rule:holding_esE)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2761
      case 2
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2762
      thus ?thesis by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2763
    qed (insert neq_taker_th, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2764
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2765
    fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2766
    assume "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2767
    hence "cs' \<noteq> cs" "holding s th cs'" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2768
    from holding_esI2[OF this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2769
    have "cs' \<in> ?L" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2770
  } ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2771
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2772
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2773
lemma cntCS_es_th [simp]: "cntCS (e#s) th = cntCS s th - 1"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2774
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2775
  have "card (holdents s th - {cs}) = card (holdents s th) - 1"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2776
  proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2777
    have "cs \<in> holdents s th" using holding_th_cs_s
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2778
      by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2779
    moreover have "finite (holdents s th)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2780
        by (simp add: finite_holdents) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2781
    ultimately show ?thesis by auto
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  2782
  qed
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2783
  thus ?thesis by (unfold cntCS_def holdents_es_th)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2784
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2785
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2786
lemma holdents_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2787
  assumes "th' \<noteq> taker"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2788
  and "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2789
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2790
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2791
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2792
    assume h: "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2793
    have "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2794
    proof(cases "cs' = cs")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2795
      case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2796
      hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2797
      from h have "holding (e#s) th' cs'" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2798
      from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2799
      show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2800
        by (unfold holdents_def s_holding_def, fold wq_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2801
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2802
      case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2803
      from h[unfolded this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2804
      have "holding (e#s) th' cs" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2805
      from held_unique[OF this holding_taker]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2806
      have "th' = taker" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2807
      with assms show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2808
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2809
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2810
    fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2811
    assume h: "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2812
    have "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2813
    proof(cases "cs' = cs")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2814
      case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2815
      hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2816
      from h have "holding s th' cs'" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2817
      from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2818
      show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2819
        by (unfold holdents_def s_holding_def, fold wq_def, insert eq_wq, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2820
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2821
      case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2822
      from h[unfolded this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2823
      have "holding s th' cs" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2824
      from held_unique[OF this holding_th_cs_s]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2825
      have "th' = th" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2826
      with assms show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2827
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2828
  } ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2829
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2830
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2831
lemma cntCS_kept [simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2832
  assumes "th' \<noteq> taker"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2833
  and "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2834
  shows "cntCS (e#s) th' = cntCS s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2835
  by (unfold cntCS_def holdents_kept[OF assms], simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2836
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2837
lemma readys_kept1: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2838
  assumes "th' \<noteq> taker"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2839
  and "th' \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2840
  shows "th' \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2841
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2842
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2843
    assume wait: "waiting s th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2844
    have n_wait: "\<not> waiting (e#s) th' cs'" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2845
        using assms(2)[unfolded readys_def] by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2846
    have False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2847
    proof(cases "cs' = cs")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2848
      case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2849
      with n_wait wait
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2850
      show ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2851
        by (unfold s_waiting_def, fold wq_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2852
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2853
      case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2854
      have "th' \<in> set (th # rest) \<and> th' \<noteq> hd (th # rest)" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2855
        using wait[unfolded True s_waiting_def, folded wq_def, unfolded wq_s_cs] .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2856
      moreover have "\<not> (th' \<in> set rest \<and> th' \<noteq> hd (taker # rest'))" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2857
        using n_wait[unfolded True s_waiting_def, folded wq_def, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2858
                    unfolded wq_es_cs set_wq', unfolded eq_wq'] .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2859
      ultimately have "th' = taker" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2860
      with assms(1)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2861
      show ?thesis by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2862
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2863
  } with assms(2) show ?thesis  
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2864
    by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2865
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2866
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2867
lemma readys_kept2: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2868
  assumes "th' \<noteq> taker"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2869
  and "th' \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2870
  shows "th' \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2871
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2872
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2873
    assume wait: "waiting (e#s) th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2874
    have n_wait: "\<not> waiting s th' cs'" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2875
        using assms(2)[unfolded readys_def] by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2876
    have False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2877
    proof(cases "cs' = cs")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2878
      case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2879
      with n_wait wait
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2880
      show ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2881
        by (unfold s_waiting_def, fold wq_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2882
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2883
      case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2884
      have "th' \<in> set rest \<and> th' \<noteq> hd (taker # rest')"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2885
          using  wait [unfolded True s_waiting_def, folded wq_def, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2886
                    unfolded wq_es_cs set_wq', unfolded eq_wq']  .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2887
      moreover have "\<not> (th' \<in> set (th # rest) \<and> th' \<noteq> hd (th # rest))"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2888
          using n_wait[unfolded True s_waiting_def, folded wq_def, unfolded wq_s_cs] .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2889
      ultimately have "th' = taker" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2890
      with assms(1)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2891
      show ?thesis by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2892
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2893
  } with assms(2) show ?thesis  
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2894
    by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2895
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2896
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2897
lemma readys_simp [simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2898
  assumes "th' \<noteq> taker"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2899
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2900
  using readys_kept1[OF assms] readys_kept2[OF assms]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2901
  by metis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2902
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2903
lemma cnp_cnv_cncs_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2904
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2905
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#s) th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2906
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2907
  { assume eq_th': "th' = taker"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2908
    have ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2909
      apply (unfold eq_th' pvD_taker_es cntCS_es_taker)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2910
      by (insert neq_taker_th assms[unfolded eq_th'], unfold is_v, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2911
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2912
    assume eq_th': "th' = th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2913
    have ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2914
      apply (unfold eq_th' pvD_th_es cntCS_es_th)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2915
      by (insert assms[unfolded eq_th'], unfold is_v, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2916
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2917
    assume h: "th' \<noteq> taker" "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2918
    have ?thesis using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2919
      apply (unfold cntCS_kept[OF h], insert h, unfold is_v, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2920
      by (fold is_v, unfold pvD_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2921
  } ultimately show ?thesis by metis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2922
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2923
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2924
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2925
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2926
context valid_trace_v_e
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2927
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2928
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2929
lemma holdents_es_th:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2930
  "holdents (e#s) th = holdents s th - {cs}" (is "?L = ?R")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2931
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2932
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2933
    assume "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2934
    hence "holding (e#s) th cs'" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2935
    hence "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2936
    proof(cases rule:holding_esE)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2937
      case 1
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2938
      thus ?thesis by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2939
    qed 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2940
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2941
    fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2942
    assume "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2943
    hence "cs' \<noteq> cs" "holding s th cs'" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2944
    from holding_esI2[OF this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2945
    have "cs' \<in> ?L" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2946
  } ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2947
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2948
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2949
lemma cntCS_es_th [simp]: "cntCS (e#s) th = cntCS s th - 1"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2950
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2951
  have "card (holdents s th - {cs}) = card (holdents s th) - 1"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2952
  proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2953
    have "cs \<in> holdents s th" using holding_th_cs_s
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2954
      by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2955
    moreover have "finite (holdents s th)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2956
        by (simp add: finite_holdents) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2957
    ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2958
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2959
  thus ?thesis by (unfold cntCS_def holdents_es_th)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2960
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2961
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2962
lemma holdents_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2963
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2964
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2965
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2966
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2967
    assume h: "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2968
    have "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2969
    proof(cases "cs' = cs")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2970
      case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2971
      hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2972
      from h have "holding (e#s) th' cs'" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2973
      from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2974
      show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2975
        by (unfold holdents_def s_holding_def, fold wq_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2976
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2977
      case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2978
      from h[unfolded this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2979
      have "holding (e#s) th' cs" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2980
      from this[unfolded s_holding_def, folded wq_def, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2981
            unfolded wq_es_cs nil_wq']
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2982
      show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2983
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2984
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2985
    fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2986
    assume h: "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2987
    have "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2988
    proof(cases "cs' = cs")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2989
      case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2990
      hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2991
      from h have "holding s th' cs'" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2992
      from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2993
      show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2994
        by (unfold holdents_def s_holding_def, fold wq_def, insert eq_wq, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2995
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2996
      case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2997
      from h[unfolded this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2998
      have "holding s th' cs" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  2999
      from held_unique[OF this holding_th_cs_s]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3000
      have "th' = th" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3001
      with assms show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3002
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3003
  } ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3004
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3005
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3006
lemma cntCS_kept [simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3007
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3008
  shows "cntCS (e#s) th' = cntCS s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3009
  by (unfold cntCS_def holdents_kept[OF assms], simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3010
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3011
lemma readys_kept1: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3012
  assumes "th' \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3013
  shows "th' \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3014
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3015
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3016
    assume wait: "waiting s th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3017
    have n_wait: "\<not> waiting (e#s) th' cs'" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3018
        using assms(1)[unfolded readys_def] by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3019
    have False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3020
    proof(cases "cs' = cs")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3021
      case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3022
      with n_wait wait
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3023
      show ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3024
        by (unfold s_waiting_def, fold wq_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3025
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3026
      case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3027
      have "th' \<in> set (th # rest) \<and> th' \<noteq> hd (th # rest)" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3028
        using wait[unfolded True s_waiting_def, folded wq_def, unfolded wq_s_cs] . 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3029
      hence "th' \<in> set rest" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3030
      with set_wq' have "th' \<in> set wq'" by metis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3031
      with nil_wq' show ?thesis by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3032
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3033
  } thus ?thesis using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3034
    by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3035
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3036
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3037
lemma readys_kept2: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3038
  assumes "th' \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3039
  shows "th' \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3040
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3041
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3042
    assume wait: "waiting (e#s) th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3043
    have n_wait: "\<not> waiting s th' cs'" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3044
        using assms[unfolded readys_def] by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3045
    have False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3046
    proof(cases "cs' = cs")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3047
      case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3048
      with n_wait wait
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3049
      show ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3050
        by (unfold s_waiting_def, fold wq_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3051
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3052
      case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3053
      have "th' \<in> set [] \<and> th' \<noteq> hd []"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3054
        using wait[unfolded True s_waiting_def, folded wq_def, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3055
              unfolded wq_es_cs nil_wq'] .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3056
      thus ?thesis by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3057
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3058
  } with assms show ?thesis  
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3059
    by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3060
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3061
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3062
lemma readys_simp [simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3063
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3064
  using readys_kept1[OF assms] readys_kept2[OF assms]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3065
  by metis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3066
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3067
lemma cnp_cnv_cncs_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3068
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3069
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#s) th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3070
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3071
  {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3072
    assume eq_th': "th' = th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3073
    have ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3074
      apply (unfold eq_th' pvD_th_es cntCS_es_th)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3075
      by (insert assms[unfolded eq_th'], unfold is_v, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3076
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3077
    assume h: "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3078
    have ?thesis using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3079
      apply (unfold cntCS_kept[OF h], insert h, unfold is_v, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3080
      by (fold is_v, unfold pvD_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3081
  } ultimately show ?thesis by metis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3082
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3083
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3084
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3085
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3086
context valid_trace_v
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3087
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3088
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3089
lemma cnp_cnv_cncs_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3090
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3091
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#s) th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3092
proof(cases "rest = []")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3093
  case True
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3094
  then interpret vt: valid_trace_v_e by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3095
  show ?thesis using assms using vt.cnp_cnv_cncs_kept by blast 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3096
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3097
  case False
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3098
  then interpret vt: valid_trace_v_n by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3099
  show ?thesis using assms using vt.cnp_cnv_cncs_kept by blast 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3100
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3101
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  3102
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  3103
80
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3104
context valid_trace_create
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3105
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3106
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3107
lemma th_not_live_s [simp]: "th \<notin> threads s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3108
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3109
  from pip_e[unfolded is_create]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3110
  show ?thesis by (cases, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3111
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3112
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3113
lemma th_not_ready_s [simp]: "th \<notin> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3114
  using th_not_live_s by (unfold readys_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3115
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3116
lemma th_live_es [simp]: "th \<in> threads (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3117
  by (unfold is_create, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3118
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3119
lemma not_waiting_th_s [simp]: "\<not> waiting s th cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3120
proof
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3121
  assume "waiting s th cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3122
  from this[unfolded s_waiting_def, folded wq_def, unfolded wq_neq_simp]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3123
  have "th \<in> set (wq s cs')" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3124
  from wq_threads[OF this] have "th \<in> threads s" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3125
  with th_not_live_s show False by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3126
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3127
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3128
lemma not_holding_th_s [simp]: "\<not> holding s th cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3129
proof
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3130
  assume "holding s th cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3131
  from this[unfolded s_holding_def, folded wq_def, unfolded wq_neq_simp]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3132
  have "th \<in> set (wq s cs')" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3133
  from wq_threads[OF this] have "th \<in> threads s" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3134
  with th_not_live_s show False by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3135
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3136
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3137
lemma not_waiting_th_es [simp]: "\<not> waiting (e#s) th cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3138
proof
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3139
  assume "waiting (e # s) th cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3140
  from this[unfolded s_waiting_def, folded wq_def, unfolded wq_neq_simp]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3141
  have "th \<in> set (wq s cs')" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3142
  from wq_threads[OF this] have "th \<in> threads s" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3143
  with th_not_live_s show False by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3144
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3145
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3146
lemma not_holding_th_es [simp]: "\<not> holding (e#s) th cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3147
proof
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3148
  assume "holding (e # s) th cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3149
  from this[unfolded s_holding_def, folded wq_def, unfolded wq_neq_simp]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3150
  have "th \<in> set (wq s cs')" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3151
  from wq_threads[OF this] have "th \<in> threads s" .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3152
  with th_not_live_s show False by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3153
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3154
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3155
lemma ready_th_es [simp]: "th \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3156
  by (simp add:readys_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3157
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3158
lemma holdents_th_s: "holdents s th = {}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3159
  by (unfold holdents_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3160
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3161
lemma holdents_th_es: "holdents (e#s) th = {}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3162
  by (unfold holdents_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3163
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3164
lemma cntCS_th_s [simp]: "cntCS s th = 0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3165
  by (unfold cntCS_def, simp add:holdents_th_s)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3166
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3167
lemma cntCS_th_es [simp]: "cntCS (e#s) th = 0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3168
  by (unfold cntCS_def, simp add:holdents_th_es)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3169
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3170
lemma pvD_th_s [simp]: "pvD s th = 0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3171
  by (unfold pvD_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3172
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3173
lemma pvD_th_es [simp]: "pvD (e#s) th = 0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3174
  by (unfold pvD_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3175
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3176
lemma holdents_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3177
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3178
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3179
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3180
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3181
    assume h: "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3182
    hence "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3183
      by (unfold holdents_def s_holding_def, fold wq_def, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3184
             unfold wq_neq_simp, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3185
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3186
    fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3187
    assume h: "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3188
    hence "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3189
      by (unfold holdents_def s_holding_def, fold wq_def, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3190
             unfold wq_neq_simp, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3191
  } ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3192
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3193
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3194
lemma cntCS_kept [simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3195
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3196
  shows "cntCS (e#s) th' = cntCS s th'" (is "?L = ?R")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3197
  using holdents_kept[OF assms]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3198
  by (unfold cntCS_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3199
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3200
lemma readys_kept1: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3201
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3202
  and "th' \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3203
  shows "th' \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3204
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3205
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3206
    assume wait: "waiting s th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3207
    have n_wait: "\<not> waiting (e#s) th' cs'" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3208
      using assms by (auto simp:readys_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3209
    from wait[unfolded s_waiting_def, folded wq_def]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3210
         n_wait[unfolded s_waiting_def, folded wq_def, unfolded wq_neq_simp]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3211
    have False by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3212
  } thus ?thesis using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3213
    by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3214
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3215
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3216
lemma readys_kept2: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3217
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3218
  and "th' \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3219
  shows "th' \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3220
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3221
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3222
    assume wait: "waiting (e#s) th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3223
    have n_wait: "\<not> waiting s th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3224
      using assms(2) by (auto simp:readys_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3225
    from wait[unfolded s_waiting_def, folded wq_def, unfolded wq_neq_simp]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3226
         n_wait[unfolded s_waiting_def, folded wq_def]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3227
    have False by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3228
  } with assms show ?thesis  
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3229
    by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3230
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3231
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3232
lemma readys_simp [simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3233
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3234
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3235
  using readys_kept1[OF assms] readys_kept2[OF assms]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3236
  by metis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3237
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3238
lemma pvD_kept [simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3239
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3240
  shows "pvD (e#s) th' = pvD s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3241
  using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3242
  by (unfold pvD_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3243
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3244
lemma cnp_cnv_cncs_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3245
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3246
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#s) th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3247
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3248
  {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3249
    assume eq_th': "th' = th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3250
    have ?thesis using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3251
      by (unfold eq_th', simp, unfold is_create, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3252
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3253
    assume h: "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3254
    hence ?thesis using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3255
      by (simp, simp add:is_create)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3256
  } ultimately show ?thesis by metis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3257
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3258
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3259
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3260
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3261
context valid_trace_exit
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3262
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3263
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3264
lemma th_live_s [simp]: "th \<in> threads s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3265
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3266
  from pip_e[unfolded is_exit]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3267
  show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3268
  by (cases, unfold runing_def readys_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3269
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3270
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3271
lemma th_ready_s [simp]: "th \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3272
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3273
  from pip_e[unfolded is_exit]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3274
  show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3275
  by (cases, unfold runing_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3276
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3277
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3278
lemma th_not_live_es [simp]: "th \<notin> threads (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3279
  by (unfold is_exit, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3280
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3281
lemma not_holding_th_s [simp]: "\<not> holding s th cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3282
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3283
  from pip_e[unfolded is_exit]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3284
  show ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3285
   by (cases, unfold holdents_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3286
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3287
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3288
lemma cntCS_th_s [simp]: "cntCS s th = 0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3289
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3290
  from pip_e[unfolded is_exit]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3291
  show ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3292
   by (cases, unfold cntCS_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3293
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3294
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3295
lemma not_holding_th_es [simp]: "\<not> holding (e#s) th cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3296
proof
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3297
  assume "holding (e # s) th cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3298
  from this[unfolded s_holding_def, folded wq_def, unfolded wq_neq_simp]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3299
  have "holding s th cs'" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3300
    by (unfold s_holding_def, fold wq_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3301
  with not_holding_th_s 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3302
  show False by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3303
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3304
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3305
lemma ready_th_es [simp]: "th \<notin> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3306
  by (simp add:readys_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3307
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3308
lemma holdents_th_s: "holdents s th = {}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3309
  by (unfold holdents_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3310
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3311
lemma holdents_th_es: "holdents (e#s) th = {}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3312
  by (unfold holdents_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3313
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3314
lemma cntCS_th_es [simp]: "cntCS (e#s) th = 0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3315
  by (unfold cntCS_def, simp add:holdents_th_es)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3316
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3317
lemma pvD_th_s [simp]: "pvD s th = 0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3318
  by (unfold pvD_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3319
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3320
lemma pvD_th_es [simp]: "pvD (e#s) th = 0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3321
  by (unfold pvD_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3322
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3323
lemma holdents_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3324
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3325
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3326
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3327
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3328
    assume h: "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3329
    hence "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3330
      by (unfold holdents_def s_holding_def, fold wq_def, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3331
             unfold wq_neq_simp, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3332
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3333
    fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3334
    assume h: "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3335
    hence "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3336
      by (unfold holdents_def s_holding_def, fold wq_def, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3337
             unfold wq_neq_simp, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3338
  } ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3339
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3340
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3341
lemma cntCS_kept [simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3342
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3343
  shows "cntCS (e#s) th' = cntCS s th'" (is "?L = ?R")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3344
  using holdents_kept[OF assms]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3345
  by (unfold cntCS_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3346
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3347
lemma readys_kept1: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3348
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3349
  and "th' \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3350
  shows "th' \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3351
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3352
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3353
    assume wait: "waiting s th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3354
    have n_wait: "\<not> waiting (e#s) th' cs'" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3355
      using assms by (auto simp:readys_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3356
    from wait[unfolded s_waiting_def, folded wq_def]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3357
         n_wait[unfolded s_waiting_def, folded wq_def, unfolded wq_neq_simp]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3358
    have False by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3359
  } thus ?thesis using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3360
    by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3361
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3362
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3363
lemma readys_kept2: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3364
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3365
  and "th' \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3366
  shows "th' \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3367
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3368
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3369
    assume wait: "waiting (e#s) th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3370
    have n_wait: "\<not> waiting s th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3371
      using assms(2) by (auto simp:readys_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3372
    from wait[unfolded s_waiting_def, folded wq_def, unfolded wq_neq_simp]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3373
         n_wait[unfolded s_waiting_def, folded wq_def]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3374
    have False by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3375
  } with assms show ?thesis  
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3376
    by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3377
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3378
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3379
lemma readys_simp [simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3380
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3381
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3382
  using readys_kept1[OF assms] readys_kept2[OF assms]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3383
  by metis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3384
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3385
lemma pvD_kept [simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3386
  assumes "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3387
  shows "pvD (e#s) th' = pvD s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3388
  using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3389
  by (unfold pvD_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3390
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3391
lemma cnp_cnv_cncs_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3392
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3393
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#s) th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3394
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3395
  {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3396
    assume eq_th': "th' = th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3397
    have ?thesis using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3398
      by (unfold eq_th', simp, unfold is_exit, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3399
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3400
    assume h: "th' \<noteq> th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3401
    hence ?thesis using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3402
      by (simp, simp add:is_exit)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3403
  } ultimately show ?thesis by metis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3404
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3405
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3406
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3407
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3408
context valid_trace_set
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3409
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3410
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3411
lemma th_live_s [simp]: "th \<in> threads s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3412
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3413
  from pip_e[unfolded is_set]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3414
  show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3415
  by (cases, unfold runing_def readys_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3416
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3417
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3418
lemma th_ready_s [simp]: "th \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3419
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3420
  from pip_e[unfolded is_set]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3421
  show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3422
  by (cases, unfold runing_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3423
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3424
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3425
lemma th_not_live_es [simp]: "th \<in> threads (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3426
  by (unfold is_set, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3427
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3428
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3429
lemma holdents_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3430
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3431
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3432
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3433
    assume h: "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3434
    hence "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3435
      by (unfold holdents_def s_holding_def, fold wq_def, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3436
             unfold wq_neq_simp, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3437
  } moreover {
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3438
    fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3439
    assume h: "cs' \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3440
    hence "cs' \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3441
      by (unfold holdents_def s_holding_def, fold wq_def, 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3442
             unfold wq_neq_simp, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3443
  } ultimately show ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3444
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3445
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3446
lemma cntCS_kept [simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3447
  shows "cntCS (e#s) th' = cntCS s th'" (is "?L = ?R")
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3448
  using holdents_kept
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3449
  by (unfold cntCS_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3450
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3451
lemma threads_kept[simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3452
  "threads (e#s) = threads s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3453
  by (unfold is_set, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3454
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3455
lemma readys_kept1: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3456
  assumes "th' \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3457
  shows "th' \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3458
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3459
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3460
    assume wait: "waiting s th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3461
    have n_wait: "\<not> waiting (e#s) th' cs'" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3462
      using assms by (auto simp:readys_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3463
    from wait[unfolded s_waiting_def, folded wq_def]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3464
         n_wait[unfolded s_waiting_def, folded wq_def, unfolded wq_neq_simp]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3465
    have False by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3466
  } moreover have "th' \<in> threads s" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3467
    using assms[unfolded readys_def] by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3468
  ultimately show ?thesis 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3469
    by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3470
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3471
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3472
lemma readys_kept2: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3473
  assumes "th' \<in> readys s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3474
  shows "th' \<in> readys (e#s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3475
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3476
  { fix cs'
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3477
    assume wait: "waiting (e#s) th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3478
    have n_wait: "\<not> waiting s th' cs'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3479
      using assms by (auto simp:readys_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3480
    from wait[unfolded s_waiting_def, folded wq_def, unfolded wq_neq_simp]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3481
         n_wait[unfolded s_waiting_def, folded wq_def]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3482
    have False by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3483
  } with assms show ?thesis  
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3484
    by (unfold readys_def, auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3485
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3486
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3487
lemma readys_simp [simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3488
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys s)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3489
  using readys_kept1 readys_kept2
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3490
  by metis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3491
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3492
lemma pvD_kept [simp]:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3493
  shows "pvD (e#s) th' = pvD s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3494
  by (unfold pvD_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3495
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3496
lemma cnp_cnv_cncs_kept:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3497
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3498
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#s) th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3499
  using assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3500
  by (unfold is_set, simp, fold is_set, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3501
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3502
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3503
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3504
context valid_trace
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3505
begin
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3506
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3507
lemma cnp_cnv_cncs: "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3508
proof(induct rule:ind)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3509
  case Nil
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3510
  thus ?case 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3511
    by (unfold cntP_def cntV_def pvD_def cntCS_def holdents_def 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3512
              s_holding_def, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3513
next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3514
  case (Cons s e)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3515
  interpret vt_e: valid_trace_e s e using Cons by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3516
  show ?case
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3517
  proof(cases e)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3518
    case (Create th prio)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3519
    interpret vt_create: valid_trace_create s e th prio 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3520
      using Create by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3521
    show ?thesis using Cons by (simp add: vt_create.cnp_cnv_cncs_kept) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3522
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3523
    case (Exit th)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3524
    interpret vt_exit: valid_trace_exit s e th  
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3525
        using Exit by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3526
   show ?thesis using Cons by (simp add: vt_exit.cnp_cnv_cncs_kept) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3527
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3528
    case (P th cs)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3529
    interpret vt_p: valid_trace_p s e th cs using P by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3530
    show ?thesis using Cons by (simp add: vt_p.cnp_cnv_cncs_kept) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3531
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3532
    case (V th cs)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3533
    interpret vt_v: valid_trace_v s e th cs using V by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3534
    show ?thesis using Cons by (simp add: vt_v.cnp_cnv_cncs_kept) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3535
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3536
    case (Set th prio)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3537
    interpret vt_set: valid_trace_set s e th prio
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3538
        using Set by (unfold_locales, simp)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3539
    show ?thesis using Cons by (simp add: vt_set.cnp_cnv_cncs_kept) 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3540
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3541
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3542
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3543
lemma not_thread_holdents:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3544
  assumes not_in: "th \<notin> threads s" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3545
  shows "holdents s th = {}"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3546
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3547
  { fix cs
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3548
    assume "cs \<in> holdents s th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3549
    hence "holding s th cs" by (auto simp:holdents_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3550
    from this[unfolded s_holding_def, folded wq_def]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3551
    have "th \<in> set (wq s cs)" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3552
    with wq_threads have "th \<in> threads s" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3553
    with assms
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3554
    have False by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3555
  } thus ?thesis by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3556
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3557
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3558
lemma not_thread_cncs:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3559
  assumes not_in: "th \<notin> threads s" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3560
  shows "cntCS s th = 0"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3561
  using not_thread_holdents[OF assms]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3562
  by (simp add:cntCS_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3563
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3564
lemma cnp_cnv_eq:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3565
  assumes "th \<notin> threads s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3566
  shows "cntP s th = cntV s th"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3567
  using assms cnp_cnv_cncs not_thread_cncs pvD_def
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3568
  by (auto)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3569
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3570
lemma runing_unique:
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3571
  assumes runing_1: "th1 \<in> runing s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3572
  and runing_2: "th2 \<in> runing s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3573
  shows "th1 = th2"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3574
proof -
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3575
  from runing_1 and runing_2 have "cp s th1 = cp s th2"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3576
    unfolding runing_def by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3577
  from this[unfolded cp_alt_def]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3578
  have eq_max: 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3579
    "Max (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th1)}) =
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3580
     Max (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th2)})" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3581
        (is "Max ?L = Max ?R") .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3582
  have "Max ?L \<in> ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3583
  proof(rule Max_in)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3584
    show "finite ?L" by (simp add: finite_subtree_threads)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3585
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3586
    show "?L \<noteq> {}" using subtree_def by fastforce 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3587
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3588
  then obtain th1' where 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3589
    h_1: "Th th1' \<in> subtree (RAG s) (Th th1)" "the_preced s th1' = Max ?L"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3590
    by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3591
  have "Max ?R \<in> ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3592
  proof(rule Max_in)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3593
    show "finite ?R" by (simp add: finite_subtree_threads)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3594
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3595
    show "?R \<noteq> {}" using subtree_def by fastforce 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3596
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3597
  then obtain th2' where 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3598
    h_2: "Th th2' \<in> subtree (RAG s) (Th th2)" "the_preced s th2' = Max ?R"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3599
    by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3600
  have "th1' = th2'"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3601
  proof(rule preced_unique)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3602
    from h_1(1)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3603
    show "th1' \<in> threads s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3604
    proof(cases rule:subtreeE)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3605
      case 1
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3606
      hence "th1' = th1" by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3607
      with runing_1 show ?thesis by (auto simp:runing_def readys_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3608
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3609
      case 2
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3610
      from this(2)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3611
      have "(Th th1', Th th1) \<in> (RAG s)^+" by (auto simp:ancestors_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3612
      from tranclD[OF this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3613
      have "(Th th1') \<in> Domain (RAG s)" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3614
      from dm_RAG_threads[OF this] show ?thesis .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3615
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3616
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3617
    from h_2(1)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3618
    show "th2' \<in> threads s"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3619
    proof(cases rule:subtreeE)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3620
      case 1
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3621
      hence "th2' = th2" by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3622
      with runing_2 show ?thesis by (auto simp:runing_def readys_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3623
    next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3624
      case 2
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3625
      from this(2)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3626
      have "(Th th2', Th th2) \<in> (RAG s)^+" by (auto simp:ancestors_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3627
      from tranclD[OF this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3628
      have "(Th th2') \<in> Domain (RAG s)" by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3629
      from dm_RAG_threads[OF this] show ?thesis .
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3630
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3631
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3632
    have "the_preced s th1' = the_preced s th2'" 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3633
     using eq_max h_1(2) h_2(2) by metis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3634
    thus "preced th1' s = preced th2' s" by (simp add:the_preced_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3635
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3636
  from h_1(1)[unfolded this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3637
  have star1: "(Th th2', Th th1) \<in> (RAG s)^*" by (auto simp:subtree_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3638
  from h_2(1)[unfolded this]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3639
  have star2: "(Th th2', Th th2) \<in> (RAG s)^*" by (auto simp:subtree_def)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3640
  from star_rpath[OF star1] obtain xs1 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3641
    where rp1: "rpath (RAG s) (Th th2') xs1 (Th th1)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3642
    by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3643
  from star_rpath[OF star2] obtain xs2 
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3644
    where rp2: "rpath (RAG s) (Th th2') xs2 (Th th2)"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3645
    by auto
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3646
  show ?thesis
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3647
  proof(cases rule:rtree_RAG.rpath_overlap[OF rp1 rp2])
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3648
    case (1 xs')
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3649
    moreover have "xs' = []"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3650
    proof(rule ccontr)
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3651
      assume otherwise: "xs' \<noteq> []"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3652
      find_theorems rpath "_@_"
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3653
    qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3654
    ultimately have "xs2 = xs1" by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3655
    from rpath_dest_eq[OF rp1 rp2[unfolded this]]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3656
    show ?thesis by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3657
  next
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3658
    case (2 xs')
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3659
    moreover have "xs' = []" sorry
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3660
    ultimately have "xs2 = xs1" by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3661
    from rpath_dest_eq[OF rp1 rp2[unfolded this]]
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3662
    show ?thesis by simp
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3663
  qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3664
qed
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3665
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3666
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3667
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3668
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3669
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3670
end
17305a85493d CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents: 79
diff changeset
  3671