CpsG.thy~
author zhangx
Sun, 17 Jan 2016 22:18:35 +0800
changeset 79 8067efcb43da
parent 77 d37703e0c5c4
child 80 17305a85493d
permissions -rw-r--r--
Still improving CpsG.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
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
     2
imports PIPDefs 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
     3
begin
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
     4
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
     5
lemma Max_f_mono:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
     6
  assumes seq: "A \<subseteq> B"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
     7
  and np: "A \<noteq> {}"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
     8
  and fnt: "finite B"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
     9
  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
    10
proof(rule Max_mono)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    11
  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
    12
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    13
  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
    14
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    15
  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
    16
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
    17
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    18
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    19
locale valid_trace = 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    20
  fixes s
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    21
  assumes vt : "vt s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    22
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    23
locale valid_trace_e = valid_trace +
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    24
  fixes e
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    25
  assumes vt_e: "vt (e#s)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    26
begin
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    27
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    28
lemma pip_e: "PIP s e"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    29
  using vt_e by (cases, simp)  
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    30
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    31
end
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
    32
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    33
locale valid_trace_create = valid_trace_e + 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    34
  fixes th prio
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    35
  assumes is_create: "e = Create th prio"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    36
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    37
locale valid_trace_exit = valid_trace_e + 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    38
  fixes th
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    39
  assumes is_exit: "e = Exit th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    40
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    41
locale valid_trace_p = valid_trace_e + 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    42
  fixes th cs
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    43
  assumes is_p: "e = P th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    44
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    45
locale valid_trace_v = valid_trace_e + 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    46
  fixes th cs
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    47
  assumes is_v: "e = V th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    48
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    49
  definition "rest = tl (wq s cs)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    50
  definition "wq' = (SOME q. distinct q \<and> set q = set rest)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    51
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    52
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    53
locale valid_trace_v_n = valid_trace_v +
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    54
  assumes rest_nnl: "rest \<noteq> []"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    55
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    56
locale valid_trace_v_e = valid_trace_v +
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    57
  assumes rest_nil: "rest = []"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    58
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    59
locale valid_trace_set= valid_trace_e + 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    60
  fixes th prio
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    61
  assumes is_set: "e = Set th prio"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    62
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    63
context valid_trace
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    64
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    65
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    66
lemma ind [consumes 0, case_names Nil Cons, induct type]:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    67
  assumes "PP []"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    68
     and "(\<And>s e. valid_trace_e s e \<Longrightarrow>
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    69
                   PP s \<Longrightarrow> PIP s e \<Longrightarrow> PP (e # s))"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    70
     shows "PP s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    71
proof(induct rule:vt.induct[OF vt, case_names Init Step])
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    72
  case Init
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    73
  from assms(1) show ?case .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    74
next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    75
  case (Step s e)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    76
  show ?case
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    77
  proof(rule assms(2))
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    78
    show "valid_trace_e s e" using Step by (unfold_locales, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    79
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    80
    show "PP s" using Step by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    81
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    82
    show "PIP s e" using Step by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    83
  qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    84
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    85
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    86
lemma  vt_moment: "\<And> t. vt (moment t s)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    87
proof(induct rule:ind)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    88
  case Nil
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    89
  thus ?case by (simp add:vt_nil)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    90
next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    91
  case (Cons s e t)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    92
  show ?case
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    93
  proof(cases "t \<ge> length (e#s)")
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    94
    case True
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    95
    from True have "moment t (e#s) = e#s" by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    96
    thus ?thesis using Cons
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    97
      by (simp add:valid_trace_def valid_trace_e_def, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    98
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
    99
    case False
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   100
    from Cons have "vt (moment t s)" by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   101
    moreover have "moment t (e#s) = moment t s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   102
    proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   103
      from False have "t \<le> length s" by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   104
      from moment_app [OF this, of "[e]"] 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   105
      show ?thesis by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   106
    qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   107
    ultimately show ?thesis by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   108
  qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   109
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   110
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   111
lemma finite_threads:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   112
  shows "finite (threads s)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   113
using vt by (induct) (auto elim: step.cases)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   114
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   115
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   116
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   117
lemma cp_eq_cpreced: "cp s th = cpreced (wq s) s th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   118
unfolding cp_def wq_def
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   119
apply(induct s rule: schs.induct)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   120
apply(simp add: Let_def cpreced_initial)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   121
apply(simp add: Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   122
apply(simp add: Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   123
apply(simp add: Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   124
apply(subst (2) schs.simps)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   125
apply(simp add: Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   126
apply(subst (2) schs.simps)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   127
apply(simp add: Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   128
done
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   129
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   130
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
   131
  by (unfold s_RAG_def, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   132
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   133
locale valid_moment = valid_trace + 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   134
  fixes i :: nat
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   135
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   136
sublocale valid_moment < vat_moment: valid_trace "(moment i s)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   137
  by (unfold_locales, insert vt_moment, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   138
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   139
lemma waiting_eq: "waiting s th cs = waiting (wq s) th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   140
  by  (unfold s_waiting_def cs_waiting_def wq_def, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   141
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   142
lemma holding_eq: "holding (s::state) th cs = holding (wq s) th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   143
  by (unfold s_holding_def wq_def cs_holding_def, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   144
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   145
lemma runing_ready: 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   146
  shows "runing s \<subseteq> readys s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   147
  unfolding runing_def readys_def
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   148
  by auto 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   149
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   150
lemma readys_threads:
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   151
  shows "readys s \<subseteq> threads s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   152
  unfolding readys_def
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   153
  by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   154
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   155
lemma wq_v_neq [simp]:
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   156
   "cs \<noteq> cs' \<Longrightarrow> wq (V thread cs#s) cs' = wq s cs'"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   157
  by (auto simp:wq_def Let_def cp_def split:list.splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   158
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   159
lemma runing_head:
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   160
  assumes "th \<in> runing s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   161
  and "th \<in> set (wq_fun (schs s) cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   162
  shows "th = hd (wq_fun (schs s) cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   163
  using assms
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   164
  by (simp add:runing_def readys_def s_waiting_def wq_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   165
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   166
context valid_trace
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   167
begin
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   168
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   169
lemma runing_wqE:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   170
  assumes "th \<in> runing s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   171
  and "th \<in> set (wq s cs)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   172
  obtains rest where "wq s cs = th#rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   173
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   174
  from assms(2) obtain th' rest where eq_wq: "wq s cs = th'#rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   175
    by (meson list.set_cases)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   176
  have "th' = th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   177
  proof(rule ccontr)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   178
    assume "th' \<noteq> th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   179
    hence "th \<noteq> hd (wq s cs)" using eq_wq by auto 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   180
    with assms(2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   181
    have "waiting s th cs" 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   182
      by (unfold s_waiting_def, fold wq_def, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   183
    with assms show False 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   184
      by (unfold runing_def readys_def, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   185
  qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   186
  with eq_wq that show ?thesis by metis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   187
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   188
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   189
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   190
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   191
context valid_trace_create
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   192
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   193
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   194
lemma wq_neq_simp [simp]:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   195
  shows "wq (e#s) cs' = wq s cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   196
    using assms unfolding is_create wq_def
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   197
  by (auto simp:Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   198
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   199
lemma wq_distinct_kept:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   200
  assumes "distinct (wq s cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   201
  shows "distinct (wq (e#s) cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   202
  using assms by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   203
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   204
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   205
context valid_trace_exit
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   206
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   207
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   208
lemma wq_neq_simp [simp]:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   209
  shows "wq (e#s) cs' = wq s cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   210
    using assms unfolding is_exit wq_def
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   211
  by (auto simp:Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   212
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   213
lemma wq_distinct_kept:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   214
  assumes "distinct (wq s cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   215
  shows "distinct (wq (e#s) cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   216
  using assms by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   217
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   218
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   219
context valid_trace_p
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   220
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   221
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   222
lemma wq_neq_simp [simp]:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   223
  assumes "cs' \<noteq> cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   224
  shows "wq (e#s) cs' = wq s cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   225
    using assms unfolding is_p wq_def
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   226
  by (auto simp:Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   227
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   228
lemma runing_th_s:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   229
  shows "th \<in> runing s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   230
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   231
  from pip_e[unfolded is_p]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   232
  show ?thesis by (cases, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   233
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   234
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   235
lemma th_not_waiting: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   236
  "\<not> waiting s th c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   237
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   238
  have "th \<in> readys s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   239
    using runing_ready runing_th_s by blast 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   240
  thus ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   241
    by (unfold readys_def, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   242
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   243
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   244
lemma waiting_neq_th: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   245
  assumes "waiting s t c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   246
  shows "t \<noteq> th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   247
  using assms using th_not_waiting by blast 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   248
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   249
lemma th_not_in_wq: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   250
  shows "th \<notin> set (wq s cs)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   251
proof
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   252
  assume otherwise: "th \<in> set (wq s cs)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   253
  from runing_wqE[OF runing_th_s this]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   254
  obtain rest where eq_wq: "wq s cs = th#rest" by blast
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   255
  with otherwise
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   256
  have "holding s th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   257
    by (unfold s_holding_def, fold wq_def, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   258
  hence cs_th_RAG: "(Cs cs, Th th) \<in> RAG s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   259
    by (unfold s_RAG_def, fold holding_eq, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   260
  from pip_e[unfolded is_p]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   261
  show False
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   262
  proof(cases)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   263
    case (thread_P)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   264
    with cs_th_RAG show ?thesis by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   265
  qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   266
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   267
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   268
lemma wq_es_cs: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   269
  "wq (e#s) cs =  wq s cs @ [th]"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   270
  by (unfold is_p wq_def, auto simp:Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   271
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   272
lemma wq_distinct_kept:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   273
  assumes "distinct (wq s cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   274
  shows "distinct (wq (e#s) cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   275
proof(cases "cs' = cs")
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   276
  case True
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   277
  show ?thesis using True assms th_not_in_wq
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   278
    by (unfold True wq_es_cs, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   279
qed (insert assms, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   280
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_v
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_v 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_v]
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
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   299
lemma th_not_waiting: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   300
  "\<not> waiting s th c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   301
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   302
  have "th \<in> readys s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   303
    using runing_ready runing_th_s by blast 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   304
  thus ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   305
    by (unfold readys_def, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   306
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   307
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   308
lemma waiting_neq_th: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   309
  assumes "waiting s t c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   310
  shows "t \<noteq> th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   311
  using assms using th_not_waiting by blast 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   312
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   313
lemma wq_s_cs:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   314
  "wq s cs = th#rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   315
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   316
  from pip_e[unfolded is_v]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   317
  show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   318
  proof(cases)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   319
    case (thread_V)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   320
    from this(2) show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   321
      by (unfold rest_def s_holding_def, fold wq_def,
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   322
                 metis empty_iff list.collapse list.set(1))
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   323
  qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   324
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   325
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   326
lemma wq_es_cs:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   327
  "wq (e#s) cs = wq'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   328
 using wq_s_cs[unfolded wq_def]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   329
 by (auto simp:Let_def wq_def rest_def wq'_def is_v, simp) 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   330
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   331
lemma wq_distinct_kept:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   332
  assumes "distinct (wq s cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   333
  shows "distinct (wq (e#s) cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   334
proof(cases "cs' = cs")
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   335
  case True
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   336
  show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   337
  proof(unfold True wq_es_cs wq'_def, rule someI2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   338
    show "distinct rest \<and> set rest = set rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   339
        using assms[unfolded True wq_s_cs] by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   340
  qed simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   341
qed (insert assms, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   342
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   343
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   344
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   345
context valid_trace_set
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   346
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   347
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   348
lemma wq_neq_simp [simp]:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   349
  shows "wq (e#s) cs' = wq s cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   350
    using assms unfolding is_set wq_def
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   351
  by (auto simp:Let_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   352
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   353
lemma wq_distinct_kept:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   354
  assumes "distinct (wq s cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   355
  shows "distinct (wq (e#s) cs')"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   356
  using assms by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   357
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   358
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   359
context valid_trace
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   360
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   361
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   362
lemma actor_inv: 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   363
  assumes "PIP s e"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   364
  and "\<not> isCreate e"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   365
  shows "actor e \<in> runing s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   366
  using assms
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   367
  by (induct, auto)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   368
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   369
lemma isP_E:
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   370
  assumes "isP e"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   371
  obtains cs where "e = P (actor e) cs"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   372
  using assms by (cases e, auto)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   373
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   374
lemma isV_E:
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   375
  assumes "isV e"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   376
  obtains cs where "e = V (actor e) cs"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   377
  using assms by (cases e, auto) 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   378
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   379
lemma wq_distinct: "distinct (wq s cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   380
proof(induct rule:ind)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   381
  case (Cons s e)
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   382
  interpret vt_e: valid_trace_e s e using Cons by simp
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   383
  show ?case 
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   384
  proof(cases e)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   385
    case (Create th prio)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   386
    interpret vt_create: valid_trace_create s e th prio 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   387
      using Create by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   388
    show ?thesis using Cons by (simp add: vt_create.wq_distinct_kept) 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   389
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   390
    case (Exit th)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   391
    interpret vt_exit: valid_trace_exit s e th  
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   392
        using Exit by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   393
    show ?thesis using Cons by (simp add: vt_exit.wq_distinct_kept) 
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   394
  next
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   395
    case (P th cs)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   396
    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
   397
    show ?thesis using Cons by (simp add: vt_p.wq_distinct_kept) 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   398
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   399
    case (V th cs)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   400
    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
   401
    show ?thesis using Cons by (simp add: vt_v.wq_distinct_kept) 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   402
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   403
    case (Set th prio)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   404
    interpret vt_set: valid_trace_set s e th prio
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   405
        using Set by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   406
    show ?thesis using Cons by (simp add: vt_set.wq_distinct_kept) 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   407
  qed
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   408
qed (unfold wq_def Let_def, simp)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   409
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   410
end
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   411
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   412
context valid_trace_e
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   413
begin
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   414
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   415
text {*
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   416
  The following lemma shows that only the @{text "P"}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   417
  operation can add new thread into waiting queues. 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   418
  Such kind of lemmas are very obvious, but need to be checked formally.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   419
  This is a kind of confirmation that our modelling is correct.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   420
*}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   421
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   422
lemma wq_in_inv: 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   423
  assumes s_ni: "thread \<notin> set (wq s cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   424
  and s_i: "thread \<in> set (wq (e#s) cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   425
  shows "e = P thread cs"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   426
proof(cases e)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   427
  -- {* This is the only non-trivial case: *}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   428
  case (V th cs1)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   429
  have False
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   430
  proof(cases "cs1 = cs")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   431
    case True
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   432
    show ?thesis
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   433
    proof(cases "(wq s cs1)")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   434
      case (Cons w_hd w_tl)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   435
      have "set (wq (e#s) cs) \<subseteq> set (wq s cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   436
      proof -
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   437
        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
   438
          using  Cons V by (auto simp:wq_def Let_def True split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   439
        moreover have "set ... \<subseteq> set (wq s cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   440
        proof(rule someI2)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   441
          show "distinct w_tl \<and> set w_tl = set w_tl"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   442
            by (metis distinct.simps(2) local.Cons wq_distinct)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   443
        qed (insert Cons True, auto)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   444
        ultimately show ?thesis by simp
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   445
      qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   446
      with assms show ?thesis by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   447
    qed (insert assms V True, auto simp:wq_def Let_def split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   448
  qed (insert assms V, auto simp:wq_def Let_def split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   449
  thus ?thesis by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   450
qed (insert assms, auto simp:wq_def Let_def split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   451
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   452
lemma wq_out_inv: 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   453
  assumes s_in: "thread \<in> set (wq s cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   454
  and s_hd: "thread = hd (wq s cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   455
  and s_i: "thread \<noteq> hd (wq (e#s) cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   456
  shows "e = V thread cs"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   457
proof(cases e)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   458
-- {* There are only two non-trivial cases: *}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   459
  case (V th cs1)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   460
  show ?thesis
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   461
  proof(cases "cs1 = cs")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   462
    case True
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   463
    have "PIP s (V th cs)" using pip_e[unfolded V[unfolded True]] .
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   464
    thus ?thesis
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   465
    proof(cases)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   466
      case (thread_V)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   467
      moreover have "th = thread" using thread_V(2) s_hd
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   468
          by (unfold s_holding_def wq_def, simp)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   469
      ultimately show ?thesis using V True by simp
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   470
    qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   471
  qed (insert assms V, auto simp:wq_def Let_def split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   472
next
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   473
  case (P th cs1)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   474
  show ?thesis
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   475
  proof(cases "cs1 = cs")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   476
    case True
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   477
    with P have "wq (e#s) cs = wq_fun (schs s) cs @ [th]"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   478
      by (auto simp:wq_def Let_def split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   479
    with s_i s_hd s_in have False
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   480
      by (metis empty_iff hd_append2 list.set(1) wq_def) 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   481
    thus ?thesis by simp
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   482
  qed (insert assms P, auto simp:wq_def Let_def split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   483
qed (insert assms, auto simp:wq_def Let_def split:if_splits)
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
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   488
context valid_trace
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   489
begin
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   490
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   491
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   492
text {* (* ddd *)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   493
  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
   494
  model, even intuitively very `basic` and `obvious` properties need to derived from scratch.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   495
  For instance, the fact 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   496
  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
   497
  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
   498
  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
   499
  blocked the second time (because it is not running). 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   500
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   501
  To derive this fact, one needs to prove by contraction and 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   502
  reason about time (or @{text "moement"}). The reasoning is based on a generic theorem
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   503
  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
   504
  a condition @{text "Q"} is @{text "True"} at a state @{text "s"},
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   505
  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
   506
  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
   507
  of events leading to it), such that @{text "Q"} switched 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   508
  from being @{text "False"} to @{text "True"} and kept being @{text "True"}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   509
  till the last moment of @{text "s"}.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   510
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   511
  Suppose a thread @{text "th"} is blocked
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   512
  on @{text "cs1"} and @{text "cs2"} in some state @{text "s"}, 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   513
  since no thread is blocked at the very beginning, by applying 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   514
  @{text "p_split"} to these two blocking facts, there exist 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   515
  two moments @{text "t1"} and @{text "t2"}  in @{text "s"}, such that 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   516
  @{text "th"} got blocked on @{text "cs1"} and @{text "cs2"} 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   517
  and kept on blocked on them respectively ever since.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   518
 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   519
  Without lost of generality, we assume @{text "t1"} is earlier than @{text "t2"}.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   520
  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
   521
  in blocked state at moment @{text "t2"} and could not
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   522
  make any request and get blocked the second time: Contradiction.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   523
*}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   524
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   525
lemma waiting_unique_pre: (* ddd *)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   526
  assumes h11: "thread \<in> set (wq s cs1)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   527
  and h12: "thread \<noteq> hd (wq s cs1)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   528
  assumes h21: "thread \<in> set (wq s cs2)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   529
  and h22: "thread \<noteq> hd (wq s cs2)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   530
  and neq12: "cs1 \<noteq> cs2"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   531
  shows "False"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   532
proof -
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   533
  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
   534
  from h11 and h12 have q1: "?Q cs1 s" by simp
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   535
  from h21 and h22 have q2: "?Q cs2 s" by simp
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   536
  have nq1: "\<not> ?Q cs1 []" by (simp add:wq_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   537
  have nq2: "\<not> ?Q cs2 []" by (simp add:wq_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   538
  from p_split [of "?Q cs1", OF q1 nq1]
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   539
  obtain t1 where lt1: "t1 < length s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   540
    and np1: "\<not> ?Q cs1 (moment t1 s)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   541
    and nn1: "(\<forall>i'>t1. ?Q cs1 (moment i' s))" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   542
  from p_split [of "?Q cs2", OF q2 nq2]
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   543
  obtain t2 where lt2: "t2 < length s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   544
    and np2: "\<not> ?Q cs2 (moment t2 s)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   545
    and nn2: "(\<forall>i'>t2. ?Q cs2 (moment i' s))" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   546
  { fix s cs
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   547
    assume q: "?Q cs s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   548
    have "thread \<notin> runing s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   549
    proof
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   550
      assume "thread \<in> runing s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   551
      hence " \<forall>cs. \<not> (thread \<in> set (wq_fun (schs s) cs) \<and> 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   552
                 thread \<noteq> hd (wq_fun (schs s) cs))"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   553
        by (unfold runing_def s_waiting_def readys_def, auto)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   554
      from this[rule_format, of cs] q 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   555
      show False by (simp add: wq_def) 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   556
    qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   557
  } 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
   558
  { fix t1 t2 cs1 cs2
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   559
    assume  lt1: "t1 < length s"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   560
    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
   561
    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
   562
    and lt2: "t2 < length s"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   563
    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
   564
    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
   565
    and lt12: "t1 < t2"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   566
    let ?t3 = "Suc t2"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   567
    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
   568
    from moment_plus [OF this] 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   569
    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
   570
    have "t2 < ?t3" by simp
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   571
    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
   572
    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
   573
         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
   574
    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
   575
    proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   576
      from vt_moment 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   577
      have "vt (moment ?t3 s)" .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   578
      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
   579
    qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   580
    then interpret vt_e: valid_trace_e "moment t2 s" "e"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   581
        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
   582
    have ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   583
    proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   584
      have "thread \<in> runing (moment t2 s)"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   585
      proof(cases "thread \<in> set (wq (moment t2 s) cs2)")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   586
        case True
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   587
        have "e = V thread cs2"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   588
        proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   589
          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
   590
              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
   591
          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
   592
          show ?thesis .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   593
        qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   594
        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
   595
      next
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   596
        case False
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   597
        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
   598
        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
   599
        show ?thesis by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   600
      qed
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   601
      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
   602
        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
   603
      ultimately show ?thesis by simp
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   604
    qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   605
  } note lt_case = this
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   606
  show ?thesis
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   607
  proof -
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   608
    { assume "t1 < t2"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   609
      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
   610
      have ?thesis .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   611
    } moreover {
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   612
      assume "t2 < t1"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   613
      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
   614
      have ?thesis .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   615
    } moreover {
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   616
      assume eq_12: "t1 = t2"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   617
      let ?t3 = "Suc t2"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   618
      from lt2 have le_t3: "?t3 \<le> length s" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   619
      from moment_plus [OF this] 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   620
      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
   621
      have lt_2: "t2 < ?t3" by simp
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   622
      from nn2 [rule_format, OF this] and eq_m
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   623
      have h1: "thread \<in> set (wq (e#moment t2 s) cs2)" and
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   624
           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
   625
      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
   626
      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
   627
           g2: "thread \<noteq> hd (wq (e#moment t1 s) cs1)" by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   628
      have "vt (e#moment t2 s)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   629
      proof -
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   630
        from vt_moment 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   631
        have "vt (moment ?t3 s)" .
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   632
        with eq_m show ?thesis by simp
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   633
      qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   634
      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
   635
          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
   636
      have "e = V thread cs2 \<or> e = P thread cs2"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   637
      proof(cases "thread \<in> set (wq (moment t2 s) cs2)")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   638
        case True
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   639
        have "e = V thread cs2"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   640
        proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   641
          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
   642
              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
   643
          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
   644
          show ?thesis .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   645
        qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   646
        thus ?thesis by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   647
      next
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   648
        case False
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   649
        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
   650
        thus ?thesis by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   651
      qed
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   652
      moreover have "e = V thread cs1 \<or> e = P thread cs1"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   653
      proof(cases "thread \<in> set (wq (moment t1 s) cs1)")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   654
        case True
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   655
        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
   656
              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
   657
        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
   658
        have "e = V thread cs1" .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   659
        thus ?thesis by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   660
      next
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   661
        case False
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   662
        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
   663
        thus ?thesis by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   664
      qed
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   665
      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
   666
    } ultimately show ?thesis using nat_neq_iff by blast 
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   667
  qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   668
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   669
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   670
text {*
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   671
  This lemma is a simple corrolary of @{text "waiting_unique_pre"}.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   672
*}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   673
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   674
lemma waiting_unique:
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   675
  assumes "waiting s th cs1"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   676
  and "waiting s th cs2"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   677
  shows "cs1 = cs2"
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   678
  using waiting_unique_pre assms
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   679
  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
   680
  by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   681
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   682
end
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   683
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   684
(* not used *)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   685
text {*
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   686
  Every thread can only be blocked on one critical resource, 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   687
  symmetrically, every critical resource can only be held by one thread. 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   688
  This fact is much more easier according to our definition. 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   689
*}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   690
lemma held_unique:
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   691
  assumes "holding (s::event list) th1 cs"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   692
  and "holding s th2 cs"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   693
  shows "th1 = th2"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   694
 by (insert assms, unfold s_holding_def, auto)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   695
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   696
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
   697
  apply (induct s, auto)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   698
  by (case_tac a, auto split:if_splits)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   699
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   700
lemma last_set_unique: 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   701
  "\<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
   702
          \<Longrightarrow> th1 = th2"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   703
  apply (induct s, auto)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   704
  by (case_tac a, auto split:if_splits dest:last_set_lt)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   705
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   706
lemma preced_unique : 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   707
  assumes pcd_eq: "preced th1 s = preced th2 s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   708
  and th_in1: "th1 \<in> threads s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   709
  and th_in2: " th2 \<in> threads s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   710
  shows "th1 = th2"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   711
proof -
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   712
  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
   713
  from last_set_unique [OF this th_in1 th_in2]
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   714
  show ?thesis .
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   715
qed
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   716
                      
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   717
lemma preced_linorder: 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   718
  assumes neq_12: "th1 \<noteq> th2"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   719
  and th_in1: "th1 \<in> threads s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   720
  and th_in2: " th2 \<in> threads s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   721
  shows "preced th1 s < preced th2 s \<or> preced th1 s > preced th2 s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   722
proof -
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   723
  from preced_unique [OF _ th_in1 th_in2] and neq_12 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   724
  have "preced th1 s \<noteq> preced th2 s" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   725
  thus ?thesis by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   726
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   727
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   728
text {*
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   729
  The following three lemmas show that @{text "RAG"} does not change
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   730
  by the happening of @{text "Set"}, @{text "Create"} and @{text "Exit"}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   731
  events, respectively.
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   732
*}
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   733
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   734
lemma RAG_set_unchanged: "(RAG (Set th prio # s)) = RAG s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   735
apply (unfold s_RAG_def s_waiting_def wq_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   736
by (simp add:Let_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   737
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   738
lemma RAG_create_unchanged: "(RAG (Create th prio # s)) = RAG s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   739
apply (unfold s_RAG_def s_waiting_def wq_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   740
by (simp add:Let_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   741
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   742
lemma RAG_exit_unchanged: "(RAG (Exit th # s)) = RAG s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   743
apply (unfold s_RAG_def s_waiting_def wq_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   744
by (simp add:Let_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   745
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   746
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   747
context valid_trace_v
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   748
begin
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   749
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   750
lemma distinct_rest: "distinct rest"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   751
  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
   752
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   753
lemma holding_cs_eq_th:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   754
  assumes "holding s t cs"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   755
  shows "t = th"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   756
proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   757
  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
   758
  show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   759
  proof(cases)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   760
    case (thread_V)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   761
    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
   762
    show ?thesis by simp
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   763
  qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   764
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   765
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   766
lemma distinct_wq': "distinct wq'"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   767
  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
   768
  
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   769
lemma th'_in_inv:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   770
  assumes "th' \<in> set wq'"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   771
  shows "th' \<in> set rest"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   772
  using assms
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   773
  by (metis (mono_tags, lifting) distinct.simps(2) 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   774
        rest_def some_eq_ex wq'_def wq_distinct wq_s_cs) 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   775
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   776
lemma neq_t_th: 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   777
  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
   778
  shows "t \<noteq> th"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   779
proof
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   780
  assume otherwise: "t = th"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   781
  show False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   782
  proof(cases "c = cs")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   783
    case True
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   784
    have "t \<in> set wq'" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   785
     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
   786
     by simp 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   787
    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
   788
    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
   789
    show ?thesis by simp
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   790
  next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   791
    case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   792
    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
   793
        by (unfold is_v, simp)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   794
    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
   795
        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
   796
    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
   797
    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
   798
    with runing_th_s[folded otherwise] show ?thesis by auto
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   799
  qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   800
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   801
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   802
lemma waiting_esI1:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   803
  assumes "waiting s t c"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   804
      and "c \<noteq> cs" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   805
  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
   806
proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   807
  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
   808
    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
   809
  with assms(1) show ?thesis 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   810
    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
   811
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   812
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   813
lemma holding_esI2:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   814
  assumes "c \<noteq> cs" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   815
  and "holding s t c"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   816
  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
   817
proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   818
  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
   819
  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
   820
                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
   821
  show ?thesis .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   822
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   823
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   824
lemma holding_esI1:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   825
  assumes "holding s t c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   826
  and "t \<noteq> th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   827
  shows "holding (e#s) t c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   828
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   829
  have "c \<noteq> cs" using assms using holding_cs_eq_th by blast 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   830
  from holding_esI2[OF this assms(1)]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   831
  show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   832
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   833
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   834
end
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   835
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   836
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
   837
begin
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 neq_wq': "wq' \<noteq> []" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   840
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
   841
  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
   842
    by (simp add: distinct_rest) 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   843
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   844
  fix x
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   845
  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
   846
  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
   847
qed 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   848
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   849
definition "taker = hd wq'"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   850
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   851
definition "rest' = tl wq'"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   852
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   853
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
   854
  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
   855
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   856
lemma next_th_taker: 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   857
  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
   858
  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
   859
  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
   860
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   861
lemma taker_unique: 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   862
  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
   863
  shows "taker' = taker"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   864
proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   865
  from assms
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   866
  obtain rest' where 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   867
    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
   868
       "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
   869
          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
   870
  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
   871
  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
   872
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   873
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   874
lemma waiting_set_eq:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   875
  "{(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
   876
  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
   877
      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
   878
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   879
lemma holding_set_eq:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   880
  "{(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
   881
  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
   882
  by fastforce
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   883
   
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   884
lemma holding_taker:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   885
  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
   886
    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
   887
        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
   888
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   889
lemma waiting_esI2:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   890
  assumes "waiting s t cs"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   891
      and "t \<noteq> taker"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   892
  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
   893
proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   894
  have "t \<in> set wq'" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   895
  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
   896
    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
   897
          by (simp add: distinct_rest)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   898
  next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   899
    fix x
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   900
    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
   901
    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
   902
        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
   903
    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
   904
  qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   905
  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
   906
    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
   907
  ultimately show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   908
    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
   909
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   910
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   911
lemma waiting_esE:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   912
  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
   913
  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
   914
     |    "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
   915
proof(cases "c = cs")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   916
  case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   917
  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
   918
  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
   919
  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
   920
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   921
  case True
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   922
  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
   923
  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
   924
  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
   925
  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
   926
  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
   927
  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
   928
    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
   929
                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
   930
  show ?thesis using that(2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   931
  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
   932
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   933
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   934
lemma holding_esI1:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   935
  assumes "c = cs"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   936
  and "t = taker"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   937
  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
   938
  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
   939
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   940
lemma holding_esE:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   941
  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
   942
  obtains "c = cs" "t = taker"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   943
      | "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
   944
proof(cases "c = cs")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   945
  case True
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   946
  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
   947
             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
   948
  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
   949
  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
   950
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   951
  case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   952
  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
   953
  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
   954
             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
   955
  have "holding s t c"  .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   956
  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
   957
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   958
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   959
end 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   960
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   961
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
   962
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
   963
begin
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   964
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   965
lemma nil_wq': "wq' = []" 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   966
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
   967
  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
   968
    by (simp add: distinct_rest) 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   969
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   970
  fix x
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   971
  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
   972
  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
   973
qed 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   974
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   975
lemma no_taker: 
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   976
  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
   977
  shows "False"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
   978
proof -
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   979
  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
   980
  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
   981
    by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   982
  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
   983
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   984
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   985
lemma waiting_set_eq:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   986
  "{(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
   987
  using no_taker by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   988
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   989
lemma holding_set_eq:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   990
  "{(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
   991
  using no_taker by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   992
   
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   993
lemma no_holding:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   994
  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
   995
  shows False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   996
proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   997
  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
   998
  have " wq (e # s) cs = []" .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
   999
  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
  1000
  show ?thesis by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1001
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1002
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1003
lemma no_waiting:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1004
  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
  1005
  shows False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1006
proof -
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1007
  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
  1008
  have " wq (e # s) cs = []" .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1009
  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
  1010
  show ?thesis by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1011
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1012
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1013
lemma waiting_esI2:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1014
  assumes "waiting s t c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1015
  shows "waiting (e#s) t c"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1016
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1017
  have "c \<noteq> cs" using assms
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1018
    using cs_waiting_def rest_nil waiting_eq wq_s_cs by auto 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1019
  from waiting_esI1[OF assms this]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1020
  show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1021
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1022
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1023
lemma waiting_esE:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1024
  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
  1025
  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
  1026
proof(cases "c = cs")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1027
  case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1028
  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
  1029
  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
  1030
  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
  1031
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1032
  case True
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1033
  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
  1034
  show ?thesis by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1035
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1036
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1037
lemma holding_esE:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1038
  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
  1039
  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
  1040
proof(cases "c = cs")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1041
  case True
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1042
  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
  1043
  show ?thesis by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1044
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1045
  case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1046
  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
  1047
  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
  1048
             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
  1049
  have "holding s t c"  .
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1050
  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
  1051
qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1052
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1053
end 
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1054
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1055
lemma rel_eqI:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1056
  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
  1057
  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
  1058
  shows "A = B"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1059
  using assms by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1060
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1061
lemma in_RAG_E:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1062
  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
  1063
  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
  1064
      | (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
  1065
  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
  1066
  by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1067
  
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1068
context valid_trace_v
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1069
begin
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1070
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1071
lemma RAG_es:
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1072
  "RAG (e # s) =
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1073
   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
  1074
     {(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
  1075
     {(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
  1076
proof(rule rel_eqI)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1077
  fix n1 n2
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1078
  assume "(n1, n2) \<in> ?L"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1079
  thus "(n1, n2) \<in> ?R"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1080
  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
  1081
    case (waiting th' cs')
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1082
    show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1083
    proof(cases "rest = []")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1084
      case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1085
      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
  1086
        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
  1087
      from waiting(3)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1088
      show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1089
      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
  1090
        case 1
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1091
        with waiting(1,2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1092
        show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1093
        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
  1094
             fold waiting_eq, auto)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1095
      next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1096
        case 2
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1097
        with waiting(1,2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1098
        show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1099
         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
  1100
             fold waiting_eq, auto)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1101
      qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1102
    next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1103
      case True
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1104
      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
  1105
        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
  1106
      from waiting(3)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1107
      show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1108
      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
  1109
        case 1
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1110
        with waiting(1,2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1111
        show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1112
        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
  1113
             fold waiting_eq, auto)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1114
      qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1115
    qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1116
  next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1117
    case (holding th' cs')
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1118
    show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1119
    proof(cases "rest = []")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1120
      case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1121
      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
  1122
        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
  1123
      from holding(3)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1124
      show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1125
      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
  1126
        case 1
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1127
        with holding(1,2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1128
        show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1129
        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
  1130
             fold waiting_eq, auto)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1131
      next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1132
        case 2
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1133
        with holding(1,2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1134
        show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1135
         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
  1136
             fold holding_eq, auto)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1137
      qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1138
    next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1139
      case True
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1140
      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
  1141
        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
  1142
      from holding(3)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1143
      show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1144
      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
  1145
        case 1
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1146
        with holding(1,2)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1147
        show ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1148
        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
  1149
             fold holding_eq, auto)
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1150
      qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1151
    qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1152
  qed
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1153
next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1154
  fix n1 n2
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1155
  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
  1156
  show "(n1, n2) \<in> ?L"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1157
  proof(cases "rest = []")
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1158
    case False
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1159
    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
  1160
        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
  1161
    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
  1162
    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
  1163
                            \<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
  1164
          (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
  1165
      by auto
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1166
   thus ?thesis
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1167
   proof
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1168
      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
  1169
      with h_n.holding_taker
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
        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
  1172
   next
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1173
    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
  1174
        (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
  1175
    hence "(n1, n2) \<in> RAG s" by simp
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1176
    thus ?thesis
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1177
    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
  1178
      case (waiting th' cs')
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1179
      from h and this(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1180
      have "th' \<noteq> h_n.taker \<or> cs' \<noteq> cs" by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1181
      hence "waiting (e#s) th' cs'" 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1182
      proof
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1183
        assume "cs' \<noteq> cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1184
        from waiting_esI1[OF waiting(3) this] 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1185
        show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1186
      next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1187
        assume neq_th': "th' \<noteq> h_n.taker"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1188
        show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1189
        proof(cases "cs' = cs")
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1190
          case False
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1191
          from waiting_esI1[OF waiting(3) this] 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1192
          show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1193
        next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1194
          case True
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1195
          from h_n.waiting_esI2[OF waiting(3)[unfolded True] neq_th', folded True]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1196
          show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1197
        qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1198
      qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1199
      thus ?thesis using waiting(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1200
        by (unfold s_RAG_def, fold waiting_eq, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1201
    next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1202
      case (holding th' cs')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1203
      from h this(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1204
      have "cs' \<noteq> cs \<or> th' \<noteq> th" by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1205
      hence "holding (e#s) th' cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1206
      proof
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1207
        assume "cs' \<noteq> cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1208
        from holding_esI2[OF this holding(3)] 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1209
        show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1210
      next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1211
        assume "th' \<noteq> th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1212
        from holding_esI1[OF holding(3) this]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1213
        show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1214
      qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1215
      thus ?thesis using holding(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1216
        by (unfold s_RAG_def, fold holding_eq, auto)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1217
    qed
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1218
   qed
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1219
 next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1220
   case True
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1221
   interpret h_e: valid_trace_v_e s e th cs
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1222
        by (unfold_locales, insert True, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1223
   from h[unfolded h_e.waiting_set_eq h_e.holding_set_eq]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1224
   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
  1225
      by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1226
   from h_s(1)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1227
   show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1228
   proof(cases rule:in_RAG_E)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1229
    case (waiting th' cs')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1230
    from h_e.waiting_esI2[OF this(3)]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1231
    show ?thesis using waiting(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1232
      by (unfold s_RAG_def, fold waiting_eq, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1233
   next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1234
    case (holding th' cs')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1235
    with h_s(2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1236
    have "cs' \<noteq> cs \<or> th' \<noteq> th" by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1237
    thus ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1238
    proof
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1239
      assume neq_cs: "cs' \<noteq> cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1240
      from holding_esI2[OF this holding(3)]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1241
      show ?thesis using holding(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1242
        by (unfold s_RAG_def, fold holding_eq, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1243
    next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1244
      assume "th' \<noteq> th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1245
      from holding_esI1[OF holding(3) this]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1246
      show ?thesis using holding(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1247
        by (unfold s_RAG_def, fold holding_eq, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1248
    qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1249
   qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1250
 qed
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1251
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1252
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1253
end
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1254
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1255
lemma step_RAG_v: 
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1256
assumes vt:
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1257
  "vt (V th cs#s)"
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1258
shows "
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1259
  RAG (V th cs # s) =
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1260
  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
  1261
  {(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
  1262
  {(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
  1263
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1264
  interpret vt_v: valid_trace_v s "V th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1265
    using assms step_back_vt by (unfold_locales, auto) 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1266
  show ?thesis using vt_v.RAG_es .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1267
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1268
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1269
lemma (in valid_trace_create)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1270
  th_not_in_threads: "th \<notin> threads s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1271
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1272
  from pip_e[unfolded is_create]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1273
  show ?thesis by (cases, simp)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1274
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1275
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1276
lemma (in valid_trace_create)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1277
  threads_es [simp]: "threads (e#s) = threads s \<union> {th}"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1278
  by (unfold is_create, simp)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1279
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1280
lemma (in valid_trace_exit)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1281
  threads_es [simp]: "threads (e#s) = threads s - {th}"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1282
  by (unfold is_exit, simp)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1283
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1284
lemma (in valid_trace_p)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1285
  threads_es [simp]: "threads (e#s) = threads s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1286
  by (unfold is_p, simp)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1287
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1288
lemma (in valid_trace_v)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1289
  threads_es [simp]: "threads (e#s) = threads s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1290
  by (unfold is_v, simp)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1291
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1292
lemma (in valid_trace_v)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1293
  th_not_in_rest[simp]: "th \<notin> set rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1294
proof
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1295
  assume otherwise: "th \<in> set rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1296
  have "distinct (wq s cs)" by (simp add: wq_distinct)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1297
  from this[unfolded wq_s_cs] and otherwise
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1298
  show False by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1299
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1300
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1301
lemma (in valid_trace_v)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1302
  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
  1303
proof(unfold wq_es_cs wq'_def, rule someI2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1304
  show "distinct rest \<and> set rest = set rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1305
    by (simp add: distinct_rest)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1306
next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1307
  fix x
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1308
  assume "distinct x \<and> set x = set rest"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1309
  thus "set x = set (wq s cs) - {th}" 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1310
      by (unfold wq_s_cs, simp)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1311
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1312
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1313
lemma (in valid_trace_exit)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1314
  th_not_in_wq: "th \<notin> set (wq s cs)"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1315
proof -
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1316
  from pip_e[unfolded is_exit]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1317
  show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1318
  by (cases, unfold holdents_def s_holding_def, fold wq_def, 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1319
             auto elim!:runing_wqE)
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1320
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1321
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1322
lemma (in valid_trace) wq_threads: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1323
  assumes "th \<in> set (wq s cs)"
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1324
  shows "th \<in> threads s"
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1325
  using assms
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1326
proof(induct rule:ind)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1327
  case (Nil)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1328
  thus ?case by (auto simp:wq_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1329
next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1330
  case (Cons s e)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1331
  interpret vt_e: valid_trace_e s e using Cons by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1332
  show ?case
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1333
  proof(cases e)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1334
    case (Create th' prio')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1335
    interpret vt: valid_trace_create s e th' prio'
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1336
      using Create by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1337
    show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1338
      using Cons.hyps(2) Cons.prems by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1339
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1340
    case (Exit th')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1341
    interpret vt: valid_trace_exit s e th'
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1342
      using Exit by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1343
    show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1344
      using Cons.hyps(2) Cons.prems vt.th_not_in_wq by auto 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1345
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1346
    case (P th' cs')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1347
    interpret vt: valid_trace_p s e th' cs'
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1348
      using P by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1349
    show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1350
      using Cons.hyps(2) Cons.prems readys_threads 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1351
        runing_ready vt.is_p vt.runing_th_s vt_e.wq_in_inv 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1352
        by fastforce 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1353
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1354
    case (V th' cs')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1355
    interpret vt: valid_trace_v s e th' cs'
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1356
      using V by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1357
    show ?thesis using Cons
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1358
      using vt.is_v vt.threads_es vt_e.wq_in_inv by blast
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1359
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1360
    case (Set th' prio)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1361
    interpret vt: valid_trace_set s e th' prio
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1362
      using Set by (unfold_locales, simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1363
    show ?thesis using Cons.hyps(2) Cons.prems vt.is_set 
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1364
        by (auto simp:wq_def Let_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1365
  qed
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1366
qed 
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1367
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1368
context valid_trace
57
f1b39d77db00 Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff changeset
  1369
begin
f1b39d77db00 Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff changeset
  1370
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1371
lemma  dm_RAG_threads:
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1372
  assumes in_dom: "(Th th) \<in> Domain (RAG s)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1373
  shows "th \<in> threads s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1374
proof -
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1375
  from in_dom obtain n where "(Th th, n) \<in> RAG s" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1376
  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
  1377
  ultimately have "(Th th, Cs cs) \<in> RAG s" by simp
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1378
  hence "th \<in> set (wq s cs)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1379
    by (unfold s_RAG_def, auto simp:cs_waiting_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1380
  from wq_threads [OF this] show ?thesis .
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1381
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1382
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1383
lemma  cp_le:
73
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1384
  assumes th_in: "th \<in> threads s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1385
  shows "cp s th \<le> Max ((\<lambda> th. (preced th s)) ` threads s)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1386
proof(unfold cp_eq_cpreced cpreced_def cs_dependants_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1387
  show "Max ((\<lambda>th. preced th s) ` ({th} \<union> {th'. (Th th', Th th) \<in> (RAG (wq s))\<^sup>+}))
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1388
         \<le> Max ((\<lambda>th. preced th s) ` threads s)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1389
    (is "Max (?f ` ?A) \<le> Max (?f ` ?B)")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1390
  proof(rule Max_f_mono)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1391
    show "{th} \<union> {th'. (Th th', Th th) \<in> (RAG (wq s))\<^sup>+} \<noteq> {}" by simp
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1392
  next
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1393
    from finite_threads
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1394
    show "finite (threads s)" .
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1395
  next
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1396
    from th_in
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1397
    show "{th} \<union> {th'. (Th th', Th th) \<in> (RAG (wq s))\<^sup>+} \<subseteq> threads s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1398
      apply (auto simp:Domain_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1399
      apply (rule_tac dm_RAG_threads)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1400
      apply (unfold trancl_domain [of "RAG s", symmetric])
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1401
      by (unfold cs_RAG_def s_RAG_def, auto simp:Domain_def)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1402
  qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1403
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1404
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1405
lemma max_cp_eq: 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1406
  shows "Max ((cp s) ` threads s) = Max ((\<lambda> th. (preced th s)) ` threads s)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1407
  (is "?l = ?r")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1408
proof(cases "threads s = {}")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1409
  case True
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1410
  thus ?thesis by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1411
next
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1412
  case False
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1413
  have "?l \<in> ((cp s) ` threads s)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1414
  proof(rule Max_in)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1415
    from finite_threads
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1416
    show "finite (cp s ` threads s)" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1417
  next
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1418
    from False show "cp s ` threads s \<noteq> {}" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1419
  qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1420
  then obtain th 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1421
    where th_in: "th \<in> threads s" and eq_l: "?l = cp s th" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1422
  have "\<dots> \<le> ?r" by (rule cp_le[OF th_in])
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1423
  moreover have "?r \<le> cp s th" (is "Max (?f ` ?A) \<le> cp s th")
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1424
  proof -
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1425
    have "?r \<in> (?f ` ?A)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1426
    proof(rule Max_in)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1427
      from finite_threads
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1428
      show " finite ((\<lambda>th. preced th s) ` threads s)" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1429
    next
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1430
      from False show " (\<lambda>th. preced th s) ` threads s \<noteq> {}" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1431
    qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1432
    then obtain th' where 
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1433
      th_in': "th' \<in> ?A " and eq_r: "?r = ?f th'" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1434
    from le_cp [of th']  eq_r
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1435
    have "?r \<le> cp s th'" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1436
    moreover have "\<dots> \<le> cp s th"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1437
    proof(fold eq_l)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1438
      show " cp s th' \<le> Max (cp s ` threads s)"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1439
      proof(rule Max_ge)
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1440
        from th_in' show "cp s th' \<in> cp s ` threads s"
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1441
          by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1442
      next
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1443
        from finite_threads
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1444
        show "finite (cp s ` threads s)" by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1445
      qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1446
    qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1447
    ultimately show ?thesis by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1448
  qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1449
  ultimately show ?thesis using eq_l by auto
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1450
qed
b0054fb0d1ce Moment.thy further improved.
zhangx
parents: 65
diff changeset
  1451
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1452
lemma max_cp_eq_the_preced:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1453
  shows "Max ((cp s) ` threads s) = Max (the_preced s ` threads s)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1454
  using max_cp_eq using the_preced_def by presburger 
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1455
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1456
end
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1457
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1458
lemma preced_v [simp]: "preced th' (V th cs#s) = preced th' s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1459
  by (unfold preced_def, simp)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1460
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1461
lemma (in valid_trace_v)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1462
  preced_es: "preced th (e#s) = preced th s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1463
  by (unfold is_v preced_def, simp)
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1464
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1465
lemma the_preced_v[simp]: "the_preced (V th cs#s) = the_preced s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1466
proof
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1467
  fix th'
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1468
  show "the_preced (V th cs # s) th' = the_preced s th'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1469
    by (unfold the_preced_def preced_def, simp)
61
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
  1470
qed
f8194fd6214f CpsG.thy has been cleaned up.
zhangx
parents: 60
diff changeset
  1471
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1472
lemma (in valid_trace_v)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1473
  the_preced_es: "the_preced (e#s) = the_preced s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1474
  by (unfold is_v preced_def, simp)
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1475
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1476
context valid_trace_p
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1477
begin
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1478
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1479
lemma not_holding_es_th_cs: "\<not> holding s th cs"
62
031d2ae9c9b8 In the middle of retrofiting ExtGG.thy.
zhangx
parents: 61
diff changeset
  1480
proof
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1481
  assume otherwise: "holding s th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1482
  from pip_e[unfolded is_p]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1483
  show False
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1484
  proof(cases)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1485
    case (thread_P)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1486
    moreover have "(Cs cs, Th th) \<in> RAG s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1487
      using otherwise cs_holding_def 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1488
            holding_eq th_not_in_wq by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1489
    ultimately show ?thesis by auto
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1490
  qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1491
qed
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1492
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1493
end
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1494
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1495
locale valid_trace_p_h = valid_trace_p +
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1496
  assumes we: "wq s cs = []"
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1497
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1498
locale valid_trace_p_w = valid_trace_p +
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1499
  assumes we: "wq s cs \<noteq> []"
63
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1500
begin
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1501
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1502
definition "holder = hd (wq s cs)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1503
definition "waiters = tl (wq s cs)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1504
definition "waiters' = waiters @ [th]"
57
f1b39d77db00 Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff changeset
  1505
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1506
lemma wq_s_cs: "wq s cs = holder#waiters"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1507
    by (simp add: holder_def waiters_def we)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1508
    
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1509
lemma wq_es_cs': "wq (e#s) cs = holder#waiters@[th]"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1510
  by (simp add: wq_es_cs wq_s_cs)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1511
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1512
lemma waiting_es_th_cs: "waiting (e#s) th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1513
  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
  1514
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1515
lemma RAG_edge: "(Th th, Cs cs) \<in> RAG (e#s)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1516
   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
  1517
b620a2a0806a ExtGG.thy finished, but more comments are needed.
zhangx
parents: 62
diff changeset
  1518
end
58
ad57323fd4d6 Extended RTree.thy
zhangx
parents: 57
diff changeset
  1519
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1520
context valid_trace_p_h
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1521
begin
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1522
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1523
lemma wq_es_cs': "wq (e#s) cs = [th]"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1524
  using wq_es_cs[unfolded we] by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1525
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1526
lemma holding_es_th_cs: 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1527
  shows "holding (e#s) th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1528
proof -
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1529
  from wq_es_cs'
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1530
  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
  1531
  thus ?thesis using cs_holding_def holding_eq by blast 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1532
qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1533
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1534
lemma RAG_edge: "(Cs cs, Th th) \<in> RAG (e#s)"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1535
  by (unfold s_RAG_def, fold holding_eq, insert holding_es_th_cs, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1536
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1537
lemma waiting_esE:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1538
  assumes "waiting (e#s) th' cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1539
  obtains "waiting s th' cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1540
  using assms
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1541
  by (metis cs_waiting_def event.distinct(15) is_p list.sel(1) 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1542
        set_ConsD waiting_eq we wq_es_cs' wq_neq_simp wq_out_inv)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1543
  
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1544
lemma holding_esE:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1545
  assumes "holding (e#s) th' cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1546
  obtains "cs' \<noteq> cs" "holding s th' cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1547
    | "cs' = cs" "th' = th"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1548
proof(cases "cs' = cs")
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1549
  case True
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1550
  from held_unique[OF holding_es_th_cs assms[unfolded True]]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1551
  have "th' = th" by simp
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1552
  from that(2)[OF True this] show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1553
next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1554
  case False
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1555
  have "holding s th' cs'" using assms
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1556
    using False cs_holding_def holding_eq by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1557
  from that(1)[OF False this] show ?thesis .
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1558
qed
57
f1b39d77db00 Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff changeset
  1559
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1560
lemma waiting_kept:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1561
  assumes "waiting s th' cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1562
  shows "waiting (e#s) th' cs'"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1563
  using assms
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1564
  by (metis cs_waiting_def list.sel(1) list.set_intros(2) 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1565
        th_not_in_wq waiting_eq we wq_es_cs' wq_neq_simp)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1566
    
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1567
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1568
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
  1569
proof(rule rel_eqI)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1570
  fix n1 n2
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1571
  assume "(n1, n2) \<in> ?L"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1572
  thus "(n1, n2) \<in> ?R" 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1573
  proof(cases rule:in_RAG_E)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1574
    case (waiting th' cs')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1575
    from this(3)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1576
    show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1577
    proof(cases rule:waiting_esE)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1578
      case 1
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1579
      thus ?thesis using waiting(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1580
        by (unfold s_RAG_def, fold waiting_eq, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1581
    qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1582
  next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1583
    case (holding th' cs')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1584
    from this(3)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1585
    show ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1586
    proof(cases rule:holding_esE)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1587
      case 1
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1588
      with holding(1,2)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1589
      show ?thesis by (unfold s_RAG_def, fold holding_eq, auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1590
    next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1591
      case 2
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1592
      with holding(1,2) show ?thesis by auto
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1593
    qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1594
  qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1595
next
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1596
  fix n1 n2
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1597
  assume "(n1, n2) \<in> ?R"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1598
  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
  1599
  thus "(n1, n2) \<in> ?L"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1600
  proof
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1601
    assume "(n1, n2) \<in> RAG s"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1602
    thus ?thesis
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1603
    proof(cases rule:in_RAG_E)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1604
      case (waiting th' cs')
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1605
      find_theorems waiting e s
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1606
    qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1607
  qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1608
qed
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1609
57
f1b39d77db00 Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff changeset
  1610
end
77
d37703e0c5c4 CpsG.thy updated. It is a copy of PIPBasics.thy under drastic improvement.
zhangx
parents: 73
diff changeset
  1611
79
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1612
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1613
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1614
lemma "RAG (e # s) =  (if (wq s cs = []) then RAG s \<union> {(Cs cs, Th th)}
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1615
                                         else RAG s \<union> {(Th th, Cs cs)})"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1616
  proof(cases "wq s cs = []")
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1617
    case True
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1618
    from wq_es_cs[unfolded this]
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1619
    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
  1620
    hence "holding (e#s) th cs"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1621
      using cs_holding_def holding_eq by blast 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1622
    thus 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1623
  qed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1624
end
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1625
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1626
text {* 
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1627
  The following @{text "step_RAG_p"} lemma charaterizes how @{text "RAG"} is changed
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1628
  with the happening of @{text "P"}-events:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1629
*}
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1630
lemma step_RAG_p:
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1631
  "vt (P th cs#s) \<Longrightarrow>
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1632
  RAG (P th cs # s) =  (if (wq s cs = []) then RAG s \<union> {(Cs cs, Th th)}
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1633
                                             else RAG s \<union> {(Th th, Cs cs)})"
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1634
  apply(simp only: s_RAG_def wq_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1635
  apply (auto split:list.splits prod.splits simp:Let_def wq_def cs_waiting_def cs_holding_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1636
  apply(case_tac "csa = cs", auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1637
  apply(fold wq_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1638
  apply(drule_tac step_back_step)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1639
  apply(ind_cases " step s (P (hd (wq s cs)) cs)")
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1640
  apply(simp add:s_RAG_def wq_def cs_holding_def)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1641
  apply(auto)
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1642
  done
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1643
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1644
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1645
8067efcb43da Still improving CpsG.thy
zhangx
parents: 77
diff changeset
  1646
end